xfsprogs: OS X partial support
v3 cover xfsprogs: OS X partial support
Hi folks.
All right, this is a third iteration of fixing the out-of-date OS X code in xfsprogs (4 years since the last touch).
Against v2, I made these changes:
- Patch 4/4 was broken to 8 smaller patches
- Issues in that patch were addressed
- Greatly enhanced commit message about LIST_ macros renaming
The last point is still open and may change, so I moved it into the last commit. First two commits were already reviewed, but I include them to keep their trace in this new numbering of the patchset.
Cheers,
Jan
Jan Tulak (11):
xfsprogs: Don't Make .po files with gettext disabled
xfsprogs: Use glibtoolize on osx
xfsprogs: undefined variable fix
xfsprogs: Add ifdef dirent checks where it was missing
xfsprogs: Change OS X-specific CFLAGS/LDFLAGS
xfsprogs: Add includes required for OS X builds
xfsprogs: missing and dummy calls for OS X support
xfsprogs: Add fls check into autoconf
xfsprogs: Add mntent.h check into autoconf
xfsprogs: replace obsolete memalign with posix_memalign
xfsprogs: Prefix LIST_... macros to XFS_LIST_...
Makefile | 19 +++++- configure.ac | 2 + copy/xfs_copy.c | 2 +- db/attrset.c | 2 +- fsr/xfs_fsr.c | 17 ++++-- include/bitops.h | 2 + include/builddefs.in | 10 +++- include/darwin.h | 159 ++++++++++++++++++++++++++++++++++++++++++++------ include/freebsd.h | 1 - include/gnukfreebsd.h | 1 - include/linux.h | 1 - include/list.h | 6 +- io/pread.c | 4 +- io/readdir.c | 4 ++ libdisk/fstype.c | 1 + libhandle/Makefile | 4 ++ libxcmd/paths.c | 2 +- libxfs/rdwr.c | 19 ++++-- m4/package_libcdev.m4 | 26 +++++++++ mkfs/xfs_mkfs.c | 6 +- repair/incore.c | 2 +- repair/incore_ino.c | 13 ++++- repair/phase1.c | 2 +- repair/phase6.c | 2 +- repair/prefetch.c | 7 +-- repair/sb.c | 10 ++-- rtcp/xfs_rtcp.c | 7 ++- 27 files changed, 274 insertions(+), 57 deletions(-)
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 3/11 xfsprogs: undefined variable fix
Typo fix, which wasn't catch earlier due to #ifdef branching. The 'rmnttomname' does not exists anywhere and looks like a hybrid between rmntfromname and rmntonname. And because the previous if has has 'fromname' on both arguments of realpath, I choose the same approach when fixing it.
--- libxcmd/paths.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libxcmd/paths.c +1 -1
@@ -364,7 +364,7 @@ fs_table_initialise_mounts(continue ;if (!realpath (stats[i].f_mntfromname, rmntfromname))continue ; - if (!realpath(stats[i].f_mntonname, rmnttomname))) +if (!realpath (stats[i].f_mntonname, rmntonname))continue ; if (path &&
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 2/11 xfsprogs: Use glibtoolize on osx
In reply to Jan Tulak(Already reviewed by Chris, but resubmiting
as the patchset itself was partially reworked.)
OS X doesn't have libtoolize binary by default, and the available$ ports are named "glibtoolize". Autodetect this issue.
--- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Makefile +11 -2
@@ -52,6 +52,14 @@ ifneq ("$(XGETTEXT)","") TOOL_SUBDIRS += po endif +# If we are on OS X, use glibtoolize from MacPorts, as OS X doesn't have +# libtoolize binary itself. +LIBTOOLIZE_TEST=$(shell libtoolize --version >/dev/null 2>&1 && echo found) +LIBTOOLIZE_BIN=libtoolize +ifneq ("$(LIBTOOLIZE_TEST)","found") +LIBTOOLIZE_BIN=glibtoolize +endif + # include is listed last so it is processed last in clean rules. SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include
@@ -85,13 +93,14 @@ else clean: # if configure hasn't run, nothing to clean endif + # Recent versions of libtool require the -i option for copying auxiliary # files (config.sub, config.guess, install-sh, ltmain.sh), while older # versions will copy those files anyway, and don't understand -i. -LIBTOOLIZE_INSTALL = `libtoolize -n -i >/dev/null 2>/dev/null && echo -i` +LIBTOOLIZE_INSTALL = `$(LIBTOOLIZE_BIN) -n -i >/dev/null 2>/dev/null && echo -i` configure: - libtoolize -c $(LIBTOOLIZE_INSTALL) -f + $(LIBTOOLIZE_BIN) -c $(LIBTOOLIZE_INSTALL) -f cp include/install-sh . aclocal -I m4 autoconf
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/11 xfsprogs: Don't Make .po files with gettext disabled
In reply to Jan Tulak(Already reviewed by Chris, but resubmiting
as the patchset itself was partially reworked.)
"po" target is added only if gettext binary is found. Without this patch, Make tried to build the target even with --enable-gettext=no configure option, which led to a failing build.
--- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
@@ -46,7 +46,11 @@ HDR_SUBDIRS = include libxfs DLIB_SUBDIRS = libxlog libxcmd libhandle libdisk LIB_SUBDIRS = libxfs $(DLIB_SUBDIRS) TOOL_SUBDIRS = copy db estimate fsck fsr growfs io logprint mkfs quota \ - mdrestore repair rtcp m4 man doc po debian + mdrestore repair rtcp m4 man doc debian + +ifneq ("$(XGETTEXT)","") +TOOL_SUBDIRS += po +endif # include is listed last so it is processed last in clean rules. SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) include
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 4/11 xfsprogs: Add ifdef dirent checks where it was missing
In reply to Jan TulakAdd check for _DIRENT_HAVED_RECLEN/_OFF to read_directory(). In dump_dirent() these checks already are used, but they were missing in read_directory.
--- io/readdir.c | 4 ++++ 1 file changed, 4 insertions(+)
io/readdir.c +4 -0
@@ -104,12 +104,16 @@ read_directory(if (!dirent)break ; +#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#endif count++;if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#endif } }
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 5/11 xfsprogs: Change OS X-specific CFLAGS/LDFLAGS
In reply to Jan TulakOS X uses clang as a default compiler.
So remove incompatible options.
--- include/builddefs.in | 2 +- libhandle/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
include/builddefs.in +1 -1
@@ -119,7 +119,7 @@ ifeq ($(PKG_PLATFORM),gnukfreebsd) PCFLAGS = -D_GNU_SOURCE $(GCCFLAGS) endif ifeq ($(PKG_PLATFORM),darwin) -PCFLAGS = -traditional-cpp $(GCCFLAGS) +PCFLAGS = $(GCCFLAGS) DEPENDFLAGS = -D__APPLE__ endif ifeq ($(PKG_PLATFORM),irix)
libhandle/Makefile +4 -0
@@ -10,7 +10,11 @@ LT_CURRENT = 1 LT_REVISION = 3 LT_AGE = 0 +ifeq ($(PKG_PLATFORM),darwin) +LTLDFLAGS += -Wl,libhandle.sym +else LTLDFLAGS += -Wl,--version-script,libhandle.sym +endif CFILES = handle.c jdm.c LSRCFILES = libhandle.sym
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 6/11 xfsprogs: Add includes required for OS X builds
In reply to Jan Tulak--- include/darwin.h | 5 +++++ libdisk/fstype.c | 1 + 2 files changed, 6 insertions(+)
include/darwin.h +5 -0
@@ -24,6 +24,11 @@#include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mount.h> +#include <sys/types.h> +#include <ftw.h> +#include <mach/mach_time.h> +#include <inttypes.h> +#include <stdio.h> #include <machine/endian.h> #define __BYTE_ORDER BYTE_ORDER
libdisk/fstype.c +1 -0
@@ -22,6 +22,7 @@#include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <sys/types.h> #include "fstype.h" /*
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 7/11 xfsprogs: missing and dummy calls for OS X support
In reply to Jan TulakAdd and update various API, macros and types where is some change in OS X or xfsprogs. Most changes are in darwin.h.
Add dummy implementations where native support is nonexistent and the tools are not expected to work anyway, so all tools can be at least compiled.
--- fsr/xfs_fsr.c | 8 +++ include/darwin.h | 153 +++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 145 insertions(+), 16 deletions(-)
fsr/xfs_fsr.c +8 -0
@@ -43,6 +43,14 @@#define _PATH_FSRLAST "/var/tmp/.fsrlast_xfs"#define _PATH_PROC_MOUNTS "/proc/mounts" +#ifdef USE_DUMMY_XATTR +/* OS X has fsetxattr with different number of arguments. +* Because it won't work anyway (no fstab/mtab and so on), +* hijack the call to a dummy function so it can at least +* compile. +*/ +# define fsetxattr (a,b,c,d,e) dummy_fsetxattr(a,b,c,d,e) +#endif char *progname;
include/darwin.h +137 -16
197 lines not on this page · raw message
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 8/11 xfsprogs: Add fls check into autoconf
In reply to Jan TulakAdd a check for fls call, and a replacement call
for platforms without fls.
--- configure.ac | 1 + include/bitops.h | 2 ++ include/builddefs.in | 4 ++++ m4/package_libcdev.m4 | 14 ++++++++++++++ 4 files changed, 21 insertions(+)
configure.ac +1 -0
@@ -113,6 +113,7 @@ AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE AC_HAVE_BLKID_TOPO($enable_blkid) AC_HAVE_READDIR +AC_HAVE_FLS AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([char *])
include/bitops.h +2 -0
@@ -5,6 +5,7 @@* fls: find last bit set. */ +#ifndef HAVE_FLS static inline int fls (int x) {int r =32 ;
@@ -32,6 +33,7 @@ static inline int fls(int x) }return r; } +#endif /* HAVE_FLS */ static inline int fls64 (__u64 x) {
include/builddefs.in +4 -0
@@ -104,6 +104,7 @@ HAVE_FIEMAP = @have_fiemap@ HAVE_PREADV = @have_preadv@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ HAVE_READDIR = @have_readdir@ +HAVE_FLS = @have_fls@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -131,6 +132,9 @@ PLDLIBS = -L/usr/local/lib -lintl PCFLAGS = -I/usr/local/include $(GCCFLAGS) DEPENDFLAGS = -D__FreeBSD__ endif +ifeq ($(HAVE_FLS),yes) +LCFLAGS+= -DHAVE_FLS +endif GCFLAGS = $(OPTIMIZER) $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
m4/package_libcdev.m4 +14 -0
@@ -202,3 +202,17 @@ AC_DEFUN([AC_HAVE_READDIR], AC_SUBST(have_readdir) ]) +# +# Check if we have a flc call (Mac OS X) +# +AC_DEFUN([AC_HAVE_FLS], + [ AC_MSG_CHECKING([for fls]) + AC_TRY_LINK([ +#include <string.h> + ], [ + fls(0); + ], have_fls=yes + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_SUBST(have_fls) + ])
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 9/11 xfsprogs: Add mntent.h check into autoconf
In reply to Jan Tulak--- configure.ac | 1 + fsr/xfs_fsr.c | 6 +++--- include/builddefs.in | 4 ++++ m4/package_libcdev.m4 | 12 ++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-)
configure.ac +1 -0
@@ -113,6 +113,7 @@ AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE AC_HAVE_BLKID_TOPO($enable_blkid) AC_HAVE_READDIR +AC_HAVE_MNTENT AC_HAVE_FLS AC_CHECK_SIZEOF([long])
fsr/xfs_fsr.c +3 -3
@@ -25,16 +25,16 @@#include <fcntl.h> #include <errno.h> -#include <malloc.h> -#include <mntent.h> #include <syslog.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/wait.h> -#include <sys/vfs.h> #include <sys/statvfs.h> #include <sys/xattr.h> +#ifdef HAVE_MNTENT +# include <mntent.h> +#endif #ifndef XFS_XFLAG_NODEFRAG #define XFS_XFLAG_NODEFRAG 0x00002000/* src dependancy, remove later */
include/builddefs.in +4 -0
@@ -104,6 +104,7 @@ HAVE_FIEMAP = @have_fiemap@ HAVE_PREADV = @have_preadv@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ HAVE_READDIR = @have_readdir@ +HAVE_MNTENT = @have_mntent@ HAVE_FLS = @have_fls@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
@@ -135,6 +136,9 @@ endif ifeq ($(HAVE_FLS),yes) LCFLAGS+= -DHAVE_FLS endif +ifeq ($(HAVE_MNTENT),yes) +PCFLAGS+= -DHAVE_MNTENT +endif GCFLAGS = $(OPTIMIZER) $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
m4/package_libcdev.m4 +12 -0
@@ -216,3 +216,15 @@ AC_DEFUN([AC_HAVE_FLS], AC_MSG_RESULT(no)) AC_SUBST(have_fls) ]) + +# +# Check if there is mntent.h +# +AC_DEFUN([AC_HAVE_MNTENT], + [ AC_MSG_CHECKING([for mntent]) + AC_CHECK_HEADERS(mntent.h, + have_mntent=yes + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_SUBST(have_mntent) + ])
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 10/11 xfsprogs: replace obsolete memalign with posix_memalign
In reply to Jan TulakMemalign from <malloc.h> was marked obsolete in favor of a posix variant from <stdlib.h>. So replace all calls and remove <malloc.h> includes. This also enhances support on other posix platforms, which doesn't have <malloc.h>.
Because posix_memalign returns any error as a return code, not in errno, change relevant checks in code (and add a missing one).
--- copy/xfs_copy.c | 2 +- db/attrset.c | 2 +- fsr/xfs_fsr.c | 3 ++- include/darwin.h | 1 - include/freebsd.h | 1 - include/gnukfreebsd.h | 1 - include/linux.h | 1 - io/pread.c | 4 ++-- libxfs/rdwr.c | 19 +++++++++++++++---- mkfs/xfs_mkfs.c | 6 +++++- repair/incore.c | 2 +- repair/incore_ino.c | 13 ++++++++++--- repair/phase1.c | 2 +- repair/prefetch.c | 7 +++---- repair/sb.c | 10 +++++----- rtcp/xfs_rtcp.c | 7 ++++++- 16 files changed, 52 insertions(+), 29 deletions(-)
copy/xfs_copy.c +1 -1
@@ -332,7 +332,7 @@ wbuf * wbuf_init(wbuf *buf, int data_size, int data_align, int min_io_size, int id) {ASSERT (data_size %BBSIZE ==0 ); -while ((buf->data =memalign (data_align, data_size)) ==NULL ) { +while (posix_memalign ((void **)&(buf->data), data_align, data_size)) { data_size >>=1 ;if (data_size < min_io_size)return NULL ;
db/attrset.c +1 -1
@@ -141,7 +141,7 @@ attr_set_f( name = argv[optind];if (valuelen) { - value = (char *)memalign (getpagesize (), valuelen); +posix_memalign ((void **)&value,getpagesize (), valuelen);if (!value) {dbprintf (_ ("cannot allocate buffer (%d)\n" ), valuelen); goto out;
fsr/xfs_fsr.c +2 -1
@@ -1306,7 +1306,8 @@ packfile(char *fname, char *tname, int fd, dio.d_maxiosz, pagesize); } -if (!(fbuf = (char *)memalign (dio.d_mem, blksz_dio))) { +posix_memalign ((void **)&fbuf, dio.d_mem, blksz_dio); +if (!fbuf) {fsrprintf (_ ("could not allocate buf: %s\n" ), tname); goto out; }
include/darwin.h +0 -1
@@ -129,7 +129,6 @@ typedef int64_t xfs_daddr_t;#define pwrite64 pwrite#define ftruncate64 ftruncate#define fdatasync fsync -#define memalign (a,sz) valloc(sz)#define O_LARGEFILE 0#ifndef O_DIRECT
include/freebsd.h +0 -1
@@ -40,7 +40,6 @@#define pwrite64 pwrite#define pread64 pread#define fdatasync fsync -#define memalign (a,sz) valloc(sz)#define constpp char * const *
include/gnukfreebsd.h +0 -1
@@ -22,7 +22,6 @@#include <sys/vfs.h> #include <sys/ioctl.h> #include <sys/sysmacros.h> -#include <malloc.h> #include <getopt.h> #include <endian.h> #include <sys/stat.h>
include/linux.h +0 -1
@@ -24,7 +24,6 @@#include <sys/sysmacros.h> #include <sys/stat.h> #include <inttypes.h> -#include <malloc.h> #include <getopt.h> #include <endian.h> #include <stdbool.h>
io/pread.c +2 -2
@@ -78,7 +78,7 @@ alloc_iovec( buffersize =0 ;for (i =0 ; i < vectors; i++) { - iov[i].iov_base =memalign (pagesize, bsize); +posix_memalign ((void **)&(iov[i].iov_base), pagesize, bsize);if (!iov[i].iov_base) {perror ("memalign" ); goto unwind;
@@ -109,7 +109,7 @@ alloc_buffer(if (bsize > highwater) {if (buffer)free (buffer); - buffer =memalign (pagesize, bsize); +posix_memalign ((void **)&buffer, pagesize, bsize);if (!buffer) {perror ("memalign" ); highwater = buffersize =0 ;
libxfs/rdwr.c +15 -4
@@ -74,12 +74,18 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len)ssize_t zsize, bytes;char *z;int fd; +int ret; zsize =min (BDSTRAT_SIZE ,BBTOB (len)); -if ((z =memalign (libxfs_device_alignment (), zsize)) ==NULL ) { + ret =posix_memalign ( + (void **)&z, +libxfs_device_alignment (), + zsize + ); +if (!z) {fprintf (stderr,_ ("%s: %s can't memalign %d bytes: %s\n" ), - progname, __FUNCTION__, (int )zsize,strerror (errno)); + progname, __FUNCTION__, (int )zsize,strerror (ret));exit (1 ); }memset (z,0 , zsize);
@@ -409,6 +415,7 @@ static void __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, unsigned int bytes) { +int ret; bp->b_flags =0 ; bp->b_bn = bno; bp->b_bcount = bytes;
@@ -416,12 +423,16 @@ __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, bp->b_target = btp; bp->b_error =0 ;if (!bp->b_addr) - bp->b_addr =memalign (libxfs_device_alignment (), bytes); + ret =posix_memalign ( + (void **)&(bp->b_addr), +libxfs_device_alignment (), + bytes + );if (!bp->b_addr) {fprintf (stderr,_ ("%s: %s can't memalign %u bytes: %s\n" ), progname, __FUNCTION__, bytes, -strerror (errno)); +strerror (ret));exit (1 ); }memset (bp->b_addr,0 , bytes);
mkfs/xfs_mkfs.c +5 -1
@@ -856,7 +856,11 @@ zero_old_xfs_structures(* read in existing filesystem superblock, use its geometry * settings and zero the existing secondary superblocks. */ - buf =memalign (libxfs_device_alignment (), new_sb->sb_sectsize); +posix_memalign ( + (void **)&buf, +libxfs_device_alignment (), + new_sb->sb_sectsize + );if (!buf) {fprintf (stderr,_ ("error reading existing superblock -- failed to memalign buffer\n" ));
repair/incore.c +1 -1
@@ -224,7 +224,7 @@ init_rt_bmap( rt_bmap_size =roundup (mp->m_sb.sb_rextents / (NBBY /XR_BB ),sizeof (__uint64_t)); - rt_bmap =memalign (sizeof (__uint64_t), rt_bmap_size); +posix_memalign ((void **)&rt_bmap,sizeof (__uint64_t), rt_bmap_size);if (!rt_bmap) { do_error( _("couldn't allocate realtime block map, size = %" PRIu64 "\n"),
repair/incore_ino.c +10 -3
@@ -626,8 +626,11 @@ set_inode_parent( irec->ino_un.plist = ptbl; ptbl->pmask =1LL << offset; - ptbl->pentries = (xfs_ino_t *)memalign (sizeof (xfs_ino_t), -sizeof (xfs_ino_t)); +posix_memalign ( + (void **)&(ptbl->pentries), +sizeof (xfs_ino_t), +sizeof (xfs_ino_t) + );if (!ptbl->pentries)do_error (_ ("couldn't memalign pentries table\n" ));#ifdef DEBUG
@@ -673,7 +676,11 @@ set_inode_parent(#endif ASSERT (cnt >= target); - tmp = (xfs_ino_t *)memalign (sizeof (xfs_ino_t), (cnt +1 ) *sizeof (xfs_ino_t)); +posix_memalign ( + (void **)&tmp, +sizeof (xfs_ino_t), + (cnt +1 ) *sizeof (xfs_ino_t) + );if (!tmp)do_error (_ ("couldn't memalign pentries table\n" ));
repair/phase1.c +1 -1
@@ -35,7 +35,7 @@ alloc_ag_buf(int size) {char *bp; - bp = (char *)memalign (libxfs_device_alignment (), size); +posix_memalign ((void **)&bp,libxfs_device_alignment (), size);if (!bp)do_error (_ ("could not allocate ag header buffer (%d bytes)\n" ), size);
repair/prefetch.c +3 -4
@@ -631,10 +631,9 @@ pf_io_worker( void *param) {prefetch_args_t *args = param; -void *buf =memalign (libxfs_device_alignment (), - pf_max_bytes); - -if (buf ==NULL ) +void *buf; +posix_memalign ((void **)&buf,libxfs_device_alignment (), pf_max_bytes); +if (!buf)return NULL ;pthread_mutex_lock (&args->lock);
repair/sb.c +5 -5
@@ -102,7 +102,7 @@ find_secondary_sb(xfs_sb_t *rsb)do_warn (_ ("\nattempting to find secondary superblock...\n" )); - sb = (xfs_sb_t *)memalign (libxfs_device_alignment (),BSIZE ); +posix_memalign ((void **)&sb,libxfs_device_alignment (),BSIZE );if (!sb) {do_error (_ ("error finding secondary superblock -- failed to memalign buffer\n" ));
@@ -438,8 +438,8 @@ write_primary_sb(xfs_sb_t *sbp, int size)if (no_modify)return ; - buf =memalign (libxfs_device_alignment (), size); -if (buf ==NULL ) { +posix_memalign ((void **)&buf,libxfs_device_alignment (), size); +if (!buf) {do_error (_ ("failed to memalign superblock buffer\n" ));return ; }
@@ -472,8 +472,8 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)int error, rval;xfs_dsb_t *buf; - buf =memalign (libxfs_device_alignment (), size); -if (buf ==NULL ) { +posix_memalign ((void **)&buf,libxfs_device_alignment (), size); +if (!buf) {do_error (_ ("error reading superblock %u -- failed to memalign buffer\n" ), agno);
rtcp/xfs_rtcp.c +6 -1
@@ -327,7 +327,12 @@ rtcp( char *source, char *target, int fextsize) } iosz = dioattr.d_miniosz; - fbuf =memalign ( dioattr.d_mem, iosz); +posix_memalign ((void **)&fbuf, dioattr.d_mem, iosz); +if (!fbuf) { +perror ( +_ ("error finding secondary superblock -- failed to memalign buffer\n" )); +exit (1 ); + }memset (fbuf,0 , iosz);/*
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 11/11 xfsprogs: Prefix LIST_... macros to XFS_LIST_...
In reply to Jan TulakOS X has two conflicting LIST_ macros:
- LIST_HEAD
- LIST_HEAD_INIT
These results in tons of warnings like:
In file included from init.c:22:
In file included from ./libxfs_priv.h:63:../include/xfs/list.h:32:9: warning: 'LIST_HEAD' macro redefined [-Wmacro-redefined]
\#define LIST_HEAD(name) \
These macros are included from sys/queue.h through sys/mount.h and possibly through more system libraries. So far, I didn't found a way how to prevent the inclusion.
Attempted solution was to avoid including with -D_SYS_QUEUE_H_ for the compiler, but this resulted in another error:
In file included from crc32.c:36:
In file included from ../include/xfs/platform_defs.h:79:
In file included from ../include/xfs/darwin.h:26:
In file included from /usr/include/sys/mount.h:76:
In file included from /usr/include/sys/attr.h:42:/usr/include/sys/ucred.h:90:2: error: type name requires a specifier or qualifierTAILQ_ENTRY(ucred) cr_link; /* never modify this without KAUTH_CRE...
I tried renaming. This works, but it doesn't look like a good solution. So this patch is still not final.
--- include/list.h | 6 +++--- repair/phase6.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
include/list.h +3 -3
@@ -27,10 +27,10 @@ struct list_head {struct list_head *prev; }; -#define LIST_HEAD_INIT (name) { &(name), &(name) } +#define XFS_LIST_HEAD_INIT (name) { &(name), &(name) } -#define LIST_HEAD (name) \ - struct list_head name = LIST_HEAD_INIT(name) +#define XFS_LIST_HEAD (name) \ + struct list_head name = XFS_LIST_HEAD_INIT(name)#define INIT_LIST_HEAD (list) list_head_init(list)static inline void list_head_init (struct list_head *list)
repair/phase6.c +1 -1
@@ -49,7 +49,7 @@ typedef struct dotdot_update {int ino_offset; } dotdot_update_t; -static LIST_HEAD (dotdot_update_list); +static XFS_LIST_HEAD (dotdot_update_list);static int dotdot_update; static void
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 03/11] xfsprogs: undefined variable fix
In reply to Jan TulakLooks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing
In reply to Jan Tulakio/readdir.c read_directory( · line 109
Quoted 11 lines
io/readdir.c +2
-0@@ -104,12 +104,16 @@ read_directory(if (!dirent)break ; +#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#endif
You probably want to use d_namen + sizeof(*dirent) to approimate the value if d_reclen doesn't exist.
io/readdir.c read_directory( · line 116
Quoted 7 lines
io/readdir.c +2
-0count++;if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#endif
We're only using the offset for dumping the value, maybe setting it to 0 and adding a comment explaining it should go into the else branch here?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v4 11/11 xfsprogs: prevent LIST_ macros conflicts
In reply to Jan TulakBSD 4.4 added some LIST_ macros into system header files, which causes "macro redefined" warnings. To ensure we use our own macros, undefine the system ones at first.
The conflicting macros are LIST_HEAD and LIST_HEAD_INIT
--- include/list.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/list.h +14 -0
@@ -19,6 +19,20 @@#define __LIST_H__/* +* This undef is here because BSD 4.4 added some LIST_ macros into system +* header file sys/queue.h. This header is included in many other system +* headers and thus causes "macro redefined" warnings. +* +* As OS X is kind of a derivate of BSD, this affects OS X too. +* +* To use our own LIST_ macros (copied from kernel code), we have to +* at first undefine the conflicting system macros. +* +*/ +#undef LIST_HEAD +#undef LIST_HEAD_INIT + +/* * Simple, generic doubly-linked list implementation. */
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missing
In reply to Christoph Hellwig----- Original Message -----
Quoted 23 lines
From: "Christoph Hellwig" <[email protected]>
To: "Jan Tulak" <[email protected]>
Cc: [email protected], [email protected]
Sent: Tuesday, August 4, 2015 10:46:25 AM
Subject: Re: [PATCH v3 04/11] xfsprogs: Add ifdef dirent checks where it was missingio/readdir.c read_directory( · line 109
Quoted 11 lines
io/readdir.c +2
-0@@ -104,12 +104,16 @@ read_directory(if (!dirent)break ; +#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#endif You probably want to use
d_namen+sizeof(*dirent)to approimate the value ifd_reclendoesn't exist.Quoted 2 lines
io/readdir.c +0
-0count++;
Quoted 10 lines
io/readdir.c read_directory( · line 116
Quoted 5 lines
io/readdir.c +2
-0if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#endif We're only using the offset for dumping the value, maybe setting it to 0 and adding a comment explaining it should go into the else branch here?
That sounds reasonable, sending an updated patch.
Thanks. :-)
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v4 4/11 xfsprogs: Add ifdef dirent checks where it was missing
In reply to Jan TulakAdd check for _DIRENT_HAVED_RECLEN/_OFF to read_directory(). In dump_dirent() these checks already are used, but they were missing in read_directory.
--- io/readdir.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
io/readdir.c +12 -0
@@ -104,12 +104,24 @@ read_directory(if (!dirent)break ; +#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#else + *total += dirent->d_namlen +sizeof (*dirent); +#endif count++;if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#else +/* Some platforms don't have dirent->d_off, but because it is +* used only for dumping the value, it should be safe to only +* set it to zero in such case. +*/ + offset =0 ; +#endif } }
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 05/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS
In reply to Jan TulakLooks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
In reply to Jan TulakQuoted 3 lines · Jan Tulak
Add check for _DIRENT_HAVED_RECLEN/_OFF to
read_directory(). Indump_dirent()these checks already are used, but they were missing inread_directory.
Needs to be fixed to avoid > 80 char lines.
Otherwise looks good:
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 06/11] xfsprogs: Add includes required for OS X builds
In reply to Jan TulakFirst hunk looks good:
Second hunk won't apply now that libdisk is gone.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
In reply to Jan TulakCan't you just use something like:
AC_CHECK_DECL([fls],
[AC_DEFINE([HAVE_FLS_PROTOTYPE], [1], [Define to 1 if have fls prototype])], [], [#include <string.h>])
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 09/11] xfsprogs: Add mntent.h check into autoconf
In reply to Jan TulakWhy not just
AC_CHECK_HEADERS([mntent.h])
?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v4 11/11] xfsprogs: prevent LIST_ macros conflicts
In reply to Jan TulakLooks fine,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
In reply to Christoph Hellwig----- Original Message -----
Quoted 6 lines
From: "Christoph Hellwig" <[email protected]>
To: "Jan Tulak" <[email protected]>
Cc: [email protected], [email protected]
Sent: Tuesday, August 4, 2015 1:21:03 PM
Subject: Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
Quoted 8 lines
Can't you just use something like:
AC_CHECK_DECL([fls],
[AC_DEFINE([HAVE_FLS_PROTOTYPE], [1], [Define to 1 if have fls prototype])], [], [#include <string.h>])
You mean to replace the entire autoconf part of the patch with this? I will try it. Autoconf is still a bit of a black magic for me, so I used the already existing checks. :-)
Cheers,
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
In reply to Christoph Hellwig----- Original Message -----
Quoted 4 lines
From: "Christoph Hellwig" <[email protected]>
Needs to be fixed to avoid > 80 char lines.
I don't see any >80 char line in this patch. O_o The longest line is 73 in the code and 62 in commit message. Though... maybe it can be a tab width issue? I use four spaces for a tab...
Cheers,
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
Quoted 10 lines · Jan Tulak
----- Original Message -----
Quoted 4 lines
From: "Christoph Hellwig" <[email protected]>
Needs to be fixed to avoid > 80 char lines.
I don't see any >80 char line in this patch.
O_oThe longest line is 73 in the code and 62 in commit message. Though... maybe it can be a tab width issue? I use four spaces for a tab...
8 spaces to a tab, please. Same coding style rules as for writing kernel code. ;)
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v5 4/11 xfsprogs: Add ifdef dirent checks where it was missing
In reply to Jan TulakCHANGED: text width fix
Add check for _DIRENT_HAVED_RECLEN/_OFF to read_directory(). In dump_dirent() these checks already are used, but they were missing in read_directory.
--- io/readdir.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
io/readdir.c +12 -0
@@ -103,12 +103,24 @@ read_directory(if (!dirent)break ; +#ifdef _DIRENT_HAVE_D_RECLEN *total += dirent->d_reclen; +#else + *total += dirent->d_namlen +sizeof (*dirent); +#endif count++;if (dump) {dump_dirent (offset, dirent); +#ifdef _DIRENT_HAVE_D_OFF offset = dirent->d_off; +#else +/* Some platforms don't have dirent->d_off, but because +* it is used only for dumping the value, it should be +* safe to only set it to zero in such case. +*/ + offset =0 ; +#endif } }
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missing
In reply to Dave Chinner----- Original Message -----
Quoted 13 lines
From: "Dave Chinner" <[email protected]>
To: "Jan Tulak" <[email protected]>
Cc: "Christoph Hellwig" <[email protected]>, [email protected]
Sent: Wednesday, August 5, 2015 1:00:00 AM
Subject: Re: [PATCH v4 04/11] xfsprogs: Add ifdef dirent checks where it was missingQuoted 6 lines · Jan Tulak
----- Original Message -----
Quoted 4 lines
From: "Christoph Hellwig" <[email protected]>
Needs to be fixed to avoid > 80 char lines.
Quoted 7 lines
Quoted 4 lines
I don't see any >80 char line in this patch.
O_oThe longest line is 73 in the code and 62 in commit message. Though... maybe it can be a tab width issue? I use four spaces for a tab...8 spaces to a tab, please. Same coding style rules as for writing kernel code. ;)
All right, fixed patch sent. :-)
Cheers,
Jan
Signature · 7 lines
Jan Tulak [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign
In reply to Jan TulakQuoted 7 lines · Jan Tulak
Memalign from <
malloc.h> was marked obsolete in favor of a posix variant from <stdlib.h>. So replace all calls and remove <malloc.h> includes. This also enhances support on other posix platforms, which doesn't have <malloc.h>.Because
posix_memalignreturns any error as a return code, not in errno, change relevant checks in code (and add a missing one).
....
libxfs/rdwr.c libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len) · line 84
Quoted 13 lines
libxfs/rdwr.c +6
-1@@ -74,12 +74,18 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len)ssize_t zsize, bytes;char *z;int fd; +int ret; zsize =min (BDSTRAT_SIZE ,BBTOB (len)); -if ((z =memalign (libxfs_device_alignment (), zsize)) ==NULL ) { + ret =posix_memalign ( + (void **)&z, +libxfs_device_alignment (), + zsize + );
Unusual function call formatting. Please use the form the rest of the code uses. i.e:
ret = posix_memalign((void **)&z, libxfs_device_alignment(), zsize);
(same for the rest of the patch).
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 6/11 xfsprogs: Add includes required for OS X builds
In reply to Christoph HellwigUPDATE: updated for libdisk gone
--- include/darwin.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/darwin.h +8 -0
@@ -18,12 +18,20 @@#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> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/mount.h> +#include <sys/types.h> +#include <ftw.h> +#include <mach/mach_time.h> +#include <inttypes.h> +#include <stdio.h> #include <machine/endian.h> #define __BYTE_ORDER BYTE_ORDER
Signature · 6 lines
2.4.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 10/11 xfsprogs: replace obsolete memalign with posix_memalign
In reply to Dave ChinnerUPDATE: code format
Memalign from <malloc.h> was marked obsolete in favor of a posix variant from <stdlib.h>. So replace all calls and remove <malloc.h> includes. This also enhances support on other posix platforms, which doesn't have <malloc.h>.
Because posix_memalign returns any error as a return code, not in errno, change relevant checks in code (and add a missing one).
--- copy/xfs_copy.c | 2 +- db/attrset.c | 2 +- fsr/xfs_fsr.c | 3 ++- include/darwin.h | 1 - include/freebsd.h | 1 - include/gnukfreebsd.h | 1 - include/linux.h | 1 - io/pread.c | 4 ++-- libxfs/rdwr.c | 12 ++++++++---- mkfs/xfs_mkfs.c | 3 ++- repair/incore.c | 2 +- repair/incore_ino.c | 7 ++++--- repair/phase1.c | 2 +- repair/prefetch.c | 7 +++---- repair/sb.c | 10 +++++----- rtcp/xfs_rtcp.c | 7 ++++++- 16 files changed, 36 insertions(+), 29 deletions(-)
copy/xfs_copy.c +1 -1
@@ -333,7 +333,7 @@ wbuf * wbuf_init(wbuf *buf, int data_size, int data_align, int min_io_size, int id) {ASSERT (data_size %BBSIZE ==0 ); -while ((buf->data =memalign (data_align, data_size)) ==NULL ) { +while (posix_memalign ((void **)&(buf->data), data_align, data_size)) { data_size >>=1 ;if (data_size < min_io_size)return NULL ;
db/attrset.c +1 -1
@@ -141,7 +141,7 @@ attr_set_f( name = argv[optind];if (valuelen) { - value = (char *)memalign (getpagesize (), valuelen); +posix_memalign ((void **)&value,getpagesize (), valuelen);if (!value) {dbprintf (_ ("cannot allocate buffer (%d)\n" ), valuelen); goto out;
fsr/xfs_fsr.c +2 -1
@@ -1306,7 +1306,8 @@ packfile(char *fname, char *tname, int fd, dio.d_maxiosz, pagesize); } -if (!(fbuf = (char *)memalign (dio.d_mem, blksz_dio))) { +posix_memalign ((void **)&fbuf, dio.d_mem, blksz_dio); +if (!fbuf) {fsrprintf (_ ("could not allocate buf: %s\n" ), tname); goto out; }
include/darwin.h +0 -1
@@ -141,7 +141,6 @@ typedef int64_t xfs_daddr_t;#define pwrite64 pwrite#define ftruncate64 ftruncate#define fdatasync fsync -#define memalign (a,sz) valloc(sz)#define O_LARGEFILE 0#ifndef O_DIRECT
include/freebsd.h +0 -1
@@ -40,7 +40,6 @@#define pwrite64 pwrite#define pread64 pread#define fdatasync fsync -#define memalign (a,sz) valloc(sz)#define constpp char * const *
include/gnukfreebsd.h +0 -1
@@ -22,7 +22,6 @@#include <sys/vfs.h> #include <sys/ioctl.h> #include <sys/sysmacros.h> -#include <malloc.h> #include <getopt.h> #include <endian.h> #include <sys/stat.h>
include/linux.h +0 -1
@@ -24,7 +24,6 @@#include <sys/sysmacros.h> #include <sys/stat.h> #include <inttypes.h> -#include <malloc.h> #include <getopt.h> #include <errno.h> #include <endian.h>
io/pread.c +2 -2
@@ -77,7 +77,7 @@ alloc_iovec( buffersize =0 ;for (i =0 ; i < vectors; i++) { - iov[i].iov_base =memalign (pagesize, bsize); +posix_memalign ((void **)&(iov[i].iov_base), pagesize, bsize);if (!iov[i].iov_base) {perror ("memalign" ); goto unwind;
@@ -108,7 +108,7 @@ alloc_buffer(if (bsize > highwater) {if (buffer)free (buffer); - buffer =memalign (pagesize, bsize); +posix_memalign ((void **)&buffer, pagesize, bsize);if (!buffer) {perror ("memalign" ); highwater = buffersize =0 ;
libxfs/rdwr.c +8 -4
@@ -74,12 +74,14 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t start, uint len)ssize_t zsize, bytes;char *z;int fd; +int ret; zsize =min (BDSTRAT_SIZE ,BBTOB (len)); -if ((z =memalign (libxfs_device_alignment (), zsize)) ==NULL ) { + ret =posix_memalign ((void **)&z,libxfs_device_alignment (), zsize); +if (!z) {fprintf (stderr,_ ("%s: %s can't memalign %d bytes: %s\n" ), - progname, __FUNCTION__, (int )zsize,strerror (errno)); + progname, __FUNCTION__, (int )zsize,strerror (ret));exit (1 ); }memset (z,0 , zsize);
@@ -409,6 +411,7 @@ static void __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, unsigned int bytes) { +int ret; bp->b_flags =0 ; bp->b_bn = bno; bp->b_bcount = bytes;
@@ -416,12 +419,13 @@ __initbuf(xfs_buf_t *bp, struct xfs_buftarg *btp, xfs_daddr_t bno, bp->b_target = btp; bp->b_error =0 ;if (!bp->b_addr) - bp->b_addr =memalign (libxfs_device_alignment (), bytes); + ret =posix_memalign ((void **)&(bp->b_addr), +libxfs_device_alignment (), bytes);if (!bp->b_addr) {fprintf (stderr,_ ("%s: %s can't memalign %u bytes: %s\n" ), progname, __FUNCTION__, bytes, -strerror (errno)); +strerror (ret));exit (1 ); }memset (bp->b_addr,0 , bytes);
mkfs/xfs_mkfs.c +2 -1
@@ -770,7 +770,8 @@ zero_old_xfs_structures(* read in existing filesystem superblock, use its geometry * settings and zero the existing secondary superblocks. */ - buf =memalign (libxfs_device_alignment (), new_sb->sb_sectsize); +posix_memalign ((void **)&buf,libxfs_device_alignment (), + new_sb->sb_sectsize);if (!buf) {fprintf (stderr,_ ("error reading existing superblock -- failed to memalign buffer\n" ));
repair/incore.c +1 -1
@@ -224,7 +224,7 @@ init_rt_bmap( rt_bmap_size =roundup (mp->m_sb.sb_rextents / (NBBY /XR_BB ),sizeof (__uint64_t)); - rt_bmap =memalign (sizeof (__uint64_t), rt_bmap_size); +posix_memalign ((void **)&rt_bmap,sizeof (__uint64_t), rt_bmap_size);if (!rt_bmap) { do_error( _("couldn't allocate realtime block map, size = %" PRIu64 "\n"),
repair/incore_ino.c +4 -3
@@ -626,8 +626,8 @@ set_inode_parent( irec->ino_un.plist = ptbl; ptbl->pmask =1LL << offset; - ptbl->pentries = (xfs_ino_t *)memalign (sizeof (xfs_ino_t), -sizeof (xfs_ino_t)); +posix_memalign ((void **)&(ptbl->pentries),sizeof (xfs_ino_t), +sizeof (xfs_ino_t));if (!ptbl->pentries)do_error (_ ("couldn't memalign pentries table\n" ));#ifdef DEBUG
@@ -673,7 +673,8 @@ set_inode_parent(#endif ASSERT (cnt >= target); - tmp = (xfs_ino_t *)memalign (sizeof (xfs_ino_t), (cnt +1 ) *sizeof (xfs_ino_t)); +posix_memalign ((void **)&tmp,sizeof (xfs_ino_t), + (cnt +1 ) *sizeof (xfs_ino_t));if (!tmp)do_error (_ ("couldn't memalign pentries table\n" ));
repair/phase1.c +1 -1
@@ -35,7 +35,7 @@ alloc_ag_buf(int size) {char *bp; - bp = (char *)memalign (libxfs_device_alignment (), size); +posix_memalign ((void **)&bp,libxfs_device_alignment (), size);if (!bp)do_error (_ ("could not allocate ag header buffer (%d bytes)\n" ), size);
repair/prefetch.c +3 -4
@@ -631,10 +631,9 @@ pf_io_worker( void *param) {prefetch_args_t *args = param; -void *buf =memalign (libxfs_device_alignment (), - pf_max_bytes); - -if (buf ==NULL ) +void *buf; +posix_memalign ((void **)&buf,libxfs_device_alignment (), pf_max_bytes); +if (!buf)return NULL ;pthread_mutex_lock (&args->lock);
repair/sb.c +5 -5
@@ -102,7 +102,7 @@ find_secondary_sb(xfs_sb_t *rsb)do_warn (_ ("\nattempting to find secondary superblock...\n" )); - sb = (xfs_sb_t *)memalign (libxfs_device_alignment (),BSIZE ); +posix_memalign ((void **)&sb,libxfs_device_alignment (),BSIZE );if (!sb) {do_error (_ ("error finding secondary superblock -- failed to memalign buffer\n" ));
@@ -438,8 +438,8 @@ write_primary_sb(xfs_sb_t *sbp, int size)if (no_modify)return ; - buf =memalign (libxfs_device_alignment (), size); -if (buf ==NULL ) { +posix_memalign ((void **)&buf,libxfs_device_alignment (), size); +if (!buf) {do_error (_ ("failed to memalign superblock buffer\n" ));return ; }
@@ -472,8 +472,8 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)int error, rval;xfs_dsb_t *buf; - buf =memalign (libxfs_device_alignment (), size); -if (buf ==NULL ) { +posix_memalign ((void **)&buf,libxfs_device_alignment (), size); +if (!buf) {do_error (_ ("error reading superblock %u -- failed to memalign buffer\n" ), agno);
rtcp/xfs_rtcp.c +6 -1
@@ -327,7 +327,12 @@ rtcp( char *source, char *target, int fextsize) } iosz = dioattr.d_miniosz; - fbuf =memalign ( dioattr.d_mem, iosz); +posix_memalign ((void **)&fbuf, dioattr.d_mem, iosz); +if (!fbuf) { +perror ( +_ ("error finding secondary superblock -- failed to memalign buffer\n" )); +exit (1 ); + }memset (fbuf,0 , iosz);/*
Signature · 6 lines
2.4.5 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconf
In reply to Jan TulakQuoted 18 lines · Jan Tulak
----- Original Message -----
Quoted 6 lines
From: "Christoph Hellwig" <[email protected]>
To: "Jan Tulak" <[email protected]>
Cc: [email protected], [email protected]
Sent: Tuesday, August 4, 2015 1:21:03 PM
Subject: Re: [PATCH v3 08/11] xfsprogs: Add fls check into autoconfQuoted 8 lines
Can't you just use something like:
AC_CHECK_DECL([fls],
[AC_DEFINE([HAVE_FLS_PROTOTYPE], [1], [Define to 1 if have fls prototype])], [], [#include <string.h>])
Quoted 4 lines
You mean to replace the entire autoconf part of the patch with this? I will try it. Autoconf is still a bit of a black magic for me, so I used the already existing checks. :-)
Hi Chris,
did you want the result to be this? (I didn't get any clarification of what you mean, so I'm asking again. :-) )
#
# Check if we have a flc call (Mac OS X)
#
AC_DEFUN([AC_HAVE_FLS],
[ AC_CHECK_DECL([fls],
have_fls=yes,
[],
[#include <string.h>]
)
AC_SUBST(have_fls)])
Cheers,
Jan
Signature · 2 lines
Jan Tulak [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v4 9/11 xfsprogs: Add mntent.h check into autoconf
In reply to Christoph HellwigUPDATE: Autoconf change. Hopefully this is what Chris meant.
--- configure.ac | 1 + fsr/xfs_fsr.c | 6 +++--- include/builddefs.in | 4 ++++ m4/package_libcdev.m4 | 8 ++++++++ 4 files changed, 16 insertions(+), 3 deletions(-)
configure.ac +1 -0
@@ -115,6 +115,7 @@ AC_HAVE_FALLOCATE AC_HAVE_FIEMAP AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE +AC_HAVE_MNTENT AC_HAVE_BLKID_TOPO AC_HAVE_READDIR
fsr/xfs_fsr.c +3 -3
@@ -25,16 +25,16 @@#include <fcntl.h> #include <errno.h> -#include <malloc.h> -#include <mntent.h> #include <syslog.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/wait.h> -#include <sys/vfs.h> #include <sys/statvfs.h> #include <sys/xattr.h> +#ifdef HAVE_MNTENT +# include <mntent.h> +#endif #ifndef XFS_XFLAG_NODEFRAG #define XFS_XFLAG_NODEFRAG 0x00002000/* src dependancy, remove later */
include/builddefs.in +4 -0
@@ -103,6 +103,7 @@ HAVE_FIEMAP = @have_fiemap@ HAVE_PREADV = @have_preadv@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ HAVE_READDIR = @have_readdir@ +HAVE_MNTENT = @have_mntent@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -130,6 +131,9 @@ PLDLIBS = -L/usr/local/lib -lintl PCFLAGS = -I/usr/local/include $(GCCFLAGS) DEPENDFLAGS = -D__FreeBSD__ endif +ifeq ($(HAVE_MNTENT),yes) +PCFLAGS+= -DHAVE_MNTENT +endif GCFLAGS = $(OPTIMIZER) $(DEBUG) \ -DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
m4/package_libcdev.m4 +8 -0
@@ -202,3 +202,11 @@ AC_DEFUN([AC_HAVE_READDIR], AC_SUBST(have_readdir) ]) +# +# Check if there is mntent.h +# +AC_DEFUN([AC_HAVE_MNTENT], + [ AC_CHECK_HEADERS(mntent.h, + have_mntent=yes) + AC_SUBST(have_mntent) + ])
Signature · 6 lines
2.4.3 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v4 3/11 xfsprogs: Add fls check into autoconf
In reply to Jan TulakUPDATE: Autoconf change. Hopefully this is what Chris meant.
--- configure.ac | 1 + include/bitops.h | 2 ++ include/builddefs.in | 4 ++++ m4/package_libcdev.m4 | 12 ++++++++++++ 4 files changed, 19 insertions(+)
configure.ac +1 -0
@@ -116,6 +116,7 @@ AC_HAVE_FIEMAP AC_HAVE_PREADV AC_HAVE_SYNC_FILE_RANGE AC_HAVE_MNTENT +AC_HAVE_FLS AC_HAVE_BLKID_TOPO AC_HAVE_READDIR
include/bitops.h +2 -0
@@ -5,6 +5,7 @@* fls: find last bit set. */ +#ifndef HAVE_FLS static inline int fls (int x) {int r =32 ;
@@ -32,6 +33,7 @@ static inline int fls(int x) }return r; } +#endif /* HAVE_FLS */ static inline int fls64 (__u64 x) {
include/builddefs.in +4 -0
@@ -104,6 +104,7 @@ HAVE_PREADV = @have_preadv@ HAVE_SYNC_FILE_RANGE = @have_sync_file_range@ HAVE_READDIR = @have_readdir@ HAVE_MNTENT = @have_mntent@ +HAVE_FLS = @have_fls@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
@@ -131,6 +132,9 @@ PLDLIBS = -L/usr/local/lib -lintl PCFLAGS = -I/usr/local/include $(GCCFLAGS) DEPENDFLAGS = -D__FreeBSD__ endif +ifeq ($(HAVE_FLS),yes) +LCFLAGS+= -DHAVE_FLS +endif ifeq ($(HAVE_MNTENT),yes) PCFLAGS+= -DHAVE_MNTENT endif
m4/package_libcdev.m4 +12 -0
@@ -203,6 +203,18 @@ AC_DEFUN([AC_HAVE_READDIR], ]) # +# Check if we have a flc call (Mac OS X) +# +AC_DEFUN([AC_HAVE_FLS], + [ AC_CHECK_DECL([fls], + have_fls=yes, + [], + [#include <string.h>] + ) + AC_SUBST(have_fls) + ]) + +# # 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
Re: [PATCH v4 09/11] xfsprogs: Add mntent.h check into autoconf
In reply to Jan TulakThis looks mostly fine. I think you could just add the AC_CHECK_HEADERS directly to configure.ac, but otherwise it's exactly what I though.
Can you please resend all your pending patches in a single series, and move the UPDATES: lines and other internal changelogs to the cover letter instead of the patch descriptions?
Thanks for doing this work!
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v4 09/11] xfsprogs: Add mntent.h check into autoconf
Quoted 4 lines · Christoph Hellwig
This looks mostly fine. I think you could just add the
AC_CHECK_HEADERSdirectly to configure.ac, but otherwise it's exactly what I though.
In configure.ac, there are no direct checks for headers, just calls of all the various
AC_HAVE_*. I'm not sure it is a good idea to mix now. Unless you think that all
the functions should be moved into configure.ac from the m4/ directory.
Quoted 6 lines
Can you please resend all your pending patches in a single series, and move the UPDATES: lines and other internal changelogs to the cover letter instead of the patch descriptions?
Thanks for doing this work!
Sure, I'll send it again as a whole. And np. :-)
Signature · 2 lines
Jan Tulak [email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs