debian: use dh_strip --dbg-package to populate the dbg packages

Use the --dbg-package option instead of manually moving the files into
the debug packages.  This is simpler to maintain, and avoids a problem
where creating directories using mkdir -p can create world-writeable
/usr/lib directory dependind on the umask used by the Debian buildd.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2image: fix printf format type match

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs: restore and tweak original error messaging

In response to reviewer comments, commit fe56188b07 included changes
that modified some of the code used to output error messages when
checking user-supplied block numbers.  These changes converted calls
to parse_ulonglong() to calls to strtoblk().  Because strtoblk() calls
parse_ulonglong(), and both output error messages, two redundant and
relatively generic messages were output on each error.

Fix this by removing the error message output from strtoblk(), and
extending it to accept an optional error message argument that it
supplies in lieu of a default to parse_ulonglong().  Also, revert to
the more descriptive original error messages with mods per reviewer
comments, and fix an error message in do_replace_node().

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debian: rationalize configure options management

As part of the debian build, the e2fsprogs sources are built multiple
times --- for the udeb packages, for e2fsck.static, etc.  Make sure
that when we disable the use of the built-in blkid and uuid libraries
(in favor of the ones shipped with util-linux), that we do so for all
of the builds.

Previously we were using the internal blkid library for e2fsck.static.
While this isn't completely broken, the internal blkid library hasn't
been maintained in quite some time, so it's better to use the
util-linux blkid library instead.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debian: update changelog for 1.42.9-2 release

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
update config.h.in file to enable loopback mount detection

Commit fbabd5c44c23 added loopback mount detection.  However, we
failed to update the config.h file, so the code wasn't actually
enabled.  Fix this oversight.

Addresses-Debian-Bug: #497984

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
mke2fs: add support to create the file system at an offset

This can be useful when creating a disk image for virtual machines.

Addresses-Debian-Bug: #497984

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debian: add mention of the badblocks program in the package description

Addresses-Debian-Bug: #718725

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
mke2fs: use [^]feature instead of just feature in the man page

Addresses-Debian-Bug: #719184

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck: improve the "superblock corrupt" message

Previously, this message used 8193 as the example alternate
superblock.  But for most file systems, the backup superblock is
located at 32768 (since most file systems have a block size of 4k, and
not 1k).

Addresses-Debian-Bug: #719185

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck.conf: clarify man page's description of accept_time_fudge

Addresses-Debian-Bug: #719189

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2image: mark strings for internationalization

Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2image: fix resource leak when running e2image -n

Addresses-Coverity-ID: #1147783

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
e2image: eliminate division by zero

Dividing a floating point number by zero is undefined in C.  It
happens to work with gcc/glibc, but it's not something that's
guaranteed.

Addresses-Coverity-ID: #1147781

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
e2image: avoid potential divide by zero

It's highly unlikely after five seconds that zero blocks would have
been written, but let's silence the Coverity warning.

Addresses-Coverity-ID: 1147780

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
libblkid: fix sizeof(foo) vs sizeof(*foo) malloc() bug

Addresses-Coverity-Bug: #709510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
subst: clean up various coverity nits

Add appropriate error checking for all error returns, and only open
each file that we need to manipulate once, to avoid potential
time-of-check/time-of-use races.  (Not that this is likely for this
program, but the result is much more clean.)

We also preserve the atime in the case where the file has not changed.

Addresses-Coverty-Id: #709537
Addresses-Coverty-Id: #1049150
Addresses-Coverty-Id: #1049151

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs: clean up read_journal_block() to avoid Coverity complaint

The read_journal_block() function was needlessly complicated, which
made it harder to read/maintain, and it also tripped up Coverity.
Cleaning it up also avoided some signed/unsigned casts, and allows us
to avoid passing got back to the caller, since it wasn't needed.

Addresses-Coverity-Bug: #709539

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck: fix possible double free when searching for config file

This happens if there is an error while scanning a directory for
config file fragments.  This is rarely used, which is why we didn't
notice this.

Addresses-Coverity-Bug: #1138576

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e4defrag: choose the best available posix_fadvise variant

Use posix_fadvise64() when available.  This allows 64bit offsets on
32bit systems.

[ Modified by tytso to try to use fadvise64() as well, and to remove
  the attempt to call the syscall directly, since because and
  complexities caused by required dummy arguments on some
  architectures, it's not worth the hair.  ]

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>