Merge branch 'maint' into next

Conflicts:
	debugfs/debugfs.8.in
diff --git a/.gitignore b/.gitignore
index 328df77..b243fc2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -183,6 +183,7 @@
 misc/uuidd.8
 misc/uuidgen
 misc/uuidgen.1
+parse-types.log
 po/Makefile.in
 po/POTFILES
 public_config.h
diff --git a/config/parse-types.sh b/config/parse-types.sh
index 00371ff..5076f6c 100755
--- a/config/parse-types.sh
+++ b/config/parse-types.sh
@@ -16,8 +16,15 @@
     CPP="$CC -E"
 fi
 
-echo '#include <asm/types.h>' | $CPP - | \
-    sed -f sed.script | grep '^#' > asm_types.h
+/bin/echo -n "checking for __uNN types... "
+# can't check [ -f /usr/include/asm/types.h ] directly, since
+# the include path might be different if cross-compiling
+if echo '#include <asm/types.h>' | $CPP - 2> parse-types.log | \
+	sed -f sed.script | grep '^#' > asm_types.h; then
+	echo "using <asm/types.h>"
+else
+	echo "using generic types"
+fi
 
 rm sed.script
 
@@ -34,7 +41,7 @@
 		       (int) sizeof(__U8_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __U8_TYPEDEF not defined
 #endif
 #ifdef __S8_TYPEDEF
@@ -43,7 +50,7 @@
 		       (int) sizeof(__S8_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __S8_TYPEDEF not defined
 #endif
 #ifdef __U16_TYPEDEF
@@ -52,7 +59,7 @@
 		       (int) sizeof(__U16_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __U16_TYPEDEF not defined
 #endif
 #ifdef __S16_TYPEDEF
@@ -61,7 +68,7 @@
 		       (int) sizeof(__S16_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __S16_TYPEDEF not defined
 #endif
 
@@ -71,7 +78,7 @@
 		       (int) sizeof(__U32_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __U32_TYPEDEF not defined
 #endif
 #ifdef __S32_TYPEDEF
@@ -80,7 +87,7 @@
 		       (int) sizeof(__S32_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __S32_TYPEDEF not defined
 #endif
 
@@ -90,7 +97,7 @@
 		       (int) sizeof(__U64_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __U64_TYPEDEF not defined
 #endif
 #ifdef __S64_TYPEDEF
@@ -99,7 +106,7 @@
 		       (int) sizeof(__S64_TYPEDEF));
 		exit(1);
 	}
-#else
+#elif defined(__linux__)
 #warning __S64_TYPEDEF not defined
 #endif
 	return 0;
diff --git a/configure b/configure
index 2338fbe..62fa843 100755
--- a/configure
+++ b/configure
@@ -10447,7 +10447,7 @@
 done
 
 fi
-for ac_header in  	dirent.h 	errno.h 	execinfo.h 	getopt.h 	malloc.h 	mntent.h 	paths.h 	semaphore.h 	setjmp.h 	signal.h 	stdarg.h 	stdint.h 	stdlib.h 	termios.h 	termio.h 	unistd.h 	utime.h 	linux/falloc.h 	linux/fd.h 	linux/major.h 	net/if_dl.h 	netinet/in.h 	sys/disklabel.h 	sys/file.h 	sys/ioctl.h 	sys/mkdev.h 	sys/mman.h 	sys/prctl.h 	sys/queue.h 	sys/resource.h 	sys/select.h 	sys/socket.h 	sys/sockio.h 	sys/stat.h 	sys/syscall.h 	sys/sysmacros.h 	sys/time.h 	sys/types.h 	sys/un.h 	sys/wait.h
+for ac_header in  	dirent.h 	errno.h 	execinfo.h 	getopt.h 	malloc.h 	mntent.h 	paths.h 	semaphore.h 	setjmp.h 	signal.h 	stdarg.h 	stdint.h 	stdlib.h 	termios.h 	termio.h 	unistd.h 	utime.h 	linux/falloc.h 	linux/fd.h 	linux/major.h 	linux/loop.h 	net/if_dl.h 	netinet/in.h 	sys/disklabel.h 	sys/file.h 	sys/ioctl.h 	sys/mkdev.h 	sys/mman.h 	sys/prctl.h 	sys/queue.h 	sys/resource.h 	sys/select.h 	sys/socket.h 	sys/sockio.h 	sys/stat.h 	sys/syscall.h 	sys/sysmacros.h 	sys/time.h 	sys/types.h 	sys/un.h 	sys/wait.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/configure.in b/configure.in
index 049dc11..fef8d9b 100644
--- a/configure.in
+++ b/configure.in
@@ -920,6 +920,7 @@
 	linux/falloc.h
 	linux/fd.h
 	linux/major.h
+	linux/loop.h
 	net/if_dl.h
 	netinet/in.h
 	sys/disklabel.h
diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in
index 65a30d5..7ff4155 100644
--- a/debugfs/debugfs.8.in
+++ b/debugfs/debugfs.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 DEBUGFS 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
 .SH NAME
 debugfs \- ext2/ext3/ext4 file system debugger
@@ -19,7 +19,7 @@
 superblock
 ]
 [
-.B \-f 
+.B \-f
 cmd_file
 ]
 [
@@ -34,8 +34,8 @@
 device
 ]
 .SH DESCRIPTION
-The 
-.B debugfs 
+The
+.B debugfs
 program is an interactive file system debugger. It can be used to
 examine and change the state of an ext2, ext3, or ext4 file system.
 .br
@@ -60,30 +60,30 @@
 catastrophic mode forces the filesystem to be opened read-only.
 .TP
 .I \-i
-Specifies that 
+Specifies that
 .I device
 represents an ext2 image file created by the
 .B e2image
 program.  Since the ext2 image file only contains the superblock, block
-group descriptor, block and inode allocation bitmaps, and 
+group descriptor, block and inode allocation bitmaps, and
 the inode table, many
 .B debugfs
-commands will not function properly.  
+commands will not function properly.
 .B Warning:
-no safety checks are in place, and 
-.B debugfs 
+no safety checks are in place, and
+.B debugfs
 may fail in interesting ways if commands such as
-.IR ls ", " dump ", " 
-etc. are tried without specifying the 
+.IR ls ", " dump ", "
+etc. are tried without specifying the
 .I data_source_device
-using the 
+using the
 .I \-d
 option.
-.B debugfs 
+.B debugfs
 is a debugging tool.  It has rough edges!
 .TP
 .I -d data_source_device
-Used with the 
+Used with the
 .I \-i
 option, specifies that
 .I data_source_device
@@ -104,11 +104,11 @@
 option.
 .TP
 .I -f cmd_file
-Causes 
+Causes
 .B debugfs
-to read in commands from 
-.IR cmd_file , 
-and execute them.  When 
+to read in commands from
+.IR cmd_file ,
+and execute them.  When
 .B debugfs
 is finished executing those commands, it will exit.
 .TP
@@ -120,14 +120,14 @@
 not support Direct I/O.
 .TP
 .I -R request
-Causes 
+Causes
 .B debugfs
-to execute the single command 
+to execute the single command
 .IR request ,
 and then exit.
 .TP
 .I -V
-print the version number of 
+print the version number of
 .B debugfs
 and exit.
 .SH SPECIFYING FILES
@@ -135,132 +135,140 @@
 .B debugfs
 commands take a
 .I filespec
-as an argument to specify an inode (as opposed to a pathname) 
-in the filesystem which is currently opened by 
-.BR debugfs . 
+as an argument to specify an inode (as opposed to a pathname)
+in the filesystem which is currently opened by
+.BR debugfs .
 The
 .I filespec
-argument may be specified in two forms.  The first form is an inode 
-number surrounded by angle brackets, e.g., 
+argument may be specified in two forms.  The first form is an inode
+number surrounded by angle brackets, e.g.,
 .IR <2> .
 The second form is a pathname; if the pathname is prefixed by a forward slash
-('/'), then it is interpreted relative to the root of the filesystem 
-which is currently opened by 
+('/'), then it is interpreted relative to the root of the filesystem
+which is currently opened by
 .BR debugfs .
-If not, the pathname is 
-interpreted relative to the current working directory as maintained by 
-.BR debugfs .  
-This may be modified by using the 
+If not, the pathname is
+interpreted relative to the current working directory as maintained by
+.BR debugfs .
+This may be modified by using the
 .B debugfs
 command
 .IR cd .
-.\" 
+.\"
 .\"
 .\"
 .SH COMMANDS
-This is a list of the commands which 
+This is a list of the commands which
 .B debugfs
 supports.
 .TP
-.I blocks filespace
+.BI blocks " filespace"
 Print the blocks used by the inode
 .I filespec
 to stdout.
 .TP
-.I bmap filespec logical_block
+.BI bmap " filespec logical_block"
 Print the physical block number corresponding to the logical block number
 .I logical_block
 in the inode
 .IR filespec .
 .TP
-.I block_dump [-f out_file] block_num
-Dump the contents of a block, optionally to
-.IR out_file .
+.BI block_dump " [-f filespec] block_num"
+Dump the filesystem block given by
+.I block_num
+in hex and ASCII format to the console.  If the
+.I -f
+option is specified, the block number is relative to the start of the given
+.BR filespec .
 .TP
-.I cat filespec
-Dump the contents of the inode 
+.BI cat " filespec"
+Dump the contents of the inode
 .I filespec
 to stdout.
 .TP
-.I cd filespec
-Change the current working directory to 
+.BI cd " filespec"
+Change the current working directory to
 .IR filespec .
 .TP
-.I chroot filespec
-Change the root directory to be the directory 
+.BI chroot " filespec"
+Change the root directory to be the directory
 .IR filespec .
 .TP
-.I close [-a]
-Close the currently open file system.  If the 
+.BI close " [-a]"
+Close the currently open file system.  If the
 .I -a
 option is specified, write out any changes to the superblock and block
 group descriptors to all of the backup superblocks, not just to the
 master superblock.
 .TP
-.I clri file
-Clear the contents of the inode 
-.IR file .
+.BI clri " filespec"
+Clear the contents of the inode
+.IR filespec .
 .TP
-.I dirsearch filespec filename
+.BI dirsearch " filespec filename"
 Search the directory
 .I filespec
 for
 .IR filename .
 .TP
-.I dump [-p] filespec out_file
-Dump the contents of the inode 
+.B dirty
+Mark the filesystem as dirty, so that the superblocks will be written on exit.
+.TP
+.BI dump " [-p] filespec out_file"
+Dump the contents of the inode
 .I filespec
-to the output file 
-.IR out_file .  
-If the 
-.I -p 
-option is given set the owner, group and permissions information on 
-.I out_file 
-to match 
+to the output file
+.IR out_file .
+If the
+.I -p
+option is given set the owner, group and permissions information on
+.I out_file
+to match
 .IR filespec .
 .TP
-.I dump_mmp
+.B dump_mmp
 Display the multiple-mount protection (mmp) field values.
 .TP
-.I dx_hash [-h hash_alg] [-s hash_seed] filename
+.BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
 Calculate the directory hash of
 .IR filename .
 The hash algorithm specified with
 .I -h
-may be "legacy" "half_md4" or "tea".
+may be
+.BR legacy , " half_md4" ", or " tea .
 The hash seed specified with
 .I -s
 must be in UUID format.
 .TP
-.I dump_extents [-n] [-l] filespec
+.BI dump_extents " [-n] [-l] filespec"
 Dump the the extent tree of the inode
 .IR filespec .
-The 
+The
 .I -n
 flag will cause
-.I dump_extents
+.B dump_extents
 to only display the interior nodes in the extent tree.   The
-.I  -l
-flag cause
-.I dump_extents
+.I -l
+flag will cause
+.B dump_extents
 to only display the leaf nodes in the extent tree.
 .IP
 (Please note that the length and range of blocks for the last extent in
 an interior node is an estimate by the extents library functions, and is
 not stored in filesystem data structures.   Hence, the values displayed
-may not necessarily by accurate and does not indicate a problem or 
+may not necessarily by accurate and does not indicate a problem or
 corruption in the file system.)
 .TP
-.I expand_dir filespec
+.BI expand_dir " filespec"
 Expand the directory
 .IR filespec .
 .TP
-.I feature [fs_feature] [-fs_feature] ...
+.BI feature " [fs_feature] [-fs_feature] ..."
 Set or clear various filesystem features in the superblock.  After setting
 or clearing any filesystem features that were requested, print the current
 state of the filesystem feature set.
 .TP
-.I filefrag [-dvr] filespec
+.BI filefrag " [-dvr] filespec"
 Print the number of contiguous extents in
 .IR filespec .
 If
@@ -281,36 +289,39 @@
 .I filefrag
 to do a recursive listing of the directory.
 .TP
-.I find_free_block [count [goal]]
-Find the first 
+.BI find_free_block " [count [goal]]"
+Find the first
 .I count
 free blocks, starting from
 .I goal
-and allocate it.
+and allocate it.  Also available as
+.BR ffb .
 .TP
-.I find_free_inode [dir [mode]]
-Find a free inode and allocate it.  If present, 
+.BI find_free_inode " [dir [mode]]"
+Find a free inode and allocate it.  If present,
 .I dir
-specifies the inode number of the directory 
-which the inode is to be located.  The second 
+specifies the inode number of the directory
+which the inode is to be located.  The second
 optional argument
 .I mode
 specifies the permissions of the new inode.  (If the directory bit is set
-on the mode, the allocation routine will function differently.)
+on the mode, the allocation routine will function differently.)  Also
+available as
+.BR ffi .
 .TP
-.I freeb block [count]
+.BI freeb " block [count]"
 Mark the block number
 .I block
 as not allocated.
-If the optional argument 
-.I count 
-is present, then 
+If the optional argument
+.I count
+is present, then
 .I count
 blocks starting at block number
 .I block
 will be marked as not allocated.
 .TP
-.I freefrag [-c chunk_kb ]
+.BI freefrag " [-c chunk_kb]"
 Report free space fragmentation on the currently open file system.
 If the
 .I \-c
@@ -320,148 +331,151 @@
 can be found in the file system.  The chunk size must be a power of two
 and be larger than the file system block size.
 .TP
-.I freei filespec [num]
-Free the inode specified by 
+.BI freei " filespec [num]"
+Free the inode specified by
 .IR filespec .
 If
 .I num
 is specified, also clear num-1 inodes after the specified inode.
 .TP
-.I help
-Print a list of commands understood by 
+.B help
+Print a list of commands understood by
 .BR debugfs .
 .TP
-.I htree_dump filespec
+.BI htree_dump " filespec"
 Dump the hash-indexed directory
 .IR filespec ,
 showing its tree structure.
 .TP
-.I icheck block ...
+.BI icheck " block ..."
 Print a listing of the inodes which use the one or more blocks specified
 on the command line.
 .TP
-.I imap filespec
-Print the location of the inode data structure (in the inode table) 
+.BI imap " filespec"
+Print the location of the inode data structure (in the inode table)
 of the inode
 .IR filespec .
 .TP
-.I init_filesys device blocksize
+.BI init_filesys " device blocksize"
 Create an ext2 file system on
 .I device
 with device size
 .IR blocksize .
-Note that this does not fully initialize all of the data structures; 
-to do this, use the 
+Note that this does not fully initialize all of the data structures;
+to do this, use the
 .BR mke2fs (8)
 program.  This is just a call to the low-level library, which sets up
 the superblock and block descriptors.
 .TP
-.I kill_file filespec
-Deallocate the inode 
+.BI kill_file " filespec"
+Deallocate the inode
 .I filespec
 and its blocks.  Note that this does not remove any directory
-entries (if any) to this inode.  See the 
+entries (if any) to this inode.  See the
 .BR rm (1)
 command if you wish to unlink a file.
 .TP
-.I lcd directory
+.BI lcd " directory"
 Change the current working directory of the
 .B debugfs
 process to
 .I directory
 on the native filesystem.
 .TP
-.I ln filespec dest_file
-Create a link named 
+.BI ln " filespec dest_file"
+Create a link named
 .I dest_file
-which is a link to 
+which is a hard link to
 .IR filespec .
 Note this does not adjust the inode reference counts.
 .TP
-.I logdump [-acs] [-b<block>] [-i<filespec>] [-f<journal_file>] [output_file]
-Dump the contents of the ext3 journal.  By default, the journal inode as
-specified in the superblock.  However, this can be overridden with the 
+.BI logdump " [-acs] [-b block] [-i filespec] [-f journal_file] [output_file]"
+Dump the contents of the ext3 journal.  By default, dump the journal inode as
+specified in the superblock.  However, this can be overridden with the
 .I \-i
-option, which uses an inode specifier to specify the journal to be
-used.  A file containing journal data can be specified using the
+option, which dumps the journal from the internal inode given by
+.IR filespec .
+A regular file containing journal data can be specified using the
 .I \-f
-option.   Finally, the 
+option.  Finally, the
 .I \-s
 option utilizes the backup information in the superblock to locate the
 journal.
 .IP
-The 
+The
 .I \-a
-option causes the 
-.I logdump
+option causes the
+.B logdump
 program to print the contents of all of the descriptor blocks.
-The 
+The
 .I \-b
-option causes 
-.I logdump
-to print all journal records that are refer to the specified block. 
-The 
+option causes
+.B logdump
+to print all journal records that are refer to the specified block.
+The
 .I \-c
 option will print out the contents of all of the data blocks selected by
-the 
+the
 .I \-a
-and 
+and
 .I \-b
 options.
 .TP
-.I ls [-l] [-c] [-d] [-p] filespec
+.BI ls " [-l] [-c] [-d] [-p] filespec"
 Print a listing of the files in the directory
 .IR filespec .
-The 
-.I \-l
-flag will list files using a more verbose format.
 The
 .I \-c
 flag causes directory block checksums (if present) to be displayed.
 The
 .I \-d
 flag will list deleted entries in the directory.
-The 
+The
+.I \-l
+flag will list files using a more verbose format.
+The
 .I \-p
 flag will list the files in a format which is more easily parsable by
 scripts, as well as making it more clear when there are spaces or other
 non-printing characters at the end of filenames.
 .TP
-.I modify_inode filespec
+.BI modify_inode " filespec"
 Modify the contents of the inode structure in the inode
 .IR filespec .
+Also available as
+.BR mi .
 .TP
-.I mkdir filespec
+.BI mkdir " filespec"
 Make a directory.
 .TP
-.I mknod filespec [p|[[c|b] major minor]]
+.BI mknod " filespec [p|[[c|b] major minor]]"
 Create a special device file (a named pipe, character or block device).
-If a character or block device is to be made, the 
+If a character or block device is to be made, the
 .I major
 and
 .I minor
 device numbers must be specified.
 .TP
-.I ncheck [-c] inode_num ...
+.BI ncheck " [-c] inode_num ..."
 Take the requested list of inode numbers, and print a listing of pathnames
 to those inodes.  The
 .I -c
 flag will enable checking the file type information in the directory
 entry to make sure it matches the inode's type.
 .TP
-.I open [-w] [-e] [-f] [-i] [-c] [-D] [-b blocksize] [-s superblock] device
-Open a filesystem for editing.  The 
-.I -f 
-flag forces the filesystem to be opened even if there are some unknown 
-or incompatible filesystem features which would normally 
+.BI open " [-weficD] [-b blocksize] [-s superblock] device"
+Open a filesystem for editing.  The
+.I -f
+flag forces the filesystem to be opened even if there are some unknown
+or incompatible filesystem features which would normally
 prevent the filesystem from being opened.  The
 .I -e
 flag causes the filesystem to be opened in exclusive mode.  The
 .IR -b ", " -c ", " -i ", " -s ", " -w ", and " -D
-options behave the same as the command-line options to 
+options behave the same as the command-line options to
 .BR debugfs .
 .TP
-.I punch filespec start_blk [end_blk]
+.BI punch " filespec start_blk [end_blk]"
 Delete the blocks in the inode ranging from
 .I start_blk
 to
@@ -476,14 +490,14 @@
 .I symlink filespec target
 Make a symbolic link.
 .TP
-.I pwd
+.B pwd
 Print the current working directory.
 .TP
-.I quit
+.B quit
 Quit
 .B debugfs
 .TP
-.I rdump directory destination
+.BI rdump " directory destination"
 Recursively dump
 .I directory
 and all its contents (including regular files, symbolic links, and other
@@ -491,169 +505,202 @@
 .I destination
 which should be an existing directory on the native filesystem.
 .TP
-.I rm pathname
-Unlink 
+.BI rm " pathname"
+Unlink
 .IR pathname .
-If this causes the inode pointed to by 
+If this causes the inode pointed to by
 .I pathname
 to have no other references, deallocate the file.  This command functions
 as the unlink() system call.
-.I 
+.I
 .TP
-.I rmdir filespec
+.BI rmdir " filespec"
 Remove the directory
 .IR filespec .
 .TP
-.I setb block [count]
+.BI setb " block [count]"
 Mark the block number
 .I block
 as allocated.
-If the optional argument 
-.I count 
-is present, then 
+If the optional argument
+.I count
+is present, then
 .I count
 blocks starting at block number
 .I block
 will be marked as allocated.
 .TP
-.I set_block_group bgnum field value
+.BI set_block_group " bgnum field value"
 Modify the block group descriptor specified by
 .I bgnum
 so that the block group descriptor field
 .I field
 has value
-.I value.
+.IR value .
+Also available as
+.BR set_bg .
 .TP
-.I seti filespec [num]
-Mark inode 
+.BI seti " filespec [num]"
+Mark inode
 .I filespec
 as in use in the inode bitmap.  If
 .I num
 is specified, also set num-1 inodes after the specified inode.
 .TP
-.I set_inode_field filespec field value
-Modify the inode specified by 
+.BI set_inode_field " filespec field value"
+Modify the inode specified by
 .I filespec
 so that the inode field
 .I field
-has value 
+has value
 .I value.
-The list of valid inode fields which can be set via this command 
+The list of valid inode fields which can be set via this command
 can be displayed by using the command:
 .B set_inode_field -l
+Also available as
+.BR sif .
 .TP
-.I set_mmp_value field value
-Modify the multiple-mount protection (mmp) data so that the
-mmp field
+.BI set_mmp_value " field value"
+Modify the multiple-mount protection (MMP) data so that the MMP field
 .I field
 has value
 .I value.
-The list of valid mmp fields which can be set via this command
+The list of valid MMP fields which can be set via this command
 can be displayed by using the command:
 .B set_mmp_value -l
+Also available as
+.BR smmp .
 .TP
-.I set_super_value field value
+.BI set_super_value " field value"
 Set the superblock field
 .I field
-to 
+to
 .I value.
-The list of valid superblock fields which can be set via this command 
+The list of valid superblock fields which can be set via this command
 can be displayed by using the command:
 .B set_super_value -l
+Also available as
+.BR ssv .
 .TP
-.I show_super_stats [-h]
+.BI show_super_stats " [-h]"
 List the contents of the super block and the block group descriptors.  If the
 .I -h
-flag is given, only print out the superblock contents.
+flag is given, only print out the superblock contents. Also available as
+.BR stats .
 .TP
-.I stat filespec
+.BI stat " filespec"
 Display the contents of the inode structure of the inode
 .IR filespec .
 .TP
-.I testb block [count]
+.BI testb " block [count]"
 Test if the block number
 .I block
 is marked as allocated in the block bitmap.
-If the optional argument 
-.I count 
-is present, then 
+If the optional argument
+.I count
+is present, then
 .I count
 blocks starting at block number
 .I block
 will be tested.
 .TP
-.I testi filespec
-Test if the inode 
+.BI testi " filespec"
+Test if the inode
 .I filespec
 is marked as allocated in the inode bitmap.
 .TP
-.I undel <inode num> [pathname]
+.BI undel " <inode_number> [pathname]"
 Undelete the specified inode number (which must be surrounded by angle
 brackets) so that it and its blocks are marked in use, and optionally
-link the recovered inode to the specified pathname.  The 
+link the recovered inode to the specified pathname.  The
 .B e2fsck
-command should always be run after using the 
+command should always be run after using the
 .B undel
 command to recover deleted files.
 .IP
 Note that if you are recovering a large number of deleted files, linking
 the inode to a directory may require the directory to be expanded, which
 could allocate a block that had been used by one of the
-yet-to-be-undeleted files.  So it is safer to undelete all of the 
+yet-to-be-undeleted files.  So it is safer to undelete all of the
 inodes without specifying a destination pathname, and then in a separate
 pass, use the debugfs
 .B link
-command to link the inode to the destination pathname, or use 
+command to link the inode to the destination pathname, or use
 .B e2fsck
 to check the filesystem and link all of the recovered inodes to the
 lost+found directory.
 .TP
-.I unlink pathname
-Remove the link specified by 
-.I pathname 
+.BI unlink " pathname"
+Remove the link specified by
+.I pathname
 to an inode.  Note this does not adjust the inode reference counts.
 .TP
-.I write source_file out_file
-Create a file in the filesystem named
-.IR out_file ,
-and copy the contents of
+.BI write " source_file out_file"
+Copy the contents of
 .I source_file
-into the destination file.
+into a newly-created file in the filesystem named
+.IR out_file .
 .TP
-.I zap_block [-f file] [-o offset] [-l length] [-p pattern] block_num
-Zero, or pattern-fill, portions of a block within a file or
-within the filesystem.
+.BI zap_block " [-f filespec] [-o offset] [-l length] [-p pattern] block_num"
 .TP
-.I zap_block [-f file] [-b bit] block_num
-Bit-flip portions of a block within a file or
-within the filesystem.
+Overwrite the block specified by
+.I block_num
+with zero (NUL) bytes, or if
+.I -p
+is given use the byte specified by
+.IR pattern .
+If
+.I -f
+is given then
+.I block_num
+is relative to the start of the file given by
+.IR filespec .
+The
+.I -o
+and
+.I -l
+options limit the range of bytes to zap to the specified
+.I offset
+and
+.I length
+relative to the start of the block.
+.TP
+.BI zap_block " [-f filespec] [-b bit] block_num"
+Bit-flip portions of the physical
+.IR block_num .
+If
+.I -f
+is given, then
+.I block_num
+is a logical block relative to the start of
+.IR filespec .
 .SH ENVIRONMENT VARIABLES
 .TP
 .B DEBUGFS_PAGER, PAGER
 The
 .B debugfs
 program always pipes the output of the some commands through a
-pager program.  These commands include: 
-.IR show_super_stats ,
-.IR list_directory ,
-.IR show_inode_info ,
-.IR list_deleted_inodes ,
+pager program.  These commands include:
+.IR show_super_stats " (" stats ),
+.IR list_directory " (" ls ),
+.IR show_inode_info " (" stat ),
+.IR list_deleted_inodes " (" lsdel ),
 and
 .IR htree_dump .
 The specific pager can explicitly specified by the
 .B DEBUGFS_PAGER
 environment variable, and if it is not set, by the
 .B PAGER
-environment variable.  
+environment variable.
 .IP
-Note that since a pager is always used, the 
+Note that since a pager is always used, the
 .BR less (1)
 pager is not particularly appropriate, since it clears the screen before
 displaying the output of the command and clears the output the screen
-when the pager is exited.  Many users prefer to use the 
+when the pager is exited.  Many users prefer to use the
 .BR less (1)
-pager for most purposes, which is why the 
-.B DEBUGFS_PAGER 
+pager for most purposes, which is why the
+.B DEBUGFS_PAGER
 environment variable is available to override the more general
 .B PAGER
 environment variable.
diff --git a/debugfs/lsdel.c b/debugfs/lsdel.c
index bed0ce6..e5b2d20 100644
--- a/debugfs/lsdel.c
+++ b/debugfs/lsdel.c
@@ -87,7 +87,7 @@
 	time_t			now;
 	FILE			*out;
 
-	if (common_args_process(argc, argv, 1, 2, "ls_deleted_inodes",
+	if (common_args_process(argc, argv, 1, 2, "list_deleted_inodes",
 				"[secs]", 0))
 		return;
 
diff --git a/debugfs/zap.c b/debugfs/zap.c
index ba205a1..8109209 100644
--- a/debugfs/zap.c
+++ b/debugfs/zap.c
@@ -193,10 +193,9 @@
 		}
 	}
 
-	if (argc != optind+1) {
+	if (argc != optind + 1) {
 	print_usage:
-		com_err(0, 0, "Usage: dump_block [-f file] "
-			" block_num");
+		com_err(0, 0, "Usage: block_dump [-f inode] block_num");
 		return;
 	}
 
diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c
index 71b1c56..8519df0 100644
--- a/e2fsck/badblocks.c
+++ b/e2fsck/badblocks.c
@@ -42,7 +42,7 @@
 	retval = ext2fs_block_iterate(fs, EXT2_BAD_INO, 0, 0,
 				      check_bb_inode_blocks, 0);
 	if (retval) {
-		com_err("ext2fs_block_iterate", retval,
+		com_err("ext2fs_block_iterate", retval, "%s",
 			_("while sanity checking the bad blocks inode"));
 		goto fatal;
 	}
@@ -54,7 +54,7 @@
 	if (!replace_bad_blocks) {
 		retval = ext2fs_read_bb_inode(fs, &bb_list);
 		if (retval) {
-			com_err("ext2fs_read_bb_inode", retval,
+			com_err("ext2fs_read_bb_inode", retval, "%s",
 				_("while reading the bad blocks inode"));
 			goto fatal;
 		}
@@ -90,7 +90,7 @@
 	else
 		pclose(f);
 	if (retval) {
-		com_err("ext2fs_read_bb_FILE", retval,
+		com_err("ext2fs_read_bb_FILE", retval, "%s",
 			_("while reading in list of bad blocks from file"));
 		goto fatal;
 	}
@@ -101,7 +101,7 @@
 	printf("%s: Updating bad block inode.\n", ctx->device_name);
 	retval = ext2fs_update_bb_inode(fs, bb_list);
 	if (retval) {
-		com_err("ext2fs_update_bb_inode", retval,
+		com_err("ext2fs_update_bb_inode", retval, "%s",
 			_("while updating bad block inode"));
 		goto fatal;
 	}
diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 22f06e7..a7b1150 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -571,7 +571,7 @@
 
 	ll_rw_block(READ, 1, &jbh);
 	if (jbh->b_err) {
-		com_err(ctx->device_name, jbh->b_err,
+		com_err(ctx->device_name, jbh->b_err, "%s",
 			_("reading journal superblock\n"));
 		return jbh->b_err;
 	}
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index 967820b..41a82cf 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -817,7 +817,7 @@
 		goto errout;
 	}
 	if (cs.errcode) {
-		com_err("clone_file", cs.errcode,
+		com_err("clone_file", cs.errcode, "%s",
 			_("returned from clone_file_block"));
 		retval = cs.errcode;
 		goto errout;
diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c
index dc9d7c1..c57aab8 100644
--- a/e2fsck/pass3.c
+++ b/e2fsck/pass3.c
@@ -718,12 +718,23 @@
 		last_blk = *blocknr;
 		return 0;
 	}
-	retval = ext2fs_new_block2(fs, last_blk, ctx->block_found_map,
-				  &new_blk);
-	if (retval) {
-		es->err = retval;
-		return BLOCK_ABORT;
+
+	if (blockcnt &&
+	    (EXT2FS_B2C(fs, last_blk) == EXT2FS_B2C(fs, last_blk + 1)))
+		new_blk = last_blk + 1;
+	else {
+		last_blk &= ~EXT2FS_CLUSTER_MASK(fs);
+		retval = ext2fs_new_block2(fs, last_blk, ctx->block_found_map,
+					  &new_blk);
+		if (retval) {
+			es->err = retval;
+			return BLOCK_ABORT;
+		}
+		es->newblocks++;
+		ext2fs_block_alloc_stats2(fs, new_blk, +1);
 	}
+	last_blk = new_blk;
+
 	if (blockcnt > 0) {
 		retval = ext2fs_new_dir_block(fs, 0, 0, &block);
 		if (retval) {
@@ -749,8 +760,6 @@
 	ext2fs_free_mem(&block);
 	*blocknr = new_blk;
 	ext2fs_mark_block_bitmap2(ctx->block_found_map, new_blk);
-	ext2fs_block_alloc_stats2(fs, new_blk, +1);
-	es->newblocks++;
 
 	if (es->num == 0)
 		return (BLOCK_CHANGED | BLOCK_ABORT);
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index 498c041..5e0d322 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -529,8 +529,8 @@
 			save_problem = problem;
 		} else {
 			if ((problem == save_problem) &&
-			    (pctx.blk2 == i-1))
-				pctx.blk2++;
+			    (pctx.blk2 == i - EXT2FS_CLUSTER_RATIO(fs)))
+				pctx.blk2 += EXT2FS_CLUSTER_RATIO(fs);
 			else {
 				print_bitmap_problem(ctx, save_problem, &pctx);
 				pctx.blk = pctx.blk2 = i;
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index 20704a9..9b90353 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -719,10 +719,18 @@
 		/* We don't need this block, so release it */
 		e2fsck_read_bitmaps(wd->ctx);
 		blk = *block_nr;
-		ext2fs_unmark_block_bitmap2(wd->ctx->block_found_map, blk);
-		ext2fs_block_alloc_stats2(fs, blk, -1);
+		/*
+		 * In theory, we only release blocks from the end of the
+		 * directory file, so it's fine to clobber a whole cluster at
+		 * once.
+		 */
+		if (blk % EXT2FS_CLUSTER_RATIO(fs) == 0) {
+			ext2fs_unmark_block_bitmap2(wd->ctx->block_found_map,
+						    blk);
+			ext2fs_block_alloc_stats2(fs, blk, -1);
+			wd->cleared++;
+		}
 		*block_nr = 0;
-		wd->cleared++;
 		return BLOCK_CHANGED;
 	}
 
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 7a8fce2..281da5a 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -77,13 +77,13 @@
 		"\t\t[-E extended-options] device\n"),
 		ctx->program_name);
 
-	fprintf(stderr, _("\nEmergency help:\n"
+	fprintf(stderr, "%s", _("\nEmergency help:\n"
 		" -p                   Automatic repair (no questions)\n"
 		" -n                   Make no changes to the filesystem\n"
 		" -y                   Assume \"yes\" to all questions\n"
 		" -c                   Check for bad blocks and add them to the badblock list\n"
 		" -f                   Force checking even if filesystem is marked clean\n"));
-	fprintf(stderr, _(""
+	fprintf(stderr, "%s", _(""
 		" -v                   Be verbose\n"
 		" -b superblock        Use alternative superblock\n"
 		" -B blocksize         Force blocksize when looking for superblock\n"
@@ -176,7 +176,7 @@
 		if (ctx->extent_depth_count[j])
 			break;
 	if (++j) {
-		log_out(ctx, _("             Extent depth histogram: "));
+		log_out(ctx, "%s", _("             Extent depth histogram: "));
 		for (i=0; i < j; i++) {
 			if (i)
 				fputc('/', stdout);
@@ -261,14 +261,14 @@
 	if (!ctx->interactive || ctx->mount_flags & EXT2_MF_BUSY)
 		fatal_error(ctx, _("Cannot continue, aborting.\n\n"));
 	puts("\007\007\007\007");
-	log_out(ctx, _("\n\nWARNING!!!  "
+	log_out(ctx, "%s", _("\n\nWARNING!!!  "
 		       "The filesystem is mounted.   "
 		       "If you continue you ***WILL***\n"
 		       "cause ***SEVERE*** filesystem damage.\n\n"));
 	puts("\007\007\007");
 	cont = ask_yn(ctx, _("Do you really want to continue"), 0);
 	if (!cont) {
-		printf (_("check aborted.\n"));
+		printf("%s", _("check aborted.\n"));
 		exit (0);
 	}
 	return;
@@ -388,7 +388,7 @@
 	if (reason) {
 		log_out(ctx, "%s", ctx->device_name);
 		log_out(ctx, reason, reason_arg);
-		log_out(ctx, _(", check forced.\n"));
+		log_out(ctx, "%s", _(", check forced.\n"));
 		return;
 	}
 
@@ -440,12 +440,14 @@
 	if (next_check <= 5) {
 		if (next_check == 1) {
 			if (batt)
-				log_out(ctx, _(" (check deferred; "
-					       "on battery)"));
+				log_out(ctx, "%s",
+					_(" (check deferred; on battery)"));
 			else
-				log_out(ctx, _(" (check after next mount)"));
+				log_out(ctx, "%s",
+					_(" (check after next mount)"));
 		} else
-			log_out(ctx, _(" (check in %ld mounts)"), next_check);
+			log_out(ctx, _(" (check in %ld mounts)"),
+				next_check);
 	}
 	log_out(ctx, "\n");
 skip:
@@ -663,7 +665,7 @@
 			ea_ver = strtoul(arg, &p, 0);
 			if (*p ||
 			    ((ea_ver != 1) && (ea_ver != 2))) {
-				fprintf(stderr,
+				fprintf(stderr, "%s",
 					_("Invalid EA version.\n"));
 				extended_usage++;
 				continue;
@@ -908,17 +910,17 @@
 		usage(ctx);
 	if ((ctx->options & E2F_OPT_NO) &&
 	    (ctx->options & E2F_OPT_COMPRESS_DIRS)) {
-		com_err(ctx->program_name, 0,
+		com_err(ctx->program_name, 0, "%s",
 			_("The -n and -D options are incompatible."));
 		fatal_error(ctx, 0);
 	}
 	if ((ctx->options & E2F_OPT_NO) && cflag) {
-		com_err(ctx->program_name, 0,
+		com_err(ctx->program_name, 0, "%s",
 			_("The -n and -c options are incompatible."));
 		fatal_error(ctx, 0);
 	}
 	if ((ctx->options & E2F_OPT_NO) && bad_blocks_file) {
-		com_err(ctx->program_name, 0,
+		com_err(ctx->program_name, 0, "%s",
 			_("The -n and -l/-L options are incompatible."));
 		fatal_error(ctx, 0);
 	}
@@ -973,8 +975,8 @@
 		close(fd);
 	}
 	if (cflag && bad_blocks_file) {
-		fprintf(stderr, _("The -c and the -l/-L options may "
-				  "not be both used at the same time.\n"));
+		fprintf(stderr, "%s", _("The -c and the -l/-L options may not "
+					"be both used at the same time.\n"));
 		exit(FSCK_USAGE);
 	}
 #ifdef HAVE_SIGNAL_H
@@ -1135,12 +1137,12 @@
 			retval = 0;
 		}
 	} else if (retval == EXT2_ET_MMP_FAILED) {
-		com_err(ctx->program_name, retval,
+		com_err(ctx->program_name, retval, "%s",
 			_("while checking MMP block"));
 		dump_mmp_msg(fs->mmp_buf, NULL);
 	} else if (retval == EXT2_ET_MMP_FSCK_ON ||
 		   retval == EXT2_ET_MMP_UNKNOWN_SEQ) {
-		com_err(ctx->program_name, retval,
+		com_err(ctx->program_name, retval, "%s",
 			_("while checking MMP block"));
 		dump_mmp_msg(fs->mmp_buf,
 			     _("If you are sure the filesystem is not "
@@ -1198,14 +1200,14 @@
 	my_ver = ext2fs_parse_version_string(my_ver_string);
 	lib_ver = ext2fs_get_library_version(0, &lib_ver_date);
 	if (my_ver > lib_ver) {
-		fprintf( stderr, _("Error: ext2fs library version "
-			"out of date!\n"));
+		fprintf( stderr, "%s",
+			 _("Error: ext2fs library version out of date!\n"));
 		show_version_only++;
 	}
 
 	retval = PRS(argc, argv, &ctx);
 	if (retval) {
-		com_err("e2fsck", retval,
+		com_err("e2fsck", retval, "%s",
 			_("while trying to initialize program"));
 		exit(FSCK_ERROR);
 	}
@@ -1340,32 +1342,34 @@
 		com_err(ctx->program_name, retval, _("while trying to open %s"),
 			ctx->filesystem_name);
 		if (retval == EXT2_ET_REV_TOO_HIGH) {
-			log_out(ctx, _("The filesystem revision is apparently "
-			       "too high for this version of e2fsck.\n"
-			       "(Or the filesystem superblock "
-			       "is corrupt)\n\n"));
+			log_out(ctx, "%s",
+				_("The filesystem revision is apparently "
+				  "too high for this version of e2fsck.\n"
+				  "(Or the filesystem superblock "
+				  "is corrupt)\n\n"));
 			fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
 		} else if (retval == EXT2_ET_SHORT_READ)
-			log_out(ctx, _("Could this be a zero-length "
-				       "partition?\n"));
+			log_out(ctx, "%s",
+				_("Could this be a zero-length partition?\n"));
 		else if ((retval == EPERM) || (retval == EACCES))
 			log_out(ctx, _("You must have %s access to the "
-			       "filesystem or be root\n"),
+				       "filesystem or be root\n"),
 			       (ctx->options & E2F_OPT_READONLY) ?
 			       "r/o" : "r/w");
 		else if (retval == ENXIO)
-			log_out(ctx, _("Possibly non-existent or "
-				       "swap device?\n"));
+			log_out(ctx, "%s",
+				_("Possibly non-existent or swap device?\n"));
 		else if (retval == EBUSY)
-			log_out(ctx, _("Filesystem mounted or opened "
-				 "exclusively by another program?\n"));
+			log_out(ctx, "%s", _("Filesystem mounted or opened "
+					 "exclusively by another program?\n"));
 		else if (retval == ENOENT)
-			log_out(ctx, _("Possibly non-existent device?\n"));
+			log_out(ctx, "%s",
+				_("Possibly non-existent device?\n"));
 #ifdef EROFS
 		else if (retval == EROFS)
-			log_out(ctx, _("Disk write-protected; use the -n "
-				       "option to do a read-only\n"
-				       "check of the device.\n"));
+			log_out(ctx, "%s", _("Disk write-protected; use the "
+					     "-n option to do a read-only\n"
+					     "check of the device.\n"));
 #endif
 		else
 			fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
@@ -1483,9 +1487,9 @@
 	 */
 	if (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) {
 		if (ctx->options & E2F_OPT_READONLY) {
-			log_out(ctx, _("Warning: skipping journal recovery "
-				       "because doing a read-only filesystem "
-				       "check.\n"));
+			log_out(ctx, "%s",
+				_("Warning: skipping journal recovery because "
+				  "doing a read-only filesystem check.\n"));
 			io_channel_flush(ctx->fs->io);
 		} else {
 			if (ctx->flags & E2F_FLAG_RESTARTED) {
@@ -1496,7 +1500,8 @@
 				 * device driver is being bogus.
 				 */
 				com_err(ctx->program_name, 0,
-					_("unable to set superblock flags on %s\n"), ctx->device_name);
+					_("unable to set superblock flags "
+					  "on %s\n"), ctx->device_name);
 				fatal_error(ctx, 0);
 			}
 			retval = e2fsck_run_ext3_journal(ctx);
@@ -1602,8 +1607,8 @@
 		log_out(ctx, _("%s: %s while reading bad blocks inode\n"),
 			ctx->program_name, error_message(retval));
 		preenhalt(ctx);
-		log_out(ctx, _("This doesn't bode well, "
-			       "but we'll try to go on...\n"));
+		log_out(ctx, "%s", _("This doesn't bode well, "
+				     "but we'll try to go on...\n"));
 	}
 
 	/*
@@ -1653,9 +1658,10 @@
 					"journal\n", error_message(retval));
 				goto no_journal;
 			}
-			log_out(ctx, _(" Done.\n"));
-			log_out(ctx, _("\n*** journal has been re-created - "
-				       "filesystem is now ext3 again ***\n"));
+			log_out(ctx, "%s", _(" Done.\n"));
+			log_out(ctx, "%s",
+				_("\n*** journal has been re-created - "
+				  "filesystem is now ext3 again ***\n"));
 		}
 	}
 no_journal:
@@ -1677,10 +1683,11 @@
 	}
 
 	if (run_result == E2F_FLAG_RESTART) {
-		log_out(ctx, _("Restarting e2fsck from the beginning...\n"));
+		log_out(ctx, "%s",
+			_("Restarting e2fsck from the beginning...\n"));
 		retval = e2fsck_reset_context(ctx);
 		if (retval) {
-			com_err(ctx->program_name, retval,
+			com_err(ctx->program_name, retval, "%s",
 				_("while resetting context"));
 			fatal_error(ctx, 0);
 		}
@@ -1756,7 +1763,7 @@
 	    !(ctx->options & E2F_OPT_READONLY)) {
 		retval = ext2fs_set_gdt_csum(ctx->fs);
 		if (retval) {
-			com_err(ctx->program_name, retval,
+			com_err(ctx->program_name, retval, "%s",
 				_("while setting block group checksum info"));
 			fatal_error(ctx, 0);
 		}
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 2d961f2..15e97b9 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -220,7 +220,7 @@
 				log_out(ctx, "\n");
 				longjmp(e2fsck_global_ctx->abort_loc, 1);
 			}
-			log_out(ctx, _("cancelled!\n"));
+			log_out(ctx, "%s", _("cancelled!\n"));
 			return 0;
 		}
 		if (strchr(short_yes, (char) c)) {
@@ -235,9 +235,9 @@
 			break;
 	}
 	if (def)
-		log_out(ctx, _("yes\n"));
+		log_out(ctx, "%s", _("yes\n"));
 	else
-		log_out(ctx, _("no\n"));
+		log_out(ctx, "%s", _("no\n"));
 #ifdef HAVE_TERMIOS_H
 	tcsetattr (0, TCSANOW, &termios);
 #endif
@@ -635,7 +635,7 @@
 	if (!buf) {
 		buf = malloc(fs->blocksize * STRIDE_LENGTH);
 		if (!buf) {
-			com_err("malloc", ENOMEM,
+			com_err("malloc", ENOMEM, "%s",
 				_("while allocating zeroizing buffer"));
 			exit(1);
 		}
diff --git a/lib/blkid/blkid_types.h.in b/lib/blkid/blkid_types.h.in
index cb5b10d..2edc0da 100644
--- a/lib/blkid/blkid_types.h.in
+++ b/lib/blkid/blkid_types.h.in
@@ -92,13 +92,13 @@
 #if (@SIZEOF_INT@ == 8)
 typedef unsigned int	__u64;
 #else
-#if (@SIZEOF_LONG@ == 8)
-typedef unsigned long	__u64;
-#else
 #if (@SIZEOF_LONG_LONG@ == 8)
 typedef unsigned long long	__u64;
-#endif /* SIZEOF_LONG_LONG == 8 */
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef unsigned long	__u64;
 #endif /* SIZEOF_LONG == 8 */
+#endif /* SIZEOF_LONG_LONG == 8 */
 #endif /* SIZEOF_INT == 8 */
 #endif /* __U64_TYPEDEF */
 
@@ -108,17 +108,17 @@
 #if (@SIZEOF_INT@ == 8)
 typedef int		__s64;
 #else
-#if (@SIZEOF_LONG@ == 8)
-typedef long		__s64;
-#else
 #if (@SIZEOF_LONG_LONG@ == 8)
 #if defined(__GNUC__)
 typedef __signed__ long long 	__s64;
 #else
 typedef signed long long 	__s64;
 #endif /* __GNUC__ */
-#endif /* SIZEOF_LONG_LONG == 8 */
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef long		__s64;
 #endif /* SIZEOF_LONG == 8 */
+#endif /* SIZEOF_LONG_LONG == 8 */
 #endif /* SIZEOF_INT == 8 */
 #endif /* __S64_TYPEDEF */
 
diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c
index f9be962..c2a8f72 100644
--- a/lib/blkid/getsize.c
+++ b/lib/blkid/getsize.c
@@ -206,8 +206,8 @@
 		perror(argv[0]);
 
 	bytes = blkid_get_dev_size(fd);
-	printf("Device %s has %Ld 1k blocks.\n", argv[1],
-	       (unsigned long long) bytes >> 10);
+	printf("Device %s has %lld 1k blocks.\n", argv[1],
+	       (unsigned long long)bytes >> 10);
 
 	return 0;
 }
diff --git a/lib/blkid/list.h b/lib/blkid/list.h
index c1cbfec..26a5ac1 100644
--- a/lib/blkid/list.h
+++ b/lib/blkid/list.h
@@ -1,4 +1,4 @@
-#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD)
+#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD_INIT)
 #define _BLKID_LIST_H
 
 #ifdef __cplusplus
@@ -27,9 +27,6 @@
 
 #define LIST_HEAD_INIT(name) { &(name), &(name) }
 
-#define LIST_HEAD(name) \
-	struct list_head name = LIST_HEAD_INIT(name)
-
 #define INIT_LIST_HEAD(ptr) do { \
 	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)
diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c
index 32788f6..3a18d76 100644
--- a/lib/ext2fs/bmap.c
+++ b/lib/ext2fs/bmap.c
@@ -173,6 +173,35 @@
 	return 0;
 }
 
+/* Try to map a logical block to an already-allocated physical cluster. */
+errcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino,
+				   struct ext2_inode *inode, blk64_t lblk,
+				   blk64_t *pblk)
+{
+	ext2_extent_handle_t handle;
+	errcode_t retval;
+
+	/* Need bigalloc and extents to be enabled */
+	*pblk = 0;
+	if (!EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+					EXT4_FEATURE_RO_COMPAT_BIGALLOC) ||
+	    !(inode->i_flags & EXT4_EXTENTS_FL))
+		return 0;
+
+	retval = ext2fs_extent_open2(fs, ino, inode, &handle);
+	if (retval)
+		goto out;
+
+	retval = implied_cluster_alloc(fs, ino, inode, handle, lblk, pblk);
+	if (retval)
+		goto out2;
+
+out2:
+	ext2fs_extent_free(handle);
+out:
+	return retval;
+}
+
 static errcode_t extent_bmap(ext2_filsys fs, ext2_ino_t ino,
 			     struct ext2_inode *inode,
 			     ext2_extent_handle_t handle,
diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c
index 22558d6..09a15fa 100644
--- a/lib/ext2fs/expanddir.c
+++ b/lib/ext2fs/expanddir.c
@@ -55,6 +55,7 @@
 			return BLOCK_ABORT;
 		}
 		es->newblocks++;
+		ext2fs_block_alloc_stats2(fs, new_blk, +1);
 	}
 	if (blockcnt > 0) {
 		retval = ext2fs_new_dir_block(fs, 0, 0, &block);
@@ -82,7 +83,6 @@
 	}
 	ext2fs_free_mem(&block);
 	*blocknr = new_blk;
-	ext2fs_block_alloc_stats2(fs, new_blk, +1);
 
 	if (es->done)
 		return (BLOCK_CHANGED | BLOCK_ABORT);
diff --git a/lib/ext2fs/ext2_types.h.in b/lib/ext2fs/ext2_types.h.in
index aa7ca3a..5b98f71 100644
--- a/lib/ext2fs/ext2_types.h.in
+++ b/lib/ext2fs/ext2_types.h.in
@@ -92,11 +92,11 @@
 #if (@SIZEOF_INT@ == 8)
 typedef unsigned int	__u64;
 #else
-#if (@SIZEOF_LONG@ == 8)
-typedef unsigned long	__u64;
-#else
 #if (@SIZEOF_LONG_LONG@ == 8)
 typedef unsigned long long	__u64;
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef unsigned long	__u64;
 #endif /* SIZEOF_LONG_LONG == 8 */
 #endif /* SIZEOF_LONG == 8 */
 #endif /* SIZEOF_INT == 8 */
@@ -108,15 +108,15 @@
 #if (@SIZEOF_INT@ == 8)
 typedef int		__s64;
 #else
-#if (@SIZEOF_LONG@ == 8)
-typedef long		__s64;
-#else
 #if (@SIZEOF_LONG_LONG@ == 8)
 #if defined(__GNUC__)
-typedef __signed__ long long 	__s64;
+typedef __signed__ long long	__s64;
 #else
-typedef signed long long 	__s64;
+typedef signed long long	__s64;
 #endif /* __GNUC__ */
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef long		__s64;
 #endif /* SIZEOF_LONG_LONG == 8 */
 #endif /* SIZEOF_LONG == 8 */
 #endif /* SIZEOF_INT == 8 */
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 0624350..b0c3036 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -924,6 +924,9 @@
 			      struct ext2_inode *inode,
 			      char *block_buf, int bmap_flags, blk64_t block,
 			      int *ret_flags, blk64_t *phys_blk);
+errcode_t ext2fs_map_cluster_block(ext2_filsys fs, ext2_ino_t ino,
+				   struct ext2_inode *inode, blk64_t lblk,
+				   blk64_t *pblk);
 
 #if 0
 /* bmove.c */
diff --git a/lib/ext2fs/ext2fsP.h b/lib/ext2fs/ext2fsP.h
index 8c7983b..319e9b0 100644
--- a/lib/ext2fs/ext2fsP.h
+++ b/lib/ext2fs/ext2fsP.h
@@ -159,6 +159,6 @@
 
 extern int ext2fs_mem_is_zero(const char *mem, size_t len);
 
-int ext2fs_file_block_offset_too_big(ext2_filsys fs,
-				     struct ext2_inode *inode,
-				     blk64_t offset);
+extern int ext2fs_file_block_offset_too_big(ext2_filsys fs,
+					    struct ext2_inode *inode,
+					    blk64_t offset);
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 582b306..7732804 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -18,6 +18,7 @@
 
 #include "ext2_fs.h"
 #include "ext2fs.h"
+#include "ext2fsP.h"
 
 struct ext2_file {
 	errcode_t		magic;
diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c
index 2c1bd75..6c6ecff 100644
--- a/lib/ext2fs/ismounted.c
+++ b/lib/ext2fs/ismounted.c
@@ -21,6 +21,13 @@
 #ifdef HAVE_LINUX_FD_H
 #include <linux/fd.h>
 #endif
+#ifdef HAVE_LINUX_LOOP_H
+#include <linux/loop.h>
+#include <sys/ioctl.h>
+#ifdef HAVE_LINUX_MAJOR_H
+#include <linux/major.h>
+#endif /* HAVE_LINUX_MAJOR_H */
+#endif /* HAVE_LINUX_LOOP_H */
 #ifdef HAVE_MNTENT_H
 #include <mntent.h>
 #endif
@@ -35,6 +42,36 @@
 #include "ext2_fs.h"
 #include "ext2fs.h"
 
+/*
+ * Check to see if a regular file is mounted.
+ * If /etc/mtab/ is a symlink of /proc/mounts, you will need the following check
+ * because the name in /proc/mounts is a loopback device not a regular file.
+ */
+static int check_loop_mounted(const char *mnt_fsname, dev_t mnt_rdev,
+				dev_t file_dev, ino_t file_ino)
+{
+#if defined(HAVE_LINUX_LOOP_H) && defined(HAVE_LINUX_MAJOR_H)
+	struct loop_info64 loopinfo;
+	int loop_fd, ret;
+
+	if (major(mnt_rdev) == LOOP_MAJOR) {
+		loop_fd = open(mnt_fsname, O_RDONLY);
+		if (loop_fd < 0)
+			return -1;
+
+		ret = ioctl(loop_fd, LOOP_GET_STATUS64, &loopinfo);
+		close(loop_fd);
+		if (ret < 0)
+			return -1;
+
+		if (file_dev == loopinfo.lo_device &&
+				file_ino == loopinfo.lo_inode)
+			return 1;
+	}
+#endif /* defined(HAVE_LINUX_LOOP_H) && defined(HAVE_LINUX_MAJOR_H) */
+	return 0;
+}
+
 #ifdef HAVE_SETMNTENT
 /*
  * Helper function which checks a file in /etc/mtab format to see if a
@@ -82,6 +119,10 @@
 #ifndef __GNU__
 				if (file_rdev && (file_rdev == st_buf.st_rdev))
 					break;
+				if (check_loop_mounted(mnt->mnt_fsname,
+						st_buf.st_rdev, file_dev,
+						file_ino) == 1)
+					break;
 #endif	/* __GNU__ */
 			} else {
 				if (file_dev && ((file_dev == st_buf.st_dev) &&
diff --git a/lib/ext2fs/kernel-list.h b/lib/ext2fs/kernel-list.h
index e07d06b..01f4f6b 100644
--- a/lib/ext2fs/kernel-list.h
+++ b/lib/ext2fs/kernel-list.h
@@ -17,9 +17,6 @@
 
 #define LIST_HEAD_INIT(name) { &(name), &(name) }
 
-#define LIST_HEAD(name) \
-	struct list_head name = { &name, &name }
-
 #define INIT_LIST_HEAD(ptr) do { \
 	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
 } while (0)
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index 69ac135..d09c458 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -250,6 +250,7 @@
 			es->err = retval;
 			return BLOCK_ABORT;
 		}
+		ext2fs_block_alloc_stats2(fs, new_blk, +1);
 		es->newblocks++;
 	}
 	if (blockcnt >= 0)
@@ -285,7 +286,6 @@
 		return BLOCK_ABORT;
 	}
 	*blocknr = es->goal = new_blk;
-	ext2fs_block_alloc_stats2(fs, new_blk, +1);
 
 	if (es->num_blocks == 0)
 		return (BLOCK_CHANGED | BLOCK_ABORT);
diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c
index 37cb62c..9fff704 100644
--- a/lib/ext2fs/punch.c
+++ b/lib/ext2fs/punch.c
@@ -177,6 +177,75 @@
 #define dbg_printf(f, a...)		do { } while (0)
 #endif
 
+/* Free a range of blocks, respecting cluster boundaries */
+static errcode_t punch_extent_blocks(ext2_filsys fs, ext2_ino_t ino,
+				     struct ext2_inode *inode,
+				     blk64_t lfree_start, blk64_t free_start,
+				     __u32 free_count, int *freed)
+{
+	blk64_t		pblk;
+	int		freed_now = 0;
+	__u32		cluster_freed;
+	errcode_t	retval = 0;
+
+	/* No bigalloc?  Just free each block. */
+	if (EXT2FS_CLUSTER_RATIO(fs) == 1) {
+		*freed += free_count;
+		while (free_count-- > 0)
+			ext2fs_block_alloc_stats2(fs, free_start++, -1);
+		return retval;
+	}
+
+	/*
+	 * Try to free up to the next cluster boundary.  We assume that all
+	 * blocks in a logical cluster map to blocks from the same physical
+	 * cluster, and that the offsets within the [pl]clusters match.
+	 */
+	if (free_start & EXT2FS_CLUSTER_MASK(fs)) {
+		retval = ext2fs_map_cluster_block(fs, ino, inode,
+						  lfree_start, &pblk);
+		if (retval)
+			goto errout;
+		if (!pblk) {
+			ext2fs_block_alloc_stats2(fs, free_start, -1);
+			freed_now++;
+		}
+		cluster_freed = EXT2FS_CLUSTER_RATIO(fs) -
+			(free_start & EXT2FS_CLUSTER_MASK(fs));
+		if (cluster_freed > free_count)
+			cluster_freed = free_count;
+		free_count -= cluster_freed;
+		free_start += cluster_freed;
+		lfree_start += cluster_freed;
+	}
+
+	/* Free whole clusters from the middle of the range. */
+	while (free_count > 0 && free_count >= EXT2FS_CLUSTER_RATIO(fs)) {
+		ext2fs_block_alloc_stats2(fs, free_start, -1);
+		freed_now++;
+		cluster_freed = EXT2FS_CLUSTER_RATIO(fs);
+		free_count -= cluster_freed;
+		free_start += cluster_freed;
+		lfree_start += cluster_freed;
+	}
+
+	/* Try to free the last cluster. */
+	if (free_count > 0) {
+		retval = ext2fs_map_cluster_block(fs, ino, inode,
+						  lfree_start, &pblk);
+		if (retval)
+			goto errout;
+		if (!pblk) {
+			ext2fs_block_alloc_stats2(fs, free_start, -1);
+			freed_now++;
+		}
+	}
+
+errout:
+	*freed += freed_now;
+	return retval;
+}
+
 static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
 				     struct ext2_inode *inode,
 				     blk64_t start, blk64_t end)
@@ -184,7 +253,7 @@
 	ext2_extent_handle_t	handle = 0;
 	struct ext2fs_extent	extent;
 	errcode_t		retval;
-	blk64_t			free_start, next;
+	blk64_t			free_start, next, lfree_start;
 	__u32			free_count, newlen;
 	int			freed = 0;
 	int			op;
@@ -225,6 +294,7 @@
 			/* Start of deleted region before extent; 
 			   adjust beginning of extent */
 			free_start = extent.e_pblk;
+			lfree_start = extent.e_lblk;
 			if (next > end)
 				free_count = end - extent.e_lblk + 1;
 			else
@@ -240,6 +310,7 @@
 			dbg_printf("Case #%d\n", 2);
 			newlen = start - extent.e_lblk;
 			free_start = extent.e_pblk + newlen;
+			lfree_start = extent.e_lblk + newlen;
 			free_count = extent.e_len - newlen;
 			extent.e_len = newlen;
 		} else {
@@ -255,6 +326,7 @@
 
 			extent.e_len = start - extent.e_lblk;
 			free_start = extent.e_pblk + extent.e_len;
+			lfree_start = extent.e_lblk + extent.e_len;
 			free_count = end - start + 1;
 
 			dbg_print_extent("inserting", &newex);
@@ -314,10 +386,10 @@
 			goto errout;
 		dbg_printf("Free start %llu, free count = %u\n",
 		       free_start, free_count);
-		while (free_count-- > 0) {
-			ext2fs_block_alloc_stats2(fs, free_start++, -1);
-			freed++;
-		}
+		retval = punch_extent_blocks(fs, ino, inode, lfree_start,
+					     free_start, free_count, &freed);
+		if (retval)
+			goto errout;
 	next_extent:
 		retval = ext2fs_extent_get(handle, op,
 					   &extent);
diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c
index efa4e3d..1b23d11 100644
--- a/lib/uuid/gen_uuid.c
+++ b/lib/uuid/gen_uuid.c
@@ -401,9 +401,10 @@
 
 	if (state_fd > 0) {
 		rewind(state_f);
-		len = fprintf(state_f, 
+		len = fprintf(state_f,
 			      "clock: %04x tv: %016lu %08lu adj: %08d\n",
-			      clock_seq, last.tv_sec, last.tv_usec, adjustment);
+			      clock_seq, last.tv_sec, (long)last.tv_usec,
+			      adjustment);
 		fflush(state_f);
 		if (ftruncate(state_fd, len) < 0) {
 			fprintf(state_f, "                   \n");
diff --git a/lib/uuid/tst_uuid.c b/lib/uuid/tst_uuid.c
index 2216970..33fb80b 100644
--- a/lib/uuid/tst_uuid.c
+++ b/lib/uuid/tst_uuid.c
@@ -144,7 +144,7 @@
 	tv.tv_usec = 0;
 	time_reg = uuid_time(buf, &tv);
 	printf("UUID generated at %lu reports %lu (%ld.%ld)\n",
-	       time_gen, time_reg, tv.tv_sec, tv.tv_usec);
+	       time_gen, time_reg, tv.tv_sec, (long)tv.tv_usec);
 	/* allow 1s margin in case of rollover between sampling
 	 * the current time and when the UUID is generated. */
 	if (time_reg > time_gen + 1) {
diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c
index 4c3536b..97fd335 100644
--- a/lib/uuid/uuid_time.c
+++ b/lib/uuid/uuid_time.c
@@ -165,7 +165,7 @@
 		printf("Warning: not a time-based UUID, so UUID time "
 		       "decoding will likely not work!\n");
 	}
-	printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
+	printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, (long)tv.tv_usec,
 	       ctime(&time_reg));
 
 	return 0;
diff --git a/misc/badblocks.c b/misc/badblocks.c
index 432c17b..89f2439 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -369,7 +369,7 @@
 	/* Seek to the correct loc. */
 	if (ext2fs_llseek (dev, (ext2_loff_t) current_block * block_size,
 			 SEEK_SET) != (ext2_loff_t) current_block * block_size)
-		com_err (program_name, errno, _("during seek"));
+		com_err (program_name, errno, "%s", _("during seek"));
 
 	/* Try the read */
 	if (d_flag)
@@ -442,7 +442,7 @@
 	/* Seek to the correct loc. */
 	if (ext2fs_llseek (dev, (ext2_loff_t) current_block * block_size,
 			 SEEK_SET) != (ext2_loff_t) current_block * block_size)
-		com_err (program_name, errno, _("during seek"));
+		com_err (program_name, errno, "%s", _("during seek"));
 
 	/* Try the write */
 	got = write (dev, buffer, try * block_size);
@@ -466,7 +466,8 @@
 #endif
 	retval = ext2fs_sync_device(host_dev, 1);
 	if (retval)
-		com_err(program_name, retval, _("during ext2fs_sync_device"));
+		com_err(program_name, retval, "%s",
+			_("during ext2fs_sync_device"));
 }
 
 static unsigned int test_ro (int dev, blk_t last_block,
@@ -485,8 +486,8 @@
 
 	errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter);
 	if (errcode) {
-		com_err (program_name, errcode,
-			 _("while beginning bad block list iteration"));
+		com_err(program_name, errcode, "%s",
+			_("while beginning bad block list iteration"));
 		exit (1);
 	}
 	do {
@@ -500,13 +501,14 @@
 	}
 	if (!blkbuf)
 	{
-		com_err (program_name, ENOMEM, _("while allocating buffers"));
+		com_err(program_name, ENOMEM, "%s",
+			_("while allocating buffers"));
 		exit (1);
 	}
 	if (v_flag) {
-		fprintf (stderr, _("Checking blocks %lu to %lu\n"),
-			 (unsigned long) first_block,
-			 (unsigned long) last_block - 1);
+		fprintf(stderr, _("Checking blocks %lu to %lu\n"),
+			(unsigned long)first_block,
+			(unsigned long)last_block - 1);
 	}
 	if (t_flag) {
 		fputs(_("Checking for bad blocks in read-only mode\n"), stderr);
@@ -599,7 +601,8 @@
 	read_buffer = buffer + blocks_at_once * block_size;
 
 	if (!buffer) {
-		com_err (program_name, ENOMEM, _("while allocating buffers"));
+		com_err(program_name, ENOMEM, "%s",
+			_("while allocating buffers"));
 		exit (1);
 	}
 
@@ -745,8 +748,8 @@
 	bb_count = 0;
 	errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter);
 	if (errcode) {
-		com_err (program_name, errcode,
-			 _("while beginning bad block list iteration"));
+		com_err(program_name, errcode, "%s",
+			_("while beginning bad block list iteration"));
 		exit (1);
 	}
 	do {
@@ -754,9 +757,10 @@
 	} while (next_bad && next_bad < first_block);
 
 	blkbuf = allocate_buffer(3 * blocks_at_once * block_size);
-	test_record = malloc (blocks_at_once*sizeof(struct saved_blk_record));
+	test_record = malloc(blocks_at_once * sizeof(struct saved_blk_record));
 	if (!blkbuf || !test_record) {
-		com_err(program_name, ENOMEM, _("while allocating buffers"));
+		com_err(program_name, ENOMEM, "%s",
+			_("while allocating buffers"));
 		exit (1);
 	}
 
@@ -1160,15 +1164,15 @@
 	}
 	if (!w_flag) {
 		if (t_flag > 1) {
-			com_err(program_name, 0,
-			_("Maximum of one test_pattern may be specified "
-			  "in read-only mode"));
+			com_err(program_name, 0, "%s",
+				_("Maximum of one test_pattern may be "
+				  "specified in read-only mode"));
 			exit(1);
 		}
 		if (t_patts && (t_patts[0] == (unsigned int) ~0)) {
-			com_err(program_name, 0,
-			_("Random test_pattern is not allowed "
-			  "in read-only mode"));
+			com_err(program_name, 0, "%s",
+				_("Random test_pattern is not allowed "
+				  "in read-only mode"));
 			exit(1);
 		}
 	}
@@ -1180,13 +1184,13 @@
 						 block_size,
 						 &last_block);
 		if (errcode == EXT2_ET_UNIMPLEMENTED) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("Couldn't determine device size; you "
 				  "must specify\nthe size manually\n"));
 			exit(1);
 		}
 		if (errcode) {
-			com_err(program_name, errcode,
+			com_err(program_name, errcode, "%s",
 				_("while trying to determine device size"));
 			exit(1);
 		}
@@ -1263,8 +1267,8 @@
 
 	errcode = ext2fs_badblocks_list_create(&bb_list,0);
 	if (errcode) {
-		com_err (program_name, errcode,
-			 _("while creating in-memory bad blocks list"));
+		com_err(program_name, errcode, "%s",
+			_("while creating in-memory bad blocks list"));
 		exit (1);
 	}
 
@@ -1272,21 +1276,26 @@
 		for(;;) {
 			switch (fscanf(in, "%llu\n", &inblk)) {
 				case 0:
-					com_err (program_name, 0, "input file - bad format");
+					com_err(program_name, 0, "%s",
+						_("input file - bad format"));
 					exit (1);
 				case EOF:
 					break;
 				default:
 					if (inblk >> 32) {
 						com_err(program_name,
-							EOVERFLOW,
-							_("while adding to in-memory bad block list"));
+							EOVERFLOW, "%s",
+						_("while adding to in-memory "
+						  "bad block list"));
 						exit(1);
 					}
 					next_bad = inblk;
 					errcode = ext2fs_badblocks_list_add(bb_list,next_bad);
 					if (errcode) {
-						com_err (program_name, errcode, _("while adding to in-memory bad block list"));
+						com_err(program_name, errcode,
+							"%s",
+						_("while adding to in-memory "
+						  "bad block list"));
 						exit (1);
 					}
 					continue;
diff --git a/misc/chattr.c b/misc/chattr.c
index 6bb33e6..39a6016 100644
--- a/misc/chattr.c
+++ b/misc/chattr.c
@@ -263,8 +263,9 @@
 
 		path = malloc(strlen (dir_name) + 1 + strlen (de->d_name) + 1);
 		if (!path) {
-			fprintf(stderr, _("Couldn't allocate path variable "
-					  "in chattr_dir_proc"));
+			fprintf(stderr, "%s",
+				_("Couldn't allocate path variable "
+				  "in chattr_dir_proc"));
 			return -1;
 		}
 		sprintf(path, "%s/%s", dir_name, de->d_name);
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 3dbfcb9..73555a9 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -215,18 +215,18 @@
 			print_number(super_blk);
 		}
 		if (old_desc_blk) {
-			printf(_(", Group descriptors at "));
+			printf("%s", _(", Group descriptors at "));
 			print_range(old_desc_blk,
 				    old_desc_blk + old_desc_blocks - 1);
 			if (reserved_gdt) {
-				printf(_("\n  Reserved GDT blocks at "));
+				printf("%s", _("\n  Reserved GDT blocks at "));
 				print_range(old_desc_blk + old_desc_blocks,
 					    old_desc_blk + old_desc_blocks +
 					    reserved_gdt - 1);
 			}
 		} else if (new_desc_blk) {
 			fputc(has_super ? ',' : ' ', stdout);
-			printf(_(" Group descriptor at "));
+			printf("%s", _(" Group descriptor at "));
 			print_number(new_desc_blk);
 			has_super++;
 		}
@@ -315,7 +315,7 @@
 	retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
 	if (retval) {
 		com_err("ext2fs_badblocks_list_iterate_begin", retval,
-			_("while printing bad block list"));
+			"%s", _("while printing bad block list"));
 		return;
 	}
 	if (dump) {
@@ -357,30 +357,30 @@
 
 	retval = ext2fs_read_inode(fs, ino,  &inode);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while reading journal inode"));
 		exit(1);
 	}
 	retval = ext2fs_file_open2(fs, ino, &inode, 0, &journal_file);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while opening journal inode"));
 		exit(1);
 	}
 	retval = ext2fs_file_read(journal_file, buf, sizeof(buf), 0);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while reading journal super block"));
 		exit(1);
 	}
 	ext2fs_file_close(journal_file);
 	jsb = (journal_superblock_t *) buf;
 	if (be32_to_cpu(jsb->s_header.h_magic) != JFS_MAGIC_NUMBER) {
-		fprintf(stderr,
-			"Journal superblock magic number invalid!\n");
+		fprintf(stderr, "%s",
+			_("Journal superblock magic number invalid!\n"));
 		exit(1);
 	}
-	printf(_("Journal features:        "));
+	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) {
@@ -433,8 +433,10 @@
 	journal_superblock_t	*jsb;
 
 	/* Get the journal superblock */
-	if ((retval = io_channel_read_blk64(fs->io, fs->super->s_first_data_block+1, -1024, buf))) {
-		com_err(program_name, retval,
+	if ((retval = io_channel_read_blk64(fs->io,
+					    fs->super->s_first_data_block + 1,
+					    -1024, buf))) {
+		com_err(program_name, retval, "%s",
 			_("while reading journal superblock"));
 		exit(1);
 	}
@@ -442,7 +444,7 @@
 	if ((jsb->s_header.h_magic != (unsigned) ntohl(JFS_MAGIC_NUMBER)) ||
 	    (jsb->s_header.h_blocktype !=
 	     (unsigned) ntohl(JFS_SUPERBLOCK_V2))) {
-		com_err(program_name, 0,
+		com_err(program_name, 0, "%s",
 			_("Couldn't find journal superblock magic numbers"));
 		exit(1);
 	}
@@ -485,7 +487,7 @@
 	len = strlen(opts);
 	buf = malloc(len+1);
 	if (!buf) {
-		fprintf(stderr,
+		fprintf(stderr, "%s",
 			_("Couldn't allocate memory to parse options!\n"));
 		exit(1);
 	}
@@ -634,7 +636,7 @@
 	if (retval) {
 		com_err (program_name, retval, _("while trying to open %s"),
 			 device_name);
-		printf (_("Couldn't find valid filesystem superblock.\n"));
+		printf("%s", _("Couldn't find valid filesystem superblock.\n"));
 		exit (1);
 	}
 	fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
diff --git a/misc/e2image.c b/misc/e2image.c
index 878149e..1bbe9c5 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -135,8 +135,8 @@
 
 	/* Sanity check */
 	if (hdr_size > wrt_size) {
-		fprintf(stderr, _("Error: header size is bigger than "
-				  "wrt_size\n"));
+		fprintf(stderr, "%s",
+			_("Error: header size is bigger than wrt_size\n"));
 	}
 
 	ret = ext2fs_get_mem(wrt_size, &header_buf);
@@ -171,7 +171,8 @@
 	hdr.offset_super = ext2fs_llseek(fd, 0, SEEK_CUR);
 	retval = ext2fs_image_super_write(fs, fd, 0);
 	if (retval) {
-		com_err(program_name, retval, _("while writing superblock"));
+		com_err(program_name, retval, "%s",
+			_("while writing superblock"));
 		exit(1);
 	}
 
@@ -179,21 +180,24 @@
 	retval = ext2fs_image_inode_write(fs, fd,
 				  (fd != 1) ? IMAGER_FLAG_SPARSEWRITE : 0);
 	if (retval) {
-		com_err(program_name, retval, _("while writing inode table"));
+		com_err(program_name, retval, "%s",
+			_("while writing inode table"));
 		exit(1);
 	}
 
 	hdr.offset_blockmap = ext2fs_llseek(fd, 0, SEEK_CUR);
 	retval = ext2fs_image_bitmap_write(fs, fd, 0);
 	if (retval) {
-		com_err(program_name, retval, _("while writing block bitmap"));
+		com_err(program_name, retval, "%s",
+			_("while writing block bitmap"));
 		exit(1);
 	}
 
 	hdr.offset_inodemap = ext2fs_llseek(fd, 0, SEEK_CUR);
 	retval = ext2fs_image_bitmap_write(fs, fd, IMAGER_FLAG_INODEMAP);
 	if (retval) {
-		com_err(program_name, retval, _("while writing inode bitmap"));
+		com_err(program_name, retval, "%s",
+			_("while writing inode bitmap"));
 		exit(1);
 	}
 
@@ -1086,13 +1090,15 @@
 
 	retval = ext2fs_open_inode_scan(fs, 0, &scan);
 	if (retval) {
-		com_err(program_name, retval, _("while opening inode scan"));
+		com_err(program_name, retval,"%s",
+			_("while opening inode scan"));
 		exit(1);
 	}
 
 	retval = ext2fs_get_mem(fs->blocksize * 3, &block_buf);
 	if (retval) {
-		com_err(program_name, 0, "Can't allocate block buffer");
+		com_err(program_name, 0, "%s",
+			_("Can't allocate block buffer"));
 		exit(1);
 	}
 
@@ -1103,7 +1109,7 @@
 		if (retval == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE)
 			continue;
 		if (retval) {
-			com_err(program_name, retval,
+			com_err(program_name, retval, "%s",
 				_("while getting next inode"));
 			exit(1);
 		}
diff --git a/misc/e2undo.c b/misc/e2undo.c
index b1cb750..a7402b3 100644
--- a/misc/e2undo.c
+++ b/misc/e2undo.c
@@ -48,8 +48,8 @@
 	io_channel_set_blksize(channel, SUPERBLOCK_OFFSET);
 	retval = io_channel_read_blk64(channel, 1, -SUPERBLOCK_SIZE, &super);
 	if (retval) {
-		com_err(prg_name,
-			retval, _("Failed to read the file system data \n"));
+		com_err(prg_name, retval,
+			"%s", _("Failed to read the file system data \n"));
 		return retval;
 	}
 
@@ -85,7 +85,7 @@
 	}
 	memcpy(s_uuid, tdb_data.dptr, sizeof(s_uuid));
 	if (memcmp(s_uuid, super.s_uuid, sizeof(s_uuid))) {
-		com_err(prg_name, 0,
+		com_err(prg_name, 0, "%s",
 			_("The file system UUID didn't match \n"));
 		return -1;
 	}
@@ -172,8 +172,8 @@
 	}
 
 	if (mount_flags & EXT2_MF_MOUNTED) {
-		com_err(prg_name, retval, _("e2undo should only be run on "
-				"unmounted file system\n"));
+		com_err(prg_name, retval, "%s", _("e2undo should only be run "
+						"on unmounted file system\n"));
 		exit(1);
 	}
 
diff --git a/misc/findsuper.c b/misc/findsuper.c
index 6b5e16f..eb9130b 100644
--- a/misc/findsuper.c
+++ b/misc/findsuper.c
@@ -172,7 +172,7 @@
 		optind++;
 	}
 	if (sk < 0) {
-		fprintf(stderr, _("startkb should be positive, not %Lu\n"), sk);
+		fprintf(stderr, _("startkb should be positive, not %llu\n"),sk);
 		exit(1);
 	}
 
@@ -183,7 +183,7 @@
 	}
 
 	/* Now, go looking for the superblock! */
-	printf(_("starting at %Lu, with %u byte increments\n"), sk, skiprate);
+	printf(_("starting at %llu, with %u byte increments\n"), sk, skiprate);
 	if (print_jnl_copies)
 		printf(_("[*] probably superblock written in the ext3 "
 			 "journal superblock,\n\tso start/end/grp wrong\n"));
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 7b89296..df244de 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -293,11 +293,11 @@
 Do not attempt to discard blocks at mkfs time.
 @QUOTA_MAN_COMMENT@.TP
 @QUOTA_MAN_COMMENT@.BI quotatype
-@QUOTA_MAN_COMMENT@Specify which quota type ('usr' or 'grp') is to be initialized. This
-@QUOTA_MAN_COMMENT@option has any effect only if
+@QUOTA_MAN_COMMENT@Specify which quota type ('usr' or 'grp') is to be
+@QUOTA_MAN_COMMENT@initialized. This option has effect only if
 @QUOTA_MAN_COMMENT@.B quota
-@QUOTA_MAN_COMMENT@feature is set. Without this extended option, the default behavior is to
-@QUOTA_MAN_COMMENT@initialize both user and group quotas.
+@QUOTA_MAN_COMMENT@feature is set. Without this extended option, the default
+@QUOTA_MAN_COMMENT@behavior is to initialize both user and group quotas.
 .RE
 .TP
 .BI \-f " fragment-size"
@@ -532,11 +532,22 @@
 .sp
 The filesystem feature set is comprised of a list of features, separated
 by commas, that are to be enabled.  To disable a feature, simply
-prefix the feature name with a  caret ('^') character.  The
-pseudo-filesystem feature "none" will clear all filesystem features.
+prefix the feature name with a  caret ('^') or a minus ('-') character.
+Features with dependents will not be removed successfully.
+The pseudo-filesystem feature "none" will clear all filesystem features.
 .RS 1.2i
 .TP
+.B 64bit
+.br
+Enables the file system to be larger than 2^32 blocks.  This feature is set
+automatically, as needed, but it can be useful to specify this feature
+explicitly if the file system might need to be resized larger than 2^32
+blocks, even if it was smaller than that threshold when it was
+originally created.  Note that some older kernels and older versions
+of e2fsprogs will not support file systems with this feature enabled.
+.TP
 .B bigalloc
+.br
 This feature enables clustered allocation, so that the unit of
 allocation is a power of two number of blocks.  That is, each bit in the
 what had traditionally been known as the block allocation bitmap now
@@ -550,21 +561,49 @@
 The bigalloc feature is still under development, and may not be fully
 supported with your kernel or may have various bugs.  Please see the web
 page http://ext4.wiki.kernel.org/index.php/Bigalloc for details.
+May clash with delayed allocation (see
+.BR nodelalloc mount option).
+.IP
+This feature requires that the
+.B extent
+features be enabled.
 .TP
 .B dir_index
+.br
 Use hashed b-trees to speed up lookups in large directories.
 .TP
-.B extents
+.B dir_nlink
+.br
+Allow more than 65000 subdirectories per directory.
+.TP
+.B extent
+.br
 Instead of using the indirect block scheme for storing the location of
 data blocks in an inode, use extents instead.  This is a much more
 efficient encoding which speeds up filesystem access, especially for
-large files.  (Note: both extent and extents are accepted for
+large files.  (Note: both
+.B extent
+and
+.B extents
+are accepted as valid names for this feature for
 historical/backwards compatibility reasons.)
 .TP
+.B extra_isize
+.br
+This feature enables storage of nanosecond timestamps and creation
+time, if the inode size is larger than 256 bytes or larger.
+.TP
+.B ext_attr
+.br
+This feature enables the use of extended attributes.
+.TP
 .B filetype
-Store file type information in directory entries.
+.br
+This feature enables the storage file type information in directory
+entries.  It is normally enabled by default for all file system types.
 .TP
 .B flex_bg
+.br
 Allow the per-block group metadata (allocation bitmaps and inode tables)
 to be placed anywhere on the storage media.  In addition,
 .B mke2fs
@@ -575,28 +614,82 @@
 option.
 .TP
 .B has_journal
-Create an ext3 journal (as if using the
+.br
+Create a journal to ensure filesystem consistency even across unclean
+shutdowns.  Setting the filesystem feature is equivalent to using the
 .B \-j
-option).
-@JDEV@.TP
-@JDEV@.B journal_dev
-@JDEV@Create an external ext3 journal on the given device
-@JDEV@instead of a regular ext2 filesystem.
-@JDEV@Note that
-@JDEV@.I external-journal
-@JDEV@must be created with the same
-@JDEV@block size as the filesystems that will be using it.
+option.
+.TP
+.B huge_file
+.br
+Allows files larger than 2TiB in size.
+.TP
+.B journal_dev
+.br
+Creates an external ext3 journal on the given device
+instead of a regular ext2 filesystem.
+Note that
+.I external-journal
+must be created with the same
+block size as the filesystems that will be using it.
+.IP
+Once ready, use
+.BR mke2fs (8)
+or
+.BR tune2fs(8)
+with
+.B \-J
+.BR device= <external-device>
+to direct a filesystem to the journaling device (see journal-options).
 .TP
 .B large_file
-Filesystem can contain files that are greater than 2GB.  (Modern kernels
-set this feature automatically when a file > 2GB is created.)
+.br
+Filesystem can contain files that are greater than 2GiB.  (Modern kernels
+set this feature automatically when a file > 2GiB is created.)
+.\" .TP
+.\" .B metadata_csum
+.\" .br
+.\" Filesystem supports metadata checksumming.  This feature enables a
+.\" superset of the functionality of the
+.\" .B uninit_bg
+.\" feature.
+.\" .br
+.\" .B Future feature, available in e2fsprogs 1.43-WIP
+.TP
+.B meta_bg
+.br
+This feature allows file systems to be resized on-line without explicitly
+needing to reserve space for growth in the size of the block group
+descriptors.  This scheme is also used to resize file systems which are
+larger than 2^32 blocks.  It is not recommended that this feature be set
+when a file system is created, since this alternate method of storing
+the block group descriptor will slow down the time needed to mount the
+file system, and newer kernels can automatically set this feature as
+necessary when doing an online resize and no more reserved space is
+available in the resize inode.
+.TP
+.B mmp
+.br
+Multiple mount protection (MMP) feature.  MMP helps to
+protect the filesystem from being multiply mounted and is useful in
+shared storage environments.
 @QUOTA_MAN_COMMENT@.TP
 @QUOTA_MAN_COMMENT@.B quota
-@QUOTA_MAN_COMMENT@Create quota inodes (inode# 3 for userquota and inode# 4 for group quota) and
-@QUOTA_MAN_COMMENT@set them in the superblock.  With this feature, the quotas will be enabled
+@QUOTA_MAN_COMMENT@.br
+@QUOTA_MAN_COMMENT@Create quota inodes (inode #3 for userquota and inode
+@QUOTA_MAN_COMMENT@#4 for group quota) and set them in the superblock.
+@QUOTA_MAN_COMMENT@With this feature, the quotas will be enabled
 @QUOTA_MAN_COMMENT@automatically when the filesystem is mounted.
+@QUOTA_MAN_COMMENT@.IP
+@QUOTA_MAN_COMMENT@Causes the quota files (i.e., user.quota and
+@QUOTA_MAN_COMMENT@group.quota which existed
+@QUOTA_MAN_COMMENT@in the older quota design) to be hidden inodes.
+@QUOTA_MAN_COMMENT@.IP
+@QUOTA_MAN_COMMENT@.B Not defined by default,
+@QUOTA_MAN_COMMENT@see https://ext4.wiki.kernel.org/index.php/Quota
 .TP
 .B resize_inode
+.br
 Reserve space so the block group descriptor table may grow in the future.
 Useful for online resizing using
 .BR resize2fs .
@@ -607,20 +700,30 @@
 using the
 .B resize
 extended option.
+.IP
+ This feature requires that the
+.B sparse_super
+feature be enabled.
 .TP
 .B sparse_super
+.br
 Create a filesystem with fewer superblock backup copies
-(saves space on large filesystems).
+(saves space on large filesystems).  This feature is normally enabled by
+default for all file systems.
 .TP
 .B uninit_bg
+.br
 Create a filesystem without initializing all of the block groups.  This
-feature also enables checksums and highest-inode-used statistics in each
-blockgroup.  This feature can
-speed up filesystem creation time noticeably (if lazy_itable_init is
-enabled), and can also reduce
-.BR e2fsck
-time dramatically.  It is only supported by the ext4 filesystem in
-recent Linux kernels.
+feature allows the kernel to initialize bitmaps and inode tables
+and keep a high watermark for the unused inodes in a filesystem, to reduce
+.BR e2fsck (8)
+time.  The result is that it can speed up filesystem creation time noticeably
+(if lazy_itable_init is enabled).
+.IP
+This first e2fsck run after enabling this feature will take the
+full time, but subsequent e2fsck runs will take only a fraction of the
+original time, depending on how full the file system is.
+It is only supported by the ext4 filesystem in recent Linux kernels.
 .RE
 .TP
 .B \-q
@@ -652,7 +755,8 @@
 .\" using the specified test.
 .TP
 .BI \-t " fs-type"
-Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is to be created.
+Specify the filesystem type (i.e., ext2, ext3, ext4, etc.) that is
+to be created.
 If this option is not specified,
 .B mke2fs
 will pick a default either via how
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index c1cbcaa..4075099 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -199,7 +199,7 @@
 	retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
 	fclose (f);
 	if (retval) {
-		com_err("ext2fs_read_bb_FILE", retval,
+		com_err("ext2fs_read_bb_FILE", retval, "%s",
 			_("while reading in list of bad blocks from file"));
 		exit(1);
 	}
@@ -228,7 +228,7 @@
 	retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
 	pclose(f);
 	if (retval) {
-		com_err("ext2fs_read_bb_FILE", retval,
+		com_err("ext2fs_read_bb_FILE", retval, "%s",
 			_("while processing list of bad blocks from program"));
 		exit(1);
 	}
@@ -299,7 +299,7 @@
 	 */
 	retval = ext2fs_badblocks_list_iterate_begin(bb_list, &bb_iter);
 	if (retval) {
-		com_err("ext2fs_badblocks_list_iterate_begin", retval,
+		com_err("ext2fs_badblocks_list_iterate_begin", retval, "%s",
 			_("while marking bad blocks as used"));
 		exit(1);
 	}
@@ -386,17 +386,17 @@
 {
 	errcode_t		retval;
 	struct ext2_inode	inode;
-	__u32			uid, gid;
 
 	retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, 0);
 	if (retval) {
-		com_err("ext2fs_mkdir", retval, _("while creating root dir"));
+		com_err("ext2fs_mkdir", retval, "%s",
+			_("while creating root dir"));
 		exit(1);
 	}
 	if (root_uid != 0 || root_gid != 0) {
 		retval = ext2fs_read_inode(fs, EXT2_ROOT_INO, &inode);
 		if (retval) {
-			com_err("ext2fs_read_inode", retval,
+			com_err("ext2fs_read_inode", retval, "%s",
 				_("while reading root inode"));
 			exit(1);
 		}
@@ -408,7 +408,7 @@
 
 		retval = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
 		if (retval) {
-			com_err("ext2fs_write_inode", retval,
+			com_err("ext2fs_write_inode", retval, "%s",
 				_("while setting root inode ownership"));
 			exit(1);
 		}
@@ -426,14 +426,14 @@
 	fs->umask = 077;
 	retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, 0, name);
 	if (retval) {
-		com_err("ext2fs_mkdir", retval,
+		com_err("ext2fs_mkdir", retval, "%s",
 			_("while creating /lost+found"));
 		exit(1);
 	}
 
 	retval = ext2fs_lookup(fs, EXT2_ROOT_INO, name, strlen(name), 0, &ino);
 	if (retval) {
-		com_err("ext2_lookup", retval,
+		com_err("ext2_lookup", retval, "%s",
 			_("while looking up /lost+found"));
 		exit(1);
 	}
@@ -446,7 +446,7 @@
 			break;
 		retval = ext2fs_expand_dir(fs, ino);
 		if (retval) {
-			com_err("ext2fs_expand_dir", retval,
+			com_err("ext2fs_expand_dir", retval, "%s",
 				_("while expanding /lost+found"));
 			exit(1);
 		}
@@ -461,7 +461,7 @@
 	ext2fs_inode_alloc_stats2(fs, EXT2_BAD_INO, +1, 0);
 	retval = ext2fs_update_bb_inode(fs, bb_list);
 	if (retval) {
-		com_err("ext2fs_update_bb_inode", retval,
+		com_err("ext2fs_update_bb_inode", retval, "%s",
 			_("while setting bad block inode"));
 		exit(1);
 	}
@@ -530,7 +530,7 @@
 	retval = ext2fs_create_journal_superblock(fs,
 				  ext2fs_blocks_count(fs->super), 0, &buf);
 	if (retval) {
-		com_err("create_journal_dev", retval,
+		com_err("create_journal_dev", retval, "%s",
 			_("while initializing journal superblock"));
 		exit(1);
 	}
@@ -568,7 +568,7 @@
 					fs->super->s_first_data_block+1,
 					1, buf);
 	if (retval) {
-		com_err("create_journal_dev", retval,
+		com_err("create_journal_dev", retval, "%s",
 			_("while writing journal superblock"));
 		exit(1);
 	}
@@ -636,7 +636,7 @@
 		return;
 	}
 
-	printf(_("Superblock backups stored on blocks: "));
+	printf("%s", _("Superblock backups stored on blocks: "));
 	group_block = s->s_first_data_block;
 	col_left = 0;
 	for (i = 1; i < fs->group_desc_count; i++) {
@@ -706,7 +706,7 @@
 	len = strlen(opts);
 	buf = malloc(len+1);
 	if (!buf) {
-		fprintf(stderr,
+		fprintf(stderr, "%s",
 			_("Couldn't allocate memory to parse options!\n"));
 		exit(1);
 	}
@@ -790,7 +790,7 @@
 				continue;
 			}
 			if (resize <= ext2fs_blocks_count(param)) {
-				fprintf(stderr,
+				fprintf(stderr, "%s",
 					_("The resize maximum must be greater "
 					  "than the filesystem size.\n"));
 				r_usage++;
@@ -814,7 +814,7 @@
 
 			if (rsv_gdb > 0) {
 				if (param->s_rev_level == EXT2_GOOD_OLD_REV) {
-					fprintf(stderr,
+					fprintf(stderr, "%s",
 	_("On-line resizing not supported with revision 0 filesystems\n"));
 					free(buf);
 					exit(1);
@@ -1113,11 +1113,11 @@
 			 "%s filesystem type.\n"), ext_type);
 		if (!strcmp(ext_type, "ext3") || !strcmp(ext_type, "ext4") ||
 		    !strcmp(ext_type, "ext4dev")) {
-			printf(_("You probably need to install an updated "
-				 "mke2fs.conf file.\n\n"));
+			printf("%s", _("You probably need to install an "
+				       "updated mke2fs.conf file.\n\n"));
 		}
 		if (!force) {
-			printf(_("Aborting...\n"));
+			printf("%s", _("Aborting...\n"));
 			exit(1);
 		}
 	}
@@ -1329,7 +1329,8 @@
 		pathlen += strlen(oldpath);
 	newpath = malloc(pathlen);
 	if (!newpath) {
-		fprintf(stderr, _("Couldn't allocate memory for new PATH.\n"));
+		fprintf(stderr, "%s",
+			_("Couldn't allocate memory for new PATH.\n"));
 		exit(1);
 	}
 	strcpy(newpath, PATH_SET);
@@ -1439,7 +1440,7 @@
 			direct_io = 1;
 			break;
 		case 'R':
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("'-R' is deprecated, use '-E' instead"));
 			/* fallthrough */
 		case 'E':
@@ -1451,12 +1452,12 @@
 		case 'g':
 			fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0);
 			if (*tmp) {
-				com_err(program_name, 0,
-					_("Illegal number for blocks per group"));
+				com_err(program_name, 0, "%s",
+				_("Illegal number for blocks per group"));
 				exit(1);
 			}
 			if ((fs_param.s_blocks_per_group % 8) != 0) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 				_("blocks per group must be multiple of 8"));
 				exit(1);
 			}
@@ -1464,13 +1465,13 @@
 		case 'G':
 			flex_bg_size = strtoul(optarg, &tmp, 0);
 			if (*tmp) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 					_("Illegal number for flex_bg size"));
 				exit(1);
 			}
 			if (flex_bg_size < 1 ||
 			    (flex_bg_size & (flex_bg_size-1)) != 0) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 					_("flex_bg size must be a power of 2"));
 				exit(1);
 			}
@@ -1503,17 +1504,18 @@
 			parse_journal_opts(optarg);
 			break;
 		case 'K':
-			fprintf(stderr, _("Warning: -K option is deprecated and "
-					  "should not be used anymore. Use "
-					  "\'-E nodiscard\' extended option "
-					  "instead!\n"));
+			fprintf(stderr, "%s",
+				_("Warning: -K option is deprecated and "
+				  "should not be used anymore. Use "
+				  "\'-E nodiscard\' extended option "
+				  "instead!\n"));
 			discard = 0;
 			break;
 		case 'l':
 			bad_blocks_filename = realloc(bad_blocks_filename,
 						      strlen(optarg) + 1);
 			if (!bad_blocks_filename) {
-				com_err(program_name, ENOMEM,
+				com_err(program_name, ENOMEM, "%s",
 					_("in malloc for bad_blocks_filename"));
 				exit(1);
 			}
@@ -1572,7 +1574,7 @@
 			break;
 		case 't':
 			if (fs_type) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 				    _("The -t option may only be used once"));
 				exit(1);
 			}
@@ -1580,7 +1582,7 @@
 			break;
 		case 'T':
 			if (usage_types) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 				    _("The -T option may only be used once"));
 				exit(1);
 			}
@@ -1679,20 +1681,20 @@
 						 &dev_size);
 
 	if (retval && (retval != EXT2_ET_UNIMPLEMENTED)) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while trying to determine filesystem size"));
 		exit(1);
 	}
 	if (!fs_blocks_count) {
 		if (retval == EXT2_ET_UNIMPLEMENTED) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("Couldn't determine device size; you "
 				"must specify\nthe size of the "
 				"filesystem\n"));
 			exit(1);
 		} else {
 			if (dev_size == 0) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 				_("Device size reported to be zero.  "
 				  "Invalid partition specified, or\n\t"
 				  "partition table wasn't reread "
@@ -1709,7 +1711,7 @@
 					     EXT2_BLOCK_SIZE(&fs_param))-1));
 		}
 	} else if (!force && (fs_blocks_count > dev_size)) {
-		com_err(program_name, 0,
+		com_err(program_name, 0, "%s",
 			_("Filesystem larger than apparent device size."));
 		proceed_question();
 	}
@@ -1730,7 +1732,7 @@
 				 fs_blocks_count ? fs_blocks_count : dev_size,
 				 argv[0]);
 	if (!fs_types) {
-		fprintf(stderr, _("Failed to parse fs types list\n"));
+		fprintf(stderr, "%s", _("Failed to parse fs types list\n"));
 		exit(1);
 	}
 
@@ -1800,13 +1802,13 @@
 	/* Get the hardware sector sizes, if available */
 	retval = ext2fs_get_device_sectsize(device_name, &lsector_size);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while trying to determine hardware sector size"));
 		exit(1);
 	}
 	retval = ext2fs_get_device_phys_sectsize(device_name, &psector_size);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while trying to determine physical sector size"));
 		exit(1);
 	}
@@ -1839,7 +1841,7 @@
 		fs_blocks_count /= (blocksize / 1024);
 	} else {
 		if (blocksize < lsector_size) {			/* Impossible */
-			com_err(program_name, EINVAL,
+			com_err(program_name, EINVAL, "%s",
 				_("while setting blocksize; too small "
 				  "for device\n"));
 			exit(1);
@@ -1889,14 +1891,15 @@
 	if (r_opt == EXT2_GOOD_OLD_REV &&
 	    (fs_param.s_feature_compat || fs_param.s_feature_incompat ||
 	     fs_param.s_feature_ro_compat)) {
-		fprintf(stderr, _("Filesystem features not supported "
-				  "with revision 0 filesystems\n"));
+		fprintf(stderr, "%s", _("Filesystem features not supported "
+					"with revision 0 filesystems\n"));
 		exit(1);
 	}
 
 	if (s_opt > 0) {
 		if (r_opt == EXT2_GOOD_OLD_REV) {
-			fprintf(stderr, _("Sparse superblocks not supported "
+			fprintf(stderr, "%s",
+				_("Sparse superblocks not supported "
 				  "with revision 0 filesystems\n"));
 			exit(1);
 		}
@@ -1908,8 +1911,8 @@
 
 	if (journal_size != 0) {
 		if (r_opt == EXT2_GOOD_OLD_REV) {
-			fprintf(stderr, _("Journals not supported "
-				  "with revision 0 filesystems\n"));
+			fprintf(stderr, "%s", _("Journals not supported with "
+						"revision 0 filesystems\n"));
 			exit(1);
 		}
 		fs_param.s_feature_compat |=
@@ -1939,8 +1942,8 @@
 	/* Check the user's mkfs options for 64bit */
 	if ((fs_param.s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) &&
 	    !(fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
-		printf(_("Extents MUST be enabled for a 64-bit filesystem.  "
-			 "Pass -O extents to rectify.\n"));
+		printf("%s", _("Extents MUST be enabled for a 64-bit "
+			       "filesystem.  Pass -O extents to rectify.\n"));
 		exit(1);
 	}
 
@@ -1958,13 +1961,13 @@
 			int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE);
 		if (fs_param.s_log_cluster_size &&
 		    fs_param.s_log_cluster_size < fs_param.s_log_block_size) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("The cluster size may not be "
 				  "smaller than the block size.\n"));
 			exit(1);
 		}
 	} else if (cluster_size) {
-		com_err(program_name, 0,
+		com_err(program_name, 0, "%s",
 			_("specifying a cluster size requires the "
 			  "bigalloc feature"));
 		exit(1);
@@ -2052,7 +2055,7 @@
 	/* Can't support bigalloc feature without extents feature */
 	if ((fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC) &&
 	    !(fs_param.s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS)) {
-		com_err(program_name, 0,
+		com_err(program_name, 0, "%s",
 			_("Can't support bigalloc feature without "
 			  "extents feature"));
 		exit(1);
@@ -2060,24 +2063,24 @@
 
 	if ((fs_param.s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) &&
 	    (fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
-		fprintf(stderr, _("The resize_inode and meta_bg features "
-				  "are not compatible.\n"
-				  "They can not be both enabled "
-				  "simultaneously.\n"));
+		fprintf(stderr, "%s", _("The resize_inode and meta_bg "
+					"features are not compatible.\n"
+					"They can not be both enabled "
+					"simultaneously.\n"));
 		exit(1);
 	}
 
 	if (!quiet &&
 	    (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC))
-		fprintf(stderr, _("\nWarning: the bigalloc feature is still "
-				  "under development\n"
+		fprintf(stderr, "%s", _("\nWarning: the bigalloc feature is "
+				  "still under development\n"
 				  "See https://ext4.wiki.kernel.org/"
 				  "index.php/Bigalloc for more information\n\n"));
 
 	if (!quiet &&
 	    (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA))
-		fprintf(stderr, _("\nWarning: the quota feature is still "
-				  "under development\n"
+		fprintf(stderr, "%s", _("\nWarning: the quota feature is "
+				  "still under development\n"
 				  "See https://ext4.wiki.kernel.org/"
 				  "index.php/Quota for more information\n\n"));
 
@@ -2086,7 +2089,7 @@
 	 */
 	if ((fs_param.s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
 	    !(fs_param.s_feature_ro_compat&EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
-		com_err(program_name, 0,
+		com_err(program_name, 0, "%s",
 			_("reserved online resize blocks not supported "
 			  "on non-sparse filesystem"));
 		exit(1);
@@ -2095,7 +2098,7 @@
 	if (fs_param.s_blocks_per_group) {
 		if (fs_param.s_blocks_per_group < 256 ||
 		    fs_param.s_blocks_per_group > 8 * (unsigned) blocksize) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("blocks per group count out of range"));
 			exit(1);
 		}
@@ -2119,7 +2122,7 @@
 	if (flex_bg_size) {
 		if (!(fs_param.s_feature_incompat &
 		      EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("Flex_bg feature not enabled, so "
 				  "flex_bg size may not be specified"));
 			exit(1);
@@ -2307,7 +2310,7 @@
 	if (free_tdb_dir)
 		free(tdb_dir);
 	free(tdb_file);
-	com_err(program_name, retval,
+	com_err(program_name, retval, "%s",
 		_("while trying to setup undo file\n"));
 	return retval;
 }
@@ -2458,7 +2461,8 @@
 		flags |= EXT2_FLAG_PRINT_PROGRESS;
 	retval = ext2fs_initialize(device_name, flags, &fs_param, io_ptr, &fs);
 	if (retval) {
-		com_err(device_name, retval, _("while setting up superblock"));
+		com_err(device_name, retval, "%s",
+			_("while setting up superblock"));
 		exit(1);
 	}
 	fs->progress_ops = &ext2fs_numeric_progress_ops;
@@ -2493,8 +2497,9 @@
 		retval = mke2fs_discard_device(fs);
 		if (!retval && io_channel_discard_zeroes_data(fs->io)) {
 			if (verbose)
-				printf(_("Discard succeeded and will return 0s "
-					 " - skipping inode table wipe\n"));
+				printf("%s",
+				       _("Discard succeeded and will return "
+					 "0s - skipping inode table wipe\n"));
 			lazy_itable_init = 1;
 			itable_zeroed = 1;
 		}
@@ -2634,19 +2639,19 @@
 	handle_bad_blocks(fs, bb_list);
 	fs->stride = fs_stride = fs->super->s_raid_stride;
 	if (!quiet)
-		printf(_("Allocating group tables: "));
+		printf("%s", _("Allocating group tables: "));
 	retval = ext2fs_allocate_tables(fs);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while trying to allocate filesystem tables"));
 		exit(1);
 	}
 	if (!quiet)
-		printf(_("done                            \n"));
+		printf("%s", _("done                            \n"));
 
 	retval = ext2fs_convert_subcluster_bitmap(fs, &fs->block_map);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("\n\twhile converting subcluster bitmap"));
 		exit(1);
 	}
@@ -2702,6 +2707,7 @@
 			retval = ext2fs_create_resize_inode(fs);
 			if (retval) {
 				com_err("ext2fs_create_resize_inode", retval,
+					"%s",
 				_("while reserving blocks for online resize"));
 				exit(1);
 			}
@@ -2737,14 +2743,14 @@
 			exit(1);
 		}
 		if (!quiet)
-			printf(_("done\n"));
+			printf("%s", _("done\n"));
 		ext2fs_close(jfs);
 		free(journal_device);
 	} else if ((journal_size) ||
 		   (fs_param.s_feature_compat &
 		    EXT3_FEATURE_COMPAT_HAS_JOURNAL)) {
 		if (super_only) {
-			printf(_("Skipping journal creation in super-only mode\n"));
+			printf("%s", _("Skipping journal creation in super-only mode\n"));
 			fs->super->s_journal_inum = EXT2_JOURNAL_INO;
 			goto no_journal;
 		}
@@ -2762,20 +2768,21 @@
 		retval = ext2fs_add_journal_inode(fs, journal_blocks,
 						  journal_flags);
 		if (retval) {
-			com_err (program_name, retval,
-				 _("\n\twhile trying to create journal"));
+			com_err(program_name, retval, "%s",
+				_("\n\twhile trying to create journal"));
 			exit(1);
 		}
 		if (!quiet)
-			printf(_("done\n"));
+			printf("%s", _("done\n"));
 	}
 no_journal:
 	if (!super_only &&
 	    fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) {
 		retval = ext2fs_mmp_init(fs);
 		if (retval) {
-			fprintf(stderr, _("\nError while enabling multiple "
-					  "mount protection feature."));
+			fprintf(stderr, "%s",
+				_("\nError while enabling multiple "
+				  "mount protection feature."));
 			exit(1);
 		}
 		if (!quiet)
@@ -2792,16 +2799,16 @@
 		create_quota_inodes(fs);
 
 	if (!quiet)
-		printf(_("Writing superblocks and "
+		printf("%s", _("Writing superblocks and "
 		       "filesystem accounting information: "));
 	checkinterval = fs->super->s_checkinterval;
 	max_mnt_count = fs->super->s_max_mnt_count;
 	retval = ext2fs_close(fs);
 	if (retval) {
-		fprintf(stderr,
+		fprintf(stderr, "%s",
 			_("\nWarning, had trouble writing out superblocks."));
 	} else if (!quiet) {
-		printf(_("done\n\n"));
+		printf("%s", _("done\n\n"));
 		if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
 			print_check_message(max_mnt_count, checkinterval);
 	}
diff --git a/misc/mklost+found.c b/misc/mklost+found.c
index 4f78bde..134e824 100644
--- a/misc/mklost+found.c
+++ b/misc/mklost+found.c
@@ -47,7 +47,7 @@
 		 E2FSPROGS_DATE);
 	if (argc != 1) {
 		(void)argv; /* avoid unused argument warning */
-		fprintf (stderr, _("Usage: mklost+found\n"));
+		fprintf (stderr, "%s", _("Usage: mklost+found\n"));
 		exit(1);
 	}
 	if (mkdir (LPF, 0700) == -1) {
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index a84e6d6..0eddf6d 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -26,7 +26,6 @@
  */
 
 #define _XOPEN_SOURCE 600 /* for inclusion of strptime() */
-#define _BSD_SOURCE /* for inclusion of strcasecmp() */
 #include "config.h"
 #include <fcntl.h>
 #include <grp.h>
@@ -41,6 +40,11 @@
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_STRINGS_H
+#include <strings.h>	/* for strcasecmp() */
+#else
+#define _BSD_SOURCE	/* for inclusion of strcasecmp() via <string.h> */
+#endif
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
@@ -213,7 +217,7 @@
 			     EXT2_FLAG_JOURNAL_DEV_OK, 0,
 			     fs->blocksize, io_ptr, &jfs);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while trying to open external journal"));
 		goto no_valid_journal;
 	}
@@ -226,7 +230,7 @@
 
 	/* Get the journal superblock */
 	if ((retval = io_channel_read_blk64(jfs->io, 1, -1024, buf))) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while reading journal superblock"));
 		goto no_valid_journal;
 	}
@@ -310,14 +314,14 @@
 
 	retval = ext2fs_read_inode(fs, ino,  &inode);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while reading journal inode"));
 		return retval;
 	}
 	if (ino == EXT2_JOURNAL_INO) {
 		retval = ext2fs_read_bitmaps(fs);
 		if (retval) {
-			com_err(program_name, retval,
+			com_err(program_name, retval, "%s",
 				_("while reading bitmaps"));
 			return retval;
 		}
@@ -325,7 +329,7 @@
 					       BLOCK_FLAG_READ_ONLY, NULL,
 					       release_blocks_proc, NULL);
 		if (retval) {
-			com_err(program_name, retval,
+			com_err(program_name, retval, "%s",
 				_("while clearing journal inode"));
 			return retval;
 		}
@@ -336,7 +340,7 @@
 		inode.i_flags &= ~EXT2_IMMUTABLE_FL;
 	retval = ext2fs_write_inode(fs, ino, &inode);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while writing journal inode"));
 		return retval;
 	}
@@ -394,7 +398,7 @@
 	fs->super->s_state &= ~EXT2_VALID_FS;
 	printf("\n%s\n", _(please_fsck));
 	if (mount_flags & EXT2_MF_READONLY)
-		printf(_("(and reboot afterwards!)\n"));
+		printf("%s", _("(and reboot afterwards!)\n"));
 }
 
 /* Rewrite extents */
@@ -968,7 +972,7 @@
 					 "match. expected: %x, actual: %x\n"),
 					 EXT4_MMP_MAGIC, mmp_cmp->mmp_magic);
 			else
-				com_err(program_name, error,
+				com_err(program_name, error, "%s",
 					_("while reading MMP block."));
 			goto mmp_error;
 		}
@@ -1193,7 +1197,7 @@
 						  journal_flags);
 		if (retval) {
 			fprintf(stderr, "\n");
-			com_err(program_name, retval,
+			com_err(program_name, retval, "%s",
 				_("\n\twhile trying to create journal file"));
 			return retval;
 		} else
@@ -1249,7 +1253,7 @@
 	quota_release_context(&qctx);
 
 	if ((usrquota == QOPT_ENABLE) || (grpquota == QOPT_ENABLE)) {
-		fprintf(stderr, _("\nWarning: the quota feature is still "
+		fprintf(stderr, "%s", _("\nWarning: the quota feature is still "
 				  "under development\n"
 				  "See https://ext4.wiki.kernel.org/"
 				  "index.php/Quota for more information\n\n"));
@@ -1264,6 +1268,7 @@
 	return;
 }
 
+#ifdef CONFIG_QUOTA
 static void parse_quota_opts(const char *opts)
 {
 	char	*buf, *token, *next, *p;
@@ -1306,8 +1311,7 @@
 	}
 	free(buf);
 }
-
-
+#endif
 
 static void parse_e2label_options(int argc, char ** argv)
 {
@@ -1515,7 +1519,7 @@
 			break;
 		case 'o':
 			if (mntopts_cmd) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 					_("-o may only be specified once"));
 				usage();
 			}
@@ -1524,7 +1528,7 @@
 			break;
 		case 'O':
 			if (features_cmd) {
-				com_err(program_name, 0,
+				com_err(program_name, 0, "%s",
 					_("-O may only be specified once"));
 				usage();
 			}
@@ -1651,7 +1655,7 @@
 	len = strlen(opts);
 	buf = malloc(len+1);
 	if (!buf) {
-		fprintf(stderr,
+		fprintf(stderr, "%s",
 			_("Couldn't allocate memory to parse options!\n"));
 		return 1;
 	}
@@ -1772,7 +1776,7 @@
 			r_usage++;
 	}
 	if (r_usage) {
-		fprintf(stderr, _("\nBad options specified.\n\n"
+		fprintf(stderr, "%s", _("\nBad options specified.\n\n"
 			"Extended options are separated by commas, "
 			"and may take an argument which\n"
 			"\tis set off by an equals ('=') sign.\n\n"
@@ -2332,7 +2336,7 @@
 	tmp_name = strdup(name);
 	if (!tmp_name) {
 	alloc_fn_fail:
-		com_err(program_name, ENOMEM, 
+		com_err(program_name, ENOMEM, "%s",
 			_("Couldn't allocate memory for tdb filename\n"));
 		return ENOMEM;
 	}
@@ -2437,7 +2441,7 @@
 				_("MMP block magic is bad. Try to fix it by "
 				  "running:\n'e2fsck -f %s'\n"), device_name);
 		else if (retval != EXT2_ET_MMP_FAILED)
-			fprintf(stderr,
+			fprintf(stderr, "%s",
 			     _("Couldn't find valid filesystem superblock.\n"));
 
 		ext2fs_free(fs);
@@ -2458,8 +2462,8 @@
 			goto closefs;
 		}
 		if (new_inode_size < EXT2_INODE_SIZE(fs->super)) {
-			fprintf(stderr, _("Shrinking the inode size is "
-					  "not supported\n"));
+			fprintf(stderr, "%s",
+				_("Shrinking inode size is not supported\n"));
 			rc = 1;
 			goto closefs;
 		}
@@ -2686,7 +2690,8 @@
 		} else if (strcasecmp(new_UUID, "random") == 0) {
 			uuid_generate(sb->s_uuid);
 		} else if (uuid_parse(new_UUID, sb->s_uuid)) {
-			com_err(program_name, 0, _("Invalid UUID format\n"));
+			com_err(program_name, 0, "%s",
+				_("Invalid UUID format\n"));
 			rc = 1;
 			goto closefs;
 		}
@@ -2729,7 +2734,7 @@
 			printf(_("Setting inode size %lu\n"),
 							new_inode_size);
 		} else {
-			printf(_("Failed to change inode size\n"));
+			printf("%s", _("Failed to change inode size\n"));
 			rc = 1;
 			goto closefs;
 		}
diff --git a/misc/util.c b/misc/util.c
index 6c93e1c..40c8858 100644
--- a/misc/util.c
+++ b/misc/util.c
@@ -150,7 +150,7 @@
 	}
 	if (mount_flags & EXT2_MF_MOUNTED) {
 		fprintf(stderr, _("%s is mounted; "), device);
-		if (force > 2) {
+		if (force >= 2) {
 			fputs(_("mke2fs forced anyway.  Hope /etc/mtab is "
 				"incorrect.\n"), stderr);
 			return;
@@ -162,7 +162,7 @@
 	if (mount_flags & EXT2_MF_BUSY) {
 		fprintf(stderr, _("%s is apparently in use by the system; "),
 			device);
-		if (force > 2) {
+		if (force >= 2) {
 			fputs(_("mke2fs forced anyway.\n"), stderr);
 			return;
 		}
diff --git a/misc/uuidd.c b/misc/uuidd.c
index 2e255ba..5a53138 100644
--- a/misc/uuidd.c
+++ b/misc/uuidd.c
@@ -544,7 +544,7 @@
 				  "%s and subsequent %d UUIDs\n", num),
 			       str, num);
 		} else {
-			printf(_("List of UUID's:\n"));
+			printf("%s", _("List of UUID's:\n"));
 			cp = buf + 4;
 			if (ret != (int) (sizeof(num) + num*sizeof(uu)))
 				goto unexpected_size;
diff --git a/po/cs.po b/po/cs.po
index 2ea495e..e38629d 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -6811,11 +6811,11 @@
 #~ msgid "startkb should be a number, not %s\n"
 #~ msgstr "startkb by mělo být číslo, ne %s\n"
 
-#~ msgid "startkb should be positive, not %Ld\n"
-#~ msgstr "startkb by mělo být kladné, ne %Ld\n"
+#~ msgid "startkb should be positive, not %lld\n"
+#~ msgstr "startkb by mělo být kladné, ne %lld\n"
 
-#~ msgid "starting at %Ld, with %d byte increments\n"
-#~ msgstr "začínám na %Ld s přírůstky %d bajtů\n"
+#~ msgid "starting at %lld, with %d byte increments\n"
+#~ msgstr "začínám na %lld s přírůstky %d bajtů\n"
 
 #~ msgid "       thisoff     block fs_blk_sz  blksz grp last_mount\n"
 #~ msgstr "       tentopos    blok  fs_blk_sz  blksz grp last_mount\n"
diff --git a/po/es.po b/po/es.po
index b9be136..bb43ba7 100644
--- a/po/es.po
+++ b/po/es.po
@@ -6997,21 +6997,21 @@
 #~ msgid "startkb should be a number, not %s\n"
 #~ msgstr "principio debe ser un número, no %s\n"
 
-#~ msgid "startkb should be positive, not %Ld\n"
-#~ msgstr "principio debe ser positivo, no %Ld\n"
+#~ msgid "startkb should be positive, not %lld\n"
+#~ msgstr "principio debe ser positivo, no %lld\n"
 
-#~ msgid "starting at %Ld, with %d byte increments\n"
-#~ msgstr "se comienza en %Ld, con incrementos de %d bytes\n"
+#~ msgid "starting at %lld, with %d byte increments\n"
+#~ msgstr "se comienza en %lld, con incrementos de %d bytes\n"
 
 #~ msgid "       thisoff     block fs_blk_sz  blksz grp last_mount\n"
 #~ msgstr "      este        bloque  fs_blk_sz  blksz grp ultimo_montado\n"
 
 #~ msgid ""
 #~ "\n"
-#~ "%14Ld: finished with errno %d\n"
+#~ "%14lld: finished with errno %d\n"
 #~ msgstr ""
 #~ "\n"
-#~ "%14Ld: se finaliza con el error número %d\n"
+#~ "%14lld: se finaliza con el error número %d\n"
 
 #~ msgid "(unknown os)"
 #~ msgstr "(so desconocido)"
diff --git a/po/fr.po b/po/fr.po
index 69c13d4..cccd69e 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -6774,21 +6774,21 @@
 #~ msgid "startkb should be a number, not %s\n"
 #~ msgstr "début en Ko doit être un nombre, non pas %s\n"
 
-#~ msgid "startkb should be positive, not %Ld\n"
-#~ msgstr "début en Ko doit être positif, non pas %Ld\n"
+#~ msgid "startkb should be positive, not %lld\n"
+#~ msgstr "début en Ko doit être positif, non pas %lld\n"
 
-#~ msgid "starting at %Ld, with %d byte increments\n"
-#~ msgstr "début à %Ld, avec un incrément de %d octets\n"
+#~ msgid "starting at %lld, with %d byte increments\n"
+#~ msgstr "début à %lld, avec un incrément de %d octets\n"
 
 #~ msgid "       thisoff     block fs_blk_sz  blksz grp last_mount\n"
 #~ msgstr "       thisoff     block fs_blk_sz  blksz grp last_mount\n"
 
 #~ msgid ""
 #~ "\n"
-#~ "%14Ld: finished with errno %d\n"
+#~ "%14lld: finished with errno %d\n"
 #~ msgstr ""
 #~ "\n"
-#~ "%14Ld: terminé avec errno %d\n"
+#~ "%14lld: terminé avec errno %d\n"
 
 #~ msgid ""
 #~ "Usage: %s <dev1> <dev2> <dev3>\n"
diff --git a/po/it.po b/po/it.po
index 7ba7d71..48a0b00 100644
--- a/po/it.po
+++ b/po/it.po
@@ -6840,18 +6840,18 @@
 #~ msgid "startkb should be a number, not %s\n"
 #~ msgstr "kb_inizio deve essere un numero, non %s\n"
 
-#~ msgid "startkb should be positive, not %Ld\n"
-#~ msgstr "kb_inizio deve essere positivo, non %Ld\n"
+#~ msgid "startkb should be positive, not %lld\n"
+#~ msgstr "kb_inizio deve essere positivo, non %lld\n"
 
-#~ msgid "starting at %Ld, with %d byte increments\n"
-#~ msgstr "inizio a %Ld, con incrementi di %d byte\n"
+#~ msgid "starting at %lld, with %d byte increments\n"
+#~ msgstr "inizio a %lld, con incrementi di %d byte\n"
 
 #~ msgid ""
 #~ "\n"
-#~ "%14Ld: finished with errno %d\n"
+#~ "%14lld: finished with errno %d\n"
 #~ msgstr ""
 #~ "\n"
-#~ "%14Ld: terminato con errore numero %d\n"
+#~ "%14lld: terminato con errore numero %d\n"
 
 #~ msgid "(unknown os)"
 #~ msgstr "(so sconosciuto)"
diff --git a/po/tr.po b/po/tr.po
index 69d6787..e52bcf3 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -7141,21 +7141,21 @@
 #~ msgid "startkb should be a number, not %s\n"
 #~ msgstr "başlangıç_kb bir sayı olmalı, %s değil\n"
 
-#~ msgid "startkb should be positive, not %Ld\n"
-#~ msgstr "başlangıç_kb poritif olmalı, %Ld değil\n"
+#~ msgid "startkb should be positive, not %lld\n"
+#~ msgstr "başlangıç_kb poritif olmalı, %lld değil\n"
 
-#~ msgid "starting at %Ld, with %d byte increments\n"
-#~ msgstr "%Ld de başlayıp %d bayt arttırımla\n"
+#~ msgid "starting at %lld, with %d byte increments\n"
+#~ msgstr "%lld de başlayıp %d bayt arttırımla\n"
 
 #~ msgid "       thisoff     block fs_blk_sz  blksz grp last_mount\n"
 #~ msgstr "       thisoff     blok ds_blok_boyu  blokboyu grup son_bağlama\n"
 
 #~ msgid ""
 #~ "\n"
-#~ "%14Ld: finished with errno %d\n"
+#~ "%14lld: finished with errno %d\n"
 #~ msgstr ""
 #~ "\n"
-#~ "%14Ld: %d hatası ile bitti\n"
+#~ "%14lld: %d hatası ile bitti\n"
 
 #~ msgid "%s failed for %s: %s\n"
 #~ msgstr "%s %s için başarısız: %s\n"
diff --git a/resize/main.c b/resize/main.c
index 1394ae1..6f3954f 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -151,10 +151,10 @@
 {
 	if (!force && EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
 				EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
-		fprintf(stderr, _("\nResizing bigalloc file systems has "
-				  "not been fully tested.  Proceed\n"
-				  "at your own risk!  Use the force option "
-				  "if you want to go ahead anyway.\n\n"));
+		fprintf(stderr, "%s", _("\nResizing bigalloc file systems has "
+					"not been fully tested.  Proceed at\n"
+					"your own risk!  Use the force option "
+					"if you want to go ahead anyway.\n\n"));
 		exit(1);
 	}
 }
@@ -312,9 +312,9 @@
 	retval = ext2fs_open2(device_name, io_options, io_flags,
 			      0, 0, io_ptr, &fs);
 	if (retval) {
-		com_err (program_name, retval, _("while trying to open %s"),
-			 device_name);
-		printf (_("Couldn't find valid filesystem superblock.\n"));
+		com_err(program_name, retval, _("while trying to open %s"),
+			device_name);
+		printf("%s", _("Couldn't find valid filesystem superblock.\n"));
 		exit (1);
 	}
 
@@ -363,7 +363,7 @@
 	retval = ext2fs_get_device_size2(device_name, fs->blocksize,
 					 &max_size);
 	if (retval) {
-		com_err(program_name, retval,
+		com_err(program_name, retval, "%s",
 			_("while trying to determine filesystem size"));
 		exit(1);
 	}
@@ -389,7 +389,7 @@
 		if (new_size == (1ULL << 32))
 			new_size--;
 		else if (new_size > (1ULL << 32)) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("New size too large to be "
 				  "expressed in 32 bits\n"));
 			exit(1);
@@ -403,7 +403,7 @@
 	}
 	if (use_stride >= 0) {
 		if (use_stride >= (int) fs->super->s_blocks_per_group) {
-			com_err(program_name, 0,
+			com_err(program_name, 0, "%s",
 				_("Invalid stride length"));
 			exit(1);
 		}
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index ff5e6a2..62610f1 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1938,7 +1938,7 @@
 		 * should never happen anyway since the filesystem
 		 * should be fsck'ed and we assume it is consistent.
 		 */
-		fprintf(stderr,
+		fprintf(stderr, "%s",
 			_("Should never happen: resize inode corrupt!\n"));
 		exit(1);
 	}