aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-07-16 14:23:09 -0700
committerDavid Anderson <dvander@google.com>2018-07-16 14:40:24 -0700
commit177b0f6def44f9fa17e097414fde7c3af221a502 (patch)
treecb6093d1d67c65bc0797e180a4a126d10198bcd6 /misc
parent702c28b202bcd98289b7d051958e3fb329863da9 (diff)
parent85e53f42f98d5334914de01e972e9ed44bccd0a5 (diff)
downloadandroid_external_e2fsprogs-177b0f6def44f9fa17e097414fde7c3af221a502.tar.gz
android_external_e2fsprogs-177b0f6def44f9fa17e097414fde7c3af221a502.tar.bz2
android_external_e2fsprogs-177b0f6def44f9fa17e097414fde7c3af221a502.zip
Merge e2fsprogs-1.44.3 from upstream into aosp/master.
Merge remote-tracking branch 'aosp/upstream-mirror-e2fsprogs' into e2fsprogs-merge Change-Id: I7283132aa6647b5f299826608a47e86c24817a5b
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile.in181
-rw-r--r--misc/badblocks.8.in46
-rw-r--r--misc/badblocks.c13
-rw-r--r--misc/base_device.c3
-rw-r--r--misc/chattr.1.in58
-rw-r--r--misc/create_inode.c33
-rw-r--r--misc/create_inode.h6
-rw-r--r--misc/dumpe2fs.8.in40
-rw-r--r--misc/dumpe2fs.c290
-rw-r--r--misc/e2freefrag.c134
-rw-r--r--misc/e2image.8.in2
-rw-r--r--misc/e2image.c53
-rw-r--r--misc/e2label.8.in38
-rw-r--r--misc/e2mmpstatus.8.in59
-rw-r--r--misc/e2undo.8.in18
-rw-r--r--misc/e2undo.c6
-rw-r--r--misc/e4crypt.8.in39
-rw-r--r--misc/e4crypt.c55
-rw-r--r--misc/e4defrag.8.in2
-rw-r--r--misc/e4defrag.c19
-rw-r--r--misc/ext4.5.in161
-rw-r--r--misc/filefrag.8.in4
-rw-r--r--misc/filefrag.c18
-rw-r--r--misc/findfs.8.in10
-rw-r--r--misc/findsuper.c4
-rw-r--r--misc/fsck.8.in158
-rw-r--r--misc/fsck.c19
-rw-r--r--misc/fsck.h2
-rw-r--r--misc/fsmap.h89
-rw-r--r--misc/fuse2fs.c63
-rw-r--r--misc/logsave.8.in18
-rw-r--r--misc/logsave.c2
-rw-r--r--misc/lsattr.1.in4
-rw-r--r--misc/mk_hugefiles.c107
-rw-r--r--misc/mke2fs.8.in59
-rw-r--r--misc/mke2fs.c123
-rw-r--r--misc/mke2fs.conf.5.in102
-rw-r--r--misc/mke2fs.conf.in7
-rw-r--r--misc/mklost+found.8.in2
-rw-r--r--misc/mklost+found.c4
-rw-r--r--misc/partinfo.c2
-rw-r--r--misc/tune2fs.8.in172
-rw-r--r--misc/tune2fs.c480
-rw-r--r--misc/tune2fs.h4
-rw-r--r--misc/util.c4
-rw-r--r--misc/uuidgen.1.in24
46 files changed, 1763 insertions, 974 deletions
diff --git a/misc/Makefile.in b/misc/Makefile.in
index d6436c2a..99028413 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -39,7 +39,8 @@ USPROGS= mklost+found filefrag e2freefrag $(UUIDD_PROG) \
SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \
e2label.8 $(FINDFS_MAN) $(BLKID_MAN) $(E2IMAGE_MAN) \
logsave.8 filefrag.8 e2freefrag.8 e2undo.8 \
- $(UUIDD_MAN) $(E4DEFRAG_MAN) $(E4CRYPT_MAN) @FSCK_MAN@
+ $(UUIDD_MAN) $(E4DEFRAG_MAN) $(E4CRYPT_MAN) @FSCK_MAN@ \
+ e2mmpstatus.8
FMANPAGES= mke2fs.conf.5 ext4.5
UPROGS= chattr lsattr @UUID_CMT@ uuidgen
@@ -69,12 +70,13 @@ E2FREEFRAG_OBJS= e2freefrag.o
E2FUZZ_OBJS= e2fuzz.o
FUSE2FS_OBJS= fuse2fs.o journal.o recovery.o revoke.o
-PROFILED_TUNE2FS_OBJS= profiled/tune2fs.o profiled/util.o
+PROFILED_TUNE2FS_OBJS= profiled/tune2fs.o profiled/util.o profiled/journal.o \
+ profiled/recovery.o profiled/revoke.o
PROFILED_MKLPF_OBJS= profiled/mklost+found.o
-PROFILED_MKE2FS_OBJS= profiled/mke2fs.o profiled/util.o profiled/profile.o \
- profiled/prof_err.o profiled/default_profile.o \
- profiled/mk_hugefiles.o profiled/create_inode.o
-
+PROFILED_MKE2FS_OBJS= profiled/mke2fs.o profiled/util.o \
+ profiled/default_profile.o \
+ profiled/mk_hugefiles.o \
+ profiled/create_inode.o
PROFILED_CHATTR_OBJS= profiled/chattr.o
PROFILED_LSATTR_OBJS= profiled/lsattr.o
PROFILED_UUIDGEN_OBJS= profiled/uuidgen.o
@@ -106,8 +108,8 @@ SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c $(srcdir)/
LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBSUPPORT)
DEPLIBS= $(LIBEXT2FS) $(DEPLIBCOM_ERR) $(DEPLIBSUPPORT)
-PROFILED_LIBS= $(PROFILED_LIBEXT2FS) $(PROFILED_LIBCOM_ERR) $(LIBSUPPORT)
-PROFILED_DEPLIBS= $(PROFILED_LIBEXT2FS) $(DEPPROFILED_LIBCOM_ERR) $(DEPLIBSUPPORT)
+PROFILED_LIBS= $(LIBSUPPORT) $(PROFILED_LIBEXT2FS) $(PROFILED_LIBCOM_ERR)
+PROFILED_DEPLIBS= $(DEPLIBSUPPORT) $(PROFILED_LIBEXT2FS) $(DEPPROFILED_LIBCOM_ERR)
STATIC_LIBS= $(LIBSUPPORT) $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
STATIC_DEPLIBS= $(DEPLIBSUPPORT) $(STATIC_LIBEXT2FS) $(DEPSTATIC_LIBCOM_ERR)
@@ -117,7 +119,7 @@ DEPLIBS_E2P= $(LIBE2P) $(DEPLIBCOM_ERR)
COMPILE_ET= _ET_DIR_OVERRIDE=$(srcdir)/../lib/et/et ../lib/et/compile_et
-# This nastyness is needed because of jfs_user.h hackery; when we finally
+# This nastiness is needed because of jfs_user.h hackery; when we finally
# clean up this mess, we should be able to drop it
JOURNAL_CFLAGS = -I$(srcdir)/../e2fsck $(ALL_CFLAGS) -DDEBUGFS
DEPEND_CFLAGS = -I$(top_srcdir)/e2fsck
@@ -157,9 +159,9 @@ findsuper: findsuper.o
$(E) " LD $@"
$(Q) $(CC) $(ALL_LDFLAGS) -o findsuper findsuper.o $(LIBS) $(SYSLIBS)
-partinfo: partinfo.o
+partinfo: partinfo.o $(DEPLIBCOM_ERR)
$(E) " LD $@"
- $(Q) $(CC) $(ALL_LDFLAGS) -o partinfo partinfo.o
+ $(Q) $(CC) $(ALL_LDFLAGS) -o partinfo partinfo.o $(LIBCOM_ERR)
e2initrd_helper: e2initrd_helper.o $(DEPLIBS) $(DEPLIBBLKID) $(LIBEXT2FS)
$(E) " LD $@"
@@ -184,10 +186,9 @@ tune2fs.profiled: $(TUNE2FS_OBJS) $(PROFILED_DEPLIBS) \
$(PROFILED_E2P) $(DEPPROFILED_LIBBLKID) $(DEPPROFILED_LIBUUID)
$(E) " LD $@"
$(Q) $(CC) $(ALL_LDFLAGS) -g -pg -o tune2fs.profiled \
- $(PROFILED_TUNE2FS_OBJS) $(PROFILED_LIBBLKID) \
- $(PROFILED_LIBUUID) $(PROFILED_LIBE2P) \
- $(LIBINTL) $(PROFILED_LIBS) $(SYSLIBS) $(PROFILED_LIBBLKID) \
- $(LIBMAGIC)
+ $(PROFILED_TUNE2FS_OBJS) $(PROFILED_LIBS) \
+ $(PROFILED_LIBBLKID) $(PROFILED_LIBUUID) $(PROFILED_LIBE2P) \
+ $(LIBINTL) $(SYSLIBS) $(PROFILED_LIBUUID) $(LIBMAGIC)
blkid: $(BLKID_OBJS) $(DEPLIBBLKID) $(LIBEXT2FS)
$(E) " LD $@"
@@ -216,6 +217,12 @@ e2image.profiled: $(E2IMAGE_OBJS) $(PROFILED_DEPLIBS) $(DEPLIBBLKID)
$(PROFILED_E2IMAGE_OBJS) $(PROFILED_LIBS) $(LIBINTL) $(SYSLIBS) \
$(LIBBLKID) $(LIBMAGIC)
+e2image.static: $(E2IMAGE_OBJS) $(PROFILED_DEPLIBS) $(DEPLIBBLKID)
+ $(E) " LD $@"
+ $(Q) $(CC) $(LDFLAGS_STATIC) -g -pg -o e2image.static \
+ $(E2IMAGE_OBJS) $(STATIC_LIBS) $(LIBINTL) $(SYSLIBS) \
+ $(STATIC_LIBBLKID) $(LIBMAGIC)
+
e2undo: $(E2UNDO_OBJS) $(DEPLIBS)
$(E) " LD $@"
$(Q) $(CC) $(ALL_LDFLAGS) -o e2undo $(E2UNDO_OBJS) $(LIBS) \
@@ -252,7 +259,7 @@ base_device: base_device.c
$(Q) $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(srcdir)/base_device.c \
-DDEBUG -o base_device $(SYSLIBS)
-check:: base_device
+fullcheck check:: base_device
./base_device < $(srcdir)/base_device.tst > base_device.out
cmp $(srcdir)/base_device.tst base_device.out
@@ -329,6 +336,12 @@ dumpe2fs.profiled: $(DUMPE2FS_OBJS) $(PROFILED_DEPLIBS) \
$(PROFILED_LIBE2P) $(PROFILED_LIBUUID) $(LIBINTL) $(SYSLIBS) \
$(PROFILED_LIBBLKID) $(LIBMAGIC)
+dumpe2fs.static: $(DUMPE2FS_OBJS) $(DEPLIBS) $(DEPLIBS_E2P) $(DEPLIBUUID) $(DEPLIBBLKID)
+ $(E) " LD $@"
+ $(Q) $(CC) $(LDFLAGS_STATIC) -o dumpe2fs.static $(DUMPE2FS_OBJS) \
+ $(STATIC_LIBS) $(STATIC_LIBE2P) $(STATIC_LIBUUID) \
+ $(LIBINTL) $(SYSLIBS) $(STATIC_LIBBLKID) $(LIBMAGIC)
+
fsck: $(FSCK_OBJS) $(DEPLIBBLKID)
$(E) " LD $@"
$(Q) $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) \
@@ -392,24 +405,28 @@ fuse2fs: $(FUSE2FS_OBJS) $(DEPLIBS) $(DEPLIBBLKID) $(DEPLIBUUID) \
$(CLOCK_GETTIME_LIB) $(SYSLIBS)
journal.o: $(srcdir)/../debugfs/journal.c
- $(E) " CC $@"
+ $(E) " CC $<"
$(Q) $(CC) -c $(JOURNAL_CFLAGS) -I$(srcdir) \
$(srcdir)/../debugfs/journal.c -o $@
+@PROFILE_CMT@ $(Q) $(CC) $(JOURNAL_CFLAGS) -g -pg -o profiled/$*.o -c $<
recovery.o: $(srcdir)/../e2fsck/recovery.c
- $(E) " CC $@"
+ $(E) " CC $<"
$(Q) $(CC) -c $(JOURNAL_CFLAGS) -I$(srcdir) \
$(srcdir)/../e2fsck/recovery.c -o $@
+@PROFILE_CMT@ $(Q) $(CC) $(JOURNAL_CFLAGS) -g -pg -o profiled/$*.o -c $<
revoke.o: $(srcdir)/../e2fsck/revoke.c
- $(E) " CC $@"
+ $(E) " CC $<"
$(Q) $(CC) -c $(JOURNAL_CFLAGS) -I$(srcdir) \
$(srcdir)/../e2fsck/revoke.c -o $@
+@PROFILE_CMT@ $(Q) $(CC) $(JOURNAL_CFLAGS) -g -pg -o profiled/$*.o -c $<
tst_ismounted: $(srcdir)/ismounted.c $(STATIC_LIBEXT2FS) $(DEPLIBCOM_ERR)
$(E) " LD $@"
$(CC) -o tst_ismounted $(srcdir)/ismounted.c -DDEBUG $(ALL_CFLAGS) \
$(LIBCOM_ERR) $(SYSLIBS)
+@PROFILE_CMT@ $(Q) $(CC) $(ALL_CFLAGS) -g -pg -o profiled/$*.o -c $<
tune2fs.8: $(DEP_SUBSTITUTE) $(srcdir)/tune2fs.8.in
$(E) " SUBST $@"
@@ -459,6 +476,10 @@ dumpe2fs.8: $(DEP_SUBSTITUTE) $(srcdir)/dumpe2fs.8.in
$(E) " SUBST $@"
$(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/dumpe2fs.8.in dumpe2fs.8
+e2mmpstatus.8: $(DEP_SUBSTITUTE) $(srcdir)/e2mmpstatus.8.in
+ $(E) " SUBST $@"
+ $(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/e2mmpstatus.8.in e2mmpstatus.8
+
badblocks.8: $(DEP_SUBSTITUTE) $(srcdir)/badblocks.8.in
$(E) " SUBST $@"
$(Q) $(SUBSTITUTE_UPTIME) $(srcdir)/badblocks.8.in badblocks.8
@@ -524,12 +545,14 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
$(ES) " INSTALL $(sbindir)/$$i"; \
$(INSTALL_PROGRAM) $$i $(DESTDIR)$(sbindir)/$$i; \
done
- $(Q) for i in ext2 ext3 ext4 ext4dev; do \
+ $(Q) for i in ext2 ext3 ext4; do \
$(ES) " LINK $(root_sbindir)/mkfs.$$i"; \
(cd $(DESTDIR)$(root_sbindir); \
$(LN) $(LINK_INSTALL_FLAGS) mke2fs mkfs.$$i); \
done
$(Q) (cd $(DESTDIR)$(root_sbindir); \
+ $(LN) $(LINK_INSTALL_FLAGS) dumpe2fs e2mmpstatus)
+ $(Q) (cd $(DESTDIR)$(root_sbindir); \
$(LN) $(LINK_INSTALL_FLAGS) tune2fs e2label)
$(Q) if test -n "$(FINDFS_LINK)"; then \
$(ES) " LINK $(root_sbindir)/findfs"; \
@@ -553,7 +576,7 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
done
$(Q) $(RM) -f $(DESTDIR)$(man8dir)/mkfs.ext2.8.gz \
$(DESTDIR)$(man8dir)/mkfs.ext3.8.gz
- $(Q) for i in ext2 ext3 ext4 ext4dev; do \
+ $(Q) for i in ext2 ext3 ext4; do \
$(ES) " LINK mkfs.$$i.8"; \
(cd $(DESTDIR)$(man8dir); \
$(LN) $(LINK_INSTALL_FLAGS) mke2fs.8 mkfs.$$i.8); \
@@ -628,8 +651,7 @@ uninstall:
done
$(RM) -f $(DESTDIR)$(root_sbindir)/mkfs.ext2 \
$(DESTDIR)$(root_sbindir)/mkfs.ext3 \
- $(DESTDIR)$(root_sbindir)/mkfs.ext4 \
- $(DESTDIR)$(root_sbindir)/mkfs.ext4dev
+ $(DESTDIR)$(root_sbindir)/mkfs.ext4
for i in $(UPROGS); do \
$(RM) -f $(DESTDIR)$(bindir)/$$i; \
done
@@ -639,16 +661,14 @@ uninstall:
$(RM) -f $(DESTDIR)$(man8dir)/mkfs.ext2.8 \
$(DESTDIR)$(man8dir)/mkfs.ext3.8 \
$(DESTDIR)$(man8dir)/mkfs.ext4.8 \
- $(DESTDIR)$(man8dir)/mkfs.ext4dev.8 \
$(DESTDIR)$(man8dir)/fsck.ext2.8 \
$(DESTDIR)$(man8dir)/fsck.ext3.8 \
- $(DESTDIR)$(man8dir)/fsck.ext4.8 \
- $(DESTDIR)$(man8dir)/fsck.ext4dev.8
+ $(DESTDIR)$(man8dir)/fsck.ext4.8
for i in $(UMANPAGES); do \
$(RM) -f $(DESTDIR)$(man1dir)/$$i; \
done
- for i in $(FINDFS_LINK) e2label ; do \
+ for i in $(FINDFS_LINK) e2label e2mmpstatus ; do \
$(RM) -f $(DESTDIR)$(root_sbindir)/$$i; \
done
for i in $(FMANPAGES); do \
@@ -670,6 +690,7 @@ clean::
uuidd e2image tune2fs.static tst_ismounted fsck.profiled \
blkid.profiled tune2fs.profiled e2image.profiled \
e2undo.profiled mke2fs.profiled dumpe2fs.profiled \
+ dumpe2fs.static e2image.static \
logsave.profiled filefrag.profiled uuidgen.profiled \
uuidd.profiled e2image.profiled e2fuzz mke2fs.conf \
profiled/*.o \#* *.s *.o *.a *~ core gmon.out
@@ -688,10 +709,11 @@ tune2fs.o: $(srcdir)/tune2fs.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/ext2fs/kernel-list.h $(top_srcdir)/lib/support/plausible.h \
- $(top_srcdir)/lib/support/quotaio.h $(top_srcdir)/lib/support/dqblk_v2.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
+ $(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h \
+ $(top_srcdir)/lib/support/plausible.h $(top_srcdir)/lib/support/quotaio.h \
+ $(top_srcdir)/lib/support/dqblk_v2.h \
$(top_srcdir)/lib/support/quotaio_tree.h $(top_srcdir)/lib/e2p/e2p.h \
$(srcdir)/util.h $(top_srcdir)/version.h \
$(top_srcdir)/lib/support/nls-enable.h
@@ -705,12 +727,12 @@ mke2fs.o: $(srcdir)/mke2fs.c $(top_builddir)/lib/config.h \
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/util.h $(top_srcdir)/lib/support/nls-enable.h \
- $(top_srcdir)/lib/support/plausible.h $(top_srcdir)/lib/support/profile.h \
- $(top_builddir)/lib/support/prof_err.h $(top_srcdir)/version.h \
- $(top_srcdir)/lib/support/quotaio.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/support/dqblk_v2.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/util.h \
+ $(top_srcdir)/lib/support/nls-enable.h $(top_srcdir)/lib/support/plausible.h \
+ $(top_srcdir)/lib/support/profile.h $(top_builddir)/lib/support/prof_err.h \
+ $(top_srcdir)/version.h $(top_srcdir)/lib/support/quotaio.h \
+ $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/support/dqblk_v2.h \
$(top_srcdir)/lib/support/quotaio_tree.h $(srcdir)/mke2fs.h \
$(srcdir)/create_inode.h $(top_srcdir)/lib/e2p/e2p.h
mk_hugefiles.o: $(srcdir)/mk_hugefiles.c $(top_builddir)/lib/config.h \
@@ -719,10 +741,10 @@ mk_hugefiles.o: $(srcdir)/mk_hugefiles.c $(top_builddir)/lib/config.h \
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(srcdir)/util.h $(top_srcdir)/lib/support/profile.h \
- $(top_builddir)/lib/support/prof_err.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/e2p/e2p.h \
+ $(top_srcdir)/lib/ext2fs/ext2fs.h $(srcdir)/util.h \
+ $(top_srcdir)/lib/support/profile.h $(top_builddir)/lib/support/prof_err.h \
$(top_srcdir)/lib/support/nls-enable.h $(srcdir)/mke2fs.h
chattr.o: $(srcdir)/chattr.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
@@ -739,19 +761,20 @@ dumpe2fs.o: $(srcdir)/dumpe2fs.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
- $(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/e2p/e2p.h \
+ $(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
+ $(top_srcdir)/lib/ext2fs/kernel-list.h \
$(top_srcdir)/lib/support/nls-enable.h $(top_srcdir)/lib/support/plausible.h \
$(top_srcdir)/version.h
badblocks.o: $(srcdir)/badblocks.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
+ $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_types.h \
+ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h \
$(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/support/nls-enable.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/support/nls-enable.h
fsck.o: $(srcdir)/fsck.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/version.h \
$(top_srcdir)/lib/support/nls-enable.h $(srcdir)/fsck.h
@@ -761,8 +784,9 @@ util.o: $(srcdir)/util.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/support/nls-enable.h $(srcdir)/util.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/support/nls-enable.h \
+ $(srcdir)/util.h
uuidgen.o: $(srcdir)/uuidgen.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/support/nls-enable.h
blkid.o: $(srcdir)/blkid.c $(top_builddir)/lib/config.h \
@@ -770,7 +794,8 @@ blkid.o: $(srcdir)/blkid.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h
logsave.o: $(srcdir)/logsave.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h
filefrag.o: $(srcdir)/filefrag.c $(top_builddir)/lib/config.h \
@@ -778,8 +803,8 @@ filefrag.o: $(srcdir)/filefrag.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/ext2fs/fiemap.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/fiemap.h
base_device.o: $(srcdir)/base_device.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(srcdir)/fsck.h
ismounted.o: $(srcdir)/ismounted.c $(top_builddir)/lib/config.h \
@@ -790,38 +815,42 @@ e2undo.o: $(srcdir)/e2undo.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/support/nls-enable.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/support/nls-enable.h
e2freefrag.o: $(srcdir)/e2freefrag.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/e2freefrag.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/e2freefrag.h $(srcdir)/fsmap.h
create_inode.o: $(srcdir)/create_inode.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/ext2fs/fiemap.h $(srcdir)/create_inode.h \
- $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/support/nls-enable.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/ext2fs/fiemap.h \
+ $(srcdir)/create_inode.h $(top_srcdir)/lib/e2p/e2p.h \
+ $(top_srcdir)/lib/support/nls-enable.h
fuse2fs.o: $(srcdir)/fuse2fs.c $(top_builddir)/lib/config.h \
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/version.h
journal.o: $(srcdir)/../debugfs/journal.c $(top_builddir)/lib/config.h \
- $(top_builddir)/lib/dirpaths.h $(top_srcdir)/e2fsck/jfs_user.h \
- $(top_srcdir)/e2fsck/e2fsck.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
- $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/support/profile.h $(top_builddir)/lib/support/prof_err.h \
- $(top_srcdir)/lib/support/quotaio.h $(top_srcdir)/lib/support/dqblk_v2.h \
+ $(top_builddir)/lib/dirpaths.h $(srcdir)/../debugfs/journal.h \
+ $(top_srcdir)/e2fsck/jfs_user.h $(top_srcdir)/e2fsck/e2fsck.h \
+ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
+ $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
+ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
+ $(top_builddir)/lib/ext2fs/ext2_err.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/support/profile.h \
+ $(top_builddir)/lib/support/prof_err.h $(top_srcdir)/lib/support/quotaio.h \
+ $(top_srcdir)/lib/support/dqblk_v2.h \
$(top_srcdir)/lib/support/quotaio_tree.h \
$(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
$(top_srcdir)/lib/ext2fs/kernel-list.h
@@ -830,9 +859,10 @@ revoke.o: $(srcdir)/../e2fsck/revoke.c $(srcdir)/../e2fsck/jfs_user.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/support/profile.h $(top_builddir)/lib/support/prof_err.h \
- $(top_srcdir)/lib/support/quotaio.h $(top_srcdir)/lib/support/dqblk_v2.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/support/profile.h \
+ $(top_builddir)/lib/support/prof_err.h $(top_srcdir)/lib/support/quotaio.h \
+ $(top_srcdir)/lib/support/dqblk_v2.h \
$(top_srcdir)/lib/support/quotaio_tree.h \
$(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
$(top_srcdir)/lib/ext2fs/kernel-list.h
@@ -841,9 +871,10 @@ recovery.o: $(srcdir)/../e2fsck/recovery.c $(srcdir)/../e2fsck/jfs_user.h \
$(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(top_srcdir)/lib/support/profile.h $(top_builddir)/lib/support/prof_err.h \
- $(top_srcdir)/lib/support/quotaio.h $(top_srcdir)/lib/support/dqblk_v2.h \
+ $(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/hashmap.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/support/profile.h \
+ $(top_builddir)/lib/support/prof_err.h $(top_srcdir)/lib/support/quotaio.h \
+ $(top_srcdir)/lib/support/dqblk_v2.h \
$(top_srcdir)/lib/support/quotaio_tree.h \
$(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
$(top_srcdir)/lib/ext2fs/kernel-list.h
diff --git a/misc/badblocks.8.in b/misc/badblocks.8.in
index c0b9ff16..ca435938 100644
--- a/misc/badblocks.8.in
+++ b/misc/badblocks.8.in
@@ -60,25 +60,25 @@ for the test, which allows the testing to start in the middle of the
disk. If it is not specified the first block on the disk is used as a default.
.PP
.B Important note:
-If the output of
+If the output of
.B badblocks
is going to be fed to the
.B e2fsck
-or
+or
.B mke2fs
programs, it is important that the block size is properly specified,
-since the block numbers which are generated are very dependent on the
-block size in use by the filesystem.
+since the block numbers which are generated are very dependent on the
+block size in use by the filesystem.
For this reason, it is strongly recommended that
-users
+users
.B not
-run
-.B badblocks
-directly, but rather use the
+run
+.B badblocks
+directly, but rather use the
.B \-c
option of the
.B e2fsck
-and
+and
.B mke2fs
programs.
.SH OPTIONS
@@ -93,7 +93,7 @@ is the number of blocks which are tested at a time. The default is 64.
This parameter, if passed and non-zero, will cause bad blocks to sleep
between reads if there were no errors encountered in the read
operation; the delay will be calculated as a percentage of the time it
-took for the read operation to be performed. In other words, a value of
+took for the read operation to be performed. In other words, a value of
100 will cause each read to be delayed by the amount the previous read
took, and a value of 200 by twice the amount.
.TP
@@ -109,9 +109,9 @@ potentially crash and/or damage the filesystem even if it is mounted
read-only. This can be overridden using the
.B \-f
flag, but should almost never be used --- if you think you're smarter
-than the
+than the
.B badblocks
-program, you almost certainly aren't. The only time when this option
+program, you almost certainly aren't. The only time when this option
might be safe to use is if the /etc/mtab file is incorrect, and the device
really isn't mounted.
.TP
@@ -132,8 +132,8 @@ can be used to retrieve the list of blocks currently marked bad on
an existing filesystem, in a format suitable for use with this option.
.TP
.B \-n
-Use non-destructive read-write mode. By default only a non-destructive
-read-only test is done. This option must not be combined with the
+Use non-destructive read-write mode. By default only a non-destructive
+read-only test is done. This option must not be combined with the
.B \-w
option, as they are mutually exclusive.
.TP
@@ -144,7 +144,7 @@ displays the list on its standard output. The format of this file is suitable
for use by the
.
.B \-l
-option in
+option in
.BR e2fsck (8)
or
.BR mke2fs (8).
@@ -168,7 +168,7 @@ option is requested by the user.
.BI \-t " test_pattern"
Specify a test pattern to be read (and written) to disk blocks. The
.I test_pattern
-may either be a numeric value between 0 and ULONG_MAX-1 inclusive, or the word
+may either be a numeric value between 0 and ULONG_MAX-1 inclusive, or the word
"random", which specifies that the block should be filled with a random
bit pattern.
For read/write (\fB-w\fR) and non-destructive (\fB-n\fR) modes,
@@ -178,9 +178,9 @@ option for each test pattern desired. For
read-only mode only a single pattern may be specified and it may not be
"random". Read-only testing with a pattern assumes that the
specified pattern has previously been written to the disk - if not, large
-numbers of blocks will fail verification.
+numbers of blocks will fail verification.
If multiple patterns
-are specified then all blocks will be tested with one pattern
+are specified then all blocks will be tested with one pattern
before proceeding to the next pattern.
.TP
.B \-v
@@ -191,9 +191,9 @@ corruptions to stderr.
Use write-mode test. With this option,
.B badblocks
scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on
-every block of the device, reading every block and comparing the contents.
-This option may not be combined with the
-.B \-n
+every block of the device, reading every block and comparing the contents.
+This option may not be combined with the
+.B \-n
option, as they are mutually exclusive.
.TP
.B \-B
@@ -212,7 +212,7 @@ option on a device containing an existing file system.
This option erases data! If you want to do write-mode testing on
an existing file system, use the
.B \-n
-option instead. It is slower, but it will preserve your data.
+option instead. It is slower, but it will preserve your data.
.PP
The
.B \-e
@@ -227,7 +227,7 @@ Theodore Ts'o <tytso@alum.mit.edu>. Non-destructive read/write test
implemented by David Beattie <dbeattie@softhome.net>.
.SH AVAILABILITY
.B badblocks
-is part of the e2fsprogs package and is available from
+is part of the e2fsprogs package and is available from
http://e2fsprogs.sourceforge.net.
.SH SEE ALSO
.BR e2fsck (8),
diff --git a/misc/badblocks.c b/misc/badblocks.c
index 0c4019a8..44252dc6 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -50,6 +50,9 @@ extern int optind;
#include <setjmp.h>
#include <time.h>
#include <limits.h>
+#ifdef HAVE_MBSTOWCS
+#include <wchar.h>
+#endif
#include <sys/time.h>
#include <sys/ioctl.h>
@@ -94,7 +97,7 @@ static unsigned int sys_page_size = 4096;
static void usage(void)
{
fprintf(stderr, _(
-"Usage: %s [-b block_size] [-i input_file] [-o output_file] [-svwnf]\n"
+"Usage: %s [-b block_size] [-i input_file] [-o output_file] [-svwnfBX]\n"
" [-c blocks_at_once] [-d delay_factor_between_reads] [-e max_bad_blocks]\n"
" [-p num_passes] [-t test_pattern [-t test_pattern [...]]]\n"
" device [last_block [first_block]]\n"),
@@ -216,6 +219,9 @@ static void print_status(void)
{
struct timeval time_end;
char diff_buf[32], line_buf[128];
+#ifdef HAVE_MBSTOWCS
+ wchar_t wline_buf[128];
+#endif
int len;
gettimeofday(&time_end, 0);
@@ -229,7 +235,10 @@ static void print_status(void)
num_write_errors,
num_corruption_errors);
#ifdef HAVE_MBSTOWCS
- len = mbstowcs(NULL, line_buf, sizeof(line_buf));
+ mbstowcs(wline_buf, line_buf, sizeof(line_buf));
+ len = wcswidth(wline_buf, sizeof(line_buf));
+ if (len < 0)
+ len = strlen(line_buf); /* Should never happen... */
#endif
fputs(line_buf, stderr);
memset(line_buf, '\b', len);
diff --git a/misc/base_device.c b/misc/base_device.c
index b2ce1380..d1c1cd94 100644
--- a/misc/base_device.c
+++ b/misc/base_device.c
@@ -150,7 +150,7 @@ errout:
#ifdef DEBUG
int main(int argc, char** argv)
{
- const char *base;
+ char *base;
char buf[256], *cp;
while (1) {
@@ -164,6 +164,7 @@ int main(int argc, char** argv)
*cp = 0;
base = base_device(buf);
printf("%s\t%s\n", buf, base ? base : "NONE");
+ free(base);
}
exit(0);
}
diff --git a/misc/chattr.1.in b/misc/chattr.1.in
index 44ee3370..028ae9e7 100644
--- a/misc/chattr.1.in
+++ b/misc/chattr.1.in
@@ -23,13 +23,13 @@ chattr \- change file attributes on a Linux file system
.B chattr
changes the file attributes on a Linux file system.
.PP
-The format of a symbolic mode is +-=[aAcCdDeijsStTu].
+The format of a symbolic mode is +-=[aAcCdDeijPsStTu].
.PP
The operator '+' causes the selected attributes to be added to the
existing attributes of the files; '-' causes them to be removed; and '='
causes them to be the only attributes that the files have.
.PP
-The letters 'aAcCdDeijsStTu' select the new attributes for the files:
+The letters 'aAcCdDeijPsStTu' select the new attributes for the files:
append only (a),
no atime updates (A),
compressed (c),
@@ -49,12 +49,9 @@ and undeletable (u).
The following attributes are read-only, and may be listed by
.BR lsattr (1)
but not modified by chattr:
-compression error (E),
-huge file (h),
+encrypted (E),
indexed directory (I),
-inline data (N),
-compression raw access (X),
-and compressed dirty file (Z).
+and inline data (N).
.PP
Not all flags are supported or utilized by all filesystems; refer to
filesystem-specific man pages such as
@@ -122,17 +119,11 @@ set or reset using
although it can be displayed by
.BR lsattr (1).
.PP
-The 'h' attribute indicates the file is storing its blocks in units of the
-filesystem blocksize instead of in units of sectors, and means that the file
-is (or at one time was) larger than 2TB. It may not be set or reset using
-.BR chattr (1),
-although it can be displayed by
-.BR lsattr (1).
-.PP
A file with the 'i' attribute cannot be modified: it cannot be deleted or
-renamed, no link can be created to this file and no data can be written
-to the file. Only the superuser or a process possessing the
-CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
+renamed, no link can be created to this file, most of the file's
+metadata can not be modified, and the file can not be opened in write mode.
+Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE
+capability can set or clear this attribute.
.PP
The 'I' attribute is used by the htree code to indicate that a directory
is being indexed using hashed trees. It may not be set or reset using
@@ -140,13 +131,13 @@ is being indexed using hashed trees. It may not be set or reset using
although it can be displayed by
.BR lsattr (1).
.PP
-A file with the 'j' attribute has all of its data written to the ext3
-or ext4 journal before being written to the file itself, if the filesystem
-is mounted with the "data=ordered" or "data=writeback" options. When the
-filesystem is mounted with the "data=journal" option all file data
-is already journalled and this attribute has no effect. Only
-the superuser or a process possessing the CAP_SYS_RESOURCE
-capability can set or clear this attribute.
+A file with the 'j' attribute has all of its data written to the ext3 or
+ext4 journal before being written to the file itself, if the file system
+is mounted with the "data=ordered" or "data=writeback" options and the
+file system has a journal. When the filesystem is mounted with the
+"data=journal" option all file data is already journalled and this
+attribute has no effect. Only the superuser or a process possessing the
+CAP_SYS_RESOURCE capability can set or clear this attribute.
.PP
A file with the 'N' attribute set indicates that the file has data
stored inline, within the inode itself. It may not be set or reset using
@@ -156,7 +147,7 @@ although it can be displayed by
.PP
A directory with the 'P' attribute set will enforce a hierarchical
structure for project id's. This means that files and directory created
-in the directory will inhert the project id of the directory, rename
+in the directory will inherit the project id of the directory, rename
operations are constrained so when a file or directory is moved into
another directory, that the project id's much match. In addition, a
hard link to file can only be created when the project id for the file
@@ -192,19 +183,6 @@ saved. This allows the user to ask for its undeletion. Note: please
make sure to read the bugs and limitations section at the end of this
document.
.PP
-The 'X' attribute is used by the experimental compression patches to
-indicate that the raw contents of a compressed file can be accessed
-directly. It currently may not be set or reset using
-.BR chattr (1),
-although it can be displayed by
-.BR lsattr (1).
-.PP
-The 'Z' attribute is used by the experimental compression patches to
-indicate a compressed file is dirty. It may not be set or reset using
-.BR chattr (1),
-although it can be displayed by
-.BR lsattr (1).
-.PP
.SH AUTHOR
.B chattr
was written by Remy Card <Remy.Card@linux.org>. It is currently being
@@ -213,8 +191,10 @@ maintained by Theodore Ts'o <tytso@alum.mit.edu>.
The 'c', 's', and 'u' attributes are not honored
by the ext2, ext3, and ext4 filesystems as implemented in the current
mainline Linux kernels.
+Setting 'a' and 'i' attributes will not affect the ability to write
+to already existing file descriptors.
.PP
-The 'j' option is only useful if the filesystem is mounted as ext3 or ext4.
+The 'j' option is only useful for ext3 and ext4 file systems.
.PP
The 'D' option is only useful on Linux kernel 2.5.19 and later.
.SH AVAILABILITY
diff --git a/misc/create_inode.c b/misc/create_inode.c
index 1373b46b..05aa6363 100644
--- a/misc/create_inode.c
+++ b/misc/create_inode.c
@@ -19,7 +19,9 @@
#include <sys/types.h>
#include <unistd.h>
#include <limits.h> /* for PATH_MAX */
-#ifdef HAVE_ATTR_XATTR_H
+#if defined HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#elif defined HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
@@ -36,7 +38,7 @@
#include "create_inode.h"
#include "support/nls-enable.h"
-/* 64KiB is the minimium blksize to best minimize system call overhead. */
+/* 64KiB is the minimum blksize to best minimize system call overhead. */
#define COPY_FILE_BUFLEN 65536
static int ext2_file_type(unsigned int mode)
@@ -140,6 +142,9 @@ static errcode_t set_inode_xattr(ext2_filsys fs, ext2_ino_t ino,
char *list = NULL;
int i;
+ if (no_copy_xattrs)
+ return 0;
+
size = llistxattr(filename, NULL, 0);
if (size == -1) {
retval = errno;
@@ -233,7 +238,7 @@ static errcode_t set_inode_xattr(ext2_filsys fs EXT2FS_ATTR((unused)),
#ifndef _WIN32
/* Make a special files (block and character devices), fifo's, and sockets */
errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd, const char *name,
- struct stat *st)
+ unsigned int st_mode, unsigned int st_rdev)
{
ext2_ino_t ino;
errcode_t retval;
@@ -241,7 +246,7 @@ errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd, const char *name,
unsigned long devmajor, devminor, mode;
int filetype;
- switch(st->st_mode & S_IFMT) {
+ switch(st_mode & S_IFMT) {
case S_IFCHR:
mode = LINUX_S_IFCHR;
filetype = EXT2_FT_CHRDEV;
@@ -297,8 +302,8 @@ errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd, const char *name,
fs->now ? fs->now : time(0);
if (filetype != S_IFIFO) {
- devmajor = major(st->st_rdev);
- devminor = minor(st->st_rdev);
+ devmajor = major(st_rdev);
+ devminor = minor(st_rdev);
if ((devmajor < 256) && (devminor < 256)) {
inode.i_block[0] = devmajor * 256 + devminor;
@@ -403,7 +408,7 @@ static ssize_t my_pread(int fd, void *buf, size_t count, off_t offset)
}
#endif /* !defined HAVE_PREAD64 && !defined HAVE_PREAD */
-static errcode_t copy_file_range(ext2_filsys fs, int fd, ext2_file_t e2_file,
+static errcode_t copy_file_chunk(ext2_filsys fs, int fd, ext2_file_t e2_file,
off_t start, off_t end, char *buf,
char *zerobuf)
{
@@ -477,7 +482,7 @@ static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf,
data_blk = data & ~(fs->blocksize - 1);
hole_blk = (hole + (fs->blocksize - 1)) & ~(fs->blocksize - 1);
- err = copy_file_range(fs, fd, e2_file, data_blk, hole_blk, buf,
+ err = copy_file_chunk(fs, fd, e2_file, data_blk, hole_blk, buf,
zerobuf);
if (err)
return err;
@@ -521,13 +526,14 @@ static errcode_t try_fiemap_copy(ext2_filsys fs, int fd, ext2_file_t e2_file,
if (err < 0 && (errno == EOPNOTSUPP || errno == ENOTTY)) {
err = EXT2_ET_UNIMPLEMENTED;
goto out;
- } else if (err < 0 || fiemap_buf->fm_mapped_extents == 0) {
+ } else if (err < 0) {
err = errno;
goto out;
- }
+ } else if (fiemap_buf->fm_mapped_extents == 0)
+ goto out;
for (i = 0, ext = ext_buf; i < fiemap_buf->fm_mapped_extents;
i++, ext++) {
- err = copy_file_range(fs, fd, e2_file, ext->fe_logical,
+ err = copy_file_chunk(fs, fd, e2_file, ext->fe_logical,
ext->fe_logical + ext->fe_length,
buf, zerobuf);
if (err)
@@ -580,7 +586,7 @@ static errcode_t copy_file(ext2_filsys fs, int fd, struct stat *statbuf,
goto out;
#endif
- err = copy_file_range(fs, fd, e2_file, 0, statbuf->st_size, buf,
+ err = copy_file_chunk(fs, fd, e2_file, 0, statbuf->st_size, buf,
zerobuf);
out:
ext2fs_free_mem(&zerobuf);
@@ -795,7 +801,8 @@ static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
case S_IFIFO:
#ifndef _WIN32
case S_IFSOCK:
- retval = do_mknod_internal(fs, parent_ino, name, &st);
+ retval = do_mknod_internal(fs, parent_ino, name,
+ st.st_mode, st.st_rdev);
if (retval) {
com_err(__func__, retval,
_("while creating special file "
diff --git a/misc/create_inode.h b/misc/create_inode.h
index 17309c68..b5eeb420 100644
--- a/misc/create_inode.h
+++ b/misc/create_inode.h
@@ -33,6 +33,9 @@ struct fs_ops_callbacks {
ext2_ino_t parent_ino, ext2_ino_t root, mode_t mode);
};
+extern int no_copy_xattrs; /* this should eventually be a flag
+ passed to populate_fs3() */
+
/* For populating the filesystem */
extern errcode_t populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
const char *source_dir, ext2_ino_t root);
@@ -40,7 +43,8 @@ extern errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino,
const char *source_dir, ext2_ino_t root,
struct fs_ops_callbacks *fs_callbacks);
extern errcode_t do_mknod_internal(ext2_filsys fs, ext2_ino_t cwd,
- const char *name, struct stat *st);
+ const char *name, unsigned int st_mode,
+ unsigned int st_rdev);
extern errcode_t do_symlink_internal(ext2_filsys fs, ext2_ino_t cwd,
const char *name, char *target,
ext2_ino_t root);
diff --git a/misc/dumpe2fs.8.in b/misc/dumpe2fs.8.in
index 8d9a559d..ce3214f3 100644
--- a/misc/dumpe2fs.8.in
+++ b/misc/dumpe2fs.8.in
@@ -35,18 +35,18 @@ print the blocks which are reserved as bad in the filesystem.
use the block
.I superblock
when examining the filesystem.
-This option is not usually needed except by a filesystem wizard who
+This option is not usually needed except by a filesystem wizard who
is examining the remains of a very badly corrupted filesystem.
.TP
.B \-o blocksize=\fIblocksize
use blocks of
.I blocksize
bytes when examining the filesystem.
-This option is not usually needed except by a filesystem wizard who
+This option is not usually needed except by a filesystem wizard who
is examining the remains of a very badly corrupted filesystem.
.TP
.B \-f
-force dumpe2fs to display a filesystem even though it may have some
+force dumpe2fs to display a filesystem even though it may have some
filesystem feature flags which dumpe2fs may not understand (and which
can cause some of dumpe2fs's display to be suspect).
.TP
@@ -57,38 +57,58 @@ first block in the group; the superblock location (or -1 if not present); the
range of blocks used by the group descriptors (or -1 if not present); the block
bitmap location; the inode bitmap location; and the range of blocks used by the
inode table.
-.TP
+.TP
.B \-h
only display the superblock information and not any of the block
group descriptor detail information.
.TP
.B \-i
-display the filesystem data from an image file created by
+display the filesystem data from an image file created by
.BR e2image ,
-using
+using
.I device
as the pathname to the image file.
.TP
+.B \-m
+If the
+.B mmp
+feature is enabled on the filesystem, check if
+.I device
+is in use by another node, see
+.BR e2mmpstatus (8)
+for full details. If used together with the
+.B \-i
+option, only the MMP block information is printed.
+.TP
.B \-x
print the detailed group information block numbers in hexadecimal format
.TP
.B \-V
-print the version number of
+print the version number of
.B dumpe2fs
and exit.
+.SH EXIT CODE
+.B dumpe2fs
+exits with a return code of 0 if the operation completed without errors.
+It will exit with a non-zero return code if there are any errors, such
+as problems reading a valid superblock, bad checksums, or if the device
+is in use by another node and
+.B -m
+is specified.
.SH BUGS
-You need to know the physical filesystem structure to understand the
+You may need to know the physical filesystem structure to understand the
output.
.SH AUTHOR
-.B dumpe2fs
+.B dumpe2fs
was written by Remy Card <Remy.Card@linux.org>. It is currently being
maintained by Theodore Ts'o <tytso@alum.mit.edu>.
.SH AVAILABILITY
.B dumpe2fs
-is part of the e2fsprogs package and is available from
+is part of the e2fsprogs package and is available from
http://e2fsprogs.sourceforge.net.
.SH SEE ALSO
.BR e2fsck (8),
+.BR e2mmpstatus (8),
.BR mke2fs (8),
.BR tune2fs (8).
.BR ext4 (5)
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index a034703b..384ce925 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -53,7 +53,7 @@ static int blocks64 = 0;
static void usage(void)
{
- fprintf(stderr, _("Usage: %s [-bfghixV] [-o superblock=<num>] "
+ fprintf(stderr, _("Usage: %s [-bfghimxV] [-o superblock=<num>] "
"[-o blocksize=<num>] device\n"), program_name);
exit(1);
}
@@ -356,16 +356,6 @@ static void list_bad_blocks(ext2_filsys fs, int dump)
ext2fs_badblocks_list_free(bb_list);
}
-static const char *journal_checksum_type_str(__u8 type)
-{
- switch (type) {
- case JBD2_CRC32C_CHKSUM:
- return "crc32c";
- default:
- return "unknown";
- }
-}
-
static void print_inline_journal_information(ext2_filsys fs)
{
journal_superblock_t *jsb;
@@ -374,8 +364,6 @@ static void print_inline_journal_information(ext2_filsys fs)
errcode_t retval;
ino_t ino = fs->super->s_journal_inum;
char buf[1024];
- __u32 *mask_ptr, mask, m;
- int i, j, size, printed = 0;
if (fs->flags & EXT2_FLAG_IMAGE_FILE)
return;
@@ -404,59 +392,14 @@ static void print_inline_journal_information(ext2_filsys fs)
_("Journal superblock magic number invalid!\n"));
exit(1);
}
- printf("%s", _("Journal features: "));
- for (i=0, mask_ptr=&jsb->s_feature_compat; i <3; i++,mask_ptr++) {
- mask = be32_to_cpu(*mask_ptr);
- for (j=0,m=1; j < 32; j++, m<<=1) {
- if (mask & m) {
- printf(" %s", e2p_jrnl_feature2string(i, m));
- printed++;
- }
- }
- }
- if (printed == 0)
- printf(" (none)");
- printf("\n");
- fputs(_("Journal size: "), stdout);
- if (ext2fs_has_feature_huge_file(fs->super) &&
- (inode.i_flags & EXT4_HUGE_FILE_FL))
- size = inode.i_blocks / (fs->blocksize / 1024);
- else
- size = inode.i_blocks >> 1;
- if (size < 8192)
- printf("%uk\n", size);
- else
- printf("%uM\n", size >> 10);
- printf(_("Journal length: %u\n"
- "Journal sequence: 0x%08x\n"
- "Journal start: %u\n"),
- (unsigned int)ntohl(jsb->s_maxlen),
- (unsigned int)ntohl(jsb->s_sequence),
- (unsigned int)ntohl(jsb->s_start));
- if (jsb->s_feature_compat &
- ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_CHECKSUM))
- printf("%s", _("Journal checksum type: crc32\n"));
- if ((jsb->s_feature_incompat &
- ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V3)) ||
- (jsb->s_feature_incompat &
- ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V2)))
- printf(_("Journal checksum type: %s\n"
- "Journal checksum: 0x%08x\n"),
- journal_checksum_type_str(jsb->s_checksum_type),
- ext2fs_be32_to_cpu(jsb->s_checksum));
- if (jsb->s_errno != 0)
- printf(_("Journal errno: %d\n"),
- (int) ntohl(jsb->s_errno));
+ e2p_list_journal_super(stdout, buf, fs->blocksize, 0);
}
static void print_journal_information(ext2_filsys fs)
{
errcode_t retval;
char buf[1024];
- char str[80];
- unsigned int i, j, printed = 0;
journal_superblock_t *jsb;
- __u32 *mask_ptr, mask, m;
/* Get the journal superblock */
if ((retval = io_channel_read_blk64(fs->io,
@@ -474,46 +417,80 @@ static void print_journal_information(ext2_filsys fs)
_("Couldn't find journal superblock magic numbers"));
exit(1);
}
+ e2p_list_journal_super(stdout, buf, fs->blocksize, 0);
+}
+
+static int check_mmp(ext2_filsys fs)
+{
+ int retval;
- if (jsb->s_feature_compat &
- ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_CHECKSUM))
- printf("%s", _("Journal checksum type: crc32\n"));
- if ((jsb->s_feature_incompat &
- ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V3)) ||
- (jsb->s_feature_incompat &
- ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_CSUM_V2)))
- printf(_("Journal checksum type: %s\n"
- "Journal checksum: 0x%08x\n"),
- journal_checksum_type_str(jsb->s_checksum_type),
- ext2fs_be32_to_cpu(jsb->s_checksum));
-
- printf("%s", _("Journal features: "));
- for (i = 0, mask_ptr = &jsb->s_feature_compat; i < 3; i++, mask_ptr++) {
- mask = be32_to_cpu(*mask_ptr);
- for (j = 0, m = 1; j < 32; j++, m <<= 1) {
- if (mask & m) {
- printf(" %s", e2p_jrnl_feature2string(i, m));
- printed++;
+ /* This won't actually start MMP on the filesystem, since fs is opened
+ * readonly, but it will do the proper activity checking for us. */
+ retval = ext2fs_mmp_start(fs);
+ if (retval) {
+ com_err(program_name, retval, _("while trying to open %s"),
+ fs->device_name);
+ if (retval == EXT2_ET_MMP_FAILED ||
+ retval == EXT2_ET_MMP_FSCK_ON ||
+ retval == EXT2_ET_MMP_CSUM_INVALID ||
+ retval == EXT2_ET_MMP_UNKNOWN_SEQ) {
+ if (fs->mmp_buf) {
+ struct mmp_struct *mmp = fs->mmp_buf;
+ time_t mmp_time = mmp->mmp_time;
+
+ fprintf(stderr,
+ "%s: MMP last updated by '%s' on %s",
+ program_name, mmp->mmp_nodename,
+ ctime(&mmp_time));
}
+ retval = 1;
+ } else {
+ retval = 2;
+ }
+ } else {
+ printf("%s: it is safe to mount '%s', MMP is clean\n",
+ program_name, fs->device_name);
+ }
+
+ return retval;
+}
+
+static void print_mmp_block(ext2_filsys fs)
+{
+ struct mmp_struct *mmp;
+ time_t mmp_time;
+ errcode_t retval;
+
+ if (fs->mmp_buf == NULL) {
+ retval = ext2fs_get_mem(fs->blocksize, &fs->mmp_buf);
+ if (retval) {
+ com_err(program_name, retval,
+ _("failed to alloc MMP buffer\n"));
+ return;
}
}
- printf(_("\nJournal block size: %u\n"
- "Journal length: %u\n"
- "Journal first block: %u\n"
- "Journal sequence: 0x%08x\n"
- "Journal start: %u\n"
- "Journal number of users: %u\n"),
- (unsigned int)ntohl(jsb->s_blocksize), (unsigned int)ntohl(jsb->s_maxlen),
- (unsigned int)ntohl(jsb->s_first), (unsigned int)ntohl(jsb->s_sequence),
- (unsigned int)ntohl(jsb->s_start), (unsigned int)ntohl(jsb->s_nr_users));
-
- for (i=0; i < ntohl(jsb->s_nr_users); i++) {
- uuid_unparse(&jsb->s_users[i*16], str);
- printf(i ? " %s\n"
- : _("Journal users: %s\n"),
- str);
+ retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
+ /* this is only dumping, not checking status, so OK to skip this */
+ if (retval == EXT2_ET_OP_NOT_SUPPORTED)
+ return;
+ if (retval) {
+ com_err(program_name, retval,
+ _("reading MMP block %llu from '%s'\n"),
+ fs->super->s_mmp_block, fs->device_name);
+ return;
}
+
+ mmp = fs->mmp_buf;
+ mmp_time = mmp->mmp_time;
+ printf("MMP_block:\n");
+ printf(" mmp_magic: 0x%x\n", mmp->mmp_magic);
+ printf(" mmp_check_interval: %d\n", mmp->mmp_check_interval);
+ printf(" mmp_sequence: %#08x\n", mmp->mmp_seq);
+ printf(" mmp_update_date: %s", ctime(&mmp_time));
+ printf(" mmp_update_time: %lld\n", mmp->mmp_time);
+ printf(" mmp_node_name: %s\n", mmp->mmp_nodename);
+ printf(" mmp_device_name: %s\n", mmp->mmp_bdevname);
}
static void parse_extended_opts(const char *opts, blk64_t *superblock,
@@ -596,11 +573,15 @@ static void parse_extended_opts(const char *opts, blk64_t *superblock,
int main (int argc, char ** argv)
{
errcode_t retval;
+ errcode_t retval_csum = 0;
+ const char *error_csum = NULL;
ext2_filsys fs;
int print_badblocks = 0;
blk64_t use_superblock = 0;
int use_blocksize = 0;
int image_dump = 0;
+ int mmp_check = 0;
+ int mmp_info = 0;
int force = 0;
int flags;
int header_only = 0;
@@ -615,12 +596,23 @@ int main (int argc, char ** argv)
set_com_err_gettext(gettext);
#endif
add_error_table(&et_ext2_error_table);
- fprintf (stderr, "dumpe2fs %s (%s)\n", E2FSPROGS_VERSION,
- E2FSPROGS_DATE);
- if (argc && *argv)
- program_name = *argv;
+ if (argc && *argv) {
+ if (strrchr(*argv, '/'))
+ program_name = strrchr(*argv, '/') + 1;
+ else
+ program_name = *argv;
- while ((c = getopt(argc, argv, "bfghixVo:")) != EOF) {
+ if (strstr(program_name, "mmpstatus") != NULL) {
+ mmp_check = 1;
+ header_only = 1;
+ }
+ }
+
+ if (!mmp_check)
+ fprintf(stderr, "dumpe2fs %s (%s)\n", E2FSPROGS_VERSION,
+ E2FSPROGS_DATE);
+
+ while ((c = getopt(argc, argv, "bfghimxVo:")) != EOF) {
switch (c) {
case 'b':
print_badblocks++;
@@ -635,7 +627,18 @@ int main (int argc, char ** argv)
header_only++;
break;
case 'i':
- image_dump++;
+ if (mmp_check)
+ mmp_info++;
+ else
+ image_dump++;
+ break;
+ case 'm':
+ mmp_check++;
+ header_only++;
+ if (image_dump) {
+ mmp_info = image_dump;
+ image_dump = 0;
+ }
break;
case 'o':
parse_extended_opts(optarg, &use_superblock,
@@ -653,12 +656,12 @@ int main (int argc, char ** argv)
usage();
}
}
- if (optind != argc - 1) {
+ if (optind != argc - 1)
usage();
- exit(1);
- }
+
device_name = argv[optind++];
- flags = EXT2_FLAG_JOURNAL_DEV_OK | EXT2_FLAG_SOFTSUPP_FEATURES | EXT2_FLAG_64BITS;
+ flags = EXT2_FLAG_JOURNAL_DEV_OK | EXT2_FLAG_SOFTSUPP_FEATURES |
+ EXT2_FLAG_64BITS;
if (force)
flags |= EXT2_FLAG_FORCE;
if (image_dump)
@@ -675,64 +678,87 @@ try_open_again:
if (!retval)
break;
}
- } else
- retval = ext2fs_open (device_name, flags, use_superblock,
- use_blocksize, unix_io_manager, &fs);
- if (retval && !(flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) {
- flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
- goto try_open_again;
+ } else {
+ retval = ext2fs_open(device_name, flags, use_superblock,
+ use_blocksize, unix_io_manager, &fs);
}
- if (!retval && (fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS))
- printf("%s", _("\n*** Checksum errors detected in filesystem! Run e2fsck now!\n\n"));
flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+ if (retval && !retval_csum) {
+ retval_csum = retval;
+ error_csum = _("while trying to open %s");
+ goto try_open_again;
+ }
if (retval) {
- com_err (program_name, retval, _("while trying to open %s"),
- device_name);
+ com_err(program_name, retval, _("while trying to open %s"),
+ device_name);
printf("%s", _("Couldn't find valid filesystem superblock.\n"));
if (retval == EXT2_ET_BAD_MAGIC)
check_plausibility(device_name, CHECK_FS_EXIST, NULL);
- exit (1);
+ goto out;
}
fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
if (ext2fs_has_feature_64bit(fs->super))
blocks64 = 1;
- if (print_badblocks) {
+ if (mmp_check) {
+ if (ext2fs_has_feature_mmp(fs->super) &&
+ fs->super->s_mmp_block != 0) {
+ if (mmp_info) {
+ print_mmp_block(fs);
+ printf(" mmp_block_number: ");
+ print_number(fs->super->s_mmp_block);
+ printf("\n");
+ } else {
+ retval = check_mmp(fs);
+ }
+ if (!retval && retval_csum)
+ retval = 2;
+ } else {
+ fprintf(stderr, _("%s: MMP feature not enabled.\n"),
+ program_name);
+ retval = 2;
+ }
+ } else if (print_badblocks) {
list_bad_blocks(fs, 1);
} else {
if (grp_only)
goto just_descriptors;
- list_super (fs->super);
+ list_super(fs->super);
if (ext2fs_has_feature_journal_dev(fs->super)) {
print_journal_information(fs);
- ext2fs_close_free(&fs);
- exit(0);
+
+ goto out_close;
}
if (ext2fs_has_feature_journal(fs->super) &&
(fs->super->s_journal_inum != 0))
print_inline_journal_information(fs);
+ if (ext2fs_has_feature_mmp(fs->super) &&
+ fs->super->s_mmp_block != 0)
+ print_mmp_block(fs);
list_bad_blocks(fs, 0);
- if (header_only) {
- ext2fs_close_free(&fs);
- exit (0);
- }
+ if (header_only)
+ goto out_close;
+
fs->flags &= ~EXT2_FLAG_IGNORE_CSUM_ERRORS;
try_bitmaps_again:
- retval = ext2fs_read_bitmaps (fs);
- if (retval && !(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS)) {
+ retval = ext2fs_read_bitmaps(fs);
+ if (retval && !retval_csum) {
fs->flags |= EXT2_FLAG_IGNORE_CSUM_ERRORS;
+ retval_csum = retval;
+ error_csum = _("while trying to read '%s' bitmaps\n");
goto try_bitmaps_again;
}
- if (!retval && (fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS))
- printf("%s", _("\n*** Checksum errors detected in bitmaps! Run e2fsck now!\n\n"));
just_descriptors:
list_desc(fs, grp_only);
- if (retval) {
- printf(_("\n%s: %s: error reading bitmaps: %s\n"),
- program_name, device_name,
- error_message(retval));
- }
+ }
+out_close:
+ if (retval_csum) {
+ com_err(program_name, retval_csum, error_csum, device_name);
+ printf("%s", _("*** Run e2fsck now!\n\n"));
+ if (!retval)
+ retval = retval_csum;
}
ext2fs_close_free(&fs);
remove_error_table(&et_ext2_error_table);
- exit (0);
+out:
+ return retval;
}
diff --git a/misc/e2freefrag.c b/misc/e2freefrag.c
index 90acb7e1..268fac96 100644
--- a/misc/e2freefrag.c
+++ b/misc/e2freefrag.c
@@ -25,11 +25,29 @@
extern char *optarg;
extern int optind;
#endif
+#if defined(HAVE_EXT2_IOCTLS) && !defined(DEBUGFS)
+# include <sys/ioctl.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <fcntl.h>
+# include <limits.h>
+#endif
#include "ext2fs/ext2_fs.h"
#include "ext2fs/ext2fs.h"
#include "e2freefrag.h"
+#if defined(HAVE_EXT2_IOCTLS) && !defined(DEBUGFS)
+# ifdef HAVE_LINUX_FSMAP_H
+# include <linux/fsmap.h>
+# endif
+# include "fsmap.h"
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
static void usage(const char *prog)
{
fprintf(stderr, "usage: %s [-c chunksize in kb] [-h] "
@@ -143,8 +161,97 @@ static void scan_block_bitmap(ext2_filsys fs, struct chunk_info *info)
update_chunk_stats(info, last_chunk_size);
}
-static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info,
- FILE *f)
+#if defined(HAVE_EXT2_IOCTLS) && !defined(DEBUGFS)
+# define FSMAP_EXTENTS 1024
+static int scan_online(ext2_filsys fs, struct chunk_info *info)
+{
+ struct fsmap_head *fsmap;
+ struct fsmap *extent;
+ struct fsmap *p;
+ char mntpoint[PATH_MAX + 1];
+ errcode_t retval;
+ int mount_flags;
+ int fd;
+ int ret;
+ unsigned int i;
+
+ /* Try to open the mountpoint for a live query. */
+ retval = ext2fs_check_mount_point(fs->device_name, &mount_flags,
+ mntpoint, PATH_MAX);
+ if (retval) {
+ com_err(fs->device_name, retval, "while checking mount status");
+ return 0;
+ }
+ if (!(mount_flags & EXT2_MF_MOUNTED))
+ return 0;
+ fd = open(mntpoint, O_RDONLY);
+ if (fd < 0) {
+ com_err(mntpoint, errno, "while opening mount point");
+ return 0;
+ }
+
+ fsmap = malloc(fsmap_sizeof(FSMAP_EXTENTS));
+ if (!fsmap) {
+ com_err(fs->device_name, errno, "while allocating memory");
+ return 0;
+ }
+
+ memset(fsmap, 0, sizeof(*fsmap));
+ fsmap->fmh_count = FSMAP_EXTENTS;
+ fsmap->fmh_keys[1].fmr_device = UINT_MAX;
+ fsmap->fmh_keys[1].fmr_physical = ULLONG_MAX;
+ fsmap->fmh_keys[1].fmr_owner = ULLONG_MAX;
+ fsmap->fmh_keys[1].fmr_offset = ULLONG_MAX;
+ fsmap->fmh_keys[1].fmr_flags = UINT_MAX;
+
+ /* Fill the extent histogram with live data */
+ while (1) {
+ ret = ioctl(fd, FS_IOC_GETFSMAP, fsmap);
+ if (ret < 0) {
+ com_err(fs->device_name, errno, "while calling fsmap");
+ free(fsmap);
+ return 0;
+ }
+
+ /* No more extents to map, exit */
+ if (!fsmap->fmh_entries)
+ break;
+
+ for (i = 0, extent = fsmap->fmh_recs;
+ i < fsmap->fmh_entries;
+ i++, extent++) {
+ if (!(extent->fmr_flags & FMR_OF_SPECIAL_OWNER) ||
+ extent->fmr_owner != FMR_OWN_FREE)
+ continue;
+ update_chunk_stats(info,
+ extent->fmr_length / fs->blocksize);
+ }
+
+ p = &fsmap->fmh_recs[fsmap->fmh_entries - 1];
+ if (p->fmr_flags & FMR_OF_LAST)
+ break;
+ fsmap_advance(fsmap);
+ }
+
+ return 1;
+}
+#else
+# define scan_online(fs, info) (0)
+#endif /* HAVE_EXT2_IOCTLS */
+
+static errcode_t scan_offline(ext2_filsys fs, struct chunk_info *info)
+{
+ errcode_t retval;
+
+ retval = ext2fs_read_block_bitmap(fs);
+ if (retval)
+ return retval;
+ scan_block_bitmap(fs, info);
+ return 0;
+}
+
+static errcode_t dump_chunk_info(ext2_filsys fs, struct chunk_info *info,
+ FILE *f)
{
unsigned long total_chunks;
const char *unitp = "KMGTPEZY";
@@ -152,11 +259,10 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info,
unsigned long start = 0, end;
int i, retval = 0;
- scan_block_bitmap(fs, info);
-
- fprintf(f, "Total blocks: %llu\nFree blocks: %u (%0.1f%%)\n",
- ext2fs_blocks_count(fs->super), fs->super->s_free_blocks_count,
- (double)fs->super->s_free_blocks_count * 100 /
+ fprintf(f, "Total blocks: %llu\nFree blocks: %llu (%0.1f%%)\n",
+ ext2fs_blocks_count(fs->super),
+ ext2fs_free_blocks_count(fs->super),
+ (double)ext2fs_free_blocks_count(fs->super) * 100 /
ext2fs_blocks_count(fs->super));
if (info->chunkbytes) {
@@ -200,7 +306,7 @@ static errcode_t get_chunk_info(ext2_filsys fs, struct chunk_info *info,
info->histogram.fc_chunks[i],
info->histogram.fc_blocks[i],
(double)info->histogram.fc_blocks[i] * 100 /
- fs->super->s_free_blocks_count);
+ ext2fs_free_blocks_count(fs->super));
}
start = end;
if (start == 1<<10) {
@@ -228,18 +334,20 @@ static void collect_info(ext2_filsys fs, struct chunk_info *chunk_info, FILE *f)
fprintf(f, "Device: %s\n", fs->device_name);
fprintf(f, "Blocksize: %u bytes\n", fs->blocksize);
- retval = ext2fs_read_block_bitmap(fs);
+ init_chunk_info(fs, chunk_info);
+ if (!scan_online(fs, chunk_info)) {
+ init_chunk_info(fs, chunk_info);
+ retval = scan_offline(fs, chunk_info);
+ }
if (retval) {
com_err(fs->device_name, retval, "while reading block bitmap");
close_device(fs->device_name, fs);
exit(1);
}
- init_chunk_info(fs, chunk_info);
-
- retval = get_chunk_info(fs, chunk_info, f);
+ retval = dump_chunk_info(fs, chunk_info, f);
if (retval) {
- com_err(fs->device_name, retval, "while collecting chunk info");
+ com_err(fs->device_name, retval, "while dumping chunk info");
close_device(fs->device_name, fs);
exit(1);
}
diff --git a/misc/e2image.8.in b/misc/e2image.8.in
index f28a76ea..a7bfdf24 100644
--- a/misc/e2image.8.in
+++ b/misc/e2image.8.in
@@ -11,7 +11,7 @@ e2image \- Save critical ext2/ext3/ext4 filesystem metadata to a file
.B \-r|Q
]
[
-.B \-fr
+.B \-f
]
.I device
.I image-file
diff --git a/misc/e2image.c b/misc/e2image.c
index e0c31883..d32b84a3 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -43,6 +43,7 @@ extern int optind;
#include "ext2fs/ext2_fs.h"
#include "ext2fs/ext2fs.h"
+#include "ext2fs/ext2fsP.h"
#include "et/com_err.h"
#include "uuid/uuid.h"
#include "e2p/e2p.h"
@@ -103,7 +104,7 @@ static int get_bits_from_size(size_t size)
static void usage(void)
{
- fprintf(stderr, _("Usage: %s [ -r|Q ] [ -fr ] device image-file\n"),
+ fprintf(stderr, _("Usage: %s [ -r|Q ] [ -f ] device image-file\n"),
program_name);
fprintf(stderr, _(" %s -I device image-file\n"), program_name);
fprintf(stderr, _(" %s -ra [ -cfnp ] [ -o src_offset ] "
@@ -239,7 +240,7 @@ static void write_image_file(ext2_filsys fs, int fd)
write_header(fd, NULL, sizeof(struct ext2_image_hdr), fs->blocksize);
memset(&hdr, 0, sizeof(struct ext2_image_hdr));
- hdr.offset_super = seek_relative(fd, 0);
+ hdr.offset_super = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_super_write(fs, fd, 0);
if (retval) {
com_err(program_name, retval, "%s",
@@ -247,7 +248,7 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.offset_inode = seek_relative(fd, 0);
+ hdr.offset_inode = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_inode_write(fs, fd,
(fd != 1) ? IMAGER_FLAG_SPARSEWRITE : 0);
if (retval) {
@@ -256,7 +257,7 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.offset_blockmap = seek_relative(fd, 0);
+ hdr.offset_blockmap = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_bitmap_write(fs, fd, 0);
if (retval) {
com_err(program_name, retval, "%s",
@@ -264,7 +265,7 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.offset_inodemap = seek_relative(fd, 0);
+ hdr.offset_inodemap = ext2fs_cpu_to_le32(seek_relative(fd, 0));
retval = ext2fs_image_bitmap_write(fs, fd, IMAGER_FLAG_INODEMAP);
if (retval) {
com_err(program_name, retval, "%s",
@@ -272,23 +273,23 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
- hdr.magic_number = EXT2_ET_MAGIC_E2IMAGE;
+ hdr.magic_number = ext2fs_cpu_to_le32(EXT2_ET_MAGIC_E2IMAGE);
strcpy(hdr.magic_descriptor, "Ext2 Image 1.0");
gethostname(hdr.fs_hostname, sizeof(hdr.fs_hostname));
strncpy(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name)-1);
hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0;
- hdr.fs_blocksize = fs->blocksize;
+ hdr.fs_blocksize = ext2fs_cpu_to_le32(fs->blocksize);
if (stat(device_name, &st) == 0)
- hdr.fs_device = st.st_rdev;
+ hdr.fs_device = ext2fs_cpu_to_le32(st.st_rdev);
if (fstat(fd, &st) == 0) {
- hdr.image_device = st.st_dev;
- hdr.image_inode = st.st_ino;
+ hdr.image_device = ext2fs_cpu_to_le32(st.st_dev);
+ hdr.image_inode = ext2fs_cpu_to_le32(st.st_ino);
}
memcpy(hdr.fs_uuid, fs->super->s_uuid, sizeof(hdr.fs_uuid));
- hdr.image_time = time(0);
+ hdr.image_time = ext2fs_cpu_to_le32(time(0));
write_header(fd, &hdr, sizeof(struct ext2_image_hdr), fs->blocksize);
}
@@ -551,7 +552,7 @@ static void sigint_handler(int unused EXT2FS_ATTR((unused)))
#define calc_percent(a, b) ((int) ((100.0 * (((float) (a)) / \
((float) (b)))) + 0.5))
-#define calc_rate(t, b, d) (((float)(t) / ((1024 * 1024) / (b))) / (d))
+#define calc_rate(t, b, d) (((float)(t) / ((float)(1024 * 1024) / (b))) / (d))
static int print_progress(blk64_t num, blk64_t total)
{
@@ -873,8 +874,8 @@ static int init_refcount(struct ext2_qcow2_image *img, blk64_t table_offset)
return ret;
}
-static int initialize_qcow2_image(int fd, ext2_filsys fs,
- struct ext2_qcow2_image *image)
+static errcode_t initialize_qcow2_image(int fd, ext2_filsys fs,
+ struct ext2_qcow2_image *image)
{
struct ext2_qcow2_hdr *header;
blk64_t total_size, offset;
@@ -882,6 +883,9 @@ static int initialize_qcow2_image(int fd, ext2_filsys fs,
int cluster_bits = get_bits_from_size(fs->blocksize);
struct ext2_super_block *sb = fs->super;
+ if (fs->blocksize < 1024)
+ return EINVAL; /* Can never happen, but just in case... */
+
/* Allocate header */
ret = ext2fs_get_memzero(sizeof(struct ext2_qcow2_hdr), &header);
if (ret)
@@ -1108,7 +1112,7 @@ static int update_refcount(int fd, struct ext2_qcow2_image *img,
/*
* We are relying on the fact that we are creating the qcow2
* image sequentially, hence we will always allocate refcount
- * block items sequentialy.
+ * block items sequentially.
*/
ref->refcount_block[ref->refcount_block_index] = ext2fs_cpu_to_be16(1);
ref->refcount_block_index++;
@@ -1422,7 +1426,7 @@ static void install_image(char *device, char *image_fn, int type)
ext2fs_rewrite_to_io(fs, io);
- seek_set(fd, fs->image_header->offset_inode);
+ seek_set(fd, ext2fs_le32_to_cpu(fs->image_header->offset_inode));
retval = ext2fs_image_inode_read(fs, fd, 0);
if (retval) {
@@ -1620,7 +1624,7 @@ skip_device:
_("Can not stat output\n"));
exit(1);
}
- if (S_ISBLK(st.st_mode))
+ if (ext2fsP_is_disk_device(st.st_mode))
output_is_blk = 1;
}
if (flags & E2IMAGE_IS_QCOW2_FLAG) {
@@ -1629,13 +1633,18 @@ skip_device:
if (ret == -QCOW_COMPRESSED)
fprintf(stderr, _("Image (%s) is compressed\n"),
image_fn);
- if (ret == -QCOW_ENCRYPTED)
+ else if (ret == -QCOW_ENCRYPTED)
fprintf(stderr, _("Image (%s) is encrypted\n"),
image_fn);
- com_err(program_name, ret,
- _("while trying to convert qcow2 image"
- " (%s) into raw image (%s)"),
- device_name, image_fn);
+ else if (ret == -QCOW_CORRUPTED)
+ fprintf(stderr, _("Image (%s) is corrupted\n"),
+ image_fn);
+ else
+ com_err(program_name, ret,
+ _("while trying to convert qcow2 image"
+ " (%s) into raw image (%s)"),
+ image_fn, device_name);
+ ret = 1;
}
goto out;
}
diff --git a/misc/e2label.8.in b/misc/e2label.8.in
index aff08d9c..2f457072 100644
--- a/misc/e2label.8.in
+++ b/misc/e2label.8.in
@@ -9,43 +9,43 @@ e2label \- Change the label on an ext2/ext3/ext4 filesystem
.B e2label
.I device
[
-.I new-label
+.I volume-label
]
.SH DESCRIPTION
.B e2label
-will display or change the filesystem label on the ext2, ext3, or ext4
+will display or change the volume label on the ext2, ext3, or ext4
filesystem located on
-.I device.
+.I device.
.PP
-If the optional argument
-.I new-label
-is not present,
+If the optional argument
+.I volume-label
+is not present,
.B e2label
-will simply display the current filesystem label.
+will simply display the current volume label.
.PP
If the optional argument
-.I new-label
-is present, then
+.I volume-label
+is present, then
.B e2label
-will set the filesystem label to be
-.IR new-label .
-Ext2 filesystem labels can be at most 16 characters long; if
-.I new-label
-is longer than 16 characters,
+will set the volume label to be
+.IR volume-label .
+Ext2 volume labels can be at most 16 characters long; if
+.I volume-label
+is longer than 16 characters,
.B e2label
-will truncate it and print a warning message.
+will truncate it and print a warning message.
.PP
-It is also possible to set the filesystem label using the
+It is also possible to set the volume label using the
.B \-L
-option of
+option of
.BR tune2fs (8).
.PP
.SH AUTHOR
-.B e2label
+.B e2label
was written by Theodore Ts'o (tytso@mit.edu).
.SH AVAILABILITY
.B e2label
-is part of the e2fsprogs package and is available from
+is part of the e2fsprogs package and is available from
http://e2fsprogs.sourceforge.net.
.SH SEE ALSO
.BR mke2fs (8),
diff --git a/misc/e2mmpstatus.8.in b/misc/e2mmpstatus.8.in
new file mode 100644
index 00000000..f7d9557e
--- /dev/null
+++ b/misc/e2mmpstatus.8.in
@@ -0,0 +1,59 @@
+.\" -*- nroff -*-
+.\" This file may be copied under the terms of the GNU Public License.
+.\"
+.TH E2MMPSTATUS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
+.SH NAME
+e2mmpstatus \- Check MMP status of an ext4 filesystem
+.SH SYNOPSIS
+.BR e2mmpstatus " [" \-i ]
+.RI < filesystem >
+.SH OPTIONS
+.TP
+.B \-i
+prints out the MMP information rather than check it.
+.SH DESCRIPTION
+.B e2mmpstatus
+is used to check Multiple-Mount Protection (MMP) status of an ext4
+filesystem with the
+.B mmp
+feature enabled. The specified
+.I filesystem
+can be a device name (e.g.
+.IR /dev/hdc1 ", " /dev/sdb2 ),
+or an ext4 filesystem label or UUID, for example
+.B UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd
+or
+.BR LABEL=root .
+By default, the
+.B e2mmpstatus
+program checks whether it is safe to mount the filesystem without taking
+the risk of mounting it more than once.
+.PP
+MMP (multiple-mount protection) is a feature that adds protection against
+the filesystem being modified simultaneously by more than one node.
+It is NOT safe to mount a filesystem when one of the following conditions
+is true:
+.br
+\ 1. e2fsck is running on the filesystem.
+.br
+\ 2. the filesystem is in use by another node.
+.br
+\ 3. The MMP block is corrupted or cannot be read for some reason.
+.br
+The
+.B e2mmpstatus
+program might wait for some time to see whether the MMP block is being
+updated by any node during this period. The time taken depends on how
+frequently the MMP block is being written by the other node.
+.SH EXIT CODE
+The exit code returned by
+.B e2mmpstatus
+is 0 when it is safe to mount the filesystem, 1 when the MMP block shows
+the filesystem is in use on another node and it is NOT safe to mount
+the filesystem, and 2 if some other failure occurred that prevents the
+check from properly detecting the current MMP status.
+.SH SEE ALSO
+.BR dumpe2fs (8),
+.BR e2fsck (8),
+.BR fstab (5),
+.BR fsck (8),
diff --git a/misc/e2undo.8.in b/misc/e2undo.8.in
index da8b9189..d8265b16 100644
--- a/misc/e2undo.8.in
+++ b/misc/e2undo.8.in
@@ -17,8 +17,16 @@ e2undo \- Replay an undo log for an ext2/ext3/ext4 filesystem
.B \-n
]
[
+.B \-o
+.I offset
+]
+[
.B \-v
]
+[
+.B \-z
+.I undo_file
+]
.I undo_log device
.SH DESCRIPTION
.B e2undo
@@ -53,6 +61,16 @@ Specify the filesystem's
.TP
.B \-v
Report which block we're currently replaying.
+.TP
+.BI \-z " undo_file"
+Before overwriting a file system block, write the old contents of the block to
+an undo file. This undo file can be used with e2undo(8) to restore the old
+contents of the file system should something go wrong. If the empty string is
+passed as the undo_file argument, the undo file will be written to a file named
+e2undo-\fIdevice\fR.e2undo in the directory specified via the
+\fIE2FSPROGS_UNDO_DIR\fR environment variable.
+
+WARNING: The undo file cannot be used to recover from a power or system crash.
.SH AUTHOR
.B e2undo
was written by Aneesh Kumar K.V. (aneesh.kumar@linux.vnet.ibm.com)
diff --git a/misc/e2undo.c b/misc/e2undo.c
index 6fb6e448..05937383 100644
--- a/misc/e2undo.c
+++ b/misc/e2undo.c
@@ -81,8 +81,10 @@ struct undo_key_block {
__le32 magic; /* KEYBLOCK_MAGIC number */
__le32 crc; /* block checksum */
__le64 reserved; /* zero */
-
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
struct undo_key keys[0]; /* keys, which come immediately after */
+#pragma GCC diagnostic pop
};
struct undo_key_info {
@@ -115,7 +117,7 @@ static char *undo_file;
static void usage(void)
{
fprintf(stderr,
- _("Usage: %s [-f] [-h] [-n] [-v] <transaction file> <filesystem>\n"), prg_name);
+ _("Usage: %s [-f] [-h] [-n] [-o offset] [-v] [-z undo_file] <transaction file> <filesystem>\n"), prg_name);
exit(1);
}
diff --git a/misc/e4crypt.8.in b/misc/e4crypt.8.in
index 6c5e4706..75b968a0 100644
--- a/misc/e4crypt.8.in
+++ b/misc/e4crypt.8.in
@@ -2,26 +2,53 @@
.SH NAME
e4crypt \- ext4 filesystem encryption utility
.SH SYNOPSIS
-.B e4crypt add_key -S \fR[\fB -k \fIkeyring\fR ] [\fB-v\fR] [\fB-q\fR] [ \fI path\fR ... ]
+.B e4crypt add_key -S \fR[\fB -k \fIkeyring\fR ] [\fB-v\fR] [\fB-q\fR] \fR[\fB -p \fIpad\fR ] [ \fIpath\fR ... ]
.br
.B e4crypt new_session
.br
.B e4crypt get_policy \fIpath\fR ...
.br
-.B e4crypt set_policy \fIpolicy path\fR ...
+.B e4crypt set_policy \fR[\fB -p \fIpad\fR ] \fIpolicy path\fR ...
.SH DESCRIPTION
.B e4crypt
performs encryption management for ext4 file systems.
.SH COMMANDS
.TP
-.B e4crypt add_key -S \fR[\fB -k \fIkeyring\fR ] [\fB-v\fR] [\fB-q\fR] [ \fI path\fR ... ]
+.B e4crypt add_key \fR[\fB-vq\fR] [\fB-S\fI salt\fR ] [\fB-k \fIkeyring\fR ] [\fB -p \fIpad\fR ] [ \fIpath\fR ... ]
Prompts the user for a passphrase and inserts it into the specified
keyring. If no keyring is specified, e4crypt will use the session
keyring if it exists or the user session keyring if it does not.
.IP
+The
+.I salt
+argument is interpreted in a number of different ways, depending on how
+its prefix value. If the first two characters are "s:", then the rest
+of the argument will be used as an text string and used as the salt
+value. If the first two characters are "0x", then the rest of the
+argument will be parsed as a hex string as used as the salt. If the
+first characters are "f:" then the rest of the argument will be
+interpreted as a filename from which the salt value will be read. If
+the string begins with a '/' character, it will similarly be treated as
+filename. Finally, if the
+.I salt
+argument can be parsed as a valid UUID, then the UUID value will be used
+as a salt value.
+.IP
+The
+.I keyring
+argument specifies the keyring to which the key should be added.
+.IP
+The
+.I pad
+value specifies the number of bytes of padding will be added to
+directory names for obfuscation purposes. Valid
+.I pad
+values are 4, 8, 16, and 32.
+.IP
If one or more directory paths are specified, e4crypt will try to
-set the policy of those directories to use the key just entered by
-the user.
+set the policy of those directories to use the key just added by the
+.B add_key
+command.
.TP
.B e4crypt get_policy \fIpath\fR ...
Print the policy for the directories specified on the command line.
@@ -30,7 +57,7 @@ Print the policy for the directories specified on the command line.
Give the invoking process (typically a shell) a new session keyring,
discarding its old session keyring.
.TP
-.B e4crypt set_policy \fIpolicy path\fR ...
+.B e4crypt set_policy \fR[\fB -p \fIpad\fR ] \fIpolicy path\fR ...
Sets the policy for the directories specified on the command line.
All directories must be empty to set the policy; if the directory
already has a policy established, e4crypt will validate that the
diff --git a/misc/e4crypt.c b/misc/e4crypt.c
index 04faca32..2ae6254a 100644
--- a/misc/e4crypt.c
+++ b/misc/e4crypt.c
@@ -507,24 +507,12 @@ static int get_keyring_id(const char *keyring)
/*
* If no keyring is specified, by default use either the user
- * session key ring or the session keyring. Fetching the
+ * session keyring or the session keyring. Fetching the
* session keyring will return the user session keyring if no
* session keyring has been set.
- *
- * We need to do this instead of simply adding the key to
- * KEY_SPEC_SESSION_KEYRING since trying to add a key to a
- * session keyring that does not yet exist will cause the
- * kernel to create a session keyring --- which wil then get
- * garbage collected as soon as e4crypt exits.
- *
- * The fact that the keyctl system call and the add_key system
- * call treats KEY_SPEC_SESSION_KEYRING differently when a
- * session keyring does not exist is very unfortunate and
- * confusing, but so it goes...
*/
if (keyring == NULL)
- return keyctl(KEYCTL_GET_KEYRING_ID,
- KEY_SPEC_SESSION_KEYRING, 0);
+ return KEY_SPEC_SESSION_KEYRING;
for (x = 0; x < (sizeof(keyrings) / sizeof(keyrings[0])); ++x) {
if (strcmp(keyring, keyrings[x].name) == 0) {
return keyrings[x].code;
@@ -578,13 +566,34 @@ static void insert_key_into_keyring(const char *keyring, struct salt *salt)
return;
} else if ((rc == -1) && (errno != ENOKEY)) {
printf("keyctl_search failed: %s\n", strerror(errno));
- if (errno == -EINVAL)
+ if (errno == EINVAL)
printf("Keyring [%s] is not available.\n", keyring);
exit(1);
}
key.mode = EXT4_ENCRYPTION_MODE_AES_256_XTS;
memcpy(key.raw, salt->key, EXT4_MAX_KEY_SIZE);
key.size = EXT4_MAX_KEY_SIZE;
+
+ /*
+ * We need to do this instead of simply adding the key to
+ * KEY_SPEC_SESSION_KEYRING since trying to add a key to a
+ * session keyring that does not yet exist will cause the
+ * kernel to create a session keyring --- which will then get
+ * garbage collected as soon as e4crypt exits.
+ *
+ * The fact that the keyctl system call and the add_key system
+ * call treats KEY_SPEC_SESSION_KEYRING differently when a
+ * session keyring does not exist is very unfortunate and
+ * confusing, but so it goes...
+ */
+ if (keyring_id == KEY_SPEC_SESSION_KEYRING) {
+ keyring_id = keyctl(KEYCTL_GET_KEYRING_ID, keyring_id, 0);
+ if (keyring_id < 0) {
+ printf("Error getting session keyring ID: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+ }
rc = add_key(EXT2FS_KEY_TYPE_LOGON, key_ref_full, (void *)&key,
sizeof(key), keyring_id);
if (rc == -1) {
@@ -632,7 +641,7 @@ static void do_help(int argc, char **argv, const struct cmd_desc *cmd);
#define add_key_desc "adds a key to the user's keyring"
#define add_key_help \
-"e4crypt add_key -S salt [ -k keyring ] [-v] [-q] [ path ... ]\n\n" \
+"e4crypt add_key -S salt [ -k keyring ] [-v] [-q] [ -p pad ] [ path ... ]\n\n" \
"Prompts the user for a passphrase and inserts it into the specified\n" \
"keyring. If no keyring is specified, e4crypt will use the session\n" \
"keyring if it exists or the user session keyring if it does not.\n\n" \
@@ -667,8 +676,10 @@ static void do_add_key(int argc, char **argv, const struct cmd_desc *cmd)
options |= OPT_QUIET;
break;
default:
- fprintf(stderr, "Unrecognized option: %c\n", opt);
case '?':
+ if (opt != '?')
+ fprintf(stderr, "Unrecognized option: %c\n",
+ opt);
fputs("USAGE:\n ", stderr);
fputs(cmd->cmd_help, stderr);
exit(1);
@@ -699,7 +710,7 @@ static void do_add_key(int argc, char **argv, const struct cmd_desc *cmd)
#define set_policy_desc "sets a policy for directories"
#define set_policy_help \
-"e4crypt set_policy policy path ... \n\n" \
+"e4crypt set_policy [ -p pad ] policy path ... \n\n" \
"Sets the policy for the directories specified on the command line.\n" \
"All directories must be empty to set the policy; if the directory\n" \
"already has a policy established, e4crypt will validate that it the\n" \
@@ -749,7 +760,6 @@ static void do_set_policy(int argc, char **argv, const struct cmd_desc *cmd)
static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd)
{
struct ext4_encryption_policy policy;
- struct stat st;
int i, j, fd, rc;
if (argc < 2) {
@@ -760,12 +770,7 @@ static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd)
}
for (i = 1; i < argc; i++) {
- if (stat(argv[i], &st) < 0) {
- perror(argv[i]);
- continue;
- }
- fd = open(argv[i],
- S_ISDIR(st.st_mode) ? O_DIRECTORY : O_RDONLY);
+ fd = open(argv[i], O_RDONLY);
if (fd == -1) {
perror(argv[i]);
exit(1);
diff --git a/misc/e4defrag.8.in b/misc/e4defrag.8.in
index 37a1c6a9..6553721f 100644
--- a/misc/e4defrag.8.in
+++ b/misc/e4defrag.8.in
@@ -66,7 +66,7 @@ is a device or a mount point,
.B e4defrag
doesn't defragment files in mount point of other device.
.PP
-It safe to run e4defrag on a file while it is actively in use by another
+It is safe to run e4defrag on a file while it is actively in use by another
application. Since the contents of file blocks are copied using the
page cache, this can result in a performance slowdown to both e4defrag
and the application due to contention over the system's memory and disk
diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 1d1b4f41..5ac251dc 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -41,6 +41,8 @@
#include <sys/statfs.h>
#include <sys/vfs.h>
+#include "../version.h"
+
/* A relatively new ioctl interface ... */
#ifndef EXT4_IOC_MOVE_EXT
#define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent)
@@ -1014,7 +1016,7 @@ static int get_best_count(ext4_fsblk_t block_count)
int ret;
unsigned int flex_bg_num;
- /* Calcuate best extents count */
+ /* Calculate best extents count */
if (feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) {
flex_bg_num = 1 << log_groups_per_flex;
ret = ((block_count - 1) /
@@ -1578,7 +1580,7 @@ static int file_defrag(const char *file, const struct stat64 *buf,
goto out;
}
- /* Calcuate donor inode's continuous physical region */
+ /* Calculate donor inode's continuous physical region */
donor_physical_cnt = get_physical_count(donor_list_physical);
/* Change donor extent list from physical to logical */
@@ -1673,12 +1675,15 @@ int main(int argc, char *argv[])
int i, j, ret = 0;
int flags = FTW_PHYS | FTW_MOUNT;
int arg_type = -1;
+ int mount_dir_len = 0;
int success_flag = 0;
char dir_name[PATH_MAX + 1];
char dev_name[PATH_MAX + 1];
struct stat64 buf;
ext2_filsys fs = NULL;
+ printf("e4defrag %s (%s)\n", E2FSPROGS_VERSION, E2FSPROGS_DATE);
+
/* Parse arguments */
if (argc == 1)
goto out;
@@ -1814,7 +1819,6 @@ int main(int argc, char *argv[])
}
switch (arg_type) {
- int mount_dir_len = 0;
case DIRNAME:
if (!(mode_flag & STATISTIC))
@@ -1826,11 +1830,11 @@ int main(int argc, char *argv[])
strncat(lost_found_dir, "/lost+found",
PATH_MAX - strnlen(lost_found_dir, PATH_MAX));
- /* Not the case("e4defrag mount_piont_dir") */
+ /* Not the case("e4defrag mount_point_dir") */
if (dir_name[mount_dir_len] != '\0') {
/*
- * "e4defrag mount_piont_dir/lost+found"
- * or "e4defrag mount_piont_dir/lost+found/"
+ * "e4defrag mount_point_dir/lost+found"
+ * or "e4defrag mount_point_dir/lost+found/"
*/
if (strncmp(lost_found_dir, dir_name,
strnlen(lost_found_dir,
@@ -1844,9 +1848,10 @@ int main(int argc, char *argv[])
continue;
}
- /* "e4defrag mount_piont_dir/else_dir" */
+ /* "e4defrag mount_point_dir/else_dir" */
memset(lost_found_dir, 0, PATH_MAX + 1);
}
+ /* fall through */
case DEVNAME:
if (arg_type == DEVNAME) {
strncpy(lost_found_dir, dir_name,
diff --git a/misc/ext4.5.in b/misc/ext4.5.in
index d7bd863f..8f4c4f51 100644
--- a/misc/ext4.5.in
+++ b/misc/ext4.5.in
@@ -69,7 +69,22 @@ ext2 file systems.
.TP
.B dir_nlink
.br
-This ext4 feature allows more than 65000 subdirectories per directory.
+Normally, ext4 allows an inode to have no more than 65,000 hard links.
+This applies to regular files as well as directories, which means that
+there can be no more than 64,998 subdirectories in a directory (because
+each of the '.' and '..' entries, as well as the directory entry for the
+directory in its parent directory counts as a hard link). This feature
+lifts this limit by causing ext4 to use a link count of 1 to indicate
+that the number of hard links to a directory is not known when the link
+count might exceed the maximum count limit.
+.TP
+.B ea_inode
+.br
+Normally, a file's extended attributes and associated metadata must fit within
+the inode or the inode's associated extended attribute block. This feature
+allows the value of each extended attribute to be placed in the data blocks of a
+separate inode if necessary, increasing the limit on the size and number of
+extended attributes per file.
.TP
.B encrypt
.br
@@ -168,27 +183,40 @@ option to
or
.BR tune2fs(8).
.TP
+.B large_dir
+.br
+This feature increases the limit on the number of files per directory by
+raising the maximum size of directories and, for hashed b-tree directories (see
+.BR dir_index ),
+the maximum height of the hashed b-tree used to store the directory entries.
+.TP
.B large_file
.br
This feature flag is set automatically by modern kernels when a file
larger than 2 gigabytes is created. Very old kernels could not
handle large files, so this feature flag was used to prohibit those
kernels from mounting file systems that they could not understand.
-.\" .TP
-.\" .B metadata_csum
-.\" .br
-.\" This ext4 feature enables metadata checksumming. This feature stores
-.\" checksums for all of the filesystem metadata (superblock, group
-.\" descriptor blocks, inode and block bitmaps, directories, and
-.\" extent tree blocks). The checksum algorithm used for the metadata
-.\" blocks is different than the one used for group descriptors with the
-.\" .B uninit_bg
-.\" feature, these two features are incompatible and
-.\" .B metadata_csum
-.\" will be used preferentially instead of
-.\" .BR uninit_bg .
-.\" .br
-.\" .B Future feature, available in e2fsprogs 1.43-WIP
+.TP
+.B metadata_csum
+.br
+This ext4 feature enables metadata checksumming. This feature stores
+checksums for all of the filesystem metadata (superblock, group
+descriptor blocks, inode and block bitmaps, directories, and
+extent tree blocks). The checksum algorithm used for the metadata
+blocks is different than the one used for group descriptors with the
+.B uninit_bg
+feature. These two features are incompatible and
+.B metadata_csum
+will be used preferentially instead of
+.BR uninit_bg .
+.TP
+.B metadata_csum_seed
+.br
+This feature allows the filesystem to store the metadata checksum seed in the
+superblock, which allows the administrator to change the UUID of a filesystem
+using the
+.B metadata_csum
+feature while it is mounted.
.TP
.B meta_bg
.br
@@ -207,10 +235,6 @@ available in the resize inode.
This ext4 feature provides multiple mount protection (MMP). MMP helps to
protect the filesystem from being multiply mounted and is useful in
shared storage environments.
-.IP
-Causes the quota files (i.e., user.quota and
-group.quota which existed
-in the older quota design) to be hidden inodes.
.TP
.B project
.br
@@ -223,6 +247,10 @@ Create quota inodes (inode #3 for userquota and inode
#4 for group quota) and set them in the superblock.
With this feature, the quotas will be enabled
automatically when the filesystem is mounted.
+.IP
+Causes the quota files (i.e., user.quota and
+group.quota which existed
+in the older quota design) to be hidden inodes.
.TP
.B resize_inode
.br
@@ -241,6 +269,8 @@ extended option.
.IP
This feature requires that the
.B sparse_super
+or
+.B sparse_super2
feature be enabled.
.TP
.B sparse_super
@@ -375,18 +405,26 @@ These options determine who can use the reserved blocks.
(Roughly: whoever has the specified uid, or belongs to the specified group.)
.TP
.BI sb= n
-Instead of block 1, use block
-.I n
-as superblock. This could be useful when the filesystem has been damaged.
-(Earlier, copies of the superblock would be made every 8192 blocks: in
-block 1, 8193, 16385, \&...\& (and one got thousands of copies on
-a big filesystem). Since version 1.08,
+Instead of using the normal superblock, use an alternative superblock
+specified by
+.IR n .
+This option is normally used when the primary superblock has been
+corrupted. The location of backup superblocks is dependent on the
+filesystem's blocksize, the number of blocks per group, and features
+such as
+.BR sparse_super .
+.IP
+Additional backup superblocks can be determined by using the
.B mke2fs
-has a \-s (sparse superblock) option to reduce the number of backup
-superblocks, and since version 1.15 this is the default. Note
-that this may mean that ext2 filesystems created by a recent
+program using the
+.B \-n
+option to print out where the superblocks exist, supposing
.B mke2fs
-cannot be mounted r/w under Linux 2.0.*.)
+is supplied with arguments that are consistent with the filesystem's layout
+(e.g. blocksize, blocks per group,
+.BR sparse_super ,
+etc.).
+.IP
The block number here uses 1\ k units. Thus, if you want to use logical
block 32768 on a filesystem with 4\ k blocks, use "sb=131072".
.TP
@@ -454,22 +492,31 @@ performance penalty. If your disks are battery-backed in one way or another,
disabling barriers may safely improve performance.
.TP
.BI commit= nrsec
-Sync all data and metadata every
+Start a journal commit every
.I nrsec
-seconds. The default value is 5 seconds. Zero means default.
+seconds. The default value is 5 seconds. Zero means default.
.TP
.B user_xattr
Enable Extended User Attributes. See the
.BR attr (5)
manual page.
.TP
-.BR usrjquota=aquota.user | grpjquota=aquota.group | jqfmt=vfsv0
+.BR jqfmt= { vfsold | vfsv0 | vfsv1 }
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
-enables journaled quotas. For journaled quotas the mount options
+ext3 also supports journaled quotas (version 2 quota). jqfmt=vfsv0 or
+jqfmt=vfsv1 enables journaled quotas. Journaled quotas have the advantage that
+even after a crash no quota check is required. When the
+.B quota
+filesystem feature is enabled, journaled quotas are used automatically, and
+this mount option is ignored.
+.TP
+.BR usrjquota=aquota.user | grpjquota=aquota.group
+For journaled quotas (jqfmt=vfsv0 or jqfmt=vfsv1), the mount options
usrjquota=aquota.user and grpjquota=aquota.group are required to tell the
-quota system which quota database files to use. Journaled quotas have the
-advantage that even after a crash no quota check is required.
+quota system which quota database files to use. When the
+.B quota
+filesystem feature is enabled, journaled quotas are used automatically, and
+this mount option is ignored.
.SH "Mount options for ext4"
The ext4 filesystem is an advanced level of the ext3 filesystem which
@@ -477,16 +524,16 @@ incorporates scalability and reliability enhancements for supporting large
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, nouid32, grpquota, usrquota
-.B usrjquota, grpjquota and jqfmt
-are backwardly compatible with ext3 or ext2.
+.B journal_dev, journal_path, norecovery, noload, data, commit, orlov,
+.B oldalloc, [no]user_xattr, [no]acl, bsddf, minixdf, debug, errors,
+.B data_err, grpid, bsdgroups, nogrpid, sysvgroups, resgid, resuid, sb,
+.B quota, noquota, nouid32, grpquota, usrquota, usrjquota, grpjquota,
+.B and jqfmt are backwardly compatible with ext3 or ext2.
.TP
-.B journal_checksum
-Enable checksumming of the journal transactions. This will allow the recovery
-code in e2fsck and the kernel to detect corruption in the kernel. It is a
-compatible change and will be ignored by older kernels.
+.B journal_checksum | nojournal_checksum
+The journal_checksum option enables checksumming of the journal transactions.
+This will allow the recovery code in e2fsck and the kernel to detect corruption
+in the kernel. It is a compatible change and will be ignored by older kernels.
.TP
.B journal_async_commit
Commit block can be written to disk without waiting for descriptor blocks. If
@@ -585,7 +632,7 @@ sparse/thinly-provisioned LUNs, but it is off by default until sufficient
testing has been done.
.TP
.BR block_validity / noblock_validity
-This options enables/disables the in-kernel facility for tracking
+This option 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
@@ -612,6 +659,18 @@ seriously cramp the system's style.)
.TP
.B i_version
Enable 64-bit inode version support. This option is off by default.
+.TP
+.B nombcache
+This option disables use of mbcache for extended attribute deduplication. On
+systems where extended attributes are rarely or never shared between files,
+use of mbcache for deduplication adds unnecessary computational overhead.
+.TP
+.B prjquota
+The prjquota mount option enables project quota support on the filesystem.
+You need the quota utilities to actually enable and manage the quota system.
+This mount option requires the
+.B project
+filesystem feature.
.SH FILE ATTRIBUTES
The ext2, ext3, and ext4 filesystems support setting the following file
@@ -693,12 +752,18 @@ ext4, 3.6
ext4, 3.8
.IP "\fBsparse_super2\fR" 2in
ext4, 3.16
-.IP "\fBmetdata_csum\fR" 2in
+.IP "\fBmetadata_csum\fR" 2in
ext4, 3.18
.IP "\fBencrypt\fR" 2in
ext4, 4.1
+.IP "\fBmetadata_csum_seed\fR" 2in
+ext4, 4.4
.IP "\fBproject\fR" 2in
ext4, 4.5
+.IP "\fBea_inode\fR" 2in
+ext4, 4.13
+.IP "\fBlarge_dir\fR" 2in
+ext4, 4.13
.SH SEE ALSO
.BR mke2fs (8),
.BR mke2fs.conf (5),
diff --git a/misc/filefrag.8.in b/misc/filefrag.8.in
index a6d7b27c..292b3b7d 100644
--- a/misc/filefrag.8.in
+++ b/misc/filefrag.8.in
@@ -15,11 +15,11 @@ filefrag \- report on file fragmentation
]
.SH DESCRIPTION
.B filefrag
-reports on how badly fragmented a particular file might be. It makes
+reports on how badly fragmented a particular file might be. It makes
allowances for indirect blocks for ext2 and ext3 filesystems, but can be
used on files for any filesystem.
.PP
-The
+The
.B filefrag
program initially attempts to get the
extent information using FIEMAP ioctl which is more efficient and faster.
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 1a185124..7f1c5bfc 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -179,7 +179,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
print_flag(&fe_flags, FIEMAP_EXTENT_SHARED, flags, "shared,");
/* print any unknown flags as hex values */
for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) {
- char hex[6];
+ char hex[sizeof(mask) * 2 + 4]; /* 2 chars/byte + 0x, + NUL */
if ((fe_flags & mask) == 0)
continue;
@@ -208,7 +208,7 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
__u64 buf[2048]; /* __u64 for proper field alignment */
struct fiemap *fiemap = (struct fiemap *)buf;
struct fiemap_extent *fm_ext = &fiemap->fm_extents[0];
- struct fiemap_extent fm_last = {0};
+ struct fiemap_extent fm_last;
int count = (sizeof(buf) - sizeof(*fiemap)) /
sizeof(struct fiemap_extent);
unsigned long long expected = 0;
@@ -221,6 +221,7 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
int rc;
memset(fiemap, 0, sizeof(struct fiemap));
+ memset(&fm_last, 0, sizeof(fm_last));
if (sync_file)
flags |= FIEMAP_FLAG_SYNC;
@@ -306,8 +307,8 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
fm_ext.fe_flags = FIEMAP_EXTENT_MERGED;
}
- if (sync_file)
- fsync(fd);
+ if (sync_file && fsync(fd) != 0)
+ return -errno;
for (i = 0, logical = 0, *num_extents = 0, count = last_block = 0;
i < numblocks;
@@ -534,15 +535,17 @@ int main(int argc, char**argv)
char *end;
blocksize = strtoul(optarg, &end, 0);
if (end) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
switch (end[0]) {
case 'g':
case 'G':
blocksize *= 1024;
- /* no break */
+ /* fall through */
case 'm':
case 'M':
blocksize *= 1024;
- /* no break */
+ /* fall through */
case 'k':
case 'K':
blocksize *= 1024;
@@ -550,6 +553,7 @@ int main(int argc, char**argv)
default:
break;
}
+#pragma GCC diagnostic pop
}
} else { /* Allow -b without argument for compat. Remove
* this eventually so "-b {blocksize}" works */
@@ -588,7 +592,7 @@ int main(int argc, char**argv)
if (optind == argc)
usage(argv[0]);
- for (cpp = argv + optind; *cpp != '\0'; cpp++) {
+ for (cpp = argv + optind; *cpp != NULL; cpp++) {
int rc2 = frag_report(*cpp);
if (rc2 < 0 && rc == 0)
diff --git a/misc/findfs.8.in b/misc/findfs.8.in
index d44cbc7a..3146e0c8 100644
--- a/misc/findfs.8.in
+++ b/misc/findfs.8.in
@@ -6,27 +6,27 @@
.SH NAME
findfs \- Find a filesystem by label or UUID
.SH SYNOPSIS
-.B findfs
+.B findfs
.BI LABEL= label
.sp
.B findfs
.BI UUID= uuid
.SH DESCRIPTION
.B findfs
-will search the disks in the system looking for a filesystem which has
+will search the disks in the system looking for a filesystem which has
a label matching
.I label
-or a UUID equal to
+or a UUID equal to
.IR uuid .
If the filesystem is found, the device name for the filesystem will
be printed on stdout.
.PP
.SH AUTHOR
-.B findfs
+.B findfs
was written by Theodore Ts'o (tytso@mit.edu).
.SH AVAILABILITY
.B findfs
-is part of the e2fsprogs package and is available from
+is part of the e2fsprogs package and is available from
http://e2fsprogs.sourceforge.net.
.SH SEE ALSO
.BR fsck (8)
diff --git a/misc/findsuper.c b/misc/findsuper.c
index 47aa43af..ff20b988 100644
--- a/misc/findsuper.c
+++ b/misc/findsuper.c
@@ -30,7 +30,7 @@
* findsuper /dev/hda
* findsuper /dev/hda 437760 1024 (my disk has cyls of 855*512)
*
- * I suppose the next step is to figgure out a way to determine if
+ * I suppose the next step is to figure out a way to determine if
* the block found is the first superblock somehow, and if so, build
* a partition table from the superblocks found... but this is still
* useful as is.
@@ -75,7 +75,7 @@
* For new systems that have a block group number in the superblock it
* is immediately clear which superblock is the first of a partition.
* For old systems where no group numbers are given, the first
- * superblock can be recognised by the timestamp: all superblock
+ * superblock can be recognized by the timestamp: all superblock
* copies have the creation time in s_mtime, except the first, which
* has the last time e2fsck or tune2fs wrote to the filesystem.
*
diff --git a/misc/fsck.8.in b/misc/fsck.8.in
index 50fd8cef..e751f8de 100644
--- a/misc/fsck.8.in
+++ b/misc/fsck.8.in
@@ -1,7 +1,7 @@
.\" -*- nroff -*-
.\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved.
.\" This file may be copied under the terms of the GNU Public License.
-.\"
+.\"
.TH FSCK 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
.SH NAME
fsck \- check and repair a Linux file system
@@ -19,34 +19,34 @@ fsck \- check and repair a Linux file system
[
.B \-t
.I fstype
-]
+]
.I [filesys ... ]
[\-\-] [
.B fs-specific-options
]
.SH DESCRIPTION
.B fsck
-is used to check and optionally repair one or more Linux file systems.
+is used to check and optionally repair one or more Linux file systems.
.I filesys
can be a device name (e.g.
.IR /dev/hdc1 ", " /dev/sdb2 ),
a mount point (e.g.
.IR / ", " /usr ", " /home ),
or an ext2 label or UUID specifier (e.g.
-UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root).
-Normally, the
-.B fsck
-program will try to handle filesystems on different physical disk drives
+UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root).
+Normally, the
+.B fsck
+program will try to handle filesystems on different physical disk drives
in parallel to reduce the total amount of time needed to check all of the
filesystems.
.PP
-If no filesystems are specified on the command line, and the
-.B \-A
-option is not specified,
+If no filesystems are specified on the command line, and the
+.B \-A
+option is not specified,
.B fsck
will default to checking filesystems in
.B /etc/fstab
-serially. This is equivalent to the
+serially. This is equivalent to the
.B \-As
options.
.PP
@@ -70,7 +70,7 @@ is the sum of the following conditions:
.br
\ 128\ \-\ Shared library error
.br
-The exit code returned when multiple file systems are checked
+The exit code returned when multiple file systems are checked
is the bit-wise OR of the exit codes for each
file system that is checked.
.PP
@@ -90,37 +90,37 @@ further details.
.SH OPTIONS
.TP
.B \-s
-Serialize
-.B fsck
+Serialize
+.B fsck
operations. This is a good idea if you are checking multiple
filesystems and the checkers are in an interactive mode. (Note:
.BR e2fsck (8)
-runs in an interactive mode by default. To make
+runs in an interactive mode by default. To make
.BR e2fsck (8)
run in a non-interactive mode, you must either specify the
.B \-p
or
.B \-a
-option, if you wish for errors to be corrected automatically, or the
+option, if you wish for errors to be corrected automatically, or the
.B \-n
option if you do not.)
.TP
.BI \-t " fslist"
Specifies the type(s) of file system to be checked. When the
-.B \-A
-flag is specified, only filesystems that match
+.B \-A
+flag is specified, only filesystems that match
.I fslist
are checked. The
.I fslist
parameter is a comma-separated list of filesystems and options
specifiers. All of the filesystems in this comma-separated list may be
-prefixed by a negation operator
+prefixed by a negation operator
.RB ' no '
-or
+or
.RB ' ! ',
which requests that only those filesystems not listed in
.I fslist
-will be checked. If all of the filesystems in
+will be checked. If all of the filesystems in
.I fslist
are not prefixed by a negation operator, then only those filesystems
listed
@@ -130,18 +130,18 @@ will be checked.
.sp
Options specifiers may be included in the comma-separated
.IR fslist .
-They must have the format
+They must have the format
.BI opts= fs-option\fR.
If an options specifier is present, then only filesystems which contain
.I fs-option
-in their mount options field of
+in their mount options field of
.B /etc/fstab
will be checked. If the options specifier is prefixed by a negation
-operator, then only
+operator, then only
those filesystems that do not have
.I fs-option
in their mount options field of
-.B /etc/fstab
+.B /etc/fstab
will be checked.
.sp
For example, if
@@ -149,7 +149,7 @@ For example, if
appears in
.IR fslist ,
then only filesystems listed in
-.B /etc/fstab
+.B /etc/fstab
with the
.B ro
option will be checked.
@@ -169,16 +169,16 @@ option.
.sp
Normally, the filesystem type is deduced by searching for
.I filesys
-in the
-.I /etc/fstab
+in the
+.I /etc/fstab
file and using the corresponding entry.
-If the type can not be deduced, and there is only a single filesystem
-given as an argument to the
-.B \-t
-option,
+If the type can not be deduced, and there is only a single filesystem
+given as an argument to the
+.B \-t
+option,
.B fsck
will use the specified filesystem type. If this type is not
-available, then the default file system type (currently ext2) is used.
+available, then the default file system type (currently ext2) is used.
.TP
.B \-A
Walk through the
@@ -191,27 +191,27 @@ a single file system.
.sp
The root filesystem will be checked first unless the
.B \-P
-option is specified (see below). After that,
-filesystems will be checked in the order specified by the
-.I fs_passno
-(the sixth) field in the
+option is specified (see below). After that,
+filesystems will be checked in the order specified by the
+.I fs_passno
+(the sixth) field in the
.I /etc/fstab
-file.
-Filesystems with a
+file.
+Filesystems with a
.I fs_passno
value of 0 are skipped and are not checked at all. Filesystems with a
.I fs_passno
-value of greater than zero will be checked in order,
+value of greater than zero will be checked in order,
with filesystems with the lowest
-.I fs_passno
+.I fs_passno
number being checked first.
-If there are multiple filesystems with the same pass number,
-fsck will attempt to check them in parallel, although it will avoid running
-multiple filesystem checks on the same physical disk.
+If there are multiple filesystems with the same pass number,
+fsck will attempt to check them in parallel, although it will avoid running
+multiple filesystem checks on the same physical disk.
.sp
-Hence, a very common configuration in
+Hence, a very common configuration in
.I /etc/fstab
-files is to set the root filesystem to have a
+files is to set the root filesystem to have a
.I fs_passno
value of 1
and to set all other filesystems to have a
@@ -226,9 +226,9 @@ machine in question is short on memory so that
excessive paging is a concern.
.TP
.B \-C\fR [ \fI "fd" \fR ]
-Display completion/progress bars for those filesystem checkers (currently
+Display completion/progress bars for those filesystem checkers (currently
only for ext2 and ext3) which support them. Fsck will manage the
-filesystem checkers so that only one of them will display
+filesystem checkers so that only one of them will display
a progress bar at a time. GUI front-ends may specify a file descriptor
.IR fd ,
in which case the progress bar information will be sent to that file descriptor.
@@ -241,12 +241,12 @@ for mounted filesystems.
Don't execute, just show what would be done.
.TP
.B \-P
-When the
+When the
.B \-A
flag is set, check the root filesystem in parallel with the other filesystems.
This is not the safest thing in the world to do,
-since if the root filesystem is in doubt things like the
-.BR e2fsck (8)
+since if the root filesystem is in doubt things like the
+.BR e2fsck (8)
executable might be corrupted! This option is mainly provided
for those sysadmins who don't want to repartition the root
filesystem to be small and compact (which is really the right solution).
@@ -264,12 +264,12 @@ Produce verbose output, including all file system-specific commands
that are executed.
.TP
.B fs-specific-options
-Options which are not understood by
-.B fsck
+Options which are not understood by
+.B fsck
are passed to the filesystem-specific checker. These arguments
.B must
not take arguments, as there is no
-way for
+way for
.B fsck
to be able to properly guess which arguments take options and which
don't.
@@ -282,13 +282,13 @@ file system-specific checker.
Please note that fsck is not
designed to pass arbitrarily complicated options to filesystem-specific
checkers. If you're doing something complicated, please just
-execute the filesystem-specific checker directly. If you pass
+execute the filesystem-specific checker directly. If you pass
.B fsck
some horribly complicated option and arguments, and it doesn't do
-what you expect,
+what you expect,
.B don't bother reporting it as a bug.
You're almost certainly doing something that you shouldn't be doing
-with
+with
.BR fsck.
.PP
Options to different filesystem-specific fsck's are not standardized.
@@ -298,46 +298,46 @@ by most file system checkers:
.TP
.B \-a
Automatically repair the file system without any questions (use
-this option with caution). Note that
+this option with caution). Note that
.BR e2fsck (8)
-supports
+supports
.B \-a
-for backwards compatibility only. This option is mapped to
+for backwards compatibility only. This option is mapped to
.BR e2fsck 's
.B \-p
-option which is safe to use, unlike the
-.B \-a
+option which is safe to use, unlike the
+.B \-a
option that some file system checkers support.
.TP
.B \-n
-For some filesystem-specific checkers, the
+For some filesystem-specific checkers, the
.B \-n
-option will cause the fs-specific fsck to avoid attempting to repair any
+option will cause the fs-specific fsck to avoid attempting to repair any
problems, but simply report such problems to stdout. This is however
-not true for all filesystem-specific checkers. In particular,
+not true for all filesystem-specific checkers. In particular,
.BR fsck.reiserfs (8)
will not report any corruption if given this option.
.BR fsck.minix (8)
-does not support the
-.B \-n
+does not support the
+.B \-n
option at all.
.TP
.B \-r
Interactively repair the filesystem (ask for confirmations). Note: It
is generally a bad idea to use this option if multiple fsck's are being
-run in parallel. Also note that this is
+run in parallel. Also note that this is
.BR e2fsck 's
default behavior; it supports this option for backwards compatibility
reasons only.
.TP
.B \-y
-For some filesystem-specific checkers, the
-.B \-y
+For some filesystem-specific checkers, the
+.B \-y
option will cause the fs-specific fsck to always attempt to fix any
detected filesystem corruption automatically. Sometimes an expert may
-be able to do better driving the fsck manually. Note that
+be able to do better driving the fsck manually. Note that
.B not
-all filesystem-specific checkers implement this option. In particular
+all filesystem-specific checkers implement this option. In particular
.BR fsck.minix (8)
and
.BR fsck.cramfs (8)
@@ -354,7 +354,7 @@ The
program's behavior is affected by the following environment variables:
.TP
.B FSCK_FORCE_ALL_PARALLEL
-If this environment variable is set,
+If this environment variable is set,
.B fsck
will attempt to run all of the specified filesystems in parallel,
regardless of whether the filesystems appear to be on the same
@@ -364,7 +364,7 @@ such as those sold by companies such as IBM or EMC.)
.B FSCK_MAX_INST
This environment variable will limit the maximum number of file system
checkers that can be running at one time. This allows configurations
-which have a large number of disks to avoid
+which have a large number of disks to avoid
.B fsck
starting too many file system checkers at once, which might overload
CPU and memory resources available on the system. If this value is
@@ -375,23 +375,23 @@ may attempt to automatically determine how many file system checks can
be run based on gathering accounting data from the operating system.
.TP
.B PATH
-The
+The
.B PATH
environment variable is used to find file system checkers. A set of
-system directories are searched first:
+system directories are searched first:
.BR /sbin ,
.BR /sbin/fs.d ,
.BR /sbin/fs ,
.BR /etc/fs ,
-and
+and
.BR /etc .
Then the set of directories found in the
.B PATH
environment are searched.
.TP
.B FSTAB_FILE
-This environment variable allows the system administrator
-to override the standard location of the
+This environment variable allows the system administrator
+to override the standard location of the
.B /etc/fstab
file. It is also useful for developers who are testing
.BR fsck .
diff --git a/misc/fsck.c b/misc/fsck.c
index 7c93ee82..4efe10ec 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -408,8 +408,12 @@ static char *find_fsck(char *type)
tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
- sprintf(prog, tpl, s, type);
- if (stat(prog, &st) == 0) break;
+ int len = snprintf(prog, sizeof(prog), tpl, s, type);
+
+ if ((len < 0) || (len >= (int) sizeof(prog)))
+ continue;
+ if (stat(prog, &st) == 0)
+ break;
}
free(p);
return(s ? prog : NULL);
@@ -435,17 +439,20 @@ static int progress_active(NOARGS)
static int execute(const char *type, const char *device, const char *mntpt,
int interactive)
{
- char *s, *argv[80], prog[80];
- int argc, i;
+ char *s, *argv[80], prog[256];
+ int argc, i, len;
struct fsck_instance *inst, *p;
pid_t pid;
+ len = snprintf(prog, sizeof(prog), "fsck.%s", type);
+ if ((len < 0) || (len >= (int) sizeof(prog)))
+ return EINVAL;
+
inst = malloc(sizeof(struct fsck_instance));
if (!inst)
return ENOMEM;
memset(inst, 0, sizeof(struct fsck_instance));
- sprintf(prog, "fsck.%s", type);
argv[0] = string_copy(prog);
argc = 1;
@@ -997,7 +1004,7 @@ static int check_all(NOARGS)
}
/*
* This is for the bone-headed user who enters the root
- * filesystem twice. Skip root will skep all root entries.
+ * filesystem twice. Skip root will skip all root entries.
*/
if (skip_root)
for (fs = filesys_info; fs; fs = fs->next)
diff --git a/misc/fsck.h b/misc/fsck.h
index 8a0f70e3..8a55fbd6 100644
--- a/misc/fsck.h
+++ b/misc/fsck.h
@@ -34,7 +34,7 @@
#define EXIT_LIBRARY 128
/*
- * Internal structure for mount tabel entries.
+ * Internal structure for mount table entries.
*/
struct fs_info {
diff --git a/misc/fsmap.h b/misc/fsmap.h
new file mode 100644
index 00000000..e9590aae
--- /dev/null
+++ b/misc/fsmap.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2017 Oracle.
+ * All Rights Reserved.
+ *
+ * Author: Darrick J. Wong <darrick.wong@oracle.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef FSMAP_H_
+#define FSMAP_H_
+
+/* FS_IOC_GETFSMAP ioctl definitions */
+#ifndef FS_IOC_GETFSMAP
+struct fsmap {
+ __u32 fmr_device; /* device id */
+ __u32 fmr_flags; /* mapping flags */
+ __u64 fmr_physical; /* device offset of segment */
+ __u64 fmr_owner; /* owner id */
+ __u64 fmr_offset; /* file offset of segment */
+ __u64 fmr_length; /* length of segment */
+ __u64 fmr_reserved[3]; /* must be zero */
+};
+
+struct fsmap_head {
+ __u32 fmh_iflags; /* control flags */
+ __u32 fmh_oflags; /* output flags */
+ __u32 fmh_count; /* # of entries in array incl. input */
+ __u32 fmh_entries; /* # of entries filled in (output). */
+ __u64 fmh_reserved[6]; /* must be zero */
+
+ struct fsmap fmh_keys[2]; /* low and high keys for the mapping search */
+ struct fsmap fmh_recs[]; /* returned records */
+};
+
+/* Size of an fsmap_head with room for nr records. */
+static inline size_t
+fsmap_sizeof(
+ unsigned int nr)
+{
+ return sizeof(struct fsmap_head) + nr * sizeof(struct fsmap);
+}
+
+/* Start the next fsmap query at the end of the current query results. */
+static inline void
+fsmap_advance(
+ struct fsmap_head *head)
+{
+ head->fmh_keys[0] = head->fmh_recs[head->fmh_entries - 1];
+}
+
+/* fmh_iflags values - set by FS_IOC_GETFSMAP caller in the header. */
+/* no flags defined yet */
+#define FMH_IF_VALID 0
+
+/* fmh_oflags values - returned in the header segment only. */
+#define FMH_OF_DEV_T 0x1 /* fmr_device values will be dev_t */
+
+/* fmr_flags values - returned for each non-header segment */
+#define FMR_OF_PREALLOC 0x1 /* segment = unwritten pre-allocation */
+#define FMR_OF_ATTR_FORK 0x2 /* segment = attribute fork */
+#define FMR_OF_EXTENT_MAP 0x4 /* segment = extent map */
+#define FMR_OF_SHARED 0x8 /* segment = shared with another file */
+#define FMR_OF_SPECIAL_OWNER 0x10 /* owner is a special value */
+#define FMR_OF_LAST 0x20 /* segment is the last in the FS */
+
+/* Each FS gets to define its own special owner codes. */
+#define FMR_OWNER(type, code) (((__u64)type << 32) | \
+ ((__u64)code & 0xFFFFFFFFULL))
+#define FMR_OWNER_TYPE(owner) ((__u32)((__u64)owner >> 32))
+#define FMR_OWNER_CODE(owner) ((__u32)(((__u64)owner & 0xFFFFFFFFULL)))
+#define FMR_OWN_FREE FMR_OWNER(0, 1) /* free space */
+#define FMR_OWN_UNKNOWN FMR_OWNER(0, 2) /* unknown owner */
+#define FMR_OWN_METADATA FMR_OWNER(0, 3) /* metadata */
+
+#define FS_IOC_GETFSMAP _IOWR('X', 59, struct fsmap_head)
+#endif /* FS_IOC_GETFSMAP */
+
+#endif
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 9fdbf30a..056d34ec 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -118,7 +118,10 @@ typedef struct {
typedef struct {
u_int32_t a_version;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
acl_ea_entry a_entries[0];
+#pragma GCC diagnostic pop
} acl_ea_header;
static inline size_t acl_ea_size(int count)
@@ -863,8 +866,9 @@ static int op_readlink(const char *path, char *buf, size_t len)
len--;
if (inode.i_size < len)
len = inode.i_size;
- if (ext2fs_inode_data_blocks2(fs, &inode) ||
- (inode.i_flags & EXT4_INLINE_DATA_FL)) {
+ if (ext2fs_is_fast_symlink(&inode))
+ memcpy(buf, (char *)inode.i_block, len);
+ else {
/* big/inline symlink */
err = ext2fs_file_open(fs, ino, 0, &file);
@@ -888,9 +892,7 @@ out2:
ret = translate_error(fs, ino, err);
goto out;
}
- } else
- /* inline symlink */
- memcpy(buf, (char *)inode.i_block, len);
+ }
buf[len] = 0;
if (fs_writeable(fs)) {
@@ -910,7 +912,7 @@ static int op_mknod(const char *path, mode_t mode, dev_t dev)
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
ext2_filsys fs;
ext2_ino_t parent, child;
- char *temp_path = strdup(path);
+ char *temp_path;
errcode_t err;
char *node_name, a;
int filetype;
@@ -921,6 +923,7 @@ static int op_mknod(const char *path, mode_t mode, dev_t dev)
fs = ff->fs;
dbg_printf("%s: path=%s mode=0%o dev=0x%x\n", __func__, path, mode,
(unsigned int)dev);
+ temp_path = strdup(path);
if (!temp_path) {
ret = -ENOMEM;
goto out;
@@ -1037,7 +1040,7 @@ static int op_mkdir(const char *path, mode_t mode)
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
ext2_filsys fs;
ext2_ino_t parent, child;
- char *temp_path = strdup(path);
+ char *temp_path;
errcode_t err;
char *node_name, a;
struct ext2_inode_large inode;
@@ -1049,6 +1052,7 @@ static int op_mkdir(const char *path, mode_t mode)
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
dbg_printf("%s: path=%s mode=0%o\n", __func__, path, mode);
+ temp_path = strdup(path);
if (!temp_path) {
ret = -ENOMEM;
goto out;
@@ -1424,7 +1428,7 @@ static int op_symlink(const char *src, const char *dest)
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
ext2_filsys fs;
ext2_ino_t parent, child;
- char *temp_path = strdup(dest);
+ char *temp_path;
errcode_t err;
char *node_name, a;
struct ext2_inode_large inode;
@@ -1433,6 +1437,7 @@ static int op_symlink(const char *src, const char *dest)
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
dbg_printf("%s: symlink %s to %s\n", __func__, src, dest);
+ temp_path = strdup(dest);
if (!temp_path) {
ret = -ENOMEM;
goto out;
@@ -1769,7 +1774,7 @@ static int op_link(const char *src, const char *dest)
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
ext2_filsys fs;
- char *temp_path = strdup(dest);
+ char *temp_path;
errcode_t err;
char *node_name, a;
ext2_ino_t parent, ino;
@@ -1779,6 +1784,7 @@ static int op_link(const char *src, const char *dest)
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
dbg_printf("%s: src=%s dest=%s\n", __func__, src, dest);
+ temp_path = strdup(dest);
if (!temp_path) {
ret = -ENOMEM;
goto out;
@@ -2537,7 +2543,7 @@ static int op_listxattr(const char *path, char *names, size_t len)
ret = check_inum_access(fs, ino, R_OK);
if (ret)
- goto out2;
+ goto out;
err = ext2fs_xattrs_open(fs, ino, &h);
if (err) {
@@ -2650,12 +2656,6 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)),
goto out3;
}
- err = ext2fs_xattrs_write(h);
- if (err) {
- ret = translate_error(fs, ino, err);
- goto out3;
- }
-
ret = update_ctime(fs, ino, NULL);
out3:
if (cvalue != value)
@@ -2722,12 +2722,6 @@ static int op_removexattr(const char *path, const char *key)
goto out2;
}
- err = ext2fs_xattrs_write(h);
- if (err) {
- ret = translate_error(fs, ino, err);
- goto out2;
- }
-
ret = update_ctime(fs, ino, NULL);
out2:
err = ext2fs_xattrs_close(&h);
@@ -2835,7 +2829,7 @@ static int op_create(const char *path, mode_t mode, struct fuse_file_info *fp)
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
ext2_filsys fs;
ext2_ino_t parent, child;
- char *temp_path = strdup(path);
+ char *temp_path;
errcode_t err;
char *node_name, a;
int filetype;
@@ -2845,6 +2839,7 @@ static int op_create(const char *path, mode_t mode, struct fuse_file_info *fp)
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
dbg_printf("%s: path=%s mode=0%o\n", __func__, path, mode);
+ temp_path = strdup(path);
if (!temp_path) {
ret = -ENOMEM;
goto out;
@@ -3754,7 +3749,7 @@ int main(int argc, char *argv[])
fctx.err_fp = fopen(logfile, "a");
if (!fctx.err_fp) {
perror(logfile);
- goto out_nofs;
+ goto out;
}
} else
fctx.err_fp = stderr;
@@ -3775,12 +3770,13 @@ int main(int argc, char *argv[])
if (err) {
printf(_("%s: %s.\n"), fctx.device, error_message(err));
printf(_("Please run e2fsck -fy %s.\n"), fctx.device);
- goto out_nofs;
+ goto out;
}
fctx.fs = global_fs;
global_fs->priv_data = &fctx;
ret = 3;
+
if (ext2fs_has_feature_journal_needs_recovery(global_fs->super)) {
if (!fctx.ro) {
printf(_("%s: recovering journal\n"), fctx.device);
@@ -3864,12 +3860,12 @@ int main(int argc, char *argv[])
ret = 0;
out:
- err = ext2fs_close(global_fs);
- if (err)
- com_err(argv[0], err, "while closing fs");
- global_fs = NULL;
-out_nofs:
-
+ if (global_fs) {
+ err = ext2fs_close(global_fs);
+ if (err)
+ com_err(argv[0], err, "while closing fs");
+ global_fs = NULL;
+ }
return ret;
}
@@ -3901,6 +3897,7 @@ static int __translate_error(ext2_filsys fs, errcode_t err, ext2_ino_t ino,
break;
case EXT2_ET_DIR_NO_SPACE:
is_err = 1;
+ /* fallthrough */
case EXT2_ET_TOOSMALL:
case EXT2_ET_BLOCK_ALLOC_FAIL:
case EXT2_ET_INODE_ALLOC_FAIL:
@@ -3947,11 +3944,11 @@ no_translation:
if (ino)
fprintf(ff->err_fp, "FUSE2FS (%s): %s (inode #%d) at %s:%d.\n",
- fs && fs->device_name ? fs->device_name : "???",
+ fs->device_name ? fs->device_name : "???",
error_message(err), ino, file, line);
else
fprintf(ff->err_fp, "FUSE2FS (%s): %s at %s:%d.\n",
- fs && fs->device_name ? fs->device_name : "???",
+ fs->device_name ? fs->device_name : "???",
error_message(err), file, line);
fflush(ff->err_fp);
diff --git a/misc/logsave.8.in b/misc/logsave.8.in
index f0fbe412..cc3ffde3 100644
--- a/misc/logsave.8.in
+++ b/misc/logsave.8.in
@@ -1,7 +1,7 @@
.\" -*- nroff -*-
.\" Copyright 2003 by Theodore Ts'o. All Rights Reserved.
.\" This file may be copied under the terms of the GNU Public License.
-.\"
+.\"
.TH LOGSAVE 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
.SH NAME
logsave \- save the output of a command in a logfile
@@ -15,17 +15,17 @@ logsave \- save the output of a command in a logfile
The
.B logsave
program will execute
-.I cmd_prog
+.I cmd_prog
with the specified argument(s), and save a copy of its output to
.IR logfile .
If the containing directory for
.I logfile
-does not exist,
+does not exist,
.B logsave
will accumulate the output in memory until it can be written out.
A copy of the output will also be written to standard output.
.PP
-If
+If
.I cmd_prog
is a single hyphen ('-'), then instead of executing a program,
.B logsave
@@ -33,20 +33,20 @@ will take its input from standard input and save it in
.I logfile
.PP
.B logsave
-is useful for saving the output of initial boot scripts
-until the /var partition is mounted, so the output can be written to
+is useful for saving the output of initial boot scripts
+until the /var partition is mounted, so the output can be written to
/var/log.
.SH OPTIONS
.TP
.B \-a
-This option will cause the output to be appended to
+This option will cause the output to be appended to
.IR logfile ,
instead of replacing its current contents.
.TP
.B \-s
-This option will cause
+This option will cause
.B logsave
-to skip writing to the log file text which is bracketed with a control-A
+to skip writing to the log file text which is bracketed with a control-A
(ASCII 001 or Start of Header) and control-B (ASCII 002 or Start of
Text). This allows progress bar information to be visible to the user
on the console, while not being written to the log file.
diff --git a/misc/logsave.c b/misc/logsave.c
index 6a624dea..96b6d8e0 100644
--- a/misc/logsave.c
+++ b/misc/logsave.c
@@ -52,7 +52,7 @@ static void usage(char *progname)
/*
* Helper function that does the right thing if write returns a
- * partial write, or an EGAIN/EINTR error.
+ * partial write, or an EAGAIN/EINTR error.
*/
static int write_all(int fd, const char *buf, size_t count)
{
diff --git a/misc/lsattr.1.in b/misc/lsattr.1.in
index bb15769e..4d02a95a 100644
--- a/misc/lsattr.1.in
+++ b/misc/lsattr.1.in
@@ -30,8 +30,8 @@ List all files in directories, including files that start with `.'.
List directories like other files, rather than listing their contents.
.TP
.B \-l
-Print the options using a long names instead of a single
-character abbreviation.
+Print the options using long names instead of single
+character abbreviations.
.TP
.B \-p
List the file's project number.
diff --git a/misc/mk_hugefiles.c b/misc/mk_hugefiles.c
index 79d3ae56..76693faf 100644
--- a/misc/mk_hugefiles.c
+++ b/misc/mk_hugefiles.c
@@ -68,7 +68,7 @@ static char *fn_buf;
static char *fn_numbuf;
int zero_hugefile = 1;
-#define SYSFS_PATH_LEN 256
+#define SYSFS_PATH_LEN 300
typedef char sysfs_path_t[SYSFS_PATH_LEN];
#ifndef HAVE_SNPRINTF
@@ -264,7 +264,12 @@ static errcode_t mk_hugefile(ext2_filsys fs, blk64_t num,
{
errcode_t retval;
+ blk64_t lblk, bend = 0;
+ __u64 size;
+ blk64_t left;
+ blk64_t count = 0;
struct ext2_inode inode;
+ ext2_extent_handle_t handle;
retval = ext2fs_new_inode(fs, 0, LINUX_S_IFREG, NULL, ino);
if (retval)
@@ -284,19 +289,93 @@ static errcode_t mk_hugefile(ext2_filsys fs, blk64_t num,
ext2fs_inode_alloc_stats2(fs, *ino, +1, 0);
- if (ext2fs_has_feature_extents(fs->super))
- inode.i_flags |= EXT4_EXTENTS_FL;
- retval = ext2fs_fallocate(fs,
- EXT2_FALLOCATE_FORCE_INIT |
- EXT2_FALLOCATE_ZERO_BLOCKS,
- *ino, &inode, goal, 0, num);
+ retval = ext2fs_extent_open2(fs, *ino, &inode, &handle);
if (retval)
return retval;
- retval = ext2fs_inode_size_set(fs, &inode, num * fs->blocksize);
+
+ /*
+ * We don't use ext2fs_fallocate() here because hugefiles are
+ * designed to be physically contiguous (if the block group
+ * descriptors are configured to be in a single block at the
+ * beginning of the file system, by using the
+ * packed_meta_blocks layout), with the extent tree blocks
+ * allocated near the beginning of the file system.
+ */
+ lblk = 0;
+ left = num ? num : 1;
+ while (left) {
+ blk64_t pblk, end;
+ blk64_t n = left;
+
+ retval = ext2fs_find_first_zero_block_bitmap2(fs->block_map,
+ goal, ext2fs_blocks_count(fs->super) - 1, &end);
+ if (retval)
+ goto errout;
+ goal = end;
+
+ retval = ext2fs_find_first_set_block_bitmap2(fs->block_map, goal,
+ ext2fs_blocks_count(fs->super) - 1, &bend);
+ if (retval == ENOENT) {
+ bend = ext2fs_blocks_count(fs->super);
+ if (num == 0)
+ left = 0;
+ }
+ if (!num || bend - goal < left)
+ n = bend - goal;
+ pblk = goal;
+ if (num)
+ left -= n;
+ goal += n;
+ count += n;
+ ext2fs_block_alloc_stats_range(fs, pblk, n, +1);
+
+ if (zero_hugefile) {
+ blk64_t ret_blk;
+ retval = ext2fs_zero_blocks2(fs, pblk, n,
+ &ret_blk, NULL);
+
+ if (retval)
+ com_err(program_name, retval,
+ _("while zeroing block %llu "
+ "for hugefile"), ret_blk);
+ }
+
+ while (n) {
+ blk64_t l = n;
+ struct ext2fs_extent newextent;
+
+ if (l > EXT_INIT_MAX_LEN)
+ l = EXT_INIT_MAX_LEN;
+
+ newextent.e_len = l;
+ newextent.e_pblk = pblk;
+ newextent.e_lblk = lblk;
+ newextent.e_flags = 0;
+
+ retval = ext2fs_extent_insert(handle,
+ EXT2_EXTENT_INSERT_AFTER, &newextent);
+ if (retval)
+ return retval;
+ pblk += l;
+ lblk += l;
+ n -= l;
+ }
+ }
+
+ retval = ext2fs_read_inode(fs, *ino, &inode);
if (retval)
- return retval;
+ goto errout;
+
+ retval = ext2fs_iblk_add_blocks(fs, &inode,
+ count / EXT2FS_CLUSTER_RATIO(fs));
+ if (retval)
+ goto errout;
+ size = (__u64) count * fs->blocksize;
+ retval = ext2fs_inode_size_set(fs, &inode, size);
+ if (retval)
+ goto errout;
- retval = ext2fs_write_inode(fs, *ino, &inode);
+ retval = ext2fs_write_new_inode(fs, *ino, &inode);
if (retval)
goto errout;
@@ -314,7 +393,13 @@ retry:
goto retry;
}
+ if (retval)
+ goto errout;
+
errout:
+ if (handle)
+ ext2fs_extent_free(handle);
+
return retval;
}
@@ -499,8 +584,6 @@ errcode_t mk_hugefiles(ext2_filsys fs, const char *device_name)
printf(_("with %llu blocks each"), num_blocks);
fputs(": ", stdout);
}
- if (num_blocks == 0)
- num_blocks = ext2fs_blocks_count(fs->super) - goal;
for (i=0; i < num_files; i++) {
ext2_ino_t ino;
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 9cb783fa..603e37e5 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -18,6 +18,10 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
.I block-size
]
[
+.B \-C
+.I cluster-size
+]
+[
.B \-d
.I root-directory
]
@@ -25,10 +29,6 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
.B \-D
]
[
-.B \-f
-.I fragment-size
-]
-[
.B \-g
.I blocks-per-group
]
@@ -338,6 +338,15 @@ small risk if the system crashes before the journal has been overwritten
entirely one time. If the option value is omitted, it defaults to 1 to
enable lazy journal inode zeroing.
.TP
+.BI no_copy_xattrs
+Normally
+.B mke2fs
+will copy the extended attributes of the files in the directory
+hierarchy specified via the (optional)
+.B \-d
+option. This will disable the copy and leaves the files in the newly
+created file system without any extended attributes.
+.TP
.BI num_backup_sb= <0|1|2>
If the
.B sparse_super2
@@ -389,9 +398,6 @@ option is not specified is both user and group quotas. If the project
feature is enabled that project quotas will be initialized as well.
.RE
.TP
-.BI \-f " fragment-size"
-Specify the size of fragments in bytes.
-.TP
.B \-F
Force
.B mke2fs
@@ -424,7 +430,7 @@ Specify the number of block groups that will be packed together to
create a larger virtual block group (or "flex_bg group") in an
ext4 filesystem. This improves meta-data locality and performance
on meta-data heavy workloads. The number of groups must be a power
-of 2 and may only be specified if the
+of 2 and may only be specified if the
.B flex_bg
filesystem feature is enabled.
.TP
@@ -440,7 +446,7 @@ be smaller than the blocksize of the filesystem, since in that case more
inodes would be made than can ever be used. Be warned that it is not
possible to change this ratio on a filesystem after it is created, so be
careful deciding the correct value for this parameter. Note that resizing
-a filesystem changes the numer of inodes to maintain this ratio.
+a filesystem changes the number of inodes to maintain this ratio.
.TP
.BI \-I " inode-size"
Specify the size of each inode in bytes.
@@ -459,7 +465,7 @@ earlier vendor kernels it is possible to utilize inodes larger than
extended attributes for improved performance.
Extended attributes
stored in large inodes are not visible with older kernels, and such
-filesystems will not be mountable with 2.4 kernels at all.
+filesystems will not be mountable with 2.4 kernels at all.
.IP
The default inode size is controlled by the
.BR mke2fs.conf (5)
@@ -745,7 +751,25 @@ will use the default filesystem type
.IR default .
.TP
.BI \-U " UUID"
-Create the filesystem with the specified UUID.
+Set the universally unique identifier (UUID) of the filesystem to
+.IR UUID .
+The format of the UUID is a series of hex digits separated by hyphens,
+like this:
+"c1b9d5a2-f162-11cf-9ece-0020afc76f16".
+The
+.I UUID
+parameter may also be one of the following:
+.RS 1.2i
+.TP
+.I clear
+clear the filesystem UUID
+.TP
+.I random
+generate a new randomly-generated UUID
+.TP
+.I time
+generate a new time-based UUID
+.RE
.TP
.B \-v
Verbose execution.
@@ -781,6 +805,11 @@ If set to non-zero integer value, its value is used to determine first meta
block group. This is mostly for debugging purposes.
.TP
.BI MKE2FS_DEVICE_SECTSIZE
+If set to non-zero integer value, its value is used to determine logical
+sector size of the
+.IR device .
+.TP
+.BI MKE2FS_DEVICE_PHYS_SECTSIZE
If set to non-zero integer value, its value is used to determine physical
sector size of the
.IR device .
@@ -792,14 +821,6 @@ mount count or check interval.
This version of
.B mke2fs
has been written by Theodore Ts'o <tytso@mit.edu>.
-.SH BUGS
-.B mke2fs
-accepts the
-.B \-f
-option but currently ignores it because the second
-extended file system does not support fragments yet.
-.br
-There may be other ones. Please, report them to the author.
.SH AVAILABILITY
.B mke2fs
is part of the e2fsprogs package and is available from
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 9ba16b91..b23ea766 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -16,7 +16,7 @@
* enforced (but it's not much fun on a character device :-).
*/
-#define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX */
+#define _XOPEN_SOURCE 600
#include "config.h"
#include <stdio.h>
@@ -95,6 +95,7 @@ int journal_size;
int journal_flags;
static int lazy_itable_init;
static int packed_meta_blocks;
+int no_copy_xattrs;
static char *bad_blocks_filename = NULL;
static __u32 fs_stride;
/* Initialize usr/grp quotas by default */
@@ -117,7 +118,6 @@ const char *src_root_dir; /* Copy files from the specified directory */
static char *undo_file;
static int android_sparse_file; /* -E android_sparse */
-static char *android_sparse_params;
static profile_t profile;
@@ -360,9 +360,15 @@ static void write_reserved_inodes(ext2_filsys fs)
exit(1);
}
- for (ino = 1; ino < EXT2_FIRST_INO(fs->super); ino++)
- ext2fs_write_inode_full(fs, ino, inode,
- EXT2_INODE_SIZE(fs->super));
+ for (ino = 1; ino < EXT2_FIRST_INO(fs->super); ino++) {
+ retval = ext2fs_write_inode_full(fs, ino, inode,
+ EXT2_INODE_SIZE(fs->super));
+ if (retval) {
+ com_err("ext2fs_write_inode_full", retval,
+ _("while writing reserved inodes"));
+ exit(1);
+ }
+ }
ext2fs_free_mem(&inode);
}
@@ -441,9 +447,9 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
}
if (sync_kludge) {
if (sync_kludge == 1)
- sync();
+ io_channel_flush(fs->io);
else if ((i % sync_kludge) == 0)
- sync();
+ io_channel_flush(fs->io);
}
}
ext2fs_numeric_progress_close(fs, &progress,
@@ -638,6 +644,7 @@ write_superblock:
retval = io_channel_write_blk64(fs->io,
fs->super->s_first_data_block+1,
1, buf);
+ (void) ext2fs_free_mem(&buf);
if (retval) {
com_err("create_journal_dev", retval, "%s",
_("while writing journal superblock"));
@@ -874,6 +881,9 @@ static void parse_extended_opts(struct ext2_super_block *param,
r_usage++;
continue;
}
+ } else if (strcmp(token, "no_copy_xattrs") == 0) {
+ no_copy_xattrs = 1;
+ continue;
} else if (strcmp(token, "num_backup_sb") == 0) {
if (!arg) {
r_usage++;
@@ -1097,11 +1107,13 @@ static __u32 ok_features[3] = {
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|
EXT2_FEATURE_INCOMPAT_META_BG|
EXT4_FEATURE_INCOMPAT_FLEX_BG|
+ EXT4_FEATURE_INCOMPAT_EA_INODE|
EXT4_FEATURE_INCOMPAT_MMP |
EXT4_FEATURE_INCOMPAT_64BIT|
EXT4_FEATURE_INCOMPAT_INLINE_DATA|
EXT4_FEATURE_INCOMPAT_ENCRYPT |
- EXT4_FEATURE_INCOMPAT_CSUM_SEED,
+ EXT4_FEATURE_INCOMPAT_CSUM_SEED |
+ EXT4_FEATURE_INCOMPAT_LARGEDIR,
/* R/O compat */
EXT2_FEATURE_RO_COMPAT_LARGE_FILE|
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
@@ -1159,7 +1171,7 @@ struct str_list {
static errcode_t init_list(struct str_list *sl)
{
sl->num = 0;
- sl->max = 0;
+ sl->max = 1;
sl->list = malloc((sl->max+1) * sizeof(char *));
if (!sl->list)
return ENOMEM;
@@ -1523,10 +1535,6 @@ static void PRS(int argc, char *argv[])
}
putenv (newpath);
- tmp = getenv("MKE2FS_SYNC");
- if (tmp)
- sync_kludge = atoi(tmp);
-
/* Determine the system page size if possible */
#ifdef HAVE_SYSCONF
#if (!defined(_SC_PAGESIZE) && defined(_SC_PAGE_SIZE))
@@ -1889,6 +1897,12 @@ profile_error:
if (optind < argc)
usage();
+ profile_get_integer(profile, "options", "sync_kludge", 0, 0,
+ &sync_kludge);
+ tmp = getenv("MKE2FS_SYNC");
+ if (tmp)
+ sync_kludge = atoi(tmp);
+
profile_get_integer(profile, "options", "proceed_delay", 0, 0,
&proceed_delay);
@@ -2010,6 +2024,7 @@ profile_error:
ext2fs_clear_feature_filetype(&fs_param);
ext2fs_clear_feature_huge_file(&fs_param);
ext2fs_clear_feature_metadata_csum(&fs_param);
+ ext2fs_clear_feature_ea_inode(&fs_param);
}
edit_feature(fs_features ? fs_features : tmp,
&fs_param.s_feature_compat);
@@ -2035,6 +2050,11 @@ profile_error:
"metadata_csum feature.\n"));
exit(1);
}
+ if (ext2fs_has_feature_ea_inode(&fs_param)) {
+ fprintf(stderr, "%s", _("The HURD does not support the "
+ "ea_inode feature.\n"));
+ exit(1);
+ }
}
/* Get the hardware sector sizes, if available */
@@ -2115,10 +2135,28 @@ profile_error:
EXT2_BLOCK_SIZE(&fs_param));
exit(1);
}
+ /*
+ * Guard against group descriptor count overflowing... Mostly to avoid
+ * strange results for absurdly large devices.
+ */
+ if (fs_blocks_count > ((1ULL << (fs_param.s_log_block_size + 3 + 32)) - 1)) {
+ fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s "
+ "too big to create\n\t"
+ "a filesystem using a blocksize of %d.\n"),
+ program_name, fs_blocks_count, device_name,
+ EXT2_BLOCK_SIZE(&fs_param));
+ exit(1);
+ }
ext2fs_blocks_count_set(&fs_param, fs_blocks_count);
if (ext2fs_has_feature_journal_dev(&fs_param)) {
+ int i;
+
+ for (i=0; fs_types[i]; i++) {
+ free(fs_types[i]);
+ fs_types[i] = 0;
+ }
fs_types[0] = strdup("journal");
fs_types[1] = 0;
}
@@ -2326,6 +2364,26 @@ profile_error:
(unsigned long long) fs_blocks_count);
}
+ if (quotatype_bits & QUOTA_PRJ_BIT)
+ ext2fs_set_feature_project(&fs_param);
+
+ if (ext2fs_has_feature_project(&fs_param)) {
+ quotatype_bits |= QUOTA_PRJ_BIT;
+ if (inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
+ com_err(program_name, 0,
+ _("%d byte inodes are too small for "
+ "project quota"),
+ inode_size);
+ exit(1);
+ }
+ if (inode_size == 0) {
+ inode_size = get_int_from_profile(fs_types,
+ "inode_size", 0);
+ if (inode_size <= EXT2_GOOD_OLD_INODE_SIZE*2)
+ inode_size = EXT2_GOOD_OLD_INODE_SIZE*2;
+ }
+ }
+
/* Don't allow user to set both metadata_csum and uninit_bg bits. */
if (ext2fs_has_feature_metadata_csum(&fs_param) &&
ext2fs_has_feature_gdt_csum(&fs_param))
@@ -2426,19 +2484,6 @@ profile_error:
exit(1);
}
- /*
- * If inode size is 128 and project quota is enabled, we need
- * to notify users that project ID will never be useful.
- */
- if (ext2fs_has_feature_project(&fs_param) &&
- fs_param.s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
- com_err(program_name, 0,
- _("%d byte inodes are too small for project quota; "
- "specify larger size"),
- fs_param.s_inode_size);
- exit(1);
- }
-
/* Make sure number of inodes specified will fit in 32 bits */
if (num_inodes == 0) {
unsigned long long n;
@@ -2728,7 +2773,7 @@ static int create_quota_inodes(ext2_filsys fs)
quota_ctx_t qctx;
errcode_t retval;
- retval = quota_init_context(&qctx, fs, QUOTA_ALL_BIT);
+ retval = quota_init_context(&qctx, fs, quotatype_bits);
if (retval) {
com_err(program_name, retval,
_("while initializing quota context"));
@@ -2835,17 +2880,19 @@ int main (int argc, char *argv[])
if (!quiet)
flags |= EXT2_FLAG_PRINT_PROGRESS;
if (android_sparse_file) {
- android_sparse_params = malloc(PATH_MAX + 32);
+ char *android_sparse_params = malloc(strlen(device_name) + 48);
+
if (!android_sparse_params) {
com_err(program_name, ENOMEM, "%s",
_("in malloc for android_sparse_params"));
exit(1);
}
- snprintf(android_sparse_params, PATH_MAX + 32, "(%s):%u:%u",
+ sprintf(android_sparse_params, "(%s):%u:%u",
device_name, fs_param.s_blocks_count,
1024 << fs_param.s_log_block_size);
retval = ext2fs_initialize(android_sparse_params, flags,
&fs_param, sparse_io_manager, &fs);
+ free(android_sparse_params);
} else
retval = ext2fs_initialize(device_name, flags, &fs_param,
io_ptr, &fs);
@@ -2883,7 +2930,7 @@ int main (int argc, char *argv[])
if (ext2fs_has_feature_csum_seed(fs->super) &&
!ext2fs_has_feature_metadata_csum(fs->super)) {
printf("%s", _("The metadata_csum_seed feature "
- "requres the metadata_csum feature.\n"));
+ "requires the metadata_csum feature.\n"));
exit(1);
}
@@ -2935,7 +2982,14 @@ int main (int argc, char *argv[])
* Parse or generate a UUID for the filesystem
*/
if (fs_uuid) {
- if (uuid_parse(fs_uuid, fs->super->s_uuid) !=0) {
+ if ((strcasecmp(fs_uuid, "null") == 0) ||
+ (strcasecmp(fs_uuid, "clear") == 0)) {
+ uuid_clear(fs->super->s_uuid);
+ } else if (strcasecmp(fs_uuid, "time") == 0) {
+ uuid_generate_time(fs->super->s_uuid);
+ } else if (strcasecmp(fs_uuid, "random") == 0) {
+ uuid_generate(fs->super->s_uuid);
+ } else if (uuid_parse(fs_uuid, fs->super->s_uuid) != 0) {
com_err(device_name, 0, "could not parse UUID: %s\n",
fs_uuid);
exit(1);
@@ -3223,8 +3277,6 @@ no_journal:
if (ext2fs_has_feature_bigalloc(&fs_param))
fix_cluster_bg_counts(fs);
- if (ext2fs_has_feature_project(&fs_param))
- quotatype_bits |= QUOTA_PRJ_BIT;
if (ext2fs_has_feature_quota(&fs_param))
create_quota_inodes(fs);
@@ -3253,8 +3305,9 @@ no_journal:
max_mnt_count = fs->super->s_max_mnt_count;
retval = ext2fs_close_free(&fs);
if (retval) {
- fprintf(stderr, "%s",
- _("\nWarning, had trouble writing out superblocks."));
+ com_err(program_name, retval, "%s",
+ _("while writing out and closing file system"));
+ retval = 1;
} else if (!quiet) {
printf("%s", _("done\n\n"));
if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
diff --git a/misc/mke2fs.conf.5.in b/misc/mke2fs.conf.5.in
index 1ce0f5eb..c086b411 100644
--- a/misc/mke2fs.conf.5.in
+++ b/misc/mke2fs.conf.5.in
@@ -78,7 +78,7 @@ used by
.BR mke2fs (8).
In general, these defaults may be overridden by a definition in the
.B fs_types
-stanza, or by an command-line option provided by the user.
+stanza, or by a command-line option provided by the user.
.TP
.I [fs_types]
Contains relations which define defaults that should be used for specific
@@ -89,64 +89,35 @@ the
options to
.BR mke2fs (8),
respectively.
+.TP
+.I [devices]
+Contains relations which define defaults for specific devices.
.SH THE [options] STANZA
The following relations are defined in the
.I [options]
stanza.
.TP
.I proceed_delay
-If this relation is set to a positive integer, then if mke2fs will
-proceed after waiting
+If this relation is set to a positive integer, then mke2fs will
+wait
.I proceed_delay
-seconds, after asking the user for permission to proceed, even if the
+seconds after asking the user for permission to proceed and
+then continue, even if the
user has not answered the question. Defaults to 0, which means to wait
until the user answers the question one way or another.
+.TP
+.I sync_kludge
+If this relation is set to a positive integer, then while writing the
+inode table, mke2fs will request the operating system flush out pending
+writes to initialize the inode table every
+.I sync_kludge
+block groups. This is needed to work around buggy kernels that don't
+handle writeback throttling correctly.
.SH THE [defaults] STANZA
The following relations are defined in the
.I [defaults]
stanza.
.TP
-.I base_features
-This relation specifies the filesystems features which are enabled in
-newly created filesystems. It may be overridden by the
-.I base_features
-relation found in the filesystem or usage type subsection of
-the
-.I [fs_types]
-stanza.
-.TP
-.I default_features
-This relation specifies a set of features that should be added or
-removed to the features listed in the
-.I base_features
-relation. It may be overridden by the filesystem-specific
-.I default_features
-in the filesystem or usage type subsection of
-.IR [fs_types] ,
-and by the
-.B -O
-command-line option
-to
-.BR mke2fs (8).
-.TP
-.I enable_periodic_fsck
-This boolean relation specifies whether periodic filesystem checks should be
-enforced at boot time. If set to true, checks will be forced every
-180 days, or after a random number of mounts. These values may
-be changed later via the
-.B -i
-and
-.B -c
-command-line options to
-.BR tune2fs (8).
-.TP
-.I force_undo
-This boolean relation, if set to a value of true, forces
-.B mke2fs
-to always try to create an undo file, even if the undo file might be
-huge and it might extend the time to create the filesystem image
-because the inode table isn't being initialized lazily.
-.TP
.I fs_type
This relation specifies the default filesystem type if the user does not
specify it via the
@@ -301,6 +272,17 @@ whose subsections define the
relation, only the last will be used by
.BR mke2fs (8).
.TP
+.I enable_periodic_fsck
+This boolean relation specifies whether periodic filesystem checks should be
+enforced at boot time. If set to true, checks will be forced every
+180 days, or after a random number of mounts. These values may
+be changed later via the
+.B -i
+and
+.B -c
+command-line options to
+.BR tune2fs (8).
+.TP
.I errors
Change the behavior of the kernel code when errors are detected.
In all cases, a filesystem error will cause
@@ -333,6 +315,13 @@ a named feature. Each
relation specified in the fs_types list will be applied in the order
found in the fs_types list.
.TP
+.I force_undo
+This boolean relation, if set to a value of true, forces
+.B mke2fs
+to always try to create an undo file, even if the undo file might be
+huge and it might extend the time to create the filesystem image
+because the inode table isn't being initialized lazily.
+.TP
.I default_features
This relation specifies set of features which should be enabled or
disabled after applying the features listed in the
@@ -375,6 +364,16 @@ initialization noticeably, but it requires the kernel to finish
initializing the filesystem in the background when the filesystem is
first mounted.
.TP
+.I lazy_journal_init
+This boolean relation specifies whether the journal inode should be
+lazily initialized. It only has meaning if the has_journal feature is
+enabled. If lazy_journal_init is true, the journal inode will not be
+fully zeroed out by
+.BR mke2fs .
+This speeds up filesystem initialization noticeably, but carries some
+small risk if the system crashes before the journal has been overwritten
+entirely one time.
+.TP
.I journal_location
This relation specifies the location of the journal.
.TP
@@ -384,7 +383,7 @@ This relation indicates whether file systems with the
feature enabled should be created with 0, 1, or 2 backup superblocks.
.TP
.I packed_meta_blocks
-This boolean relation specifes whether the allocation bitmaps, inode
+This boolean relation specifies whether the allocation bitmaps, inode
table, and journal should be located at the beginning of the file system.
.TP
.I inode_ratio
@@ -441,7 +440,16 @@ command line option to
.TP
.I make_hugefiles
This boolean relation enables the creation of pre-allocated files as
-part of formatting the file system.
+part of formatting the file system. The extent tree blocks for these
+pre-allocated files will be placed near the beginning of the file
+system, so that if all of the other metadata blocks are also configured
+to be placed near the beginning of the file system (by disabling the
+backup superblocks, using the packed_meta_blocks option, etc.), the data
+blocks of the pre-allocated files will be contiguous.
+.TP
+.I hugefiles_dir
+This relation specifies the directory where huge files are created,
+relative to the filesystem root.
.TP
.I hugefiles_uid
This relation controls the user ownership for all of the files and
diff --git a/misc/mke2fs.conf.in b/misc/mke2fs.conf.in
index 78fe50ac..01e35cf8 100644
--- a/misc/mke2fs.conf.in
+++ b/misc/mke2fs.conf.in
@@ -11,14 +11,9 @@
features = has_journal
}
ext4 = {
- features = has_journal,extent,huge_file,flex_bg,64bit,dir_nlink,extra_isize
+ features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize
inode_size = 256
}
- ext4dev = {
- features = has_journal,extent,huge_file,flex_bg,inline_data,64bit,dir_nlink,extra_isize
- inode_size = 256
- options = test_fs=1
- }
small = {
blocksize = 1024
inode_size = 128
diff --git a/misc/mklost+found.8.in b/misc/mklost+found.8.in
index 712740c8..ba0c1c18 100644
--- a/misc/mklost+found.8.in
+++ b/misc/mklost+found.8.in
@@ -36,7 +36,7 @@ maintained by Theodore Ts'o <tytso@alum.mit.edu>.
There are none :-)
.SH AVAILABILITY
.B mklost+found
-is part of the e2fsprogs package and is available from
+is part of the e2fsprogs package and is available from
http://e2fsprogs.sourceforge.net.
.SH SEE ALSO
.BR e2fsck (8),
diff --git a/misc/mklost+found.c b/misc/mklost+found.c
index c0613578..14311877 100644
--- a/misc/mklost+found.c
+++ b/misc/mklost+found.c
@@ -31,8 +31,8 @@
int main (int argc, char ** argv)
{
- char name [EXT2_NAME_LEN];
- char path [sizeof (LPF) + 1 + 256];
+ char name[EXT2_NAME_LEN + 2];
+ char path[sizeof (LPF) + 1 + 256];
struct stat st;
int i, j;
int d;
diff --git a/misc/partinfo.c b/misc/partinfo.c
index 2b69c896..b79d1839 100644
--- a/misc/partinfo.c
+++ b/misc/partinfo.c
@@ -18,7 +18,9 @@
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
+#include <string.h>
#include "support/nls-enable.h"
+#include "et/com_err.h"
#if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
#define BLKGETSIZE _IO(0x12,96) /* return device size */
diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in
index fc326a1c..740d1661 100644
--- a/misc/tune2fs.8.in
+++ b/misc/tune2fs.8.in
@@ -45,18 +45,10 @@ tune2fs \- adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
.RI [^]mount-options [,...]
]
[
-.B \-p
-.I mmp_update_interval
-]
-[
.B \-r
.I reserved-blocks-count
]
[
-.B \-s
-.I sparse-super-flag
-]
-[
.B \-u
.I user
]
@@ -74,14 +66,14 @@ tune2fs \- adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
]
[
.B \-L
-.I volume-name
+.I volume-label
]
[
.B \-M
.I last-mounted-directory
]
[
-.B \-O
+.B \-O
.RI [^] feature [,...]
]
[
@@ -103,8 +95,8 @@ tune2fs \- adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems
device
.SH DESCRIPTION
.BI tune2fs
-allows the system administrator to adjust various tunable filesystem
-parameters on Linux ext2, ext3, or ext4 filesystems. The current values
+allows the system administrator to adjust various tunable filesystem
+parameters on Linux ext2, ext3, or ext4 filesystems. The current values
of these options can be displayed by using the
.B -l
option to
@@ -116,16 +108,16 @@ program.
The
.I device
specifier can either be a filename (i.e., /dev/sda1), or a LABEL or UUID
-specifier: "\fBLABEL=\fIvolume-name\fR" or "\fBUUID=\fIuuid\fR". (i.e.,
+specifier: "\fBLABEL=\fIvolume-label\fR" or "\fBUUID=\fIuuid\fR". (i.e.,
LABEL=home or UUID=e40486c6-84d5-4f2f-b99c-032281799c9d).
.SH OPTIONS
.TP
.BI \-c " max-mount-counts"
-Adjust the number of mounts after which the filesystem will be checked by
-.BR e2fsck (8).
+Adjust the number of mounts after which the filesystem will be checked by
+.BR e2fsck (8).
If
.I max-mount-counts
-is 0 or \-1, the number of times the filesystem is mounted will be disregarded
+is 0 or \-1, the number of times the filesystem is mounted will be disregarded
by
.BR e2fsck (8)
and the kernel.
@@ -134,7 +126,9 @@ Staggering the mount-counts at which filesystems are forcibly
checked will avoid all filesystems being checked at one time
when using journaled filesystems.
.sp
-You should strongly consider the consequences of disabling
+Mount-count-dependent checking is disabled by default to avoid
+unanticipated long reboots while e2fsck does its work. However,
+you may wish to consider the consequences of disabling
mount-count-dependent checking entirely. Bad disk drives, cables,
memory, and kernel bugs could all corrupt a filesystem without
marking the filesystem dirty or in error. If you are using
@@ -152,10 +146,10 @@ option for time-dependent checking.
.BI \-C " mount-count"
Set the number of times the filesystem has been mounted.
If set to a greater value than the max-mount-counts parameter
-set by the
+set by the
.B \-c
option,
-.BR e2fsck (8)
+.BR e2fsck (8)
will check the filesystem at the next reboot.
.TP
.BI \-e " error-behavior"
@@ -254,12 +248,12 @@ using production-level filesystem code.
.RE
.TP
.B \-f
-Force the tune2fs operation to complete even in the face of errors. This
-option is useful when removing the
+Force the tune2fs operation to complete even in the face of errors. This
+option is useful when removing the
.B has_journal
-filesystem feature from a filesystem which has
+filesystem feature from a filesystem which has
an external journal (or is corrupted
-such that it appears to have an external journal), but that
+such that it appears to have an external journal), but that
external journal is not available. If the filesystem appears to require
journal replay, the
.B \-f
@@ -272,13 +266,13 @@ severe data loss and filesystem corruption.
.TP
.BI \-g " group"
Set the group which can use the reserved filesystem blocks.
-The
+The
.I group
parameter can be a numerical gid or a group name. If a group name is given,
it is converted to a numerical gid before it is stored in the superblock.
.TP
.B \-i " \fIinterval-between-checks\fR[\fBd\fR|\fBm\fR|\fBw\fR]"
-Adjust the maximal time between two filesystem checks.
+Adjust the maximal time between two filesystem checks.
No suffix or
.B d
will interpret the number
@@ -289,15 +283,10 @@ as months, and
.B w
as weeks. A value of zero will disable the time-dependent checking.
.sp
-It is strongly recommended that either
+There are pros and cons to disabling these periodic checks; see the
+discussion under the
.B \-c
-(mount-count-dependent) or
-.B \-i
-(time-dependent) checking be enabled to force periodic full
-.BR e2fsck (8)
-checking of the filesystem. Failure to do so may lead to filesystem
-corruption (due to bad disks, cables, memory, or kernel bugs) going
-unnoticed, ultimately resulting in data loss or corruption.
+(mount-count-dependent check) option for details.
.TP
.B \-I
Change the inode size used by the file system. This requires rewriting
@@ -309,10 +298,10 @@ corrupted and data lost if it is interrupted while in the middle of
converting the file system.
.TP
.B \-j
-Add an ext3 journal to the filesystem. If the
+Add an ext3 journal to the filesystem. If the
.B \-J
option is not specified, the default journal parameters will be used to create
-an appropriately sized journal (given the size of the filesystem)
+an appropriately sized journal (given the size of the filesystem)
stored within the filesystem. Note that you must be using a kernel
which has ext3 support in order to actually make use of the journal.
.IP
@@ -324,9 +313,9 @@ the only safe way to create the journal inode while the filesystem is
mounted. While the ext3 journal is visible, it is not safe to
delete it, or modify it while the filesystem is mounted; for this
reason the file is marked immutable.
-While checking unmounted filesystems,
+While checking unmounted filesystems,
.BR e2fsck (8)
-will automatically move
+will automatically move
.B .journal
files to the invisible, reserved journal inode. For all filesystems
except for the root filesystem, this should happen automatically and
@@ -337,7 +326,7 @@ must be run from a rescue floppy in order to effect this transition.
.IP
On some distributions, such as Debian, if an initial ramdisk is used,
the initrd scripts will automatically convert an ext2 root filesystem
-to ext3 if the
+to ext3 if the
.BR /etc/fstab
file specifies the ext3 filesystem for the root filesystem in order to
avoid requiring the use of a rescue floppy to add an ext3 journal to
@@ -368,10 +357,10 @@ beginning of the file system.
@JDEV@.BI device= external-journal
@JDEV@Attach the filesystem to the journal block device located on
@JDEV@.IR external-journal .
-@JDEV@The external
+@JDEV@The external
@JDEV@journal must have been already created using the command
@JDEV@.IP
-@JDEV@.B mke2fs -O journal_dev
+@JDEV@.B mke2fs -O journal_dev
@JDEV@.I external-journal
@JDEV@.IP
@JDEV@Note that
@@ -380,7 +369,7 @@ beginning of the file system.
@JDEV@size as filesystems which will be using it.
@JDEV@In addition, while there is support for attaching
@JDEV@multiple filesystems to a single external journal,
-@JDEV@the Linux kernel and
+@JDEV@the Linux kernel and
@JDEV@.BR e2fsck (8)
@JDEV@do not currently support shared external journals yet.
@JDEV@.IP
@@ -408,10 +397,10 @@ List the contents of the filesystem superblock, including the current
values of the parameters that can be set via this program.
.TP
.BI \-L " volume-label"
-Set the volume label of the filesystem.
+Set the volume label of the filesystem.
Ext2 filesystem labels can be at most 16 characters long; if
-.I volume-label
-is longer than 16 characters,
+.I volume-label
+is longer than 16 characters,
.B tune2fs
will truncate it and print a warning. The volume label can be used
by
@@ -420,19 +409,19 @@ by
and
.BR /etc/fstab (5)
(and possibly others) by specifying
-.BI LABEL= volume_label
+.BI LABEL= volume-label
instead of a block special device name like
.BR /dev/hda5 .
.TP
.BI \-m " reserved-blocks-percentage"
Set the percentage of the filesystem which may only be allocated
-by privileged processes. Reserving some number of filesystem blocks
-for use by privileged processes is done
+by privileged processes. Reserving some number of filesystem blocks
+for use by privileged processes is done
to avoid filesystem fragmentation, and to allow system
-daemons, such as
+daemons, such as
.BR syslogd (8),
-to continue to function correctly after non-privileged processes are
-prevented from writing to the filesystem. Normally, the default percentage
+to continue to function correctly after non-privileged processes are
+prevented from writing to the filesystem. Normally, the default percentage
of reserved blocks is 5%.
.TP
.BI \-M " last-mounted-directory"
@@ -440,19 +429,19 @@ Set the last-mounted directory for the filesystem.
.TP
.BR \-o " [^]\fImount-option\fR[,...]"
Set or clear the indicated default mount options in the filesystem.
-Default mount options can be overridden by mount options specified
-either in
+Default mount options can be overridden by mount options specified
+either in
.BR /etc/fstab (5)
or on the command line arguments to
-.BR mount (8).
+.BR mount (8).
Older kernels may not support this feature; in particular,
kernels which predate 2.4.20 will almost certainly ignore the
default mount options field in the superblock.
.IP
More than one mount option can be cleared or set by separating
-features with commas. Mount options prefixed with a
-caret character ('^') will be cleared in the filesystem's superblock;
-mount options without a prefix character or prefixed with a plus
+features with commas. Mount options prefixed with a
+caret character ('^') will be cleared in the filesystem's superblock;
+mount options without a prefix character or prefixed with a plus
character ('+') will be added to the filesystem.
.IP
The following mount options can be set or cleared using
@@ -466,8 +455,8 @@ Enable debugging code for this filesystem.
Emulate BSD behavior when creating new files: they will take the group-id
of the directory in which they were created. The standard System V behavior
is the default, where newly created files take on the fsgid of the current
-process, unless the directory has the setgid bit set, in which case it takes
-the gid from the parent directory, and also gets the setgid bit set if it is
+process, unless the directory has the setgid bit set, in which case it takes
+the gid from the parent directory, and also gets the setgid bit set if it is
a directory itself.
.TP
.B user_xattr
@@ -487,7 +476,7 @@ into the main filesystem.
.TP
.B journal_data_ordered
When the filesystem is mounted with journalling enabled, all data is forced
-directly out to the main file system prior to its metadata being committed
+directly out to the main file system prior to its metadata being committed
to the journal.
.TP
.B journal_data_writeback
@@ -529,9 +518,9 @@ only supported by the ext4 file system driver in 2.6.35+ kernels.)
.BR \-O " [^]\fIfeature\fR[,...]"
Set or clear the indicated filesystem features (options) in the filesystem.
More than one filesystem feature can be cleared or set by separating
-features with commas. Filesystem features prefixed with a
-caret character ('^') will be cleared in the filesystem's superblock;
-filesystem features without a prefix character or prefixed with a plus
+features with commas. Filesystem features prefixed with a
+caret character ('^') will be cleared in the filesystem's superblock;
+filesystem features without a prefix character or prefixed with a plus
character ('+') will be added to the filesystem. For a detailed
description of the file system features, please see the man page
.BR ext4 (5).
@@ -540,12 +529,22 @@ The following filesystem features can be set or cleared using
.BR tune2fs :
.RS 1.2i
.TP
+.B 64bit
+Enable the file system to be larger than 2^32 blocks.
+.TP
.B dir_index
Use hashed b-trees to speed up lookups for large directories.
.TP
.B dir_nlink
Allow more than 65000 subdirectories per directory.
.TP
+.B ea_inode
+Allow the value of each extended attribute to be placed in the data blocks of a
+separate inode if necessary, increasing the limit on the size and number of
+extended attributes per file.
+.B Tune2fs
+currently only supports setting this filesystem feature.
+.TP
.B encrypt
Enable file system level encryption.
.B Tune2fs
@@ -573,10 +572,15 @@ enabled.
.TP
.B has_journal
Use a journal to ensure filesystem consistency even across unclean shutdowns.
-Setting the filesystem feature is equivalent to using the
+Setting the filesystem feature is equivalent to using the
.B \-j
option.
.TP
+.B large_dir
+Increase the limit on the number of files per directory.
+.B Tune2fs
+currently only supports setting this filesystem feature.
+.TP
.B huge_file
Support files larger than 2 terabytes in size.
.TP
@@ -586,6 +590,13 @@ Filesystem can contain files that are greater than 2GB.
.B metadata_csum
Store a checksum to protect the contents in each metadata block.
.TP
+.B metadata_csum_seed
+Allow the filesystem to store the metadata checksum seed in the
+superblock, enabling the administrator to change the UUID of a filesystem
+using the
+.B metadata_csum
+feature while it is mounted.
+.TP
.B mmp
Enable or disable multiple mount protection (MMP) feature.
.TP
@@ -618,7 +629,7 @@ full time, but subsequent e2fsck runs will take only a fraction of the
original time, depending on how full the file system is.
.RE
.IP
-After setting or clearing
+After setting or clearing
.BR sparse_super ,
.BR uninit_bg ,
.BR filetype ,
@@ -631,9 +642,9 @@ to return the filesystem to a consistent state.
.B Tune2fs
will print a message requesting that the system administrator run
.BR e2fsck (8)
-if necessary. After setting the
+if necessary. After setting the
.B dir_index
-feature,
+feature,
.B e2fsck -D
can be run to convert existing directories to the hashed B-tree format.
Enabling certain filesystem features may prevent the filesystem from being
@@ -643,9 +654,6 @@ and
.BR flex_bg
features are only supported by the ext4 filesystem.
.TP
-.BI \-p " mmp_check_interval"
-Set the desired MMP check interval in seconds. It is 5 seconds by default.
-.TP
.BI \-r " reserved-blocks-count"
Set the number of reserved filesystem blocks.
.TP
@@ -669,31 +677,31 @@ Set the time the filesystem was last checked using
.BR e2fsck .
The time is interpreted using the current (local) timezone.
This can be useful in scripts which use a Logical Volume Manager to make
-a consistent snapshot of a filesystem, and then check the filesystem
-during off hours to make sure it hasn't been corrupted due to
-hardware problems, etc. If the filesystem was clean, then this option can
-be used to set the last checked time on the original filesystem. The format
-of
+a consistent snapshot of a filesystem, and then check the filesystem
+during off hours to make sure it hasn't been corrupted due to
+hardware problems, etc. If the filesystem was clean, then this option can
+be used to set the last checked time on the original filesystem. The format
+of
.I time-last-checked
is the international date format, with an optional time specifier, i.e.
-YYYYMMDD[HH[MM[SS]]]. The keyword
+YYYYMMDD[HH[MM[SS]]]. The keyword
.B now
-is also accepted, in which case the last checked time will be set to the
+is also accepted, in which case the last checked time will be set to the
current time.
.TP
.BI \-u " user"
Set the user who can use the reserved filesystem blocks.
.I user
-can be a numerical uid or a user name. If a user name is given, it
+can be a numerical uid or a user name. If a user name is given, it
is converted to a numerical uid before it is stored in the superblock.
.TP
.BI \-U " UUID"
Set the universally unique identifier (UUID) of the filesystem to
.IR UUID .
-The format of the UUID is a series of hex digits separated by hyphens,
-like this:
-"c1b9d5a2-f162-11cf-9ece-0020afc76f16".
-The
+The format of the UUID is a series of hex digits separated by hyphens,
+like this:
+"c1b9d5a2-f162-11cf-9ece-0020afc76f16".
+The
.I UUID
parameter may also be one of the following:
.RS 1.2i
@@ -749,7 +757,7 @@ This manual page was written by Christian Kuhtz <chk@data-hh.Hanse.DE>.
Time-dependent checking was added by Uwe Ohse <uwe@tirka.gun.de>.
.SH AVAILABILITY
.B tune2fs
-is part of the e2fsprogs package and is available from
+is part of the e2fsprogs package and is available from
http://e2fsprogs.sourceforge.net.
.SH SEE ALSO
.BR debugfs (8),
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 09e65baf..f1ddfe42 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -116,6 +116,8 @@ struct blk_move {
errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs);
+static const char *fsck_explain = N_("\nThis operation requires a freshly checked filesystem.\n");
+
static const char *please_fsck = N_("Please run e2fsck -f on the filesystem.\n");
static const char *please_dir_fsck =
N_("Please run e2fsck -fD on the filesystem.\n");
@@ -135,9 +137,8 @@ static void usage(void)
"[-g group]\n"
"\t[-i interval[d|m|w]] [-j] [-J journal_options] [-l]\n"
"\t[-m reserved_blocks_percent] [-o [^]mount_options[,...]]\n"
- "\t[-p mmp_update_interval] [-r reserved_blocks_count] "
- "[-u user]\n"
- "\t[-C mount_count] [-L volume_label] [-M last_mounted_dir]\n"
+ "\t[-r reserved_blocks_count] [-u user] [-C mount_count]\n"
+ "\t[-L volume_label] [-M last_mounted_dir]\n"
"\t[-O [^]feature[,...]] [-Q quota_options]\n"
"\t[-E extended-option[,...]] [-T last_check_time] "
"[-U UUID]\n\t[-I new_inode_size] [-z undo_file] device\n"),
@@ -153,10 +154,12 @@ static __u32 ok_features[3] = {
EXT2_FEATURE_INCOMPAT_FILETYPE |
EXT3_FEATURE_INCOMPAT_EXTENTS |
EXT4_FEATURE_INCOMPAT_FLEX_BG |
+ EXT4_FEATURE_INCOMPAT_EA_INODE|
EXT4_FEATURE_INCOMPAT_MMP |
EXT4_FEATURE_INCOMPAT_64BIT |
EXT4_FEATURE_INCOMPAT_ENCRYPT |
- EXT4_FEATURE_INCOMPAT_CSUM_SEED,
+ EXT4_FEATURE_INCOMPAT_CSUM_SEED |
+ EXT4_FEATURE_INCOMPAT_LARGEDIR,
/* R/O compat */
EXT2_FEATURE_RO_COMPAT_LARGE_FILE |
EXT4_FEATURE_RO_COMPAT_HUGE_FILE|
@@ -188,6 +191,7 @@ static __u32 clear_ok_features[3] = {
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE|
EXT4_FEATURE_RO_COMPAT_GDT_CSUM |
EXT4_FEATURE_RO_COMPAT_QUOTA |
+ EXT4_FEATURE_RO_COMPAT_PROJECT |
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM |
EXT4_FEATURE_RO_COMPAT_READONLY
};
@@ -418,7 +422,8 @@ static void check_fsck_needed(ext2_filsys fs, const char *prompt)
if (!(fs->super->s_state & EXT2_VALID_FS) ||
(fs->super->s_state & EXT2_ERROR_FS) ||
(fs->super->s_lastcheck < fs->super->s_mtime)) {
- printf("\n%s\n", _(please_fsck));
+ puts(_(fsck_explain));
+ puts(_(please_fsck));
if (mount_flags & EXT2_MF_READONLY)
printf("%s", _("(and reboot afterwards!)\n"));
exit(1);
@@ -440,7 +445,8 @@ static void request_dir_fsck_afterwards(ext2_filsys fs)
return;
fsck_requested++;
fs->super->s_state &= ~EXT2_VALID_FS;
- printf("\n%s\n", _(please_dir_fsck));
+ puts(_(fsck_explain));
+ puts(_(please_dir_fsck));
if (mount_flags & EXT2_MF_READONLY)
printf("%s", _("(and reboot afterwards!)\n"));
}
@@ -460,9 +466,6 @@ static void request_fsck_afterwards(ext2_filsys fs)
static void convert_64bit(ext2_filsys fs, int direction)
{
- if (!direction)
- return;
-
/*
* Is resize2fs going to demand a fsck run? Might as well tell the
* user now.
@@ -716,114 +719,226 @@ static errcode_t rewrite_directory(ext2_filsys fs, ext2_ino_t dir,
}
/*
+ * Context information that does not change across rewrite_one_inode()
+ * invocations.
+ */
+struct rewrite_context {
+ ext2_filsys fs;
+ struct ext2_inode *zero_inode;
+ char *ea_buf;
+ int inode_size;
+};
+
+#define fatal_err(code, args...) \
+ do { \
+ com_err(__func__, code, args); \
+ exit(1); \
+ } while (0);
+
+static void update_ea_inode_hash(struct rewrite_context *ctx, ext2_ino_t ino,
+ struct ext2_inode *inode)
+{
+ errcode_t retval;
+ ext2_file_t file;
+ __u32 hash;
+
+ retval = ext2fs_file_open(ctx->fs, ino, 0, &file);
+ if (retval)
+ fatal_err(retval, "open ea_inode");
+ retval = ext2fs_file_read(file, ctx->ea_buf, inode->i_size,
+ NULL);
+ if (retval)
+ fatal_err(retval, "read ea_inode");
+ retval = ext2fs_file_close(file);
+ if (retval)
+ fatal_err(retval, "close ea_inode");
+
+ hash = ext2fs_crc32c_le(ctx->fs->csum_seed,
+ (unsigned char *) ctx->ea_buf, inode->i_size);
+ ext2fs_set_ea_inode_hash(inode, hash);
+}
+
+static int update_xattr_entry_hashes(ext2_filsys fs,
+ struct ext2_ext_attr_entry *entry,
+ struct ext2_ext_attr_entry *end)
+{
+ int modified = 0;
+ errcode_t retval;
+
+ while (entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry)) {
+ if (entry->e_value_inum) {
+ retval = ext2fs_ext_attr_hash_entry2(fs, entry, NULL,
+ &entry->e_hash);
+ if (retval)
+ fatal_err(retval, "hash ea_inode entry");
+ modified = 1;
+ }
+ entry = EXT2_EXT_ATTR_NEXT(entry);
+ }
+ return modified;
+}
+
+static void update_inline_xattr_hashes(struct rewrite_context *ctx,
+ struct ext2_inode_large *inode)
+{
+ struct ext2_ext_attr_entry *start, *end;
+ __u32 *ea_magic;
+
+ if (inode->i_extra_isize == 0)
+ return;
+
+ if (inode->i_extra_isize & 3 ||
+ inode->i_extra_isize > ctx->inode_size - EXT2_GOOD_OLD_INODE_SIZE)
+ fatal_err(EXT2_ET_INODE_CORRUPTED, "bad i_extra_isize")
+
+ ea_magic = (__u32 *)((char *)inode + EXT2_GOOD_OLD_INODE_SIZE +
+ inode->i_extra_isize);
+ if (*ea_magic != EXT2_EXT_ATTR_MAGIC)
+ return;
+
+ start = (struct ext2_ext_attr_entry *)(ea_magic + 1);
+ end = (struct ext2_ext_attr_entry *)((char *)inode + ctx->inode_size);
+
+ update_xattr_entry_hashes(ctx->fs, start, end);
+}
+
+static void update_block_xattr_hashes(struct rewrite_context *ctx,
+ char *block_buf)
+{
+ struct ext2_ext_attr_header *header;
+ struct ext2_ext_attr_entry *start, *end;
+
+ header = (struct ext2_ext_attr_header *)block_buf;
+ if (header->h_magic != EXT2_EXT_ATTR_MAGIC)
+ return;
+
+ start = (struct ext2_ext_attr_entry *)(header+1);
+ end = (struct ext2_ext_attr_entry *)(block_buf + ctx->fs->blocksize);
+
+ if (update_xattr_entry_hashes(ctx->fs, start, end))
+ ext2fs_ext_attr_block_rehash(header, end);
+}
+
+static void rewrite_one_inode(struct rewrite_context *ctx, ext2_ino_t ino,
+ struct ext2_inode *inode)
+{
+ blk64_t file_acl_block;
+ errcode_t retval;
+
+ if (!ext2fs_test_inode_bitmap2(ctx->fs->inode_map, ino)) {
+ if (!memcmp(inode, ctx->zero_inode, ctx->inode_size))
+ return;
+ memset(inode, 0, ctx->inode_size);
+ }
+
+ if (inode->i_flags & EXT4_EA_INODE_FL)
+ update_ea_inode_hash(ctx, ino, inode);
+
+ if (ctx->inode_size != EXT2_GOOD_OLD_INODE_SIZE)
+ update_inline_xattr_hashes(ctx,
+ (struct ext2_inode_large *)inode);
+
+ retval = ext2fs_write_inode_full(ctx->fs, ino, inode, ctx->inode_size);
+ if (retval)
+ fatal_err(retval, "while writing inode");
+
+ retval = rewrite_extents(ctx->fs, ino, inode);
+ if (retval)
+ fatal_err(retval, "while rewriting extents");
+
+ if (LINUX_S_ISDIR(inode->i_mode) &&
+ ext2fs_inode_has_valid_blocks2(ctx->fs, inode)) {
+ retval = rewrite_directory(ctx->fs, ino, inode);
+ if (retval)
+ fatal_err(retval, "while rewriting directories");
+ }
+
+ file_acl_block = ext2fs_file_acl_block(ctx->fs, inode);
+ if (!file_acl_block)
+ return;
+
+ retval = ext2fs_read_ext_attr3(ctx->fs, file_acl_block, ctx->ea_buf,
+ ino);
+ if (retval)
+ fatal_err(retval, "while rewriting extended attribute");
+
+ update_block_xattr_hashes(ctx, ctx->ea_buf);
+ retval = ext2fs_write_ext_attr3(ctx->fs, file_acl_block, ctx->ea_buf,
+ ino);
+ if (retval)
+ fatal_err(retval, "while rewriting extended attribute");
+}
+
+/*
* Forcibly set checksums in all inodes.
*/
static void rewrite_inodes(ext2_filsys fs)
{
- int length = EXT2_INODE_SIZE(fs->super);
- struct ext2_inode *inode, *zero;
- char *ea_buf;
ext2_inode_scan scan;
errcode_t retval;
ext2_ino_t ino;
- blk64_t file_acl_block;
- int inode_dirty;
+ struct ext2_inode *inode;
+ int pass;
+ struct rewrite_context ctx = {
+ .fs = fs,
+ .inode_size = EXT2_INODE_SIZE(fs->super),
+ };
if (fs->super->s_creator_os == EXT2_OS_HURD)
return;
- retval = ext2fs_open_inode_scan(fs, 0, &scan);
- if (retval) {
- com_err("set_csum", retval, "while opening inode scan");
- exit(1);
- }
-
- retval = ext2fs_get_mem(length, &inode);
- if (retval) {
- com_err("set_csum", retval, "while allocating memory");
- exit(1);
- }
-
- retval = ext2fs_get_memzero(length, &zero);
- if (retval) {
- com_err("set_csum", retval, "while allocating memory");
- exit(1);
- }
+ retval = ext2fs_get_mem(ctx.inode_size, &inode);
+ if (retval)
+ fatal_err(retval, "while allocating memory");
- retval = ext2fs_get_mem(fs->blocksize, &ea_buf);
- if (retval) {
- com_err("set_csum", retval, "while allocating memory");
- exit(1);
- }
+ retval = ext2fs_get_memzero(ctx.inode_size, &ctx.zero_inode);
+ if (retval)
+ fatal_err(retval, "while allocating memory");
- do {
- retval = ext2fs_get_next_inode_full(scan, &ino, inode, length);
- if (retval) {
- com_err("set_csum", retval, "while getting next inode");
- exit(1);
- }
- if (!ino)
- break;
- if (ext2fs_test_inode_bitmap2(fs->inode_map, ino)) {
- inode_dirty = 1;
- } else {
- if (memcmp(inode, zero, length) != 0) {
- memset(inode, 0, length);
- inode_dirty = 1;
- } else {
- inode_dirty = 0;
- }
- }
+ retval = ext2fs_get_mem(64 * 1024, &ctx.ea_buf);
+ if (retval)
+ fatal_err(retval, "while allocating memory");
- if (inode_dirty) {
- retval = ext2fs_write_inode_full(fs, ino, inode,
- length);
- if (retval) {
- com_err("set_csum", retval, "while writing "
- "inode");
- exit(1);
- }
- }
+ /*
+ * Extended attribute inodes have a lookup hash that needs to be
+ * recalculated with the new csum_seed. Other inodes referencing xattr
+ * inodes need this value to be up to date. That's why we do two passes:
+ *
+ * pass 1: update xattr inodes to update their lookup hash as well as
+ * other checksums.
+ *
+ * pass 2: go over other inodes to update their checksums.
+ */
+ if (ext2fs_has_feature_ea_inode(fs->super))
+ pass = 1;
+ else
+ pass = 2;
+ for (;pass <= 2; pass++) {
+ retval = ext2fs_open_inode_scan(fs, 0, &scan);
+ if (retval)
+ fatal_err(retval, "while opening inode scan");
- retval = rewrite_extents(fs, ino, inode);
- if (retval) {
- com_err("rewrite_extents", retval,
- "while rewriting extents");
- exit(1);
- }
+ do {
+ retval = ext2fs_get_next_inode_full(scan, &ino, inode,
+ ctx.inode_size);
+ if (retval)
+ fatal_err(retval, "while getting next inode");
+ if (!ino)
+ break;
- if (LINUX_S_ISDIR(inode->i_mode) &&
- ext2fs_inode_has_valid_blocks2(fs, inode)) {
- retval = rewrite_directory(fs, ino, inode);
- if (retval) {
- com_err("rewrite_directory", retval,
- "while rewriting directories");
- exit(1);
- }
- }
+ if (((pass == 1) &&
+ (inode->i_flags & EXT4_EA_INODE_FL)) ||
+ ((pass == 2) &&
+ !(inode->i_flags & EXT4_EA_INODE_FL)))
+ rewrite_one_inode(&ctx, ino, inode);
+ } while (ino);
- file_acl_block = ext2fs_file_acl_block(fs, inode);
- if (!file_acl_block)
- continue;
- retval = ext2fs_read_ext_attr3(fs, file_acl_block, ea_buf, ino);
- if (retval) {
- com_err("rewrite_eablock", retval,
- "while rewriting extended attribute");
- exit(1);
- }
- retval = ext2fs_write_ext_attr3(fs, file_acl_block, ea_buf,
- ino);
- if (retval) {
- com_err("rewrite_eablock", retval,
- "while rewriting extended attribute");
- exit(1);
- }
- } while (ino);
+ ext2fs_close_inode_scan(scan);
+ }
- ext2fs_free_mem(&zero);
+ ext2fs_free_mem(&ctx.zero_inode);
+ ext2fs_free_mem(&ctx.ea_buf);
ext2fs_free_mem(&inode);
- ext2fs_free_mem(&ea_buf);
- ext2fs_close_inode_scan(scan);
}
static void rewrite_metadata_checksums(ext2_filsys fs)
@@ -836,11 +951,8 @@ static void rewrite_metadata_checksums(ext2_filsys fs)
for (i = 0; i < fs->group_desc_count; i++)
ext2fs_group_desc_csum_set(fs, i);
retval = ext2fs_read_bitmaps(fs);
- if (retval) {
- com_err("rewrite_metadata_checksums", retval,
- "while reading bitmaps");
- exit(1);
- }
+ if (retval)
+ fatal_err(retval, "while reading bitmaps");
rewrite_inodes(fs);
ext2fs_mark_ib_dirty(fs);
ext2fs_mark_bb_dirty(fs);
@@ -1308,15 +1420,23 @@ mmp_error:
}
if (FEATURE_ON(E2P_FEATURE_RO_INCOMPAT,
- EXT4_FEATURE_RO_COMPAT_PROJECT)) {
- if (!Q_flag && !ext2fs_has_feature_quota(sb))
- fputs(_("\nWarning: enabled project without quota together\n"),
- stderr);
+ EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ if (fs->super->s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
+ fprintf(stderr, _("Cannot enable project feature; "
+ "inode size too small.\n"));
+ exit(1);
+ }
Q_flag = 1;
quota_enable[PRJQUOTA] = QOPT_ENABLE;
}
if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
+ EXT4_FEATURE_RO_COMPAT_PROJECT)) {
+ Q_flag = 1;
+ quota_enable[PRJQUOTA] = QOPT_DISABLE;
+ }
+
+ if (FEATURE_OFF(E2P_FEATURE_RO_INCOMPAT,
EXT4_FEATURE_RO_COMPAT_QUOTA)) {
/*
* Set the Q_flag here and handle the quota options in the code
@@ -1357,16 +1477,18 @@ mmp_error:
uuid_seed = ext2fs_crc32c_le(~0, fs->super->s_uuid,
sizeof(fs->super->s_uuid));
- if (fs->super->s_checksum_seed != uuid_seed &&
- (mount_flags & EXT2_MF_MOUNTED)) {
- fputs(_("UUID has changed since enabling "
- "metadata_csum. Filesystem must be unmounted "
- "\nto safely rewrite all metadata to "
- "match the new UUID.\n"), stderr);
- return 1;
+ if (fs->super->s_checksum_seed != uuid_seed) {
+ if (mount_flags & (EXT2_MF_BUSY|EXT2_MF_MOUNTED)) {
+ fputs(_("UUID has changed since enabling "
+ "metadata_csum. Filesystem must be unmounted "
+ "\nto safely rewrite all metadata to match the new UUID.\n"),
+ stderr);
+ return 1;
+ }
+ check_fsck_needed(fs, _("Recalculating checksums "
+ "could take some time."));
+ rewrite_checksums = 1;
}
-
- rewrite_checksums = 1;
}
if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
@@ -1483,7 +1605,8 @@ static void handle_quota_options(ext2_filsys fs)
quota_ctx_t qctx;
ext2_ino_t qf_ino;
enum quota_type qtype;
- int enable = 0;
+ unsigned int qtype_bits = 0;
+ int need_dirty = 0;
for (qtype = 0 ; qtype < MAXQUOTAS; qtype++)
if (quota_enable[qtype] != 0)
@@ -1492,19 +1615,26 @@ static void handle_quota_options(ext2_filsys fs)
/* Nothing to do. */
return;
- retval = quota_init_context(&qctx, fs, QUOTA_ALL_BIT);
+ if (quota_enable[PRJQUOTA] == QOPT_ENABLE &&
+ fs->super->s_inode_size == EXT2_GOOD_OLD_INODE_SIZE) {
+ fprintf(stderr, _("Cannot enable project quota; "
+ "inode size too small.\n"));
+ exit(1);
+ }
+
+ for (qtype = 0; qtype < MAXQUOTAS; qtype++) {
+ if (quota_enable[qtype] == QOPT_ENABLE)
+ qtype_bits |= 1 << qtype;
+ }
+
+ retval = quota_init_context(&qctx, fs, qtype_bits);
if (retval) {
com_err(program_name, retval,
_("while initializing quota context in support library"));
exit(1);
}
- for (qtype = 0 ; qtype < MAXQUOTAS; qtype++) {
- if (quota_enable[qtype] == QOPT_ENABLE) {
- enable = 1;
- break;
- }
- }
- if (enable)
+
+ if (qtype_bits)
quota_compute_usage(qctx);
for (qtype = 0 ; qtype < MAXQUOTAS; qtype++) {
@@ -1527,6 +1657,16 @@ static void handle_quota_options(ext2_filsys fs)
qtype);
exit(1);
}
+ /* Enable Quota feature if one of quota enabled */
+ if (!ext2fs_has_feature_quota(fs->super)) {
+ ext2fs_set_feature_quota(fs->super);
+ need_dirty = 1;
+ }
+ if (qtype == PRJQUOTA &&
+ !ext2fs_has_feature_project(fs->super)) {
+ ext2fs_set_feature_project(fs->super);
+ need_dirty = 1;
+ }
} else if (quota_enable[qtype] == QOPT_DISABLE) {
retval = quota_remove_inode(fs, qtype);
if (retval) {
@@ -1535,25 +1675,27 @@ static void handle_quota_options(ext2_filsys fs)
qtype);
exit(1);
}
+ if (qtype == PRJQUOTA) {
+ ext2fs_clear_feature_project(fs->super);
+ need_dirty = 1;
+ }
}
}
quota_release_context(&qctx);
-
- if (enable) {
- ext2fs_set_feature_quota(fs->super);
- ext2fs_mark_super_dirty(fs);
- } else {
+ /* Clear Quota feature if all quota types disabled. */
+ if (!qtype_bits) {
for (qtype = 0 ; qtype < MAXQUOTAS; qtype++)
- if (*quota_sb_inump(fs->super, qtype) != 0)
+ if (*quota_sb_inump(fs->super, qtype))
break;
if (qtype == MAXQUOTAS) {
- fs->super->s_feature_ro_compat &=
- ~EXT4_FEATURE_RO_COMPAT_QUOTA;
- ext2fs_mark_super_dirty(fs);
+ ext2fs_clear_feature_quota(fs->super);
+ need_dirty = 1;
}
- }
+ }
+ if (need_dirty)
+ ext2fs_mark_super_dirty(fs);
return;
}
@@ -2055,6 +2197,7 @@ static int parse_extended_opts(ext2_filsys fs, const char *opts)
"\tclear_mmp\n"
"\thash_alg=<hash algorithm>\n"
"\tmount_opts=<extended default mount options>\n"
+ "\tmmp_update_interval=<mmp update interval in seconds>\n"
"\tstride=<RAID per-disk chunk size in blocks>\n"
"\tstripe_width=<RAID stride*data disks in blocks>\n"
"\ttest_fs\n"
@@ -2880,6 +3023,36 @@ retry_open:
rc = 1;
goto closefs;
}
+
+#ifdef NO_RECOVERY
+ /* Warn if file system needs recovery and it is opened for writing. */
+ if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
+ (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+ (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER)) {
+ fprintf(stderr,
+_("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
+ "\te2fsck -E journal_only %s\n\n"
+ "then rerun this command. Otherwise, any changes made may be overwritten\n"
+ "by journal recovery.\n"), device_name);
+ }
+#else
+ /* Recover the journal if possible. */
+ if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & (EXT2_MF_BUSY | EXT2_MF_MOUNTED)) &&
+ ext2fs_has_feature_journal_needs_recovery(fs->super)) {
+ errcode_t err;
+
+ printf(_("Recovering journal.\n"));
+ err = ext2fs_run_ext3_journal(&fs);
+ if (err) {
+ com_err("tune2fs", err, "while recovering journal.\n");
+ printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
+ if (fs)
+ ext2fs_close_free(&fs);
+ exit(1);
+ }
+ }
+#endif
+
/* Normally we only need to write out the superblock */
fs->flags |= EXT2_FLAG_SUPER_ONLY;
@@ -3116,8 +3289,9 @@ retry_open:
}
ext2fs_mark_super_dirty(fs);
- if (ext2fs_has_feature_metadata_csum(fs->super) &&
- !ext2fs_has_feature_csum_seed(fs->super))
+ if (!ext2fs_has_feature_csum_seed(fs->super) &&
+ (ext2fs_has_feature_metadata_csum(fs->super) ||
+ ext2fs_has_feature_ea_inode(fs->super)))
rewrite_checksums = 1;
}
@@ -3183,35 +3357,6 @@ retry_open:
free(ext_mount_opts);
}
-#ifdef NO_RECOVERY
- /* Warn if file system needs recovery and it is opened for writing. */
- if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
- (sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
- (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER)) {
- fprintf(stderr,
-_("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
- "\te2fsck -E journal_only %s\n\n"
- "then rerun this command. Otherwise, any changes made may be overwritten\n"
- "by journal recovery.\n"), device_name);
- }
-#else
- /* Recover the journal if possible. */
- if ((open_flag & EXT2_FLAG_RW) && !(mount_flags & EXT2_MF_MOUNTED) &&
- ext2fs_has_feature_journal_needs_recovery(fs->super)) {
- errcode_t err;
-
- printf(_("Recovering journal.\n"));
- err = ext2fs_run_ext3_journal(&fs);
- if (err) {
- com_err("tune2fs", err, "while recovering journal.\n");
- printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
- goto closefs;
- }
- ext2fs_clear_feature_journal_needs_recovery(fs->super);
- ext2fs_mark_super_dirty(fs);
- }
-#endif
-
free(device_name);
remove_error_table(&et_ext2_error_table);
@@ -3223,6 +3368,7 @@ closefs:
#endif
}
- convert_64bit(fs, feature_64bit);
+ if (feature_64bit)
+ convert_64bit(fs, feature_64bit);
return (ext2fs_close_free(&fs) ? 1 : 0);
}
diff --git a/misc/tune2fs.h b/misc/tune2fs.h
index 7b7e431e..f31c8322 100644
--- a/misc/tune2fs.h
+++ b/misc/tune2fs.h
@@ -14,8 +14,8 @@
extern "C" {
#endif
-/* Takes exactly the same args as the tune2fs exectuable.
- * Is the entrypoint for libtune2fs.
+/* Takes exactly the same args as the tune2fs executable.
+ * Is the entry point for libtune2fs.
*/
int tune2fs_main(int argc, char **argv);
diff --git a/misc/util.c b/misc/util.c
index fabc9d17..1d33883d 100644
--- a/misc/util.c
+++ b/misc/util.c
@@ -101,11 +101,11 @@ void proceed_question(int delay)
return;
}
signal(SIGALRM, alarm_signal);
- printf(_("Proceed anyway (or wait %d seconds) ? (y,n) "),
+ printf(_("Proceed anyway (or wait %d seconds to proceed) ? (y,N) "),
delay);
alarm(delay);
} else
- fputs(_("Proceed anyway? (y,n) "), stdout);
+ fputs(_("Proceed anyway? (y,N) "), stdout);
buf[0] = 0;
if (!fgets(buf, sizeof(buf), stdin) ||
strchr(short_yes, buf[0]) == 0) {
diff --git a/misc/uuidgen.1.in b/misc/uuidgen.1.in
index 985e80d7..cb8b3a83 100644
--- a/misc/uuidgen.1.in
+++ b/misc/uuidgen.1.in
@@ -1,15 +1,15 @@
.\" Copyright 1999 Andreas Dilger (adilger@enel.ucalgary.ca)
.\"
.\" This man page was created for libuuid.so.1.1 from e2fsprogs-1.14.
-.\"
+.\"
.\" This file may be copied under the terms of the GNU Public License.
-.\"
+.\"
.\" Created Wed Mar 10 17:42:12 1999, Andreas Dilger
.TH UUIDGEN 1 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
.SH NAME
uuidgen \- command\-line utility to create a new UUID value
.SH SYNOPSIS
-.B uuidgen
+.B uuidgen
[
.B \-r
|
@@ -18,22 +18,22 @@ uuidgen \- command\-line utility to create a new UUID value
.SH DESCRIPTION
The
.B uuidgen
-program creates (and prints)
+program creates (and prints)
a new universally unique identifier (UUID) using the
.BR libuuid (3)
-library. The new UUID can reasonably be considered unique among
-all UUIDs created on the local system,
+library. The new UUID can reasonably be considered unique among
+all UUIDs created on the local system,
and among UUIDs created on other systems in the past
and in the future.
.PP
-There are two types of UUID's which
+There are two types of UUID's which
.B uuidgen
-can generate: time-based UUID's and random-based UUID's. By
-default
+can generate: time-based UUID's and random-based UUID's. By
+default
.B uuidgen
will generate a random-based UUID if a high-quality random number
-generator is present. Otherwise, it will chose a time-based UUID. It
-is possible to force the generation of one of these two
+generator is present. Otherwise, it will chose a time-based UUID. It
+is possible to force the generation of one of these two
UUID types by using the
.B \-r
or
@@ -48,7 +48,7 @@ quality random number generator, such as
.IR /dev/random .
.TP
.B \-t
-Generate a time-based UUID. This method creates a UUID based on the system
+Generate a time-based UUID. This method creates a UUID based on the system
clock plus the system's ethernet hardware address, if present.
.SH "CONFORMING TO"
OSF DCE 1.1