]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
build: Move fallocate include into global.h
authorLukas Czerner <lczerner@redhat.com>
Thu, 13 Mar 2014 04:19:52 +0000 (15:19 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 13 Mar 2014 04:19:52 +0000 (15:19 +1100)
Move the inclusion of falloc.h with all it's possible defines for the
fallocate mode into global.h header file so we do not have to include
and define it manually in every tool using fallocate.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
configure.ac
ltp/fsstress.c
ltp/fsx.c
src/global.h

index 6fba3ad9e97bb4d04d8eafc371fc7fc11fa4824b..2f95c4c04126e77015fcb5051db1bceca33bd230 100644 (file)
@@ -25,7 +25,8 @@ AC_HEADER_STDC
                        sys/wait.h              \
                        sys/types.h             \
                        strings.h               \
-                       err.h
+                       err.h                   \
+                       linux/falloc.h
     ])
     AC_CHECK_HEADERS([ sys/fs/xfs_fsops.h      \
                        sys/fs/xfs_itable.h     \
index 7f91c0431f2c8f02591c3d3df7489a63a4e5604a..071d78bea76017fedfa1beba8aca2615f662f72c 100644 (file)
 #ifdef HAVE_LINUX_FIEMAP_H
 #include <linux/fiemap.h>
 #endif
-#ifdef FALLOCATE
-#include <linux/falloc.h>
-#ifndef FALLOC_FL_PUNCH_HOLE
-/* Copy-paste from linux/falloc.h */
-#define FALLOC_FL_PUNCH_HOLE    0x02 /* de-allocates range */
-#endif
-#endif
 #ifndef HAVE_ATTR_LIST
 #define attr_list(path, buf, size, flags, cursor) (errno = -ENOSYS, -1)
 #endif
@@ -2093,7 +2086,7 @@ dwrite_f(int opno, long r)
 void
 fallocate_f(int opno, long r)
 {
-#ifdef FALLOCATE
+#ifdef HAVE_LINUX_FALLOC_H
        int             e;
        pathname_t      f;
        int             fd;
@@ -2515,7 +2508,7 @@ mknod_f(int opno, long r)
 void
 punch_f(int opno, long r)
 {
-#ifdef FALLOCATE
+#ifdef HAVE_LINUX_FALLOC_H
        int             e;
        pathname_t      f;
        int             fd;
index 2f1e3e834250f357f65a138734bce3a96ef848f3..c36a0381fd26b662440effdf12066dc7bcd6cea5 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -33,9 +33,6 @@
 #ifdef AIO
 #include <libaio.h>
 #endif
-#ifdef FALLOCATE
-#include <linux/falloc.h>
-#endif
 
 #ifndef MAP_FILE
 # define MAP_FILE 0
@@ -882,7 +879,7 @@ do_punch_hole(unsigned offset, unsigned length)
 }
 #endif
 
-#ifdef FALLOCATE
+#ifdef HAVE_LINUX_FALLOC_H
 /* fallocate is basically a no-op unless extending, then a lot like a truncate */
 void
 do_preallocate(unsigned offset, unsigned length)
@@ -1139,7 +1136,7 @@ usage(void)
 "      -A: Use the AIO system calls\n"
 #endif
 "      -D startingop: debug output starting at specified operation\n"
-#ifdef FALLOCATE
+#ifdef HAVE_LINUX_FALLOC_H
 "      -F: Do not use fallocate (preallocation) calls\n"
 #endif
 #ifdef FALLOC_FL_PUNCH_HOLE
@@ -1296,7 +1293,7 @@ int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset)
 void
 test_fallocate()
 {
-#ifdef FALLOCATE
+#ifdef HAVE_LINUX_FALLOC_H
        if (!lite && fallocate_calls) {
                if (fallocate(fd, 0, 0, 1) && errno == EOPNOTSUPP) {
                        if(!quiet)
@@ -1306,7 +1303,7 @@ test_fallocate()
                        ftruncate(fd, 0);
                }
        }
-#else /* ! FALLOCATE */
+#else /* ! HAVE_LINUX_FALLOC_H */
        fallocate_calls = 0;
 #endif
 
index e6a2c2bcbc61e501a484c07c2f4c7ce6d76ab93f..8180f66821e3ad286149dcb155dad6dde630ec14 100644 (file)
 #include <sys/param.h>
 #endif
 
+#ifdef HAVE_LINUX_FALLOC_H
+#include <linux/falloc.h>
+
+#ifndef FALLOC_FL_KEEP_SIZE
+#define FALLOC_FL_KEEP_SIZE            0x01
+#endif
+
+#ifndef FALLOC_FL_PUNCH_HOLE
+#define FALLOC_FL_PUNCH_HOLE           0x02
 #endif
+
+#ifndef FALLOC_FL_NO_HIDE_STALE
+#define FALLOC_FL_NO_HIDE_STALE                0x04
+#endif
+
+#ifndef FALLOC_FL_COLLAPSE_RANGE
+#define FALLOC_FL_COLLAPSE_RANGE       0x08
+#endif
+
+#ifndef FALLOC_FL_ZERO_RANGE
+#define FALLOC_FL_ZERO_RANGE           0x10
+#endif
+
+#endif /* HAVE_LINUX_FALLOC_H */
+
+#endif /* GLOBAL_H */