linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] disabling e4defrag build with --disable-defrag
@ 2010-12-17 19:50 Andreas Dilger
  2010-12-17 19:50 ` [PATCH] allow e4defrag build against old kernel headers Andreas Dilger
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Dilger @ 2010-12-17 19:50 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Andreas Dilger

This is useful for systems that are known not have the necessary support
for e4defrag to run (fallocate() and EXT4_IOC_MOVE_EXT support).  It cannot
be determined at compile time whether the target kernel will have them.
---
 configure        |   24 ++++++++++++++++++++++++
 configure.in     |   18 ++++++++++++++++++
 misc/Makefile.in |    4 ++--
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 14d9652..9e6d39e 100755
--- a/configure
+++ b/configure
@@ -675,6 +675,7 @@ FSCK_MAN
 FSCK_PROG
 RESIZER_CMT
 IMAGER_CMT
+DEFRAG_CMT
 DEBUGFS_CMT
 BLKID_CMT
 DEPPROFILED_LIBBLKID
@@ -803,6 +804,7 @@ enable_libblkid
 enable_debugfs
 enable_imager
 enable_resizer
+enable_defrag
 enable_fsck
 enable_e2initrd_helper
 enable_tls
@@ -1454,6 +1456,7 @@ Optional Features:
   --disable-debugfs   	  disable support of debugfs program
   --disable-imager   	  disable support of e2image program
   --disable-resizer   	  disable support of e2resize program
+  --disable-defrag   	  disable support of e4defrag program
   --enable-fsck           build fsck wrapper program
   --enable-e2initrd-helper build e2initrd-helper program
   --disable-tls           disable use of thread local support
@@ -5396,6 +5399,27 @@ RESIZER_CMT=
 fi
 
 
+# Check whether --enable-defrag was given.
+if test "${enable_defrag+set}" = set; then :
+  enableval=$enable_defrag; if test "$enableval" = "no"
+then
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Disabling e4defrag support" >&5
+$as_echo "Disabling e4defrag support" >&6; }
+	DEFRAG_CMT="#"
+else
+	DEFRAG_CMT=
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling e4defrag support" >&5
+$as_echo "Enabling e4defrag support" >&6; }
+fi
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling e4defrag support by default" >&5
+$as_echo "Enabling e4defrag support by default" >&6; }
+DEFRAG_CMT=
+
+fi
+
+
 # Check whether --enable-fsck was given.
 if test "${enable_fsck+set}" = set; then :
   enableval=$enable_fsck; if test "$enableval" = "no"
diff --git a/configure.in b/configure.in
index 5e67688..13ea07a 100644
--- a/configure.in
+++ b/configure.in
@@ -577,6 +577,24 @@ RESIZER_CMT=
 )
 AC_SUBST(RESIZER_CMT)
 dnl
+dnl handle --enable-defrag
+dnl
+AC_ARG_ENABLE([defrag],
+[  --disable-defrag   	  disable support of e4defrag program],
+if test "$enableval" = "no"
+then
+	AC_MSG_RESULT([Disabling e4defrag support])
+	DEFRAG_CMT="#"
+else
+	DEFRAG_CMT=
+	AC_MSG_RESULT([Enabling e4defrag support])
+fi
+,
+AC_MSG_RESULT([Enabling e4defrag support by default])
+DEFRAG_CMT=
+)
+AC_SUBST(DEFRAG_CMT)
+dnl
 dnl See whether to install the `fsck' wrapper program (that calls e2fsck)
 dnl
 AC_ARG_ENABLE([fsck],
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 8fd7704..d905e14 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -11,8 +11,8 @@ INSTALL = @INSTALL@
 
 @MCONFIG@
 
-@LINUX_CMT@E4DEFRAG_PROG= e4defrag
-@LINUX_CMT@E4DEFRAG_MAN= e4defrag.8
+@DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_PROG= e4defrag
+@DEFRAG_CMT@@LINUX_CMT@E4DEFRAG_MAN= e4defrag.8
 
 @IMAGER_CMT@E2IMAGE_PROG= e2image
 @IMAGER_CMT@E2IMAGE_MAN= e2image.8
-- 
1.4.4.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] allow e4defrag build against old kernel headers
  2010-12-17 19:50 [PATCH] disabling e4defrag build with --disable-defrag Andreas Dilger
@ 2010-12-17 19:50 ` Andreas Dilger
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Dilger @ 2010-12-17 19:50 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Andreas Dilger

Building e2fsprogs with older userspace with old kernel headers may
not define the __NR_fallocate and __NR_sync_file_range system calls,
even if a newer kernel is installed on the system.

Avoid e4defrag build failures for e2fsprogs on older systems, but may
result in the e4defrag command failing at runtime due to the actual
lack of these system calls, as opposed to just old kernel headers
on a system running a new kernel.
---
 misc/e4defrag.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 82e3868..d739da2 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -304,12 +304,6 @@ static int posix_fadvise(int fd, loff_t offset, size_t len, int advise)
 #ifndef HAVE_SYNC_FILE_RANGE
 #warning Using locally defined sync_file_range interface.
 
-#ifndef __NR_sync_file_range
-#ifndef __NR_sync_file_range2 /* ppc */
-#error Your kernel headers dont define __NR_sync_file_range
-#endif
-#endif
-
 /*
  * sync_file_range() -	Sync file region.
  *
@@ -322,8 +316,19 @@ int sync_file_range(int fd, loff_t offset, loff_t length, unsigned int flag)
 {
 #ifdef __NR_sync_file_range
 	return syscall(__NR_sync_file_range, fd, offset, length, flag);
-#else
+#elif defined(__NR_sync_file_range2)
 	return syscall(__NR_sync_file_range2, fd, flag, offset, length);
+#else
+	return fsync(fd);
+#ifndef SYNC_FILE_RANGE_WAIT_BEFORE
+#define SYNC_FILE_RANGE_WAIT_BEFORE 0
+#endif
+#ifndef SYNC_FILE_RANGE_WRITE
+#define SYNC_FILE_RANGE_WRITE 0
+#endif
+#ifndef SYNC_FILE_RANGE_WAIT_AFTER
+#define SYNC_FILE_RANGE_WAIT_AFTER 0
+#endif
 #endif
 }
 #endif /* ! HAVE_SYNC_FILE_RANGE */
@@ -332,7 +337,17 @@ int sync_file_range(int fd, loff_t offset, loff_t length, unsigned int flag)
 #warning Using locally defined fallocate syscall interface.
 
 #ifndef __NR_fallocate
-#error Your kernel headers dont define __NR_fallocate
+# if defined(__x86_64__)
+#  define __NR_fallocate 285
+# elif defined(__i386__)
+#  define __NR_fallocate 324
+# elif defined(__powerpc__)
+#  define __NR_fallocate 309
+# else
+/* fallback position might be posix_fallocate(), but I suspect any kernel
+ * that doesn't have fallocate will also not have EXT4_IOC_MOVE_EXT */
+#  error Your kernel headers dont define __NR_fallocate
+# endif
 #endif
 
 /*
-- 
1.4.4.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-17 19:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-17 19:50 [PATCH] disabling e4defrag build with --disable-defrag Andreas Dilger
2010-12-17 19:50 ` [PATCH] allow e4defrag build against old kernel headers Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).