xfsprogs: Partial OSX support
v5 cover xfsprogs: Partial OSX support
Hi all,
An updated version. This set is intended to put together the current versions of the individual patches with the exception of a new patch 14, and rebase it against the current master branch.
Patch 4 contains renaming required by Dave, however I'm not sure if it is still needed with the changes in patches 2 and 3.
Patch 10 (adding timer) was mentioned that it "doesn't look to work", but I didn't get a reasoning. The added code, when tested, really run. For testing it in xfs_repair, I don't have how to create a large enough FS where the timer would be noticable on OSX. (Not enough of empty space.)
Cheers,
Jan
CHANGELOG:
v5:
- patch 2 was split into 3 patches, numbered 2, 3 and 4
- in patches 2-4, instead of just prefixing it all, a mixed approach was used.
- patch 9 renames the function directly instead of using #define
- patch 11 now adds a simple rename
- patch 12 uses mntinfo instead of dummy code
- in patch 13, make mremap build optional instead of dummy code
- new patch 14 with lstat64
v4:
- added #warning message (patch 1)
- use dummy blkid_get_topology instead of #ifdefs (patch 1)
- fix autoconf (wasn't passing -DENABLE_BLKID flag, lost during patch cleaning.) (patch 1)
- remove dependency on linux XATTR_ constants (patch 2)
- add autoconf detection for fsetxattr (patch 4)
- use uuid_t instead of unsigned char (patch 5)
- add a basic timer functionality (patch 8)
- mremap replacement now returns MAP_FAILED (patch 11)
Version 3:
- better commit messages (patch 1)
- formatting fixes (patch 2, 8)
- autoconf updates (patch 6, 7)
- changed default behaviour if BLKID is disabled such that mkfs -f is required (patch 11)
Jan Tulak (14):
xfsprogs: Add a way to compile without blkid
xfsprogs: Add XATTR_LIST_MAX to OS X headers
xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX
xfsprogs: prefix XATTR_LIST_MAX with XFS_
xfsprogs: Add includes required for OS X builds (delta)
xfsprogs: Add autoconf check for fsetxattr call
xfsprogs: uuid changes for OS X
xfsprogs: Remove conflicting define for OS X
xfsprogs: change nftw64 to nftw
xfsprogs: Add a timer implementation for OS X
xfsprogs: Add statvfs64 for osx
xfsprogs: make fsr use mntinfo when there is no mntent
xfsprogs: Make mremap conditional
xfsprogs: rename lstat64 to lstat for OS X
configure.ac | 12 +++++- estimate/xfs_estimate.c | 6 +-- fsr/Makefile | 8 ++++ fsr/xfs_fsr.c | 85 ++++++++++++++++++++++++++++++++----- include/builddefs.in | 12 +++++- include/darwin.h | 106 ++++++++++++++++++++++++++++++++++++++++------- include/xfs.h | 2 + io/mmap.c | 8 ++++ libhandle/handle.c | 4 +- libhandle/jdm.c | 4 +- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_format.h | 10 ++++- m4/package_libcdev.m4 | 26 ++++++++++++ mkfs/xfs_mkfs.c | 37 ++++++++++++++++- repair/progress.c | 16 ++++++- 15 files changed, 298 insertions(+), 40 deletions(-)
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 1/14 xfsprogs: Add a way to compile without blkid
Because not all platforms have up-to-date blkid with required functions, allow at least partial functionality by adding --enable-blkid=yes/no optional configure argument.
When blkid is disabled, signature detection and device geometry detection doesn't work.
--- configure.ac | 10 +++++++++- include/builddefs.in | 5 +++++ mkfs/xfs_mkfs.c | 37 ++++++++++++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 2 deletions(-)
configure.ac +9 -1
@@ -26,6 +26,11 @@ AC_ARG_ENABLE(gettext, enable_gettext=yes) AC_SUBST(enable_gettext) +AC_ARG_ENABLE(blkid, +[ --enable-blkid=[yes/no] Enable use of block device id library [default=yes]],, + enable_blkid=yes) +AC_SUBST(enable_blkid) + AC_ARG_ENABLE(readline, [ --enable-readline=[yes/no] Enable readline command editing [default=no]], test $enable_readline = yes && libreadline="-lreadline",
@@ -117,9 +122,12 @@ AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE AC_HAVE_MNTENT AC_HAVE_FLS -AC_HAVE_BLKID_TOPO AC_HAVE_READDIR +if test "$enable_blkid" = yes; then +AC_HAVE_BLKID_TOPO +fi + AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([char *]) AC_TYPE_UMODE_T
include/builddefs.in +5 -0
@@ -89,6 +89,7 @@ ENABLE_SHARED = @enable_shared@ ENABLE_GETTEXT = @enable_gettext@ ENABLE_EDITLINE = @enable_editline@ ENABLE_READLINE = @enable_readline@ +ENABLE_BLKID = @enable_blkid@ HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
@@ -138,6 +139,10 @@ endif ifeq ($(HAVE_MNTENT),yes) PCFLAGS+= -DHAVE_MNTENT endif +ifeq ($(ENABLE_BLKID),yes) +PCFLAGS+= -DENABLE_BLKID +endif + GCFLAGS = $(OPTIMIZER) $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
mkfs/xfs_mkfs.c +36 -1
@@ -18,7 +18,9 @@#include "libxfs.h" #include <ctype.h> -#include <blkid/blkid.h> +#ifdef ENABLE_BLKID +# include <blkid/blkid.h> +#endif /* ENABLE_BLKID */ #include "xfs_mkfs.h" /*
@@ -298,6 +300,7 @@ calc_stripe_factors(* 0 for nothing found * -1 for internal error */ +#ifdef ENABLE_BLKID static int check_overwrite (char *device)
@@ -451,6 +454,38 @@ out_free_probe:_ ("warning: unable to probe device topology for device %s\n" ), device); } +#else /* ifdef ENABLE_BLKID */ +/* +* Without blkid, we can't do a good check for signatures. +* So instead of some messy attempts, just disable any checks +* and always return 'nothing found'. +*/ +# warning BLKID is disabled, so signature detection and block device\ + access are not working! +static int +check_overwrite ( +char *device) +{ +return 1 ; +} + +static void blkid_get_topology ( +const char *device, +int *sunit, +int *swidth, +int *lsectorsize, +int *psectorsize, +int force_overwrite) +{ +/* +* Shouldn't make any difference (no blkid = no block device access), +* but make sure this dummy replacement returns with at least some +* sanity. +*/ + *lsectorsize = *psectorsize =512 ; +} + +#endif /* ENABLE_BLKID */ static void get_topology( libxfs_init_t *xi,
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 2/14 xfsprogs: Add XATTR_LIST_MAX to OS X headers
In reply to Jan TulakOS X has no XATTR_LIST_MAX value. So add it to the platform header.
--- include/darwin.h | 5 +++++ 1 file changed, 5 insertions(+)
include/darwin.h +5 -0
@@ -39,6 +39,11 @@# ifndef SYS_fsctl# define SYS_fsctl 242# endif + +#ifndef XATTR_LIST_MAX +#define XATTR_LIST_MAX 65536 +#endif +static __inline__int xfsctl (const char *path,int fd,int cmd,void *p) {return syscall (SYS_fsctl, path, cmd, p,0 );
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 3/14 xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX
In reply to Jan TulakCurrently, we depends on Linux XATTR value for on disk definitions. Which causes trouble on other platforms and maybe also if this value was to change.
Fix it by creating a custom definition independent from those in Linux (although with the same values), so it is OK with the be16 fields used for holding these attributes.
--- libxfs/xfs_attr_remote.c | 2 +- libxfs/xfs_format.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-)
libxfs/xfs_attr_remote.c +1 -1
@@ -102,7 +102,7 @@ xfs_attr3_rmt_verify(if (be32_to_cpu (rmt->rm_bytes) > fsbsize -sizeof (*rmt))return false;if (be32_to_cpu (rmt->rm_offset) + -be32_to_cpu (rmt->rm_bytes) >XATTR_SIZE_MAX ) +be32_to_cpu (rmt->rm_bytes) >XFS_XATTR_SIZE_MAX )return false;if (rmt->rm_owner ==0 )return false;
libxfs/xfs_format.h +9 -1
@@ -60,6 +60,14 @@ struct xfs_ifork;#define XFS_SB_VERSION_MOREBITSBIT 0x8000/* +* The size of a single extended attribute on disk is limited by +* the size of index values within the attribute entries themselves. +* These are be16 fields, so we can only support attribute data +* sizes up to 2^16 bytes in length. +*/ +#define XFS_XATTR_SIZE_MAX (1 << 16) + +/* * Supported feature bit list is just all bits in the versionnum field because * we've used them all up and understand them all. Except, of course, for the * shared superblock bit, which nobody knows what it does and so is unsupported.
@@ -1483,7 +1491,7 @@ struct xfs_acl {*/ #define XFS_ACL_MAX_ENTRIES (mp) \ (xfs_sb_version_hascrc(&mp->m_sb) \ - ? (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ + ? (XFS_XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ sizeof(struct xfs_acl_entry) \ : 25)
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 03/14] xfsprogs: avoid dependency on Linux XATTR_SIZE_MAX
Quoted 9 lines · Jan Tulak
Currently, we depends on Linux XATTR value for on disk definitions. Which causes trouble on other platforms and maybe also if this value was to change.
Fix it by creating a custom definition independent from those in Linux (although with the same values), so it is OK with the be16 fields used for holding these attributes.
Signed-off-by Jan Tulak <[email protected]>
Looks good. We'll need a kernel version of this patch, too.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 4/14 xfsprogs: prefix XATTR_LIST_MAX with XFS_
In reply to Jan TulakWILL CHANGE THE COMMIT MESSAGE.
All right, I make the renaming with define - though I'm not sure that with the ifdef for OS X and SIZE_MAX moved to a standalone patch we need it - shouldn't be this change rather dropped?
--- include/xfs.h | 2 ++ libhandle/handle.c | 4 ++-- libhandle/jdm.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)
include/xfs.h +2 -0
@@ -53,6 +53,8 @@# define ASSERT (EX ) ((void) 0)#endif +#define XFS_XATTR_LIST_MAX XATTR_LIST_MAX +/* * sparse kernel source annotations */
libhandle/handle.c +2 -2
@@ -397,8 +397,8 @@ attr_list_by_handle( alhreq.buffer = buf; alhreq.buflen = bufsize;/* prevent needless EINVAL from the kernel */ -if (alhreq.buflen >XATTR_LIST_MAX ) - alhreq.buflen =XATTR_LIST_MAX ; +if (alhreq.buflen >XFS_XATTR_LIST_MAX ) + alhreq.buflen =XFS_XATTR_LIST_MAX ; error =xfsctl (path, fd,XFS_IOC_ATTRLIST_BY_HANDLE , &alhreq);
libhandle/jdm.c +2 -2
@@ -168,8 +168,8 @@ jdm_attr_list( jdm_fshandle_t *fshp,int rval;/* prevent needless EINVAL from the kernel */ -if (bufsz >XATTR_LIST_MAX ) - bufsz =XATTR_LIST_MAX ; +if (bufsz >XFS_XATTR_LIST_MAX ) + bufsz =XFS_XATTR_LIST_MAX ;jdm_fill_filehandle ( &filehandle, fshandlep, statp ); rval = attr_list_by_handle (( void * )&filehandle,
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/14] xfsprogs: prefix XATTR_LIST_MAX with XFS_
Quoted 1 line · Jan Tulak
WILL CHANGE THE COMMIT MESSAGE.
OK?
Quoted 16 lines
All right, I make the renaming with define - though I'm not sure that with the ifdef for OS X and
SIZE_MAXmoved to a standalone patch we need it - shouldn't be this change rather dropped?Signed-off-by Jan Tulak <[email protected]>--- include/xfs.h | 2 ++ libhandle/handle.c | 4 ++-- libhandle/jdm.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)include/xfs.h +0
-0
include/xfs.h line 57
Quoted 5 lines
include/xfs.h +2
-0@@ -53,6 +53,8 @@# define ASSERT (EX ) ((void) 0)#endif +#define XFS_XATTR_LIST_MAX XATTR_LIST_MAX +
This does not belong here - it is a limit that applies to the ioctl API and so must be the same in userspace and the kernel. Such definitions belong in libxfs/xfs_fs.h, and should respect local OS limits if defined. e.g. something like:
#ifdef XATTR_LIST_MAX
#define XFS_XATTR_LIST_MAX XATTR_LIST_MAX
#else
#define XFS_XATTR_LIST_MAX 65536
#endif
Will work on both the kernel and userspace side. This will also need a kernel side patch...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/14] xfsprogs: prefix XATTR_LIST_MAX with XFS_
Quoted 32 lines · Dave Chinner
Quoted 1 line · Jan Tulak
WILL CHANGE THE COMMIT MESSAGE.
OK?
All right, I make the renaming with define - though I'm not sure
Quoted 15 lines
that with the ifdef for OS X and
SIZE_MAXmoved to a standalone patch we need it - shouldn't be this change rather dropped?Signed-off-by Jan Tulak <[email protected]>--- include/xfs.h | 2 ++ libhandle/handle.c | 4 ++-- libhandle/jdm.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-)include/xfs.h +0
-0include/xfs.h line 57
Quoted 5 lines
include/xfs.h +2
-0@@ -53,6 +53,8 @@# define ASSERT (EX ) ((void) 0)#endif +#define XFS_XATTR_LIST_MAX XATTR_LIST_MAX +This does not belong here - it is a limit that applies to the ioctl API and so must be the same in userspace and the kernel. Such definitions belong in
libxfs/xfs_fs.h, and should respect local OS limits if defined. e.g. something like:
Quoted 7 lines
#ifdef
XATTR_LIST_MAX
#defineXFS_XATTR_LIST_MAXXATTR_LIST_MAX
#else
#defineXFS_XATTR_LIST_MAX65536
#endif
OK, that makes sense.
Quoted 2 lines
Will work on both the kernel and userspace side. This will also need a kernel side patch...
Now, this is something where I may need a bit help/confirmation, I guess. What I suppose I should do is:
1) Clone linux-xfs (git://
git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git)
2) Edit linux-xfs/fs/xfs/libxfs/xfs_fs.h and add the same change there
3) Send it to this mailing list as usual, with "[PATCH] xfs: ..."
(The same goes for the other patch with the kernel need too.)
Is it all right? Correct repository URL? :-)
Thanks,
Jan
Signature · 2 lines
Jan Tulak [email protected] / [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/14] xfsprogs: prefix XATTR_LIST_MAX with XFS_
Quoted 11 lines · Jan Tulak
Quoted 2 lines · Dave Chinner
Will work on both the kernel and userspace side. This will also need a kernel side patch...
Now, this is something where I may need a bit help/confirmation, I guess. What I suppose I should do is:
1) Clone linux-xfs (
git://
git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs.git)
2) Editlinux-xfs/fs/xfs/libxfs/xfs_fs.hand add the same change there
and to the files in fs/xfs that directly use XATTR_LIST_MAX.
2.5) compile, install kernel, run xfstests.
Quoted 5 lines
3) Send it to this mailing list as usual, with "[PATCH] xfs: ..."
(The same goes for the other patch with the kernel need too.)
Is it all right? Correct repository URL? :-)
Yup.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 4/14 xfsprogs: prefix XATTR_LIST_MAX with XFS_
In reply to Jan TulakUPDATE:
- moved define from include/xfs.h to libxfs/xfs_fs.h
As we depends on XATTR_ value that is available only on some platforms, prefix it with XFS_ and allow for an alternative value in future.
--- libhandle/handle.c | 4 ++-- libhandle/jdm.c | 4 ++-- libxfs/xfs_fs.h | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-)
libhandle/handle.c +2 -2
@@ -397,8 +397,8 @@ attr_list_by_handle( alhreq.buffer = buf; alhreq.buflen = bufsize;/* prevent needless EINVAL from the kernel */ -if (alhreq.buflen >XATTR_LIST_MAX ) - alhreq.buflen =XATTR_LIST_MAX ; +if (alhreq.buflen >XFS_XATTR_LIST_MAX ) + alhreq.buflen =XFS_XATTR_LIST_MAX ; error =xfsctl (path, fd,XFS_IOC_ATTRLIST_BY_HANDLE , &alhreq);
libhandle/jdm.c +2 -2
@@ -168,8 +168,8 @@ jdm_attr_list( jdm_fshandle_t *fshp,int rval;/* prevent needless EINVAL from the kernel */ -if (bufsz >XATTR_LIST_MAX ) - bufsz =XATTR_LIST_MAX ; +if (bufsz >XFS_XATTR_LIST_MAX ) + bufsz =XFS_XATTR_LIST_MAX ;jdm_fill_filehandle ( &filehandle, fshandlep, statp ); rval = attr_list_by_handle (( void * )&filehandle,
libxfs/xfs_fs.h +9 -0
@@ -490,6 +490,15 @@ typedef struct xfs_swapext#define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH 0x2/* don't flush log nor data */ /* +* ioctl limits +*/ +#ifdef XATTR_LIST_MAX +# define XFS_XATTR_LIST_MAX XATTR_LIST_MAX +#else +# define XFS_XATTR_LIST_MAX 65536 +#endif + +/* * ioctl commands that are used by Linux filesystems */ #define XFS_IOC_GETXFLAGS FS_IOC_GETFLAGS
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 5/14 xfsprogs: Add includes required for OS X builds (delta)
In reply to Jan TulakDelta patch, an older version missing 3 includes was merged into 4.2.0-rc2.
--- include/darwin.h | 3 +++ 1 file changed, 3 insertions(+)
include/darwin.h +3 -0
@@ -18,6 +18,9 @@#ifndef __XFS_DARWIN_H__#define __XFS_DARWIN_H__ +#include <unistd.h> +#include <sys/types.h> +#include <string.h> #include <uuid/uuid.h> #include <libgen.h> #include <sys/vm.h>
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 6/14 xfsprogs: Add autoconf check for fsetxattr call
In reply to Jan TulakOS X has fsetxattr() in another header and with different arguments. For now, check for the Linux variant and if not available, skip the code using the call.
--- configure.ac | 1 + fsr/xfs_fsr.c | 2 ++ include/builddefs.in | 4 ++++ m4/package_libcdev.m4 | 13 +++++++++++++ 4 files changed, 20 insertions(+)
configure.ac +1 -0
@@ -123,6 +123,7 @@ AC_HAVE_SYNC_FILE_RANGE AC_HAVE_MNTENT AC_HAVE_FLS AC_HAVE_READDIR +AC_HAVE_FSETXATTR if test "$enable_blkid" = yes; then AC_HAVE_BLKID_TOPO
fsr/xfs_fsr.c +2 -0
@@ -1025,6 +1025,7 @@ fsr_setup_attr_fork(int tfd, xfs_bstat_t *bstatp) { +#ifdef HAVE_FSETXATTR struct stat64 tstatbuf;int i;int diff =0 ;
@@ -1199,6 +1200,7 @@ out:if (dflag && diff)fsrprintf (_ ("failed to match fork offset\n" ));; +#endif /* HAVE_FSETXATTR */ return 0 ; }
include/builddefs.in +4 -0
@@ -106,6 +106,7 @@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ HAVE_READDIR = @have_readdir@ HAVE_MNTENT = @have_mntent@ HAVE_FLS = @have_fls@ +HAVE_FSETXATTR = @have_fsetxattr@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -139,6 +140,9 @@ endif ifeq ($(HAVE_MNTENT),yes) PCFLAGS+= -DHAVE_MNTENT endif +ifeq ($(HAVE_FSETXATTR),yes) +PCFLAGS+= -DHAVE_FSETXATTR +endif ifeq ($(ENABLE_BLKID),yes) PCFLAGS+= -DENABLE_BLKID endif
m4/package_libcdev.m4 +13 -0
@@ -215,6 +215,19 @@ AC_DEFUN([AC_HAVE_FLS], ]) # +# Check if we have a fsetxattr call (Mac OS X) +# +AC_DEFUN([AC_HAVE_FSETXATTR], + [ AC_CHECK_DECL([fsetxattr], + have_fsetxattr=yes, + [], + [#include <sys/types.h> + #include <attr/xattr.h>] + ) + AC_SUBST(have_fsetxattr) + ]) + +# # Check if there is mntent.h # AC_DEFUN([AC_HAVE_MNTENT],
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 7/14 xfsprogs: uuid changes for OS X
In reply to Jan TulakUUID API changed in OS X in last few years, so fix the platform_ calls.
--- include/darwin.h | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
include/darwin.h +7 -15
@@ -81,45 +81,37 @@ static __inline__ void platform_getoptreset(void)static __inline__int platform_uuid_compare (uuid_t *uu1,uuid_t *uu2) { -return uuid_compare (uu1, uu2,NULL ); +return uuid_compare (*uu1, *uu2); }static __inline__void platform_uuid_unparse (uuid_t *uu,char *buffer) { -uint32_t status; -char *s; -uuid_to_string (uu, &s, &status); -if (status == uuid_s_ok) -strcpy (buffer, s); -else buffer[0 ] ='\0' ; -free (s); +uuid_unparse (*uu, buffer); }static __inline__int platform_uuid_parse (char *buffer,uuid_t *uu) { -uint32_t status; -uuid_from_string (buffer, uu, &status); -return (status == uuid_s_ok); +return uuid_parse (buffer, *uu); }static __inline__int platform_uuid_is_null (uuid_t *uu) { -return uuid_is_nil (uu,NULL ); +return uuid_is_null (*uu); }static __inline__void platform_uuid_generate (uuid_t *uu) { -uuid_create (uu,NULL ); +uuid_generate (*uu); }static __inline__void platform_uuid_clear (uuid_t *uu) { -uuid_create_nil (uu,NULL ); +uuid_clear (*uu); }static __inline__void platform_uuid_copy (uuid_t *dst,uuid_t *src) { -memcpy (dst, src,sizeof (uuid_t)); +uuid_copy (*dst, *src); }typedef unsigned char __u8 ;
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 8/14 xfsprogs: Remove conflicting define for OS X
In reply to Jan TulakENOATTR already exists in OS X.
--- include/darwin.h | 1 - 1 file changed, 1 deletion(-)
include/darwin.h +0 -1
@@ -156,7 +156,6 @@ typedef int64_t xfs_daddr_t;#define O_SYNC 0#endif -#define ENOATTR 989/* Attribute not found */ #define EFSCORRUPTED 990/* Filesystem is corrupted */ #define EFSBADCRC 991/* Bad CRC detected */ #define constpp char * const *
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 9/14 xfsprogs: change nftw64 to nftw
In reply to Jan TulakThere is only one usage of nftw64 in entire xfsprogs, but multiple usages of nftw. It seems the 64 variant has no reason, and causes difficulties with some other platforms which has only nftw call.
--- estimate/xfs_estimate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
estimate/xfs_estimate.c +3 -3
@@ -45,7 +45,7 @@ cvtnum(char *s)return 0LL ; } -int ffn (const char *,const struct stat64 *,int ,struct FTW *); +int ffn (const char *,const struct stat *,int ,struct FTW *);#define BLOCKSIZE 4096#define INODESIZE 256
@@ -168,7 +168,7 @@ main(int argc, char **argv) ndirs=0LL ;/* number of directories */ nspecial=0LL ;/* number of special files */ -nftw64 (argv[optind], ffn,40 ,FTW_PHYS |FTW_MOUNT ); +nftw (argv[optind], ffn,40 ,FTW_PHYS |FTW_MOUNT );if (__debug) {printf (_ ("dirsize=%llu\n" ), dirsize);
@@ -214,7 +214,7 @@ main(int argc, char **argv) }int -ffn (const char *path,const struct stat64 *stb,int flags,struct FTW *f) +ffn (const char *path,const struct stat *stb,int flags,struct FTW *f) {/* cases are in most-encountered to least-encountered order */ dirsize+=PERDIRENTRY +strlen (path);
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 10/14 xfsprogs: Add a timer implementation for OS X
In reply to Jan TulakOS X does not have the timer used in xfs_repair. Add a simple implementation providing the required capabilities.
--- include/darwin.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ repair/progress.c | 16 ++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-)
include/darwin.h +48 -0
@@ -28,6 +28,7 @@#include <sys/ioctl.h> #include <sys/mount.h> #include <sys/types.h> +#include <sys/time.h> #include <ftw.h> #include <mach/mach_time.h> #include <inttypes.h>
@@ -168,4 +169,51 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) return 0; } +/* +* POSIX timer replacement. +* It really just do the minimum we need for xfs_repair. +* Also, as setitimer can't create multiple timers, +* the timerid things are useless - we have only one ITIMER_REAL +* timer. +*/ +#define CLOCK_REALTIME ITIMER_REAL +#define itimerspec itimerval +typedef uint64_t timer_t ; +typedef double timer_c ; +typedef clock_id_t clockid_t ; + + +static inline int timer_create (clockid_t __clock_id, +struct sigevent *__restrict __evp, +timer_t *__restrict timer) +{ +// set something, to initialize the variable, just in case + *timer =0 ; +return 0 ; +} + +static inline int timer_settime (timer_t timerid,int flags, +const struct itimerspec *__restrict timerspec, +struct itimerspec *__restrict ovalue) +{ +return setitimer (ITIMER_REAL , timerspec, ovalue); +} + +static inline int timer_delete (timer_t timerid) +{ +struct itimerspec timespec; + + timespec.it_interval.tv_sec=0 ; + timespec.it_interval.tv_usec=0 ; + timespec.it_value.tv_sec=0 ; + timespec.it_value.tv_usec=0 ; + +return setitimer (ITIMER_REAL , ×pec,NULL ); +} + +static inline int timer_gettime (timer_t timerid,struct itimerspec *value) +{ +return getitimer (ITIMER_REAL , value); +} +#endif /* __XFS_DARWIN_H__ */
repair/progress.c +14 -2
@@ -184,10 +184,22 @@ progress_rpt_thread (void *p)*/ timespec.it_value.tv_sec = msgp->interval; - timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_sec = msgp->interval; +/* +* On some platforms (like OS X), timers and time things are slightly +* different: itimerspec is replaced with itimerval and timeval struct +* has no tv_nsec, but just tv_usec member. +* For compatibility, itimerspec is a macro defined to the existing +* itimerval on these platforms, and in such case, use usec instead +* of nsec. +*/ +#ifndef itimerspec + timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_nsec =0 ; - +#else + timespec.it_value.tv_usec =0 ; + timespec.it_interval.tv_usec =0 ; +#endif if (timer_create (CLOCK_REALTIME ,NULL , &timerid))do_error (_ ("progress_rpt: cannot create timer\n" ));
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 10/14] xfsprogs: Add a timer implementation for OS X
Quoted 3 lines · Jan Tulak
OS X does not have the timer used in
xfs_repair. Add a simple implementation providing the required capabilities.
....
Quoted 17 lines
#endif /*
__XFS_DARWIN_H__*/repair/progress.c +6
-1@@ -184,10 +184,22 @@ progress_rpt_thread (void *p)*/ timespec.it_value.tv_sec = msgp->interval; - timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_sec = msgp->interval; +/* +* On some platforms (like OS X), timers and time things are slightly +* different: itimerspec is replaced with itimerval and timeval struct +* has no tv_nsec, but just tv_usec member. +* For compatibility, itimerspec is a macro defined to the existing +* itimerval on these platforms, and in such case, use usec instead
repair/progress.c progress_rpt_thread (void *p) · line 202
Quoted 10 lines
repair/progress.c +8
-1+* of nsec. +*/ +#ifndef itimerspec + timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_nsec =0 ; - +#else + timespec.it_value.tv_usec =0 ; + timespec.it_interval.tv_usec =0 ; +#endif
That's pretty nasty. How about this:
memset(×pec, 0, sizeof(timespec)); timespec.it_value.tv_sec = msgp->interval; timespec.it_interval.tv_sec = msgp->interval;
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 10/14] xfsprogs: Add a timer implementation for OS X
Quoted 37 lines · Dave Chinner
Quoted 3 lines · Jan Tulak
OS X does not have the timer used in
xfs_repair. Add a simple implementation providing the required capabilities.....
repair/progress.c progress_rpt_thread (void *p) · line 189
Quoted 13 lines
#endif /*
__XFS_DARWIN_H__*/repair/progress.c +2
-1@@ -184,10 +184,22 @@ progress_rpt_thread (void *p)*/ timespec.it_value.tv_sec = msgp->interval; - timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_sec = msgp->interval; +/* +* On some platforms (like OS X), timers and time things are slightly
repair/progress.c progress_rpt_thread (void *p) · line 190
Quoted 1 line
repair/progress.c +1
-0+* different: itimerspec is replaced with itimerval and timeval struct
repair/progress.c progress_rpt_thread (void *p) · line 202
Quoted 13 lines
repair/progress.c +11
-1+* has no tv_nsec, but just tv_usec member. +* For compatibility, itimerspec is a macro defined to the existing +* itimerval on these platforms, and in such case, use usec instead +* of nsec. +*/ +#ifndef itimerspec + timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_nsec =0 ; - +#else + timespec.it_value.tv_usec =0 ; + timespec.it_interval.tv_usec =0 ; +#endif That's pretty nasty. How about this:
Quoted 4 lines
memset(×pec, 0, sizeof(timespec));
timespec.it_value.tv_sec = msgp->interval;
timespec.it_interval.tv_sec = msgp->interval;This is much better and elegant solution. :-)
Cheers,
Jan
Signature · 2 lines
Jan Tulak [email protected] / [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 10/14 xfsprogs: Add a timer implementation for OS X
In reply to Jan TulakUPDATE:
- Instead of ifndef just call memset to zero the structure universally.
OS X does not have the timer used in xfs_repair. Add a simple implementation providing the required capabilities.
--- include/darwin.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ repair/progress.c | 3 +-- 2 files changed, 49 insertions(+), 2 deletions(-)
include/darwin.h +48 -0
@@ -28,6 +28,7 @@#include <sys/ioctl.h> #include <sys/mount.h> #include <sys/types.h> +#include <sys/time.h> #include <ftw.h> #include <mach/mach_time.h> #include <inttypes.h>
@@ -168,4 +169,51 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) return 0; } +/* +* POSIX timer replacement. +* It really just do the minimum we need for xfs_repair. +* Also, as setitimer can't create multiple timers, +* the timerid things are useless - we have only one ITIMER_REAL +* timer. +*/ +#define CLOCK_REALTIME ITIMER_REAL +#define itimerspec itimerval +typedef uint64_t timer_t ; +typedef double timer_c ; +typedef clock_id_t clockid_t ; + + +static inline int timer_create (clockid_t __clock_id, +struct sigevent *__restrict __evp, +timer_t *__restrict timer) +{ +// set something, to initialize the variable, just in case + *timer =0 ; +return 0 ; +} + +static inline int timer_settime (timer_t timerid,int flags, +const struct itimerspec *__restrict timerspec, +struct itimerspec *__restrict ovalue) +{ +return setitimer (ITIMER_REAL , timerspec, ovalue); +} + +static inline int timer_delete (timer_t timerid) +{ +struct itimerspec timespec; + + timespec.it_interval.tv_sec=0 ; + timespec.it_interval.tv_usec=0 ; + timespec.it_value.tv_sec=0 ; + timespec.it_value.tv_usec=0 ; + +return setitimer (ITIMER_REAL , ×pec,NULL ); +} + +static inline int timer_gettime (timer_t timerid,struct itimerspec *value) +{ +return getitimer (ITIMER_REAL , value); +} +#endif /* __XFS_DARWIN_H__ */
repair/progress.c +1 -2
@@ -183,10 +183,9 @@ progress_rpt_thread (void *p)* Specify a repeating timer that fires each MSG_INTERVAL seconds. */ +memset (×pec,0 ,sizeof (timespec)); timespec.it_value.tv_sec = msgp->interval; - timespec.it_value.tv_nsec =0 ; timespec.it_interval.tv_sec = msgp->interval; - timespec.it_interval.tv_nsec =0 ;if (timer_create (CLOCK_REALTIME ,NULL , &timerid))do_error (_ ("progress_rpt: cannot create timer\n" ));
Signature · 6 lines
2.5.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 11/14 xfsprogs: Add statvfs64 for osx
In reply to Jan TulakSimply rename statvfs64 to statfs with a #define.
OSX version of statvfs is missing some members, so if the renaming is in effect (stavfs64 is defined), don't try to use them and go directly for the other member value.
--- fsr/xfs_fsr.c | 14 ++++++++++++++ include/builddefs.in | 2 +- include/darwin.h | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-)
fsr/xfs_fsr.c +14 -0
@@ -36,6 +36,12 @@# include <mntent.h> #endif +#ifdef __APPLE__ +//# define statvfs64 statfs; +# include <sys/param.h> +# include <sys/mount.h> +#endif +#ifndef XFS_XFLAG_NODEFRAG #define XFS_XFLAG_NODEFRAG 0x00002000/* src dependancy, remove later */ #endif
@@ -948,7 +954,11 @@ fsrfile_common( 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: "
@@ -1728,7 +1738,11 @@ 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 ;
include/builddefs.in +1 -1
@@ -123,7 +123,7 @@ PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS) endif ifeq ($(PKG_PLATFORM),darwin) PCFLAGS = $(GCCFLAGS) -DEPENDFLAGS = -D__APPLE__ +DEPENDFLAGS = -D__APPLE__ -D_DARWIN_FEATURE_64_BIT_INODE endif ifeq ($(PKG_PLATFORM),irix) PLDLIBS = -ldisk -lgen
include/darwin.h +5 -0
@@ -216,4 +216,9 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value) return getitimer(ITIMER_REAL, value); } +/* FSR */ + +#define statvfs64 statfs +#define _PATH_MOUNTED "/etc/mtab" +#endif /* __XFS_DARWIN_H__ */
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 11/14] xfsprogs: Add statvfs64 for osx
Quoted 17 lines · Jan Tulak
Simply rename statvfs64 to statfs with a #define.
OSX version of statvfs is missing some members, so if the renaming is in effect (stavfs64 is defined), don't try to use them and go directly for the other member value.Signed-off-by Jan Tulak <[email protected]>--- fsr/xfs_fsr.c | 14 ++++++++++++++ include/builddefs.in | 2 +- include/darwin.h | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-)fsr/xfs_fsr.c +0
-0
fsr/xfs_fsr.c line 43
Quoted 8 lines
fsr/xfs_fsr.c +5
-0@@ -36,6 +36,12 @@# include <mntent.h> #endif +#ifdef __APPLE__ +//# define statvfs64 statfs; +# include <sys/param.h> +# include <sys/mount.h> +#endif
Why is this here? We've included libxfs.h in this file, so we've got access to the platform specific includes already, and later in the patch you put the commented out define there...
fsr/xfs_fsr.c fsrfile_common( · line 961
Quoted 13 lines
fsr/xfs_fsr.c +5
-0+#ifndef XFS_XFLAG_NODEFRAG #define XFS_XFLAG_NODEFRAG 0x00002000/* src dependancy, remove later */ #endif @@ -948,7 +954,11 @@ fsrfile_common( fname, strerror(errno));return -1 ; } +#ifndef statvfs64 bsize = vfss.f_frsize ? vfss.f_frsize : vfss.f_bsize; +#else + bsize = vfss.f_bsize; +#endif
bsize = platform_statvfs_bsize(&vfss);
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 11/14] xfsprogs: Add statvfs64 for osx
Quoted 21 lines · Dave Chinner
Quoted 20 lines · Jan Tulak
Simply rename statvfs64 to statfs with a #define.
OSX version of statvfs is missing some members, so if the renaming is in effect (stavfs64 is defined), don't try to use them and go directly for the other member value.Signed-off-by Jan Tulak <[email protected]>--- fsr/xfs_fsr.c | 14 ++++++++++++++ include/builddefs.in | 2 +- include/darwin.h | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-)fsr/xfs_fsr.c +0
-0@@ -36,6 +36,12 @@# include <mntent.h> #endif
Quoted 10 lines
fsr/xfs_fsr.c line 43
Quoted 5 lines
fsr/xfs_fsr.c +5
-0+#ifdef __APPLE__ +//# define statvfs64 statfs; +# include <sys/param.h> +# include <sys/mount.h> +#endif Why is this here? We've included
libxfs.hin this file, so we've got access to the platform specific includes already, and later in the patch you put the commented out define there...
Most likely because I messed it in a rebase during some conflict. I try to check for these things, but apparently this one escaped. Removing it again..
Thanks for catching it.
Cheers,
Jan
Signature · 2 lines
Jan Tulak [email protected] / [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 11/14 xfsprogs: Add statvfs64 for osx
In reply to Jan TulakUPDATE:
- removing unnecessary include lines (again)
Simply rename statvfs64 to statfs with a #define.
OSX version of statvfs is missing some members, so if the renaming is in effect (stavfs64 is defined), don't try to use them and go directly for the other member value.
--- fsr/xfs_fsr.c | 8 ++++++++ include/builddefs.in | 2 +- include/darwin.h | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-)
fsr/xfs_fsr.c +8 -0
@@ -948,7 +948,11 @@ fsrfile_common( 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: "
@@ -1728,7 +1732,11 @@ 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 ;
include/builddefs.in +1 -1
@@ -123,7 +123,7 @@ PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS) endif ifeq ($(PKG_PLATFORM),darwin) PCFLAGS = $(GCCFLAGS) -DEPENDFLAGS = -D__APPLE__ +DEPENDFLAGS = -D__APPLE__ -D_DARWIN_FEATURE_64_BIT_INODE endif ifeq ($(PKG_PLATFORM),irix) PLDLIBS = -ldisk -lgen
include/darwin.h +5 -0
@@ -216,4 +216,9 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value) return getitimer(ITIMER_REAL, value); } +/* FSR */ + +#define statvfs64 statfs +#define _PATH_MOUNTED "/etc/mtab" +#endif /* __XFS_DARWIN_H__ */
Signature · 6 lines
2.5.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 12/14 xfsprogs: make fsr use mntinfo when there is no mntent
In reply to Jan TulakFor what fsr needs, mntinfo can be used instead of mntent. Custom mntent struct is used to avoid too big ifdefs:
We only change few lines and the rest of the code can still use mntent as before.
--- fsr/Makefile | 8 +++++++ fsr/xfs_fsr.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-------- include/darwin.h | 20 ++++++++++++++++ 3 files changed, 87 insertions(+), 10 deletions(-)
fsr/Makefile +8 -0
@@ -9,6 +9,14 @@ LTCOMMAND = xfs_fsr CFILES = xfs_fsr.c LLDLIBS = $(LIBHANDLE) +ifeq ($(HAVE_GETMNTENT),yes) +LCFLAGS += -DHAVE_GETMNTENT +endif + +ifeq ($(HAVE_GETMNTINFO),yes) +LCFLAGS += -DHAVE_GETMNTINFO +endif + default: depend $(LTCOMMAND) include $(BUILDRULES)
fsr/xfs_fsr.c +59 -10
124 lines not on this page · raw message
include/darwin.h +20 -0
@@ -218,7 +218,27 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value)/* FSR */ +# include <sys/mount.h> +# include <sys/param.h> +#include <sys/ucred.h> +#include <errno.h> #define statvfs64 statfs#define _PATH_MOUNTED "/etc/mtab" +struct mntent +{ +char *mnt_fsname; +char *mnt_dir; +char *mnt_type; +char *mnt_opts; +int mnt_freq; +int mnt_passno; +}; + +static inline void mntinfo2mntent (struct statfs * stats,struct mntent * mnt) { + mnt->mnt_fsname = stats->f_mntfromname; + mnt->mnt_dir = stats->f_mntonname; + mnt->mnt_type = stats->f_fstypename; +} +#endif /* __XFS_DARWIN_H__ */
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/14] xfsprogs: make fsr use mntinfo when there is no mntent
Quoted 74 lines · Jan Tulak
For what fsr needs, mntinfo can be used instead of mntent. Custom mntent struct is used to avoid too big ifdefs:
We only change few lines and the rest of the code can still use mntent as before.Signed-off-by Jan Tulak <[email protected]>--- fsr/Makefile | 8 +++++++ fsr/xfs_fsr.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-------- include/darwin.h | 20 ++++++++++++++++ 3 files changed, 87 insertions(+), 10 deletions(-)fsr/Makefile +8
-0@@ -9,6 +9,14 @@ LTCOMMAND = xfs_fsr CFILES = xfs_fsr.c LLDLIBS = $(LIBHANDLE) +ifeq ($(HAVE_GETMNTENT),yes) +LCFLAGS += -DHAVE_GETMNTENT +endif + +ifeq ($(HAVE_GETMNTINFO),yes) +LCFLAGS += -DHAVE_GETMNTINFO +endif + default: depend $(LTCOMMAND) include $(BUILDRULES)fsr/xfs_fsr.c +16
-2@@ -32,8 +32,10 @@#include <sys/statvfs.h> #include <sys/xattr.h> -#ifdef HAVE_MNTENT +#if defined(HAVE_GETMNTENT )# include <mntent.h> +#elif defined(HAVE_GETMNTINFO ) +# include <sys/mount.h> #endif #ifdef __APPLE__@@ -191,9 +193,10 @@ find_mountpoint(char *mtab, char *argname, struct stat64 *sb) { struct mntent *t; struct stat64 ms; -FILE *mtabp; char *mntp = NULL; +#if defined(HAVE_GETMNTENT) + FILE *mtabp; mtabp = setmntent(mtab, "r"); if (!mtabp) { fprintf(stderr, _("%s: cannot read %s\n"),@@ -202,6 +205,27 @@ find_mountpoint(char *mtab, char *argname, struct stat64 *sb) }while ((t =getmntent (mtabp))) { +#elif defined(HAVE_GETMNTINFO) +struct statfs *stats; +int error, i, count; +// because "t" is a pointer, but we don't need to use +// malloc for this usage +struct mntent t_tmp; + t = &t_tmp; + + + error =0 ; +if ((count =getmntinfo (&stats,0 )) <0 ) {
fsr/xfs_fsr.c find_mountpoint(char *mtab, char *argname, struct stat64 *sb) · line 228
Quoted 10 lines
fsr/xfs_fsr.c +10
-0+fprintf (stderr,_ ("%s: getmntinfo() failed: %s\n" ), + progname,strerror (errno)); + return 0; + } + +for (i =0 ; i < count; i++) { +mntinfo2mntent (&stats[i], t); +#else +# error "How do I extract info about mounted filesystems on this platform?" +#endif
No, please don't do that. Having a loop iterator split across two separate defines is unmaintainable. Write two separate functions with the different loop iterators, then factor the common bit out of them into a single function.
Quoted 23 lines
fsr/xfs_fsr.c +19
-0/* find all rw xfs file systems */ mi =0 ; fs = fsbase; + +#if defined(HAVE_GETMNTENT ) +FILE *fp; + fp =setmntent (mtab,"r" ); +if (fp ==NULL ) { +fsrprintf (_ ("could not open mtab file: %s\n" ), mtab); +exit (1 ); + } +while ((mp =getmntent (fp))) { +#elif defined(HAVE_GETMNTINFO) +struct statfs *stats; +int error, i, count; +// because "t" is a pointer, but we don't need to use +// malloc for this usage +struct mntent mp_tmp; + mp = &mp_tmp; + error =0 ; +if ((count =getmntinfo (&stats,0 )) <0 ) { + fprintf(stderr, _("%s: getmntinfo() failed: %s\n"),
fsr/xfs_fsr.c initallfs(char *mtab) · line 483
Quoted 10 lines
fsr/xfs_fsr.c +10
-0+ progname, strerror(errno)); + exit(1); + } + +for (i =0 ; i < count; i++) { +mntinfo2mntent (&stats[i], mp); +#else +# error "How do I extract info about mounted filesystems on this platform?" +#endif +
Same again here.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/14] xfsprogs: make fsr use mntinfo when there is no mntent
Quoted 27 lines · Dave Chinner
Review find_mountpoint(char *mtab, char *argname, struct
Quoted 1 line · Jan Tulak
(quoted diff) +0
-0@@ -202,6 +205,27 @@ find_mountpoint(char *mtab, char *argname, structstat64 *sb)
Quoted 13 lines
fsr/xfs_fsr.c +10
-0}while ((t =getmntent (mtabp))) { +#elif defined(HAVE_GETMNTINFO) +struct statfs *stats; +int error, i, count; +// because "t" is a pointer, but we don't need to use +// malloc for this usage +struct mntent t_tmp; + t = &t_tmp; + + + error =0 ;fsr/xfs_fsr.c find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
Quoted 10 lines
fsr/xfs_fsr.c +10
-0+if ((count =getmntinfo (&stats,0 )) <0 ) { +fprintf (stderr,_ ("%s: getmntinfo() failed: %s\n" ), + progname,strerror (errno)); +return 0 ; + } + +for (i =0 ; i < count; i++) { +mntinfo2mntent (&stats[i], t); +#else +# error "How do I extract info about mounted filesystems on thisplatform?"
Quoted 8 lines
Review find_mountpoint(char *mtab, char *argname, struct · line 228
Quoted 1 line
(quoted diff) +1
-0+#endifNo, please don't do that. Having a loop iterator split across two separate defines is unmaintainable. Write two separate functions with the different loop iterators, then factor the common bit out of them into a single function.
I did a little refactoring to solve it. What I would like to ask about is this:
When I can put ifdef just inside of a function like fnc(void) { #ifdef... #else ... #endif }, with little to no code outside of the ifdef, is it better to put the ifdef outside, or keep it inside?
I suppose the outside placement allows for easier changes for one of the branches when there would be a new function just for a specific branch. But on the other side, it makes it easier to forget the second function in another branch when making some change later.
Cheers,
Jan
--
-
Jan Tulak
[email protected] / [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/14] xfsprogs: make fsr use mntinfo when there is no mntent
Quoted 37 lines · Jan Tulak
Quoted 27 lines · Dave Chinner
Review find_mountpoint(char *mtab, char *argname, struct
Quoted 1 line · Jan Tulak
(quoted diff) +0
-0@@ -202,6 +205,27 @@ find_mountpoint(char *mtab, char *argname, structstat64 *sb)
Quoted 13 lines
fsr/xfs_fsr.c +10
-0}while ((t =getmntent (mtabp))) { +#elif defined(HAVE_GETMNTINFO) +struct statfs *stats; +int error, i, count; +// because "t" is a pointer, but we don't need to use +// malloc for this usage +struct mntent t_tmp; + t = &t_tmp; + + + error =0 ;fsr/xfs_fsr.c find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
Quoted 10 lines
fsr/xfs_fsr.c +10
-0+if ((count =getmntinfo (&stats,0 )) <0 ) { +fprintf (stderr,_ ("%s: getmntinfo() failed: %s\n" ), + progname,strerror (errno)); +return 0 ; + } + +for (i =0 ; i < count; i++) { +mntinfo2mntent (&stats[i], t); +#else +# error "How do I extract info about mounted filesystems on thisplatform?"
Quoted 8 lines
Review find_mountpoint(char *mtab, char *argname, struct · line 228
Quoted 1 line
(quoted diff) +1
-0+#endifNo, please don't do that. Having a loop iterator split across two separate defines is unmaintainable. Write two separate functions with the different loop iterators, then factor the common bit out of them into a single function.
Quoted 5 lines
I did a little refactoring to solve it. What I would like to ask about is this:
When I can put ifdef just inside of a function like fnc(void) { #ifdef... #else ... #endif }, with little to no code outside of the ifdef, is it better to put the ifdef outside, or keep it inside?
The idea is that the "little differences" are put in functions that end up in include/<platform>.h or libxfs/<platform>.c, so there are no ifdefs in any of the application or library code. The build will automatically include the correct function on the given platform, and so the application code does not need such ifdefs at all.
e.g. you could implement these functions to abstract the differences away from xfs_fsr and any other code that iterates the mount table:
struct mntent_cursor {
/* variables needed to track iteration of the mtab */
};platform_first_mntent()platform_next_mntent()platform_end_mntent()
and so the code would look like:
struct mntent_cursor cursor;
mntent = platform_first_mntent(&cursor)
do {
/* process mntent */
} while (mntent = platform_next_mntent(&cursor, mntent));
platform_end_mntent(&cursor);This completely abstracts the differences related to the the mount table traversal, and allows the aplication level code to be written in a clean, easily maintainable fashion...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/14] xfsprogs: make fsr use mntinfo when there is no mntent
Quoted 76 lines · Dave Chinner
Quoted 1 line · Jan Tulak
On Wed, Sep 23, 2015 at 5:36 AM, Dave Chinner <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines · Jan Tulak
Review find_mountpoint(char *mtab, char *argname,
Quoted 1 line
(quoted diff) +0
-0@@ -202,6 +205,27 @@ find_mountpoint(char *mtab, char *argname,struct
Quoted 27 lines
Quoted 27 lines
stat64 *sb)
Quoted 13 lines
fsr/xfs_fsr.c +10
-0}while ((t =getmntent (mtabp))) { +#elif defined(HAVE_GETMNTINFO) +struct statfs *stats; +int error, i, count; +// because "t" is a pointer, but we don't need to use +// malloc for this usage +struct mntent t_tmp; + t = &t_tmp; + + + error =0 ;fsr/xfs_fsr.c find_mountpoint(char *mtab, char *argname, struct stat64 *sb)
Quoted 10 lines
fsr/xfs_fsr.c +10
-0+if ((count =getmntinfo (&stats,0 )) <0 ) { +fprintf (stderr,_ ("%s: getmntinfo() failed: %s\n" ), + progname,strerror (errno)); +return 0 ; + } + +for (i =0 ; i < count; i++) { +mntinfo2mntent (&stats[i], t); +#else +# error "How do I extract info about mounted filesystems on thisplatform?"
Quoted 1 line
(quoted diff) +1
-0+#endifQuoted 7 lines
Quoted 6 lines
No, please don't do that. Having a loop iterator split across two separate defines is unmaintainable. Write two separate functions with the different loop iterators, then factor the common bit out of them into a single function.
I did a little refactoring to solve it. What I would like to ask about
is
Quoted 4 lines
this:
When I can put ifdef just inside of a function like fnc(void) { #ifdef... #else ... #endif }, with little to no code outside of the ifdef, is it better to put the ifdef outside, or keep it inside?The idea is that the "little differences" are put in functions that end up in include/<platform>.h or libxfs/<platform>.c, so there are no ifdefs in any of the application or library code. The build will automatically include the correct function on the given platform, and so the application code does not need such ifdefs at all.
e.g. you could implement these functions to abstract the differences away from
xfs_fsrand any other code that iterates the mount table:struct mntent_cursor { /* variables needed to track iteration of the mtab */ };
platform_first_mntent()platform_next_mntent()platform_end_mntent()and so the code would look like:
struct mntent_cursor cursor; mntent = platform_first_mntent(&cursor) do { /* process mntent */ } while (mntent = platform_next_mntent(&cursor, mntent)); platform_end_mntent(&cursor);
Quoted 4 lines
This completely abstracts the differences related to the the mount table traversal, and allows the aplication level code to be written in a clean, easily maintainable fashion...
So something like what I just posted? I added the same code that works for Linux into other platforms other than OS X.
Because as it was there before, it either works on them, or no one care. And I really don't have an idea how to test it on Irix... :-)
Cheers,
Jan
Signature · 2 lines
Jan Tulak [email protected] / [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 12/14 xfsprogs: make fsr use mntinfo when there is no mntent
In reply to Jan TulakUPDATE:
- refactor ifdefs to platform_ functions
For what fsr needs, mntinfo can be used instead of mntent on some platforms. Exctract the platform-specific code to platform headers.
--- fsr/Makefile | 8 ++++ fsr/xfs_fsr.c | 127 +++++++++++++++++++++++++++++++------------------- include/darwin.h | 64 +++++++++++++++++++++++++ include/freebsd.h | 32 +++++++++++++ include/gnukfreebsd.h | 31 ++++++++++++ include/irix.h | 32 +++++++++++++ include/linux.h | 31 ++++++++++++ 7 files changed, 276 insertions(+), 49 deletions(-)
fsr/Makefile +8 -0
@@ -9,6 +9,14 @@ LTCOMMAND = xfs_fsr CFILES = xfs_fsr.c LLDLIBS = $(LIBHANDLE) +ifeq ($(HAVE_GETMNTENT),yes) +LCFLAGS += -DHAVE_GETMNTENT +endif + +ifeq ($(HAVE_GETMNTINFO),yes) +LCFLAGS += -DHAVE_GETMNTINFO +endif + default: depend $(LTCOMMAND) include $(BUILDRULES)
fsr/xfs_fsr.c +78 -49
180 lines not on this page · raw message
include/darwin.h +64 -0
77 lines not on this page · raw message
include/freebsd.h +32 -0
@@ -26,6 +26,7 @@#include <libgen.h> #include <paths.h> #include <uuid.h> +#include <mntent.h> #include <sys/endian.h> #define __BYTE_ORDER BYTE_ORDER
@@ -147,4 +148,35 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) return 0; } +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} + +#endif /* __XFS_FREEBSD_H__ */
include/gnukfreebsd.h +31 -0
@@ -31,6 +31,7 @@#include <ctype.h> #include <libgen.h> #include <paths.h> +#include <mntent.h> #define constpp char * const *
@@ -126,4 +127,34 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) return 0; } +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} +#endif /* __XFS_KFREEBSD_H__ */
include/irix.h +32 -0
@@ -37,6 +37,7 @@#include <sys/sysmacros.h> #include <sys/fs/xfs_fsops.h> #include <sys/fs/xfs_itable.h> +#include <mntent.h> #define __int8_t char#define __int16_t short
@@ -423,4 +424,35 @@ static __inline__ char * strsep(char **s, const char *ct)#define XFS_XFLAG_NODEFRAG 0x00002000 +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} + +#endif /* __XFS_IRIX_H__ */
include/linux.h +31 -0
@@ -30,6 +30,7 @@#include <endian.h> #include <stdbool.h> #include <asm/types.h> +#include <mntent.h> static __inline__int xfsctl (const char *path,int fd,int cmd,void *p) {
@@ -145,4 +146,34 @@ typedef __uint64_t xfs_ino_t;typedef __uint32_t xfs_dev_t ;typedef __int64_t xfs_daddr_t ; +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} +#endif /* __XFS_LINUX_H__ */
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/14 v2] xfsprogs: make fsr use mntinfo when there is no mntent
Quoted 7 lines · Jan Tulak
UPDATE:
- refactor ifdefs toplatform_functionsFor what fsr needs, mntinfo can be used instead of mntent on some platforms. Exctract the platform-specific code to platform headers.
Signed-off-by Jan Tulak <[email protected]>
I haven't commited this patch - I think it still needs some work to clean up....
Quoted 41 lines
static void
initallfs(char *mtab)
{fsr/xfs_fsr.c +18
-7-FILE *fp;struct mntent *mp;int mi;char *cp;struct stat64 sb; - fp =setmntent (mtab,"r" ); -if (fp ==NULL ) { -fsrprintf (_ ("could not open mtab file: %s\n" ), mtab); -exit (1 ); - } -/* malloc a number of descriptors, increased later if needed */ if (!(fsbase = (fsdesc_t *)malloc (fsbufsize *sizeof (fsdesc_t)))) {fsrprintf (_ ("out of memory: %s\n" ),strerror (errno));@@ -427,7 +425,36 @@ initallfs(char *mtab)/* find all rw xfs file systems */ mi =0 ; fs = fsbase; + +#if defined(HAVE_GETMNTENT ) +FILE *fp; + fp =setmntent (mtab,"r" ); +if (fp ==NULL ) { +fsrprintf (_ ("could not open mtab file: %s\n" ), mtab); +exit (1 ); + } +while ((mp =getmntent (fp))) { +#elif defined(HAVE_GETMNTINFO) +struct statfs *stats; +int error, i, count; +// because "t" is a pointer, but we don't need to use +// malloc for this usage +struct mntent mp_tmp; + mp = &mp_tmp; + error =0 ; +if ((count =getmntinfo (&stats,0 )) <0 ) {
fsr/xfs_fsr.c initallfs(char *mtab) · line 456
Quoted 10 lines
fsr/xfs_fsr.c +10
-0+fprintf (stderr,_ ("%s: getmntinfo() failed: %s\n" ), + progname,strerror (errno)); + exit(1); + } + +for (i =0 ; i < count; i++) { +mntinfo2mntent (&stats[i], mp); +#else +# error "How do I extract info about mounted filesystems on this platform?" +#endif
this stuff here. This iteration should be able to be done via the cursor abstraction, such as by keeping the iteration information within the cursor...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 12/14 v2] xfsprogs: make fsr use mntinfo when there is no mntent
Quoted 6 lines · Dave Chinner
this stuff here. This iteration should be able to be done via the cursor abstraction, such as by keeping the iteration information within the cursor...
Ah, sorry! I forgot to change the other #if...
Fixing it right now.
Cheers,
Jan
Signature · 2 lines
Jan Tulak [email protected] / [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 12/14 xfsprogs: make fsr use mntinfo when there is no mntent
In reply to Jan TulakUPDATE:
- refactor ifdefs to platform_ functions
- refactor also the other ifdef which I forgot to change before
For what fsr needs, mntinfo can be used instead of mntent on some platforms. Exctract the platform-specific code to platform headers.
--- fsr/Makefile | 8 ++++ fsr/xfs_fsr.c | 111 +++++++++++++++++++++++++++----------------------- include/darwin.h | 64 +++++++++++++++++++++++++++++ include/freebsd.h | 32 +++++++++++++++ include/gnukfreebsd.h | 31 ++++++++++++++ include/irix.h | 32 +++++++++++++++ include/linux.h | 31 ++++++++++++++ 7 files changed, 259 insertions(+), 50 deletions(-)
fsr/Makefile +8 -0
@@ -9,6 +9,14 @@ LTCOMMAND = xfs_fsr CFILES = xfs_fsr.c LLDLIBS = $(LIBHANDLE) +ifeq ($(HAVE_GETMNTENT),yes) +LCFLAGS += -DHAVE_GETMNTENT +endif + +ifeq ($(HAVE_GETMNTINFO),yes) +LCFLAGS += -DHAVE_GETMNTINFO +endif + default: depend $(LTCOMMAND) include $(BUILDRULES)
fsr/xfs_fsr.c +61 -50
158 lines not on this page · raw message
include/darwin.h +64 -0
77 lines not on this page · raw message
include/freebsd.h +32 -0
@@ -26,6 +26,7 @@#include <libgen.h> #include <paths.h> #include <uuid.h> +#include <mntent.h> #include <sys/endian.h> #define __BYTE_ORDER BYTE_ORDER
@@ -147,4 +148,35 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) return 0; } +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} + +#endif /* __XFS_FREEBSD_H__ */
include/gnukfreebsd.h +31 -0
@@ -31,6 +31,7 @@#include <ctype.h> #include <libgen.h> #include <paths.h> +#include <mntent.h> #define constpp char * const *
@@ -126,4 +127,34 @@ platform_discard_blocks(int fd, uint64_t start, uint64_t len) return 0; } +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} +#endif /* __XFS_KFREEBSD_H__ */
include/irix.h +32 -0
@@ -37,6 +37,7 @@#include <sys/sysmacros.h> #include <sys/fs/xfs_fsops.h> #include <sys/fs/xfs_itable.h> +#include <mntent.h> #define __int8_t char#define __int16_t short
@@ -423,4 +424,35 @@ static __inline__ char * strsep(char **s, const char *ct)#define XFS_XFLAG_NODEFRAG 0x00002000 +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} + +#endif /* __XFS_IRIX_H__ */
include/linux.h +31 -0
@@ -30,6 +30,7 @@#include <endian.h> #include <stdbool.h> #include <asm/types.h> +#include <mntent.h> static __inline__int xfsctl (const char *path,int fd,int cmd,void *p) {
@@ -145,4 +146,34 @@ typedef __uint64_t xfs_ino_t;typedef __uint32_t xfs_dev_t ;typedef __int64_t xfs_daddr_t ; +/** +* Abstraction of mountpoints. +*/ +struct mntent_cursor { +FILE *mtabp; +}; + +static inline int platform_mntent_open (struct mntent_cursor * cursor,char *mtab) +{ + cursor->mtabp =setmntent (mtab,"r" ); +if (!cursor->mtabp) { +fprintf (stderr,"Error: cannot read %s\n" , mtab); +return 1 ; + } +return 0 ; +} + +static inline int platform_mntent_next (struct mntent_cursor * cursor,struct mntent * t) +{ + t =getmntent (cursor->mtabp); +if (t ==NULL ) +return 1 ; +return 0 ; +} + +static inline void platform_mntent_close (struct mntent_cursor * cursor) +{ +endmntent (cursor->mtabp); +} +#endif /* __XFS_LINUX_H__ */
Signature · 6 lines
2.6.0 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 13/14 xfsprogs: Make mremap conditional
In reply to Jan TulakDon't build mremap (in xfs_io) on platforms where it has no support.
--- configure.ac | 1 + include/builddefs.in | 1 + include/darwin.h | 1 + io/mmap.c | 8 ++++++++ m4/package_libcdev.m4 | 13 +++++++++++++ 5 files changed, 24 insertions(+)
configure.ac +1 -0
@@ -124,6 +124,7 @@ AC_HAVE_MNTENT AC_HAVE_FLS AC_HAVE_READDIR AC_HAVE_FSETXATTR +AC_HAVE_MREMAP if test "$enable_blkid" = yes; then AC_HAVE_BLKID_TOPO
include/builddefs.in +1 -0
@@ -107,6 +107,7 @@ HAVE_READDIR = @have_readdir@ HAVE_MNTENT = @have_mntent@ HAVE_FLS = @have_fls@ HAVE_FSETXATTR = @have_fsetxattr@ +HAVE_MREMAP = @have_mremap@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
include/darwin.h +1 -0
@@ -33,6 +33,7 @@#include <mach/mach_time.h> #include <inttypes.h> #include <stdio.h> +#include <sys/mman.h> #include <machine/endian.h> #define __BYTE_ORDER BYTE_ORDER
io/mmap.c +8 -0
@@ -28,7 +28,9 @@ static cmdinfo_t mread_cmd;static cmdinfo_t msync_cmd;static cmdinfo_t munmap_cmd;static cmdinfo_t mwrite_cmd; +#ifdef HAVE_MREMAP static cmdinfo_t mremap_cmd; +#endif /* HAVE_MREMAP */ mmap_region_t *maptable;int mapcount;
@@ -574,6 +576,7 @@ mwrite_f(return 0 ; } +#ifdef HAVE_MREMAP static void mremap_help (void ) {
@@ -633,6 +636,7 @@ mremap_f( return 0; } +#endif /* HAVE_MREMAP */ void mmap_init (void )
@@ -688,6 +692,7 @@ mmap_init(void)_ ("writes data into a region in the current memory mapping" ); mwrite_cmd.help = mwrite_help; +#ifdef HAVE_MREMAP mremap_cmd.name ="mremap" ; mremap_cmd.altname ="mrm" ; mremap_cmd.cfunc = mremap_f;
@@ -698,11 +703,14 @@ mmap_init(void) mremap_cmd.oneline =_ ("alters the size of the current memory mapping" ); mremap_cmd.help = mremap_help; +#endif /* HAVE_MREMAP */ add_command (&mmap_cmd);add_command (&mread_cmd);add_command (&msync_cmd);add_command (&munmap_cmd);add_command (&mwrite_cmd); +#ifdef HAVE_MREMAP add_command (&mremap_cmd); +#endif /* HAVE_MREMAP */ }
m4/package_libcdev.m4 +13 -0
@@ -235,3 +235,16 @@ AC_DEFUN([AC_HAVE_MNTENT], have_mntent=yes) AC_SUBST(have_mntent) ]) + +# +# Check if we have a mremap call (not on Mac OS X) +# +AC_DEFUN([AC_HAVE_MREMAP], + [ AC_CHECK_DECL([mremap], + have_mremap=yes, + [], + [#define _GNU_SOURCE + #include <sys/mman.h>] + ) + AC_SUBST(have_mremap) + ])
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 13/14] xfsprogs: Make mremap conditional
Quoted 3 lines · Jan Tulak
Don't build mremap (in
xfs_io) on platforms where it has no support.Signed-off-by Jan Tulak <[email protected]>
This doesn't define HAVE_REMAP as a build define in io/Makefile, so always fails to build in mremap support. this leads to:
generic/030 2s ... [not run] xfs_io mremap support is missing
I've fixed this on commit.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 14/14 xfsprogs: rename lstat64 to lstat for OS X
In reply to Jan TulakOS X has a different means to distinguish between
a 32 and 64bit calls - using xxx64 is deprecated.
--- include/darwin.h | 1 + 1 file changed, 1 insertion(+)
include/darwin.h +1 -0
@@ -224,6 +224,7 @@ static inline int timer_gettime (timer_t timerid, struct itimerspec *value)#include <sys/ucred.h> #include <errno.h> #define statvfs64 statfs +#define lstat64 lstat#define _PATH_MOUNTED "/etc/mtab"struct mntent
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs