Whamcloud - gitweb
Synchronize debian packaging with next
authorTheodore Ts'o <tytso@mit.edu>
Tue, 24 May 2016 17:50:50 +0000 (13:50 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 24 May 2016 19:07:13 +0000 (15:07 -0400)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian/patches/add-enable-hardening-which-builds-e2fsprogs-with-security-options [new file with mode: 0644]
debian/patches/clean-up-spelling-errors-and-other-nits-in-man-pages [new file with mode: 0644]
debian/patches/e2fsck-fix-project-quota-support [new file with mode: 0644]
debian/patches/e2fsck-use-com_err-error-codes-instead-of-EBADMSG-et-al [new file with mode: 0644]
debian/patches/mke2fs-fix-project-quota-creation [new file with mode: 0644]
debian/patches/series
debian/patches/tests-fix-filter.sed-to-filter-out-version-numbers-out [new file with mode: 0644]

diff --git a/debian/patches/add-enable-hardening-which-builds-e2fsprogs-with-security-options b/debian/patches/add-enable-hardening-which-builds-e2fsprogs-with-security-options
new file mode 100644 (file)
index 0000000..70664a1
--- /dev/null
@@ -0,0 +1,564 @@
+Description: Add --enable-hardening which builds e2fsprogs with security hardening
+ Enable the following security features: stack protection, fortify,
+ read-only relocation tables, immediate dynamic symbol binding, and
+ text segment ASLR by enabling position independent executable
+ (PIE).
+ .
+ Special handling is provided for shared library and statically linked
+ executables.  For all the gory details please see:
+ .
+   https://lists.debian.org/debian-devel/2016/05/msg00302.html
+ .
+ Distributions who want to do their own special thing can set CFLAGS,
+ CFLAGS_SHLIB, CLFAGS_STLIB, LDFLAGS, LDFLAGS_SHLIB and LDFLAGS_STATIC
+ as appropriate.
+
+Author: Theodore Ts'o <tytso@mit.edu>
+---
+ MCONFIG.in               |  7 ++++++-
+ configure                | 39 +++++++++++++++++++++++++++++++++++----
+ configure.ac             | 39 ++++++++++++++++++++++++++++++++++-----
+ lib/Makefile.bsd-lib     |  2 +-
+ lib/Makefile.elf-lib     |  2 +-
+ lib/Makefile.solaris-lib |  2 +-
+ lib/blkid/Makefile.in    |  8 ++++----
+ lib/e2p/Makefile.in      |  8 ++++----
+ lib/et/Makefile.in       |  8 ++++----
+ lib/ext2fs/Makefile.in   | 38 +++++++++++++++++++-------------------
+ lib/ss/Makefile.in       |  8 ++++----
+ lib/uuid/Makefile.in     |  8 ++++----
+ misc/Makefile.in         |  8 ++++----
+ resize/Makefile.in       |  3 +--
+ 14 files changed, 122 insertions(+), 58 deletions(-)
+
+diff --git a/MCONFIG.in b/MCONFIG.in
+index e15b855..db4b4de 100644
+--- a/MCONFIG.in
++++ b/MCONFIG.in
+@@ -74,11 +74,16 @@ pkgconfigdir = $(libdir)/pkgconfig
+ CC = @CC@
+ BUILD_CC = @BUILD_CC@
+ CFLAGS = @CFLAGS@
++CFLAGS_SHLIB = @CFLAGS_SHLIB@
++CFLAGS_STLIB = @CFLAGS_STLIB@
+ CPPFLAGS = @INCLUDES@
+ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) @DEFS@ $(LOCAL_CFLAGS)
++ALL_CFLAGS_SHLIB = $(CPPFLAGS) $(CFLAGS_SHLIB) @DEFS@ $(LOCAL_CFLAGS)
++ALL_CFLAGS_STLIB = $(CPPFLAGS) $(CFLAGS_STLIB) @DEFS@ $(LOCAL_CFLAGS)
+ LDFLAGS = @LDFLAGS@
++LDFLAGS_SHLIB = @LDFLAGS_SHLIB@
+ ALL_LDFLAGS = $(LDFLAGS) @LDFLAG_DYNAMIC@
+-LDFLAGS_STATIC = $(LDFLAGS) @LDFLAG_STATIC@
++LDFLAGS_STATIC = @LDFLAGS_STATIC@
+ BUILD_CFLAGS = @BUILD_CFLAGS@
+ BUILD_LDFLAGS = @BUILD_LDFLAGS@
+ RDYNAMIC = @RDYNAMIC@
+diff --git a/configure b/configure
+index 5a08392..3759c9c 100755
+--- a/configure
++++ b/configure
+@@ -625,6 +625,9 @@ gl_use_threads_default=
+ ac_func_list=
+ ac_subst_vars='LTLIBOBJS
+ LIBOBJS
++LDFLAGS_SHLIB
++CFLAGS_STLIB
++CFLAGS_SHLIB
+ BUILD_LDFLAGS
+ BUILD_CFLAGS
+ MKINSTALLDIRS
+@@ -632,7 +635,7 @@ INCLUDES
+ DO_TEST_SUITE
+ ET_DIR
+ SS_DIR
+-LDFLAG_STATIC
++LDFLAGS_STATIC
+ root_sysconfdir
+ root_libdir
+ root_sbindir
+@@ -857,6 +860,7 @@ enable_elf_shlibs
+ enable_bsd_shlibs
+ enable_profile
+ enable_gcov
++enable_hardening
+ enable_jbd_debug
+ enable_blkid_debug
+ enable_testio_debug
+@@ -1529,6 +1533,7 @@ Optional Features:
+   --enable-bsd-shlibs   select BSD shared libraries
+   --enable-profile      build profiling libraries
+   --enable-gcov                 build for coverage testing using gcov
++  --enable-hardening            build for coverage testing using gcov
+   --enable-jbd-debug            enable journal debugging
+   --enable-blkid-debug    enable blkid debugging
+   --disable-testio-debug  disable the use of the test I/O manager for debugging
+@@ -5012,6 +5017,27 @@ fi
+ fi
++CFLAGS_SHLIB="${CFLAGS_SHLIB:-$CFLAGS}"
++CFLAGS_STLIB="${CFLAGS_STLIB:-$CFLAGS}"
++LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
++LDFLAGS_STATIC=${LDFLAGS_STATIC:-$LDFLAGS}
++# Check whether --enable-hardening was given.
++if test "${enable_hardening+set}" = set; then :
++  enableval=$enable_hardening; if test "$enableval" = "yes"
++then
++      HARDEN_CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
++      HARDEN_LDFLAGS="-Wl,-z,relro -Wl,-z,now"
++      CFLAGS="$CFLAGS $HARDEN_CFLAGS -fPIE"
++      CFLAGS_SHLIB="$CFLAGS_SHLIB $HARDEN_CFLAGS"
++      CFLAGS_STLIB="$CFLAGS_STLIB $HARDEN_CFLAGS -fPIE"
++      LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS -fPIE -pie"
++      LDFLAGS_STATIC="$LDFLAGS_STATIC $HARDEN_LDFLAGS"
++      LDFLAGS_SHLIB="$LDFLAGS_SHLIB $HARDEN_LDFLAGS"
++      { $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling hardening support" >&5
++$as_echo "Enabling hardening support" >&6; }
++fi
++
++fi
+@@ -13625,7 +13651,7 @@ $as_echo_n "checking whether we can link with -static... " >&6; }
+ if ${ac_cv_e2fsprogs_use_static+:} false; then :
+   $as_echo_n "(cached) " >&6
+ else
+-  SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
++  SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS_STATIC -static"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ #include <stdio.h>
+@@ -13654,9 +13680,8 @@ solaris2.*)
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_e2fsprogs_use_static" >&5
+ $as_echo "$ac_cv_e2fsprogs_use_static" >&6; }
+-LDFLAG_STATIC=
+ if test $ac_cv_e2fsprogs_use_static = yes; then
+-      LDFLAG_STATIC=-static
++      LDFLAGS_STATIC="$LDFLAGS_STATIC -static"
+ fi
+ case "$host_os" in
+@@ -13708,6 +13733,12 @@ if test $cross_compiling = no; then
+ fi
++CFLAGS_SHLIB=${CFLAGS_SHLIB:-$CFLAGS}
++CFLAGS_STLIB=${CFLAGS_STLIB:-$CFLAGS}
++LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
++
++
++
+ test -d lib || mkdir lib
+ test -d include || mkdir include
+ test -d include/linux || mkdir include/linux
+diff --git a/configure.ac b/configure.ac
+index ceceeb6..e8e0d68 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -355,7 +355,28 @@ then
+       AC_MSG_RESULT([Enabling gcov support])
+ fi
+ )
+-
++dnl
++dnl handle --enable-hardening
++dnl
++CFLAGS_SHLIB="${CFLAGS_SHLIB:-$CFLAGS}"
++CFLAGS_STLIB="${CFLAGS_STLIB:-$CFLAGS}"
++LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
++LDFLAGS_STATIC=${LDFLAGS_STATIC:-$LDFLAGS}
++AC_ARG_ENABLE([hardening],
++[  --enable-hardening           build for coverage testing using gcov],
++if test "$enableval" = "yes"
++then
++      HARDEN_CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong"
++      HARDEN_LDFLAGS=["-Wl,-z,relro -Wl,-z,now"]
++      CFLAGS="$CFLAGS $HARDEN_CFLAGS -fPIE"
++      CFLAGS_SHLIB="$CFLAGS_SHLIB $HARDEN_CFLAGS"
++      CFLAGS_STLIB="$CFLAGS_STLIB $HARDEN_CFLAGS -fPIE"
++      LDFLAGS="$LDFLAGS $HARDEN_LDFLAGS -fPIE -pie"
++      LDFLAGS_STATIC="$LDFLAGS_STATIC $HARDEN_LDFLAGS"
++      LDFLAGS_SHLIB="$LDFLAGS_SHLIB $HARDEN_LDFLAGS"
++      AC_MSG_RESULT([Enabling hardening support])
++fi
++)
+ dnl
+ dnl Substitute library extensions
+ dnl
+@@ -1310,7 +1331,7 @@ dnl in static form.
+ dnl
+ AC_MSG_CHECKING([whether we can link with -static])
+ AC_CACHE_VAL(ac_cv_e2fsprogs_use_static,
+-[SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
++[SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS_STATIC -static"
+ AC_TRY_LINK([#include <stdio.h>],[fflush(stdout);],
+  ac_cv_e2fsprogs_use_static=yes, ac_cv_e2fsprogs_use_static=no)
+ LDFLAGS=$SAVE_LDFLAGS])
+@@ -1327,11 +1348,10 @@ solaris2.*)
+ ;;
+ esac
+ AC_MSG_RESULT($ac_cv_e2fsprogs_use_static)
+-LDFLAG_STATIC=
+ if test $ac_cv_e2fsprogs_use_static = yes; then
+-      LDFLAG_STATIC=-static
++      LDFLAGS_STATIC="$LDFLAGS_STATIC -static"
+ fi
+-AC_SUBST(LDFLAG_STATIC)
++AC_SUBST(LDFLAGS_STATIC)
+ dnl
+ dnl Work around mysterious Darwin / GNU libintl problem
+ dnl (__asm__ redirection doesn't work for some mysterious reason.  Looks like
+@@ -1385,6 +1405,15 @@ fi
+ AC_SUBST(BUILD_CFLAGS)
+ AC_SUBST(BUILD_LDFLAGS)
+ dnl
++dnl Define CFLAGS and LDFLAGS for shared libraries
++dnl
++CFLAGS_SHLIB=${CFLAGS_SHLIB:-$CFLAGS}
++CFLAGS_STLIB=${CFLAGS_STLIB:-$CFLAGS}
++LDFLAGS_SHLIB=${LDFLAGS_SHLIB:-$LDFLAGS}
++AC_SUBST(CFLAGS_SHLIB)
++AC_SUBST(CFLAGS_STLIB)
++AC_SUBST(LDFLAGS_SHLIB)
++dnl
+ dnl Make our output files, being sure that we create the some miscellaneous 
+ dnl directories
+ dnl
+diff --git a/lib/Makefile.bsd-lib b/lib/Makefile.bsd-lib
+index 0ca09f8..db0947f 100644
+--- a/lib/Makefile.bsd-lib
++++ b/lib/Makefile.bsd-lib
+@@ -22,7 +22,7 @@ BSDLIB_PIC_FLAG = -fpic
+ image:                $(BSD_LIB)
+ $(BSD_LIB): $(OBJS)
+-      (cd pic; ld -Bshareable -o $(BSD_LIB) $(LDFLAGS) $(OBJS))
++      (cd pic; ld -Bshareable -o $(BSD_LIB) $(LDFLAGS_SHLIB) $(OBJS))
+       $(MV) pic/$(BSD_LIB) .
+       $(RM) -f ../$(BSD_LIB)
+       (cd ..; $(LN) $(LINK_BUILD_FLAGS) \
+diff --git a/lib/Makefile.elf-lib b/lib/Makefile.elf-lib
+index 78479d3..272175f 100644
+--- a/lib/Makefile.elf-lib
++++ b/lib/Makefile.elf-lib
+@@ -25,7 +25,7 @@ image:               $(ELF_LIB)
+ $(ELF_LIB): $(OBJS)
+       $(E) "  GEN_ELF_SOLIB $(ELF_LIB)"
+       $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \
+-              -L$(top_builddir)/../lib $(LDFLAGS) \
++              -L$(top_builddir)/../lib $(LDFLAGS_SHLIB) \
+               -Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
+       $(Q) $(MV) elfshared/$(ELF_LIB) .
+       $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
+diff --git a/lib/Makefile.solaris-lib b/lib/Makefile.solaris-lib
+index 5990be8..a3d395e 100644
+--- a/lib/Makefile.solaris-lib
++++ b/lib/Makefile.solaris-lib
+@@ -25,7 +25,7 @@ image:               $(ELF_LIB)
+ $(ELF_LIB): $(OBJS)
+       $(E) "  GEN_ELF_SOLIB $(ELF_LIB)"
+       $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) \
+-              -L$(top_builddir)/../lib $(LDFLAGS) \
++              -L$(top_builddir)/../lib $(LDFLAGS_SHLIB) \
+               -Wl,-h,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
+       $(Q) $(MV) elfshared/$(ELF_LIB) .
+       $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
+diff --git a/lib/blkid/Makefile.in b/lib/blkid/Makefile.in
+index 275ba84..789d2a1 100644
+--- a/lib/blkid/Makefile.in
++++ b/lib/blkid/Makefile.in
+@@ -53,12 +53,12 @@ DEPLIBS_BLKID=     $(DEPSTATIC_LIBBLKID) $(DEPSTATIC_LIBUUID)
+ .c.o:
+       $(E) "  CC $<"
+-      $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
++      $(Q) $(CC) $(ALL_CFLAGS_STLIB) -c $< -o $@
+       $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+       $(Q) $(CPPCHECK_CMD) $(CPPFLAGS) $<
+-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
+-@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
+-@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
++@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS_STLIB) -g -pg -o profiled/$*.o -c $<
++@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS_SHLIB) -fPIC -o elfshared/$*.o -c $<
++@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS_SHLIB) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
+ all:: $(SMANPAGES) blkid.pc
+diff --git a/lib/e2p/Makefile.in b/lib/e2p/Makefile.in
+index 83f04ff..9931c77 100644
+--- a/lib/e2p/Makefile.in
++++ b/lib/e2p/Makefile.in
+@@ -54,12 +54,12 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
+ .c.o:
+       $(E) "  CC $<"
+-      $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
++      $(Q) $(CC) $(ALL_CFLAGS_STLIB) -c $< -o $@
+       $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+       $(Q) $(CPPCHECK_CMD) $(CPPFLAGS) $<
+-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
+-@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
+-@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
++@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS_STLIB) -g -pg -o profiled/$*.o -c $<
++@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS_SHLIB) -fPIC -o elfshared/$*.o -c $<
++@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS_SHLIB) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
+ e2p.pc: $(srcdir)/e2p.pc.in $(top_builddir)/config.status
+       $(E) "  CONFIG.STATUS $@"
+diff --git a/lib/et/Makefile.in b/lib/et/Makefile.in
+index dbf7c1a..7547f07 100644
+--- a/lib/et/Makefile.in
++++ b/lib/et/Makefile.in
+@@ -42,12 +42,12 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
+ #
+ .c.o:
+       $(E) "  CC $<"
+-      $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
++      $(Q) $(CC) $(ALL_CFLAGS_STLIB) -c $< -o $@
+       $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+       $(Q) $(CPPCHECK_CMD) $(CPPFLAGS) $<
+-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
+-@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
+-@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
++@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS_STLIB) -g -pg -o profiled/$*.o -c $<
++@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS_SHLIB) -fPIC -o elfshared/$*.o -c $<
++@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS_SHLIB) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
+ @MAKEFILE_LIBRARY@
+ @MAKEFILE_ELF@
+diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
+index d42334e..cd83dcb 100644
+--- a/lib/ext2fs/Makefile.in
++++ b/lib/ext2fs/Makefile.in
+@@ -245,12 +245,12 @@ all:: ext2fs.pc
+ .c.o:
+       $(E) "  CC $<"
+-      $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
++      $(Q) $(CC) $(ALL_CFLAGS_STLIB) -c $< -o $@
+       $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+       $(Q) $(CPPCHECK_CMD) $(CPPFLAGS) $<
+-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
+-@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
+-@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
++@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS_STLIB) -g -pg -o profiled/$*.o -c $<
++@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS_SHLIB) -fPIC -o elfshared/$*.o -c $<
++@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS_SHLIB) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
+ COMPILE_ET=../et/compile_et --build-tree
+@@ -270,7 +270,7 @@ ext2fs.pc: $(srcdir)/ext2fs.pc.in $(top_builddir)/config.status
+ tst_badblocks: tst_badblocks.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_badblocks tst_badblocks.o $(ALL_LDFLAGS) \
++      $(Q) $(CC) -o tst_badblocks tst_badblocks.o $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_digest_encode: $(srcdir)/digest_encode.c $(srcdir)/ext2_fs.h
+@@ -281,46 +281,46 @@ tst_digest_encode: $(srcdir)/digest_encode.c $(srcdir)/ext2_fs.h
+ tst_icount: $(srcdir)/icount.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+       $(Q) $(CC) -o tst_icount $(srcdir)/icount.c -DDEBUG \
+-              $(ALL_CFLAGS) $(ALL_LDFLAGS) \
++              $(ALL_CFLAGS) $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_iscan: tst_iscan.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_iscan tst_iscan.o $(ALL_LDFLAGS) \
++      $(Q) $(CC) -o tst_iscan tst_iscan.o $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_getsize: tst_getsize.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_getsize tst_getsize.o $(ALL_LDFLAGS) \
++      $(Q) $(CC) -o tst_getsize tst_getsize.o $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_ismounted: $(srcdir)/ismounted.c $(STATIC_LIBEXT2FS) \
+               $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+       $(Q) $(CC) -o tst_ismounted $(srcdir)/ismounted.c \
+-              $(STATIC_LIBEXT2FS) -DDEBUG $(ALL_CFLAGS) $(ALL_LDFLAGS) \
++              $(STATIC_LIBEXT2FS) -DDEBUG $(ALL_CFLAGS) $(LDFLAGS_STATIC) \
+               $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_byteswap: tst_byteswap.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_byteswap tst_byteswap.o $(ALL_LDFLAGS) \
++      $(Q) $(CC) -o tst_byteswap tst_byteswap.o $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_bitops: tst_bitops.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_bitops tst_bitops.o $(ALL_CFLAGS) $(ALL_LDFLAGS) \
++      $(Q) $(CC) -o tst_bitops tst_bitops.o $(ALL_CFLAGS) $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_getsectsize: tst_getsectsize.o $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_sectgetsize tst_getsectsize.o $(ALL_LDFLAGS) \
++      $(Q) $(CC) -o tst_sectgetsize tst_getsectsize.o $(LDFLAGS_STATIC) \
+               $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_types.o: $(srcdir)/tst_types.c ext2_types.h 
+ tst_types: tst_types.o ext2_types.h 
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_types tst_types.o $(ALL_LDFLAGS) $(SYSLIBS)
++      $(Q) $(CC) -o tst_types tst_types.o $(LDFLAGS_STATIC) $(SYSLIBS)
+ tst_super_size.o: $(srcdir)/tst_super_size.c $(srcdir)/ext2_fs.h
+@@ -467,7 +467,7 @@ tst_bitmaps: tst_bitmaps.o tst_bitmaps_cmd.o $(srcdir)/blkmap64_rb.c \
+       $(E) "  LD $@"
+       $(Q) $(CC) -o $@ tst_bitmaps.o tst_bitmaps_cmd.o \
+               -DDEBUG_RB $(srcdir)/blkmap64_rb.c $(ALL_CFLAGS) \
+-              $(ALL_LDFLAGS) $(STATIC_LIBEXT2FS) $(STATIC_LIBSS) \
++              $(LDFLAGS_STATIC) $(STATIC_LIBEXT2FS) $(STATIC_LIBSS) \
+               $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_extents: $(srcdir)/extent.c $(DEBUG_OBJS) $(DEPSTATIC_LIBSS) libext2fs.a \
+@@ -475,7 +475,7 @@ tst_extents: $(srcdir)/extent.c $(DEBUG_OBJS) $(DEPSTATIC_LIBSS) libext2fs.a \
+       $(DEPLIBSUPPORT)
+       $(E) "  LD $@"
+       $(Q) $(CC) -o tst_extents $(srcdir)/extent.c \
+-              $(ALL_CFLAGS) $(ALL_LDFLAGS) -DDEBUG $(DEBUG_OBJS) \
++              $(ALL_CFLAGS) $(LDFLAGS_STATIC) -DDEBUG $(DEBUG_OBJS) \
+               $(STATIC_LIBSS) $(STATIC_LIBE2P) $(LIBSUPPORT) \
+               $(STATIC_LIBEXT2FS) $(LIBBLKID) $(LIBUUID) \
+               $(STATIC_LIBCOM_ERR) $(SYSLIBS) -I $(top_srcdir)/debugfs
+@@ -484,7 +484,7 @@ tst_libext2fs: $(DEBUG_OBJS) \
+       $(DEPSTATIC_LIBSS) $(STATIC_LIBE2P) $(DEPLIBUUID) libext2fs.a \
+       $(DEPLIBBLKID) $(DEPSTATIC_LIBCOM_ERR) $(DEPLIBSUPPORT)
+       $(E) "  LD $@"
+-      $(Q) $(CC) -o tst_libext2fs $(ALL_LDFLAGS) -DDEBUG $(DEBUG_OBJS) \
++      $(Q) $(CC) -o tst_libext2fs $(LDFLAGS_STATIC) -DDEBUG $(DEBUG_OBJS) \
+               $(STATIC_LIBSS) $(STATIC_LIBE2P) $(LIBSUPPORT) \
+               $(STATIC_LIBEXT2FS) $(LIBBLKID) $(LIBUUID) $(LIBMAGIC) \
+               $(STATIC_LIBCOM_ERR) $(SYSLIBS) -I $(top_srcdir)/debugfs
+@@ -492,7 +492,7 @@ tst_libext2fs: $(DEBUG_OBJS) \
+ tst_inline: $(srcdir)/inline.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+       $(E) "  LD $@"
+       $(Q) $(CC) -o tst_inline $(srcdir)/inline.c $(ALL_CFLAGS) \
+-              $(ALL_LDFLAGS) -DDEBUG $(STATIC_LIBEXT2FS) \
++              $(LDFLAGS_STATIC) -DDEBUG $(STATIC_LIBEXT2FS) \
+               $(STATIC_LIBCOM_ERR) $(SYSLIBS)
+ tst_inline_data: inline_data.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+@@ -504,11 +504,11 @@ tst_csum: csum.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR) $(STATIC_LIBE2P) \
+               $(top_srcdir)/lib/e2p/e2p.h
+       $(E) "  LD $@"
+       $(Q) $(CC) -o tst_csum $(srcdir)/csum.c -DDEBUG \
+-              $(ALL_CFLAGS) $(ALL_LDFLAGS) $(STATIC_LIBEXT2FS) \
++              $(ALL_CFLAGS) $(LDFLAGS_STATIC) $(STATIC_LIBEXT2FS) \
+               $(STATIC_LIBCOM_ERR) $(STATIC_LIBE2P) $(SYSLIBS)
+ tst_crc32c: $(srcdir)/crc32c.c $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+-      $(Q) $(CC) $(ALL_LDFLAGS) $(ALL_CFLAGS) -o tst_crc32c $(srcdir)/crc32c.c \
++      $(Q) $(CC) $(LDFLAGS_STATIC) $(ALL_CFLAGS) -o tst_crc32c $(srcdir)/crc32c.c \
+               -DUNITTEST $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) \
+               $(SYSLIBS)
+diff --git a/lib/ss/Makefile.in b/lib/ss/Makefile.in
+index cfe0f38..36528d8 100644
+--- a/lib/ss/Makefile.in
++++ b/lib/ss/Makefile.in
+@@ -33,12 +33,12 @@ MK_CMDS=_SS_DIR_OVERRIDE=. ./mk_cmds
+ .c.o:
+       $(E) "  CC $<"
+-      $(Q) $(CC) $(ALL_CFLAGS) -c $<
++      $(Q) $(CC) $(ALL_CFLAGS_STLIB) -c $<
+       $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+       $(Q) $(CPPCHECK_CMD) $(CPPFLAGS) $<
+-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
+-@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS) -DSHARED_ELF_LIB -fPIC -o elfshared/$*.o -c $<
+-@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
++@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS_STLIB) -g -pg -o profiled/$*.o -c $<
++@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS_SHLIB) -DSHARED_ELF_LIB -fPIC -o elfshared/$*.o -c $<
++@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS_SHLIB) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
+ # for the library
+diff --git a/lib/uuid/Makefile.in b/lib/uuid/Makefile.in
+index acdcea6..c62c739 100644
+--- a/lib/uuid/Makefile.in
++++ b/lib/uuid/Makefile.in
+@@ -60,12 +60,12 @@ BSDLIB_INSTALL_DIR = $(root_libdir)
+ .c.o:
+       $(E) "  CC $<"
+-      $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
++      $(Q) $(CC) $(ALL_CFLAGS_STLIB) -c $< -o $@
+       $(Q) $(CHECK_CMD) $(ALL_CFLAGS) $<
+       $(Q) $(CPPCHECK_CMD) $(CPPFLAGS) $<
+-@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
+-@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS) -fPIC -o elfshared/$*.o -c $<
+-@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
++@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS_STLIB) -g -pg -o profiled/$*.o -c $<
++@ELF_CMT@     $(Q) $(CC) $(ALL_CFLAGS_SHLIB) -fPIC -o elfshared/$*.o -c $<
++@BSDLIB_CMT@  $(Q) $(CC) $(ALL_CFLAGS_SHLIB) $(BSDLIB_PIC_FLAG) -o pic/$*.o -c $<
+ all:: tst_uuid uuid_time $(SMANPAGES) uuid.pc
+diff --git a/misc/Makefile.in b/misc/Makefile.in
+index 57c81a2..43e3c7e 100644
+--- a/misc/Makefile.in
++++ b/misc/Makefile.in
+@@ -108,8 +108,8 @@ DEPLIBS= $(LIBEXT2FS) $(DEPLIBCOM_ERR) $(DEPLIBSUPPORT)
+ PROFILED_LIBS= $(PROFILED_LIBEXT2FS) $(PROFILED_LIBCOM_ERR) $(LIBSUPPORT)
+ PROFILED_DEPLIBS= $(PROFILED_LIBEXT2FS) $(DEPPROFILED_LIBCOM_ERR) $(DEPLIBSUPPORT)
+-STATIC_LIBS= $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR) $(LIBSUPPORT)
+-STATIC_DEPLIBS= $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR) $(DEPLIBSUPPORT)
++STATIC_LIBS= $(LIBSUPPORT) $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
++STATIC_DEPLIBS= $(DEPLIBSUPPORT) $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
+ LIBS_E2P= $(LIBE2P) $(LIBCOM_ERR)
+ DEPLIBS_E2P= $(LIBE2P) $(DEPLIBCOM_ERR)
+@@ -233,7 +233,7 @@ e4defrag: $(E4DEFRAG_OBJS) $(DEPLIBS)
+ e4crypt: $(E4CRYPT_OBJS) $(DEPLIBS) $(DEPSTATIC_LIBUUID)
+       $(E) "  LD $@"
+       $(Q) $(CC) $(ALL_LDFLAGS) -o e4crypt $(E4CRYPT_OBJS) \
+-              $(STATIC_LIBUUID) $(STATIC_LIBS)
++              $(LIBUUID) $(LIBS)
+ e4defrag.profiled: $(E4DEFRAG_OBJS) $(PROFILED_DEPLIBS)
+       $(E) "  LD $@"
+@@ -270,7 +270,7 @@ mke2fs: $(MKE2FS_OBJS) $(DEPLIBS) $(LIBE2P) $(DEPLIBBLKID) $(DEPLIBUUID) \
+ mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIBUUID) \
+               $(DEPSTATIC_LIBBLKID)
+       $(E) "  LD $@"
+-      $(Q) $(CC) $(ALL_LDFLAGS) -static -o mke2fs.static $(MKE2FS_OBJS) \
++      $(Q) $(CC) $(LDFLAGS_STATIC) -o mke2fs.static $(MKE2FS_OBJS) \
+               $(STATIC_LIBS) $(STATIC_LIBE2P) \
+               $(STATIC_LIBBLKID) $(STATIC_LIBUUID) $(LIBINTL) $(SYSLIBS) \
+               $(LIBMAGIC)
+diff --git a/resize/Makefile.in b/resize/Makefile.in
+index ecd8619..6014bdd 100644
+--- a/resize/Makefile.in
++++ b/resize/Makefile.in
+@@ -8,7 +8,6 @@ VPATH = @srcdir@
+ top_builddir = ..
+ my_dir = resize
+ INSTALL = @INSTALL@
+-LDFLAG_STATIC = @LDFLAG_STATIC@
+ @MCONFIG@
+@@ -49,7 +48,7 @@ resize2fs: $(RESIZE_OBJS) $(DEPLIBS)
+ resize2fs.static: $(RESIZE_OBJS) $(DEPSTATIC_LIBS)
+       $(E) "  LD $@"
+-      $(Q) $(LD) $(ALL_LDFLAGS) $(LDFLAG_STATIC) -o resize2fs.static \
++      $(Q) $(LD) $(LDFLAGS_STATIC) -o resize2fs.static \
+               $(RESIZE_OBJS) $(STATIC_LIBS) 
+ resize2fs.8: $(DEP_SUBSTITUTE) $(srcdir)/resize2fs.8.in
+-- 
+2.5.0
+
diff --git a/debian/patches/clean-up-spelling-errors-and-other-nits-in-man-pages b/debian/patches/clean-up-spelling-errors-and-other-nits-in-man-pages
new file mode 100644 (file)
index 0000000..bd4aec9
--- /dev/null
@@ -0,0 +1,214 @@
+Description: Clean up spelling errors and other nits in man pages
+
+Author: Theodore Ts'o <tytso@mit.edu>
+---
+ e2fsck/e2fsck.conf.5.in |  2 +-
+ misc/e2image.8.in       |  2 +-
+ misc/ext4.5.in          | 30 ++++++------------------------
+ misc/mke2fs.conf.5.in   |  2 +-
+ misc/tune2fs.8.in       | 32 ++++++++++++++++++++++++--------
+ 5 files changed, 33 insertions(+), 35 deletions(-)
+
+diff --git a/e2fsck/e2fsck.conf.5.in b/e2fsck/e2fsck.conf.5.in
+index 1f80a04..b6fdafe 100644
+--- a/e2fsck/e2fsck.conf.5.in
++++ b/e2fsck/e2fsck.conf.5.in
+@@ -179,7 +179,7 @@ or
+ are not available or are not yet writeable, e2fsck will save the output
+ in a memory buffer, and a child process will periodically test to see if
+ the log directory has become available after the boot sequence has
+-mounted the requiste filesytem for reading/writing.  This implements the
++mounted the requiste file system for reading/writing.  This implements the
+ functionality provided by
+ .BR logsave (8)
+ for e2fsck log files.
+diff --git a/misc/e2image.8.in b/misc/e2image.8.in
+index 75002d7..f28a76e 100644
+--- a/misc/e2image.8.in
++++ b/misc/e2image.8.in
+@@ -62,7 +62,7 @@ or
+ .B \-Q
+ options, the filesystem must be unmounted or be mounted read/only, in order
+ for the image file to be in a consistent state.  This requirement can be
+-overriden using the
++overridden using the
+ .B \-f
+ option, but the resulting image file is very likely not going to be useful.
+ .PP
+diff --git a/misc/ext4.5.in b/misc/ext4.5.in
+index e892743..902c332 100644
+--- a/misc/ext4.5.in
++++ b/misc/ext4.5.in
+@@ -20,7 +20,7 @@ mounted using the ext4 file system driver, and indeed in many modern
+ Linux distributions, the ext4 file system driver has been configured
+ handle mount requests for ext2 and ext3 file systems.
+ .SH FILE SYSTEM FEATURES
+-A file system formated for ext2, ext3, or ext4 can be have some
++A file system formatted for ext2, ext3, or ext4 can be have some
+ collection of the follow file system feature flags enabled.  Some of
+ these features are not supported by all implementations of the ext2,
+ ext3, and ext4 file system drivers, depending on Linux kernel version in
+@@ -271,7 +271,9 @@ is determined by the filesystem superblock. Set them with
+ .BR tune2fs (8).
+ .TP
+ .BR acl | noacl
+-Support POSIX Access Control Lists (or not).
++Support POSIX Access Control Lists (or not).  See the
++.BR acl (5)
++manual page.
+ .TP
+ .BR bsddf | minixdf
+ Set the behavior for the
+@@ -382,16 +384,6 @@ The ext3 filesystem is a version of the ext2 filesystem which has been
+ enhanced with journaling.  It supports the same options as ext2 as
+ well as the following additions:
+ .TP
+-.B journal=update
+-Update the ext3 filesystem's journal to the current format.
+-.TP
+-.B journal=inum
+-When a journal already exists, this option is ignored. Otherwise, it
+-specifies the number of the inode which will represent the ext3 filesystem's
+-journal file; ext3 will create a new journal, overwriting the old contents
+-of the file whose inode number is
+-.IR inum .
+-.TP
+ .BR journal_dev=devnum / journal_path=path
+ When the external journal device's major/minor numbers
+ have changed, these options allow the user to specify
+@@ -456,11 +448,6 @@ Enable Extended User Attributes. See the
+ .BR attr (5)
+ manual page.
+ .TP
+-.B acl
+-Enable POSIX Access Control Lists. See the
+-.BR acl (5)
+-manual page.
+-.TP
+ .BR usrjquota=aquota.user | grpjquota=aquota.group | jqfmt=vfsv0
+ Apart from the old quota system (as in ext2, jqfmt=vfsold aka version 1 quota)
+ ext3 also supports journaled quotas (version 2 quota). jqfmt=vfsv0
+@@ -477,7 +464,7 @@ filesystem.
+ The options
+ .B journal_dev, norecovery, noload, data, commit, orlov, oldalloc, [no]user_xattr
+ .B [no]acl, bsddf, minixdf, debug, errors, data_err, grpid, bsdgroups, nogrpid
+-.B sysvgroups, resgid, resuid, sb, quota, noquota, grpquota, usrquota
++.B sysvgroups, resgid, resuid, sb, quota, noquota, nouid32, grpquota, usrquota
+ .B usrjquota, grpjquota and jqfmt
+ are backwardly compatible with ext3 or ext2.
+ .TP
+@@ -582,13 +569,8 @@ block device when blocks are freed.  This is useful for SSD devices and
+ sparse/thinly-provisioned LUNs, but it is off by default until sufficient
+ testing has been done.
+ .TP
+-.B nouid32
+-Disables 32-bit UIDs and GIDs.  This is for
+-interoperability  with  older kernels which only
+-store and expect 16-bit values.
+-.TP
+ .BR block_validity / noblock_validity
+-This options allows to enables/disables the in-kernel facility for tracking
++This options enables/disables the in-kernel facility for tracking
+ filesystem metadata blocks within internal data structures. This allows multi-\c
+ block allocator and other routines to quickly locate extents which might
+ overlap with filesystem metadata blocks. This option is intended for debugging
+diff --git a/misc/mke2fs.conf.5.in b/misc/mke2fs.conf.5.in
+index 0830d2e..1ce0f5e 100644
+--- a/misc/mke2fs.conf.5.in
++++ b/misc/mke2fs.conf.5.in
+@@ -484,7 +484,7 @@ requested alignment.  If this relation is not specified, no alignment
+ requirement will be imposed on the huge files.
+ .TP
+ .I hugefiles_align_disk
+-Thie relations specifies whether the alignment should be relative to the
++This relations specifies whether the alignment should be relative to the
+ beginning of the hard drive (assuming that the starting offset of the
+ partition is available to mke2fs).  The default value is false, which
+ will cause hugefile alignment to be relative to the beginning of the
+diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in
+index 15cd967..fc326a1 100644
+--- a/misc/tune2fs.8.in
++++ b/misc/tune2fs.8.in
+@@ -546,8 +546,15 @@ Use hashed b-trees to speed up lookups for large directories.
+ .B dir_nlink
+ Allow more than 65000 subdirectories per directory.
+ .TP
++.B encrypt
++Enable file system level encryption.
++.B Tune2fs
++currently only supports setting this filesystem feature.
++.TP
+ .B extent
+ Enable the use of extent trees to store the location of data blocks in inodes.
++.B Tune2fs
++currently only supports setting this filesystem feature.
+ .TP
+ .B extra_isize
+ Enable the extended inode fields used by ext4.
+@@ -576,29 +583,37 @@ Support files larger than 2 terabytes in size.
+ .B large_file
+ Filesystem can contain files that are greater than 2GB.
+ .TP
+-.B resize_inode
+-Reserve space so the block group descriptor table may grow in the
+-future.
+-.B Tune2fs 
+-only supports clearing this filesystem feature.
++.B metadata_csum
++Store a checksum to protect the contents in each metadata block.
+ .TP
+ .B mmp
+ Enable or disable multiple mount protection (MMP) feature.
+ .TP
++.B project
++Enable project ID tracking.  This is used for project quota tracking.
++.TP
+ .B quota
+ Enable internal file system quota inodes.
+ .TP
+ .B read-only
+ Force the kernel to mount the file system read-only.
+ .TP
++.B resize_inode
++Reserve space so the block group descriptor table may grow in the
++future.
++.B Tune2fs
++only supports clearing this filesystem feature.
++.TP
+ .B sparse_super
+ Limit the number of backup superblocks to save space on large filesystems.
++.B Tune2fs
++currently only supports setting this filesystem feature.
+ .TP
+ .B uninit_bg
+ Allow the kernel to initialize bitmaps and inode tables lazily, and to
+ keep a high watermark for the unused inodes in a filesystem, to reduce
+ .BR e2fsck (8)
+-time.  This first e2fsck run after enabling this feature will take the
++time.  The first e2fsck run after enabling this feature will take the
+ full time, but subsequent e2fsck runs will take only a fraction of the
+ original time, depending on how full the file system is.
+ .RE
+@@ -610,8 +625,9 @@ After setting or clearing
+ or
+ .B resize_inode
+ filesystem features,
++the file system may require being checked using
+ .BR e2fsck (8)
+-must be run on the filesystem to return the filesystem to a consistent state.
++to return the filesystem to a consistent state.
+ .B Tune2fs
+ will print a message requesting that the system administrator run
+ .BR e2fsck (8)
+@@ -724,7 +740,7 @@ WARNING: The undo file cannot be used to recover from a power or system crash.
+ .SH BUGS
+ We haven't found any bugs yet.  That doesn't mean there aren't any...
+ .SH AUTHOR
+-.B tune2fs 
++.B tune2fs
+ was written by Remy Card <Remy.Card@linux.org>.  It is currently being
+ maintained by Theodore Ts'o <tytso@alum.mit.edu>.
+ .B tune2fs
+-- 
+2.5.0
+
diff --git a/debian/patches/e2fsck-fix-project-quota-support b/debian/patches/e2fsck-fix-project-quota-support
new file mode 100644 (file)
index 0000000..919c6e3
--- /dev/null
@@ -0,0 +1,550 @@
+Description: fix project quota support
+ Use a large_inode so that when e2fsck is fixing a file system with
+ project quota enabled, the correct project id's quota is adjusted when
+ a corrupted inode is deleted.
+
+Author: Theodore Ts'o <tytso@mit.edu>
+---
+ e2fsck/pass1.c        |  7 +++--
+ e2fsck/pass1b.c       | 83 +++++++++++++++++++++++++++++----------------------
+ e2fsck/pass3.c        | 21 +++++++------
+ e2fsck/pass4.c        | 33 ++++++++++----------
+ lib/ext2fs/ext2_fs.h  |  6 ++++
+ lib/support/mkquota.c | 22 +++++++-------
+ lib/support/quotaio.h | 12 ++++----
+ 7 files changed, 103 insertions(+), 81 deletions(-)
+
+diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
+index e097c39..799158e 100644
+--- a/e2fsck/pass1.c
++++ b/e2fsck/pass1.c
+@@ -3165,9 +3165,10 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
+       if (ino != quota_type2inum(PRJQUOTA, fs->super) &&
+           (ino == EXT2_ROOT_INO || ino >= EXT2_FIRST_INODE(ctx->fs->super))) {
+-              quota_data_add(ctx->qctx, inode, ino,
+-                             pb.num_blocks * fs->blocksize);
+-              quota_data_inodes(ctx->qctx, inode, ino, +1);
++              quota_data_add(ctx->qctx, (struct ext2_inode_large *) inode,
++                             ino, pb.num_blocks * fs->blocksize);
++              quota_data_inodes(ctx->qctx, (struct ext2_inode_large *) inode,
++                                ino, +1);
+       }
+       if (!ext2fs_has_feature_huge_file(fs->super) ||
+diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
+index 2cbf82a..b40f026 100644
+--- a/e2fsck/pass1b.c
++++ b/e2fsck/pass1b.c
+@@ -79,7 +79,7 @@ struct dup_cluster {
+ struct dup_inode {
+       ext2_ino_t              dir;
+       int                     num_dupblocks;
+-      struct ext2_inode       inode;
++      struct ext2_inode_large inode;
+       struct cluster_el       *cluster_list;
+ };
+@@ -118,7 +118,7 @@ static int dict_int_cmp(const void *a, const void *b)
+  * Add a duplicate block record
+  */
+ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk64_t cluster,
+-                   struct ext2_inode *inode)
++                   struct ext2_inode_large *inode)
+ {
+       dnode_t *n;
+       struct dup_cluster      *db;
+@@ -263,7 +263,7 @@ struct process_block_struct {
+       int             dup_blocks;
+       blk64_t         cur_cluster, phys_cluster;
+       blk64_t         last_blk;
+-      struct ext2_inode *inode;
++      struct ext2_inode_large *inode;
+       struct problem_context *pctx;
+ };
+@@ -271,7 +271,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
+ {
+       ext2_filsys fs = ctx->fs;
+       ext2_ino_t ino = 0;
+-      struct ext2_inode inode;
++      struct ext2_inode_large inode;
+       ext2_inode_scan scan;
+       struct process_block_struct pb;
+       struct problem_context pctx;
+@@ -288,7 +288,7 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
+               ctx->flags |= E2F_FLAG_ABORT;
+               return;
+       }
+-      ctx->stashed_inode = &inode;
++      ctx->stashed_inode = EXT2_INODE(&inode);
+       pb.ctx = ctx;
+       pb.pctx = &pctx;
+       pctx.str = "pass1b";
+@@ -297,7 +297,8 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
+                       if (e2fsck_mmp_update(fs))
+                               fatal_error(ctx, 0);
+               }
+-              pctx.errcode = ext2fs_get_next_inode(scan, &ino, &inode);
++              pctx.errcode = ext2fs_get_next_inode_full(scan, &ino,
++                              EXT2_INODE(&inode), sizeof(inode));
+               if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
+                       continue;
+               if (pctx.errcode) {
+@@ -321,18 +322,18 @@ static void pass1b(e2fsck_t ctx, char *block_buf)
+               pb.last_blk = 0;
+               pb.pctx->blk = pb.pctx->blk2 = 0;
+-              if (ext2fs_inode_has_valid_blocks2(fs, &inode) ||
++              if (ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(&inode)) ||
+                   (ino == EXT2_BAD_INO))
+                       pctx.errcode = ext2fs_block_iterate3(fs, ino,
+                                            BLOCK_FLAG_READ_ONLY, block_buf,
+                                            process_pass1b_block, &pb);
+               /* If the feature is not set, attrs will be cleared later anyway */
+               if (ext2fs_has_feature_xattr(fs->super) &&
+-                  ext2fs_file_acl_block(fs, &inode)) {
+-                      blk64_t blk = ext2fs_file_acl_block(fs, &inode);
++                  ext2fs_file_acl_block(fs, EXT2_INODE(&inode))) {
++                      blk64_t blk = ext2fs_file_acl_block(fs, EXT2_INODE(&inode));
+                       process_pass1b_block(fs, &blk,
+                                            BLOCK_COUNT_EXTATTR, 0, 0, &pb);
+-                      ext2fs_file_acl_block_set(fs, &inode, blk);
++                      ext2fs_file_acl_block_set(fs, EXT2_INODE(&inode), blk);
+               }
+               if (pb.dup_blocks) {
+                       if (ino != EXT2_BAD_INO) {
+@@ -548,7 +549,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
+               /*
+                * Report the inode that we are working on
+                */
+-              pctx.inode = &p->inode;
++              pctx.inode = EXT2_INODE(&p->inode);
+               pctx.ino = ino;
+               pctx.dir = p->dir;
+               pctx.blkcount = p->num_dupblocks;
+@@ -568,7 +569,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
+                       /*
+                        * Report the inode that we are sharing with
+                        */
+-                      pctx.inode = &t->inode;
++                      pctx.inode = EXT2_INODE(&t->inode);
+                       pctx.ino = shared[i];
+                       pctx.dir = t->dir;
+                       fix_problem(ctx, PR_1D_DUP_FILE_LIST, &pctx);
+@@ -668,7 +669,7 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
+       pctx.str = "delete_file";
+       pb.cur_cluster = ~0;
+-      if (ext2fs_inode_has_valid_blocks2(fs, &dp->inode))
++      if (ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(&dp->inode)))
+               pctx.errcode = ext2fs_block_iterate3(fs, ino,
+                                                    BLOCK_FLAG_READ_ONLY,
+                                                    block_buf,
+@@ -683,20 +684,23 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
+       quota_data_inodes(ctx->qctx, &dp->inode, ino, -1);
+       /* Inode may have changed by block_iterate, so reread it */
+-      e2fsck_read_inode(ctx, ino, &dp->inode, "delete_file");
+-      e2fsck_clear_inode(ctx, ino, &dp->inode, 0, "delete_file");
+-      if (ext2fs_file_acl_block(fs, &dp->inode) &&
++      e2fsck_read_inode_full(ctx, ino, EXT2_INODE(&dp->inode),
++                             sizeof(dp->inode), "delete_file");
++      e2fsck_clear_inode(ctx, ino, EXT2_INODE(&dp->inode), 0, "delete_file");
++      if (ext2fs_file_acl_block(fs, EXT2_INODE(&dp->inode)) &&
+           ext2fs_has_feature_xattr(fs->super)) {
++              blk64_t file_acl_block = ext2fs_file_acl_block(fs,
++                                              EXT2_INODE(&dp->inode));
++
+               count = 1;
+-              pctx.errcode = ext2fs_adjust_ea_refcount3(fs,
+-                                      ext2fs_file_acl_block(fs, &dp->inode),
++              pctx.errcode = ext2fs_adjust_ea_refcount3(fs, file_acl_block,
+                                       block_buf, -1, &count, ino);
+               if (pctx.errcode == EXT2_ET_BAD_EA_BLOCK_NUM) {
+                       pctx.errcode = 0;
+                       count = 1;
+               }
+               if (pctx.errcode) {
+-                      pctx.blk = ext2fs_file_acl_block(fs, &dp->inode);
++                      pctx.blk = file_acl_block;
+                       fix_problem(ctx, PR_1B_ADJ_EA_REFCOUNT, &pctx);
+               }
+               /*
+@@ -707,12 +711,13 @@ static void delete_file(e2fsck_t ctx, ext2_ino_t ino,
+                */
+               if ((count == 0) ||
+                   ext2fs_test_block_bitmap2(ctx->block_dup_map,
+-                                      ext2fs_file_acl_block(fs, &dp->inode))) {
+-                      blk64_t blk = ext2fs_file_acl_block(fs, &dp->inode);
+-                      delete_file_block(fs, &blk,
++                                            file_acl_block)) {
++                      delete_file_block(fs, &file_acl_block,
+                                         BLOCK_COUNT_EXTATTR, 0, 0, &pb);
+-                      ext2fs_file_acl_block_set(fs, &dp->inode, blk);
+-                      quota_data_sub(ctx->qctx, &dp->inode, ino, fs->blocksize);
++                      ext2fs_file_acl_block_set(fs, EXT2_INODE(&dp->inode),
++                                                file_acl_block);
++                      quota_data_sub(ctx->qctx, &dp->inode, ino,
++                                     fs->blocksize);
+               }
+       }
+ }
+@@ -724,7 +729,7 @@ struct clone_struct {
+       ext2_ino_t      dir, ino;
+       char    *buf;
+       e2fsck_t ctx;
+-      struct ext2_inode       *inode;
++      struct ext2_inode_large *inode;
+       struct dup_cluster *save_dup_cluster;
+       blk64_t save_blocknr;
+@@ -800,7 +805,8 @@ static int clone_file_block(ext2_filsys fs,
+                * mapped to multiple physical clusters.
+                */
+               new_block = 0;
+-              retval = ext2fs_map_cluster_block(fs, cs->ino, cs->inode,
++              retval = ext2fs_map_cluster_block(fs, cs->ino,
++                                                EXT2_INODE(cs->inode),
+                                                 blockcnt, &new_block);
+               if (retval == 0 && new_block != 0 &&
+                   EXT2FS_B2C(ctx->fs, new_block) !=
+@@ -882,7 +888,7 @@ static errcode_t clone_file(e2fsck_t ctx, ext2_ino_t ino,
+       pctx.ino = ino;
+       pctx.str = "clone_file";
+-      if (ext2fs_inode_has_valid_blocks2(fs, &dp->inode))
++      if (ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(&dp->inode)))
+               pctx.errcode = ext2fs_block_iterate3(fs, ino, 0, block_buf,
+                                                    clone_file_block, &cs);
+       deferred_dec_badcount(&cs);
+@@ -899,14 +905,16 @@ static errcode_t clone_file(e2fsck_t ctx, ext2_ino_t ino,
+               goto errout;
+       }
+       /* The inode may have changed on disk, so we have to re-read it */
+-      e2fsck_read_inode(ctx, ino, &dp->inode, "clone file EA");
+-      blk = ext2fs_file_acl_block(fs, &dp->inode);
++      e2fsck_read_inode_full(ctx, ino, EXT2_INODE(&dp->inode),
++                             sizeof(dp->inode), "clone file EA");
++      blk = ext2fs_file_acl_block(fs, EXT2_INODE(&dp->inode));
+       new_blk = blk;
+       if (blk && (clone_file_block(fs, &new_blk,
+                                    BLOCK_COUNT_EXTATTR, 0, 0, &cs) ==
+                   BLOCK_CHANGED)) {
+-              ext2fs_file_acl_block_set(fs, &dp->inode, new_blk);
+-              e2fsck_write_inode(ctx, ino, &dp->inode, "clone file EA");
++              ext2fs_file_acl_block_set(fs, EXT2_INODE(&dp->inode), new_blk);
++              e2fsck_write_inode_full(ctx, ino, EXT2_INODE(&dp->inode),
++                                      sizeof(dp->inode), "clone file EA");
+               /*
+                * If we cloned the EA block, find all other inodes
+                * which refered to that EA block, and modify
+@@ -935,11 +943,14 @@ static errcode_t clone_file(e2fsck_t ctx, ext2_ino_t ino,
+                               goto errout;
+                       }
+                       di = (struct dup_inode *) dnode_get(n);
+-                      if (ext2fs_file_acl_block(fs, &di->inode) == blk) {
+-                              ext2fs_file_acl_block_set(fs, &di->inode,
+-                                      ext2fs_file_acl_block(fs, &dp->inode));
+-                              e2fsck_write_inode(ctx, ino_el->inode,
+-                                         &di->inode, "clone file EA");
++                      if (ext2fs_file_acl_block(fs,
++                                      EXT2_INODE(&di->inode)) == blk) {
++                              ext2fs_file_acl_block_set(fs,
++                                      EXT2_INODE(&di->inode),
++                                      ext2fs_file_acl_block(fs, EXT2_INODE(&dp->inode)));
++                              e2fsck_write_inode_full(ctx, ino_el->inode,
++                                      EXT2_INODE(&di->inode),
++                                      sizeof(di->inode), "clone file EA");
+                               decrement_badcount(ctx, blk, dc);
+                       }
+               }
+diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
+index 3b076c4..44203ca 100644
+--- a/e2fsck/pass3.c
++++ b/e2fsck/pass3.c
+@@ -381,7 +381,7 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix)
+       ext2_ino_t                      ino;
+       blk64_t                 blk;
+       errcode_t               retval;
+-      struct ext2_inode       inode;
++      struct ext2_inode_large inode;
+       char *                  block;
+       static const char       name[] = "lost+found";
+       struct  problem_context pctx;
+@@ -406,7 +406,8 @@ ext2_ino_t e2fsck_get_lost_and_found(e2fsck_t ctx, int fix)
+               return 0;
+       if (!retval) {
+               /* Lost+found shouldn't have inline data */
+-              retval = ext2fs_read_inode(fs, ino, &inode);
++              retval = ext2fs_read_inode_full(fs, ino, EXT2_INODE(&inode),
++                                              sizeof(inode));
+               if (fix && retval)
+                       return 0;
+@@ -518,13 +519,13 @@ skip_new_block:
+       inode.i_size = fs->blocksize;
+       inode.i_atime = inode.i_ctime = inode.i_mtime = ctx->now;
+       inode.i_links_count = 2;
+-      ext2fs_iblk_set(fs, &inode, 1);
++      ext2fs_iblk_set(fs, EXT2_INODE(&inode), 1);
+       inode.i_block[0] = blk;
+       /*
+        * Next, write out the inode.
+        */
+-      pctx.errcode = ext2fs_write_new_inode(fs, ino, &inode);
++      pctx.errcode = ext2fs_write_new_inode(fs, ino, EXT2_INODE(&inode));
+       if (pctx.errcode) {
+               pctx.str = "ext2fs_write_inode";
+               fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx);
+@@ -855,7 +856,7 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
+       ext2_filsys fs = ctx->fs;
+       errcode_t       retval;
+       struct expand_dir_struct es;
+-      struct ext2_inode       inode;
++      struct ext2_inode_large inode;
+       blk64_t         sz;
+       if (!(fs->flags & EXT2_FLAG_RW))
+@@ -888,18 +889,20 @@ errcode_t e2fsck_expand_directory(e2fsck_t ctx, ext2_ino_t dir,
+       /*
+        * Update the size and block count fields in the inode.
+        */
+-      retval = ext2fs_read_inode(fs, dir, &inode);
++      retval = ext2fs_read_inode_full(fs, dir,
++                                      EXT2_INODE(&inode), sizeof(inode));
+       if (retval)
+               return retval;
+       sz = (es.last_block + 1) * fs->blocksize;
+-      retval = ext2fs_inode_size_set(fs, &inode, sz);
++      retval = ext2fs_inode_size_set(fs, EXT2_INODE(&inode), sz);
+       if (retval)
+               return retval;
+-      ext2fs_iblk_add_blocks(fs, &inode, es.newblocks);
++      ext2fs_iblk_add_blocks(fs, EXT2_INODE(&inode), es.newblocks);
+       quota_data_add(ctx->qctx, &inode, dir, es.newblocks * fs->blocksize);
+-      e2fsck_write_inode(ctx, dir, &inode, "expand_directory");
++      e2fsck_write_inode_full(ctx, dir, EXT2_INODE(&inode),
++                              sizeof(inode), "expand_directory");
+       return 0;
+ }
+diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c
+index c490438..8c101fd 100644
+--- a/e2fsck/pass4.c
++++ b/e2fsck/pass4.c
+@@ -26,23 +26,21 @@
+  * rest of the pass 4 tests.
+  */
+ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
+-                          struct ext2_inode *inode)
++                          struct ext2_inode_large *inode)
+ {
+       ext2_filsys fs = ctx->fs;
+       struct problem_context  pctx;
+       __u32 eamagic = 0;
+       int extra_size = 0;
+-      if (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE) {
+-              e2fsck_read_inode_full(ctx, i, inode,EXT2_INODE_SIZE(fs->super),
+-                                     "pass4: disconnect_inode");
+-              extra_size = ((struct ext2_inode_large *)inode)->i_extra_isize;
+-      } else {
+-              e2fsck_read_inode(ctx, i, inode, "pass4: disconnect_inode");
+-      }
++      e2fsck_read_inode_full(ctx, i, EXT2_INODE(inode),
++                             EXT2_INODE_SIZE(fs->super),
++                             "pass4: disconnect_inode");
++      if (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE)
++              extra_size = inode->i_extra_isize;
+       clear_problem_context(&pctx);
+       pctx.ino = i;
+-      pctx.inode = inode;
++      pctx.inode = EXT2_INODE(inode);
+       if (EXT2_INODE_SIZE(fs->super) -EXT2_GOOD_OLD_INODE_SIZE -extra_size >0)
+               eamagic = *(__u32 *)(((char *)inode) +EXT2_GOOD_OLD_INODE_SIZE +
+@@ -56,7 +54,7 @@ static int disconnect_inode(e2fsck_t ctx, ext2_ino_t i,
+       if (!inode->i_blocks && eamagic != EXT2_EXT_ATTR_MAGIC &&
+           (LINUX_S_ISREG(inode->i_mode) || LINUX_S_ISDIR(inode->i_mode))) {
+               if (fix_problem(ctx, PR_4_ZERO_LEN_INODE, &pctx)) {
+-                      e2fsck_clear_inode(ctx, i, inode, 0,
++                      e2fsck_clear_inode(ctx, i, EXT2_INODE(inode), 0,
+                                          "disconnect_inode");
+                       /*
+                        * Fix up the bitmaps...
+@@ -92,7 +90,8 @@ void e2fsck_pass4(e2fsck_t ctx)
+ {
+       ext2_filsys fs = ctx->fs;
+       ext2_ino_t      i;
+-      struct ext2_inode       *inode;
++      struct ext2_inode_large *inode;
++      int inode_size = EXT2_INODE_SIZE(fs->super);
+ #ifdef RESOURCE_TRACK
+       struct resource_track   rtrack;
+ #endif
+@@ -127,8 +126,7 @@ void e2fsck_pass4(e2fsck_t ctx)
+               if ((ctx->progress)(ctx, 4, 0, maxgroup))
+                       return;
+-      inode = e2fsck_allocate_memory(ctx, EXT2_INODE_SIZE(fs->super),
+-                                     "scratch inode");
++      inode = e2fsck_allocate_memory(ctx, inode_size, "scratch inode");
+       /* Protect loop from wrap-around if s_inodes_count maxed */
+       for (i=1; i <= fs->super->s_inodes_count && i > 0; i++) {
+@@ -171,9 +169,10 @@ void e2fsck_pass4(e2fsck_t ctx)
+               if (isdir && (link_counted > EXT2_LINK_MAX))
+                       link_counted = 1;
+               if (link_counted != link_count) {
+-                      e2fsck_read_inode(ctx, i, inode, "pass4");
++                      e2fsck_read_inode_full(ctx, i, EXT2_INODE(inode),
++                                             inode_size, "pass4");
+                       pctx.ino = i;
+-                      pctx.inode = inode;
++                      pctx.inode = EXT2_INODE(inode);
+                       if ((link_count != inode->i_links_count) && !isdir &&
+                           (inode->i_links_count <= EXT2_LINK_MAX)) {
+                               pctx.num = link_count;
+@@ -188,7 +187,9 @@ void e2fsck_pass4(e2fsck_t ctx)
+                            link_count == 1 && !(ctx->options & E2F_OPT_NO)) ||
+                           fix_problem(ctx, PR_4_BAD_REF_COUNT, &pctx)) {
+                               inode->i_links_count = link_counted;
+-                              e2fsck_write_inode(ctx, i, inode, "pass4");
++                              e2fsck_write_inode_full(ctx, i,
++                                                      EXT2_INODE(inode),
++                                                      inode_size, "pass4");
+                       }
+               }
+       }
+diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
+index 9918356..ee9a5f2 100644
+--- a/lib/ext2fs/ext2_fs.h
++++ b/lib/ext2fs/ext2_fs.h
+@@ -519,6 +519,12 @@ struct ext2_inode_large {
+ #define ext2fs_set_i_uid_high(inode,x) ((inode).osd2.linux2.l_i_uid_high = (x))
+ #define ext2fs_set_i_gid_high(inode,x) ((inode).osd2.linux2.l_i_gid_high = (x))
++static inline
++struct ext2_inode *EXT2_INODE(struct ext2_inode_large *large_inode)
++{
++      return (struct ext2_inode *) large_inode;
++}
++
+ /*
+  * File system states
+  */
+diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c
+index a432d4e..add60ca 100644
+--- a/lib/support/mkquota.c
++++ b/lib/support/mkquota.c
+@@ -243,9 +243,8 @@ static int dict_uint_cmp(const void *a, const void *b)
+               return -1;
+ }
+-static inline qid_t get_qid(struct ext2_inode *inode, enum quota_type qtype)
++static inline qid_t get_qid(struct ext2_inode_large *inode, enum quota_type qtype)
+ {
+-      struct ext2_inode_large *large_inode;
+       int inode_size;
+       switch (qtype) {
+@@ -254,11 +253,10 @@ static inline qid_t get_qid(struct ext2_inode *inode, enum quota_type qtype)
+       case GRPQUOTA:
+               return inode_gid(*inode);
+       case PRJQUOTA:
+-              large_inode = (struct ext2_inode_large *)inode;
+               inode_size = EXT2_GOOD_OLD_INODE_SIZE +
+-                           large_inode->i_extra_isize;
++                      inode->i_extra_isize;
+               if (inode_includes(inode_size, i_projid))
+-                      return inode_projid(*large_inode);
++                      return inode_projid(*inode);
+       default:
+               return 0;
+       }
+@@ -368,7 +366,7 @@ static struct dquot *get_dq(dict_t *dict, __u32 key)
+ /*
+  * Called to update the blocks used by a particular inode
+  */
+-void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode,
++void quota_data_add(quota_ctx_t qctx, struct ext2_inode_large *inode,
+                   ext2_ino_t ino EXT2FS_ATTR((unused)),
+                   qsize_t space)
+ {
+@@ -395,7 +393,7 @@ void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode,
+ /*
+  * Called to remove some blocks used by a particular inode
+  */
+-void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode,
++void quota_data_sub(quota_ctx_t qctx, struct ext2_inode_large *inode,
+                   ext2_ino_t ino EXT2FS_ATTR((unused)),
+                   qsize_t space)
+ {
+@@ -421,7 +419,7 @@ void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode,
+ /*
+  * Called to count the files used by an inode's user/group
+  */
+-void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode,
++void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode_large *inode,
+                      ext2_ino_t ino EXT2FS_ATTR((unused)), int adjust)
+ {
+       struct dquot    *dq;
+@@ -448,7 +446,7 @@ errcode_t quota_compute_usage(quota_ctx_t qctx)
+       ext2_filsys fs;
+       ext2_ino_t ino;
+       errcode_t ret;
+-      struct ext2_inode *inode;
++      struct ext2_inode_large *inode;
+       int inode_size;
+       qsize_t space;
+       ext2_inode_scan scan;
+@@ -467,7 +465,8 @@ errcode_t quota_compute_usage(quota_ctx_t qctx)
+       if (!inode)
+               return ENOMEM;
+       while (1) {
+-              ret = ext2fs_get_next_inode_full(scan, &ino, inode, inode_size);
++              ret = ext2fs_get_next_inode_full(scan, &ino,
++                                               EXT2_INODE(inode), inode_size);
+               if (ret) {
+                       log_err("while getting next inode. ret=%ld", ret);
+                       ext2fs_close_inode_scan(scan);
+@@ -479,7 +478,8 @@ errcode_t quota_compute_usage(quota_ctx_t qctx)
+               if (inode->i_links_count &&
+                   (ino == EXT2_ROOT_INO ||
+                    ino >= EXT2_FIRST_INODE(fs->super))) {
+-                      space = ext2fs_inode_i_blocks(fs, inode) << 9;
++                      space = ext2fs_inode_i_blocks(fs,
++                                                    EXT2_INODE(inode)) << 9;
+                       quota_data_add(qctx, inode, ino, space);
+                       quota_data_inodes(qctx, inode, ino, +1);
+               }
+diff --git a/lib/support/quotaio.h b/lib/support/quotaio.h
+index 5f1073f..8f7ddcb 100644
+--- a/lib/support/quotaio.h
++++ b/lib/support/quotaio.h
+@@ -217,12 +217,12 @@ const char *quota_get_qf_name(enum quota_type, int fmt, char *buf);
+ /* In mkquota.c */
+ errcode_t quota_init_context(quota_ctx_t *qctx, ext2_filsys fs,
+                            unsigned int qtype_bits);
+-void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
+-              int adjust);
+-void quota_data_add(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
+-              qsize_t space);
+-void quota_data_sub(quota_ctx_t qctx, struct ext2_inode *inode, ext2_ino_t ino,
+-              qsize_t space);
++void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode_large *inode,
++                     ext2_ino_t ino, int adjust);
++void quota_data_add(quota_ctx_t qctx, struct ext2_inode_large *inode,
++                  ext2_ino_t ino, qsize_t space);
++void quota_data_sub(quota_ctx_t qctx, struct ext2_inode_large *inode,
++                  ext2_ino_t ino, qsize_t space);
+ errcode_t quota_write_inode(quota_ctx_t qctx, enum quota_type qtype);
+ errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino,
+                             enum quota_type type);
+-- 
+2.5.0
+
diff --git a/debian/patches/e2fsck-use-com_err-error-codes-instead-of-EBADMSG-et-al b/debian/patches/e2fsck-use-com_err-error-codes-instead-of-EBADMSG-et-al
new file mode 100644 (file)
index 0000000..69148b8
--- /dev/null
@@ -0,0 +1,45 @@
+Description: use com_err error codes instead of EBADMSG and EUCLEAN
+ Some operating systems may not define EBADMSG and EUCLEAN, so for
+ better portability use our own private error code numbers.
+
+Author: Theodore Ts'o <tytso@mit.edu>
+---
+ e2fsck/jfs_user.h         | 4 ++--
+ lib/ext2fs/ext2_err.et.in | 6 ++++++
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h
+index f46bb1e..16185a5 100644
+--- a/e2fsck/jfs_user.h
++++ b/e2fsck/jfs_user.h
+@@ -182,10 +182,10 @@ extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
+ #endif /* DEBUGFS */
+ #ifndef EFSBADCRC
+-#define EFSBADCRC     EBADMSG         /* Bad CRC detected */
++#define EFSBADCRC     EXT2_ET_BAD_CRC
+ #endif
+ #ifndef EFSCORRUPTED
+-#define EFSCORRUPTED  EUCLEAN         /* Filesystem is corrupted */
++#define EFSCORRUPTED  EXT2_ET_FILESYSTEM_CORRUPTED
+ #endif
+ /* recovery.c */
+diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in
+index 894789e..464c01f 100644
+--- a/lib/ext2fs/ext2_err.et.in
++++ b/lib/ext2fs/ext2_err.et.in
+@@ -530,4 +530,10 @@ ec        EXT2_ET_UNDO_FILE_CORRUPT,
+ ec    EXT2_ET_UNDO_FILE_WRONG,
+       "Wrong undo file for this filesystem"
++ec    EXT2_ET_FILESYSTEM_CORRUPTED,
++      "File system is corrupted"
++
++ec    EXT2_ET_BAD_CRC,
++      "Bad CRC detected in file system"
++
+       end
+-- 
+2.5.0
+
diff --git a/debian/patches/mke2fs-fix-project-quota-creation b/debian/patches/mke2fs-fix-project-quota-creation
new file mode 100644 (file)
index 0000000..a3de389
--- /dev/null
@@ -0,0 +1,74 @@
+Description: fix project quota creation
+ Creating a file system with project quotas can fail if mke2fs is built
+ using hardening options.  This is because quota_compute_usage() used
+ ext2fs_get_next_inode() instead of ext2fs_get_inode_full(), and a
+ small inode was passed into quota_data_add, when a large inode needs
+ to be used.  As a result get_dq() would end up dereferencing undefined
+ space in the stack.  Without the hardening options, this would be
+ zero, so "mke2fs -t ext4 -O project.quota -I 256 test.img" would work
+ essentially by accident.
+ .
+ Fix this by using ext2fs_get_inode_full() so that a large inode is
+ available to quota_data_inodes().
+
+Author: Theodore Ts'o <tytso@mit.edu>
+---
+ lib/support/mkquota.c | 21 +++++++++++++--------
+ 1 file changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c
+index c5dd140..a432d4e 100644
+--- a/lib/support/mkquota.c
++++ b/lib/support/mkquota.c
+@@ -448,7 +448,8 @@ errcode_t quota_compute_usage(quota_ctx_t qctx)
+       ext2_filsys fs;
+       ext2_ino_t ino;
+       errcode_t ret;
+-      struct ext2_inode inode;
++      struct ext2_inode *inode;
++      int inode_size;
+       qsize_t space;
+       ext2_inode_scan scan;
+@@ -461,27 +462,31 @@ errcode_t quota_compute_usage(quota_ctx_t qctx)
+               log_err("while opening inode scan. ret=%ld", ret);
+               return ret;
+       }
+-
++      inode_size = fs->super->s_inode_size;
++      inode = malloc(inode_size);
++      if (!inode)
++              return ENOMEM;
+       while (1) {
+-              ret = ext2fs_get_next_inode(scan, &ino, &inode);
++              ret = ext2fs_get_next_inode_full(scan, &ino, inode, inode_size);
+               if (ret) {
+                       log_err("while getting next inode. ret=%ld", ret);
+                       ext2fs_close_inode_scan(scan);
++                      free(inode);
+                       return ret;
+               }
+               if (ino == 0)
+                       break;
+-              if (inode.i_links_count &&
++              if (inode->i_links_count &&
+                   (ino == EXT2_ROOT_INO ||
+                    ino >= EXT2_FIRST_INODE(fs->super))) {
+-                      space = ext2fs_inode_i_blocks(fs, &inode) << 9;
+-                      quota_data_add(qctx, &inode, ino, space);
+-                      quota_data_inodes(qctx, &inode, ino, +1);
++                      space = ext2fs_inode_i_blocks(fs, inode) << 9;
++                      quota_data_add(qctx, inode, ino, space);
++                      quota_data_inodes(qctx, inode, ino, +1);
+               }
+       }
+       ext2fs_close_inode_scan(scan);
+-
++      free(inode);
+       return 0;
+ }
+-- 
+2.5.0
+
index 7725d99..7941371 100644 (file)
@@ -1 +1,7 @@
 enable-metadata_csum-by-default
+tests-fix-filter.sed-to-filter-out-version-numbers-out
+clean-up-spelling-errors-and-other-nits-in-man-pages
+e2fsck-use-com_err-error-codes-instead-of-EBADMSG-et-al
+mke2fs-fix-project-quota-creation
+e2fsck-fix-project-quota-support
+add-enable-hardening-which-builds-e2fsprogs-with-security-options
diff --git a/debian/patches/tests-fix-filter.sed-to-filter-out-version-numbers-out b/debian/patches/tests-fix-filter.sed-to-filter-out-version-numbers-out
new file mode 100644 (file)
index 0000000..168397a
--- /dev/null
@@ -0,0 +1,34 @@
+Description: fix filter.sed to address regression test failures
+ The regular expression worked for version numbers such as 1.42.12, but
+ not if there isn't a third component in the version number.
+
+Author: Theodore Ts'o <tytso@mit.edu>
+---
+ tests/filter.sed | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/tests/filter.sed b/tests/filter.sed
+index bec899c..628309d 100644
+--- a/tests/filter.sed
++++ b/tests/filter.sed
+@@ -1,10 +1,10 @@
+-/^debugfs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+-/^dumpe2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+-/^e2fsck [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+-/^mke2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+-/^resize2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+-/^tune2fs [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+-/^e2image [1-9]\.[0-9]*[.-][^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^debugfs [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^dumpe2fs [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^e2fsck [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^mke2fs [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^resize2fs [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^tune2fs [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
++/^e2image [1-9]\.[0-9]*[^ ]* ([0-9]*-[A-Za-z]*-[0-9]*)/d
+ s/\\015//g
+ /automatically checked/d
+ /^Directory Hash Seed:/d
+-- 
+2.5.0
+