Message ID | f4fc0b97ae8cdb30f1e0b0d55521f136877b33f5.1470555003.git.felix.janda@posteo.de (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Sun, Aug 07, 2016 at 08:24:40AM +0200, Felix Janda wrote: > For this it was necessary to change a workaround for missing > f_brsize on Mac OS X. If we can get rid of that it'd be fine, but can you explain a bit more why we can get rid of it?
Christoph Hellwig wrote: > On Sun, Aug 07, 2016 at 08:24:40AM +0200, Felix Janda wrote: > > For this it was necessary to change a workaround for missing > > f_brsize on Mac OS X. > > If we can get rid of that it'd be fine, but can you explain a bit > more why we can get rid of it? Since we are using transparent LFS, statvfs64 is the same as statvfs, if statvfs64 is defined at all. In commit b35b4eb8f91d13a326213f989e it was noticed that OS X is missing statvfs64, and a define was added to darwin.h. The same commit also fixes the absense of the f_brsize field in struct statfs on OS X by adding code conditional on the statvfs64 define. (Notice that this condition might have false positives. Indeed, on linux with musl libc, statvfs64 is also a define.) This patch removes the usage of statvfs64 and thus one of the problems for Mac OS X. The other problem is solved by giving a suitable definition of f_brsize. Note that this might collide with other uses of f_brsize (if they exist). It might be cleaner to just check for Mac OS X in xfs_fsr.c. Felix
On Tue, Aug 09, 2016 at 07:41:58PM +0200, Felix Janda wrote: > This patch removes the usage of statvfs64 and thus one of the problems > for Mac OS X. The other problem is solved by giving a suitable > definition of f_brsize. Note that this might collide with other uses > of f_brsize (if they exist). It might be cleaner to just check for Mac > OS X in xfs_fsr.c. Yes, that's probably better. Or simply not build fsr on MacOS given that there is no kernel XFS support anyway..
Christoph Hellwig wrote: > On Tue, Aug 09, 2016 at 07:41:58PM +0200, Felix Janda wrote: > > This patch removes the usage of statvfs64 and thus one of the problems > > for Mac OS X. The other problem is solved by giving a suitable > > definition of f_brsize. Note that this might collide with other uses > > of f_brsize (if they exist). It might be cleaner to just check for Mac > > OS X in xfs_fsr.c. > > Yes, that's probably better. Or simply not build fsr on MacOS given > that there is no kernel XFS support anyway.. That second option sounds interesting. If fsr was not built on Mac OS X, then commit 7141fc5b04905e (add *mntent abstraction) can basically be reverted, simplifying the platform headers a bit. Felix
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 98390e7..f3cc07e 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -89,7 +89,7 @@ static void fsrallfs(char *mtab, int howlong, char *leftofffile); static void fsrall_cleanup(int timeout); static int getnextents(int); int xfsrtextsize(int fd); -int xfs_getrt(int fd, struct statvfs64 *sfbp); +int xfs_getrt(int fd, struct statvfs *sfbp); char * gettmpname(char *fname); char * getparent(char *fname); int fsrprintf(const char *fmt, ...); @@ -888,7 +888,7 @@ fsrfile_common( xfs_bstat_t *statp) { int error; - struct statvfs64 vfss; + struct statvfs vfss; struct fsxattr fsx; unsigned long bsize; @@ -940,16 +940,12 @@ fsrfile_common( * Note that xfs_bstat.bs_blksize returns the filesystem blocksize, * not the optimal I/O size as struct stat. */ - if (statvfs64(fsname ? fsname : fname, &vfss) < 0) { + if (statvfs(fsname ? fsname : fname, &vfss) < 0) { fsrprintf(_("unable to get fs stat on %s: %s\n"), fname, strerror(errno)); return -1; } -#ifndef statvfs64 bsize = vfss.f_frsize ? vfss.f_frsize : vfss.f_bsize; -#else - bsize = vfss.f_bsize; -#endif if (statp->bs_blksize * statp->bs_blocks > vfss.f_bfree * bsize - minimumfree) { fsrprintf(_("insufficient freespace for: %s: " @@ -1704,7 +1700,7 @@ xfs_getgeom(int fd, xfs_fsop_geom_v1_t * fsgeom) * Get xfs realtime space information */ int -xfs_getrt(int fd, struct statvfs64 *sfbp) +xfs_getrt(int fd, struct statvfs *sfbp) { unsigned long bsize; unsigned long factor; @@ -1717,11 +1713,7 @@ xfs_getrt(int fd, struct statvfs64 *sfbp) close(fd); return -1; } -#ifndef statvfs64 bsize = (sfbp->f_frsize ? sfbp->f_frsize : sfbp->f_bsize); -#else - bsize = sfbp->f_bsize; -#endif factor = fsgeom.blocksize / bsize; /* currently this is == 1 */ sfbp->f_bfree = (cnt.freertx * fsgeom.rtextsize) * factor; return 0; diff --git a/include/darwin.h b/include/darwin.h index fb13915..bd1a112 100644 --- a/include/darwin.h +++ b/include/darwin.h @@ -216,8 +216,8 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value) # include <sys/param.h> #include <sys/ucred.h> #include <errno.h> -#define statvfs64 statfs -#define _PATH_MOUNTED "/etc/mtab" +#define f_frsize f_bsize +#define _PATH_MOUNTED "/etc/mtab" struct mntent {
For this it was necessary to change a workaround for missing f_brsize on Mac OS X. Signed-off-by: Felix Janda <felix.janda@posteo.de> --- fsr/xfs_fsr.c | 16 ++++------------ include/darwin.h | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-)