Changeset View
Changeset View
Standalone View
Standalone View
head/sys/cddl/compat/opensolaris/sys/stat.h
Show All 26 Lines | |||||
* | * | ||||
*/ | */ | ||||
#ifndef _COMPAT_OPENSOLARIS_SYS_STAT_H_ | #ifndef _COMPAT_OPENSOLARIS_SYS_STAT_H_ | ||||
#define _COMPAT_OPENSOLARIS_SYS_STAT_H_ | #define _COMPAT_OPENSOLARIS_SYS_STAT_H_ | ||||
#include_next <sys/stat.h> | #include_next <sys/stat.h> | ||||
/* | |||||
* When bootstrapping on Linux a stat64/fstat64 functions exists in both | |||||
* glibc and musl libc. To avoid compilation errors, use those functions instead | |||||
* of redefining them to stat/fstat. | |||||
* Similarly, macOS provides (deprecated) stat64 functions that we can use | |||||
* for now. | |||||
*/ | |||||
#if !defined(__linux__) && !defined(__APPLE__) | |||||
#define stat64 stat | #define stat64 stat | ||||
#define MAXOFFSET_T OFF_MAX | #define MAXOFFSET_T OFF_MAX | ||||
#ifndef _KERNEL | #if !defined(_KERNEL) | ||||
#include <sys/disk.h> | #include <sys/disk.h> | ||||
static __inline int | static __inline int | ||||
fstat64(int fd, struct stat *sb) | fstat64(int fd, struct stat *sb) | ||||
{ | { | ||||
int ret; | int ret; | ||||
ret = fstat(fd, sb); | ret = fstat(fd, sb); | ||||
if (ret == 0) { | if (ret == 0) { | ||||
if (S_ISCHR(sb->st_mode)) | if (S_ISCHR(sb->st_mode)) | ||||
(void)ioctl(fd, DIOCGMEDIASIZE, &sb->st_size); | (void)ioctl(fd, DIOCGMEDIASIZE, &sb->st_size); | ||||
} | } | ||||
return (ret); | return (ret); | ||||
} | } | ||||
#endif | #endif /* !defined(_KERNEL) */ | ||||
#endif /* !defined(__linux__) && !defined(__APPLE__) */ | |||||
#endif /* !_COMPAT_OPENSOLARIS_SYS_STAT_H_ */ | #endif /* !_COMPAT_OPENSOLARIS_SYS_STAT_H_ */ |