Commit Graph

1156 Commits (6d82e1f4c7af427975009063d387f66cf9672962)

Author SHA1 Message Date
Theodore Ts'o 6d82e1f4c7 mke2fs: only print the low-level file system stats in verbose mode
Also print the file system UUID if it is non-NULL.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-04 23:15:29 -04:00
Theodore Ts'o dbcd617882 mke2fs: check for pre-existing file system
Warn the system administrator if there is an existing file system on
the block device, and give the administrator an opportunity to abort
the mkfs operation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-04 22:22:45 -04:00
Theodore Ts'o f83f4132e1 mke2fs: add an option in mke2fs.conf to proceed after a delay
If mke2fs needs to ask the user for permission, and the user doesn't
type anything the specified delay in the /etc/mke2fs.conf file,
proceed as if the user had said yes.  The default is to do what we
currently do, which is to wait until the user answers the question one
way or the other.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-04 22:20:35 -04:00
Theodore Ts'o 802146c017 mke2fs: create a regular file if necessary
This is useful when creating a filesystem for use with a VM, for
example.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-26 16:17:38 -04:00
Theodore Ts'o 8273945866 mke2fs: don't complain if the regular file is too small
Don't ask the user if it's OK that a regular file is smaller than the
requested size.  This test only makes sense if we are creating the
file system on a block device.  This allow users to not need to
manually answer the "proceed?" question when creating a file system
backed by a simple file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-26 15:12:21 -04:00
Theodore Ts'o d69f43f56a mke2fs, tune2fs: call proceed_question() from check_plausibility()'s caller
Move the call to proceed_question() from check_plausibility() to its
caller.  This allows more fine grained control by mke2fs about when it
might want to call check_plausibility().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-26 13:14:32 -04:00
Theodore Ts'o 83c469bc33 mke2fs: don't ask the proceed question using a regular file
Very often people are creating file systems using regular files, so we
shouldn't ask the user to confirm using the proceed question.
Otherwise it encourages users to use the -F flag, which is a bad
thing.

We do need to continue to check if the external journal device is a
block device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-26 13:12:39 -04:00
Andreas Dilger d8f401b135 fix miscellaneous build warnings
Fix various unused variable and use-uninitialized warnings.

Add generated files into .gitignore.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-14 12:22:42 -04:00
Theodore Ts'o aa73432f71 e4defrag: fix error reporting when ext2fs_open fails
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-10 23:16:34 -04:00
Jon Ernst 4a77520a98 e4defrag: open fs with EXT2_FLAG_64BITS flag
This allows e4defrag to work with 64-bit and bigalloc file systems.

Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-10 23:06:35 -04:00
Theodore Ts'o 767183d45d logsave: make message when process has a non-zero exit code to be less scary
Addresses-Debian-Bug: #468821

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-29 10:25:49 -04:00
Eryu Guan 9aef4b6954 mke2fs: disable resize_inode feature if 64bit feature is enabled
Since auto_64-bit_support is on by default, resize_inode feature will
be disabled when creating a >16T ext4 according to mke2fs.conf(5).

This should also be done when making ext4 with "-O 64bit" to enable
64bit feature explicitly. Otherwise online resize to enlarge a
over-16T fs to larger would fail.

[root@localhost resize]# truncate -s 50t fs.img
[root@localhost resize]# losetup /dev/loop0 fs.img
[root@localhost resize]# mkfs -t ext4 -O 64bit /dev/loop0 30t
[root@localhost resize]# mount /dev/loop0 mnt
[root@localhost resize]# resize2fs /dev/loop0
resize2fs 1.42.7 (21-Jan-2013)
Filesystem at /dev/loop0 is mounted on /root/resize/mnt; on-line resizing required
old_desc_blocks = 3840, new_desc_blocks = 6400
resize2fs: Invalid argument While checking for on-line resizing support

And dmesg shows
[688378.442623] EXT4-fs (loop0): resizing filesystem from 6710886400 to 13421772800 blocks
[688378.443216] EXT4-fs warning (device loop0): verify_reserved_gdb:700: reserved GDT 3201 missing grp 177147 (5804756097)
[688378.443222] EXT4-fs (loop0): resized filesystem to 8858370048
[688378.528451] EXT4-fs warning (device loop0): ext4_group_extend:1710: can't shrink FS - resize aborted

With this fix resize2fs could do the online enlarge correctly.

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-06 10:14:12 -05:00
Theodore Ts'o fedfb27fe5 Add coverage testing using gcov
To check the coverage of e2fsprogs's regression test, do the
following:

	configure --enable-gcov
	make -j8 ; make -j8 check ; make coverage.txt

The coverage information will be the coverage.txt and *.gcov files in
the build directories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-23 00:17:09 -05:00
Eric Sandeen 5fe2bd6084 tune2fs: allow removal of dirty journal with two "-f" options
Jim pointed out that "tune2fs -f -O ^has_journal" won't remove the
journal if the needs_recovery flag is set; the manpage seems to indicate
that it should.  And if you've lost an external journal and can no longer
replay it, how should one proceed?

Change tune2fs so that two "-f" options will allow removal of a dirty
journal from a filesystem, even if the filesystem needs recovery.

e2fsck can then do its best to pick up the pieces.

Addresses-Debian-Bug: #559301

Reported-by: Jim Faulkner <james.faulkner@yale.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-20 20:49:56 -05:00
Baruch Siach 58229aaf85 e4defrag: remove local sync_file_range and fallocate
The locally defined versions of both sync_file_range and fallocate are broken
on 32bit systems. On these systems two 32bit registers are needed for each
64bit parameter. Also, sync_file_range on MIPS32 needs a dummy parameters
after the fd parameter. Just leave all these subtleties to the C library.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-02-18 20:02:49 -05:00
Andreas Dilger 4d46e6c737 build: fix LLVM compiler warnings
Fix a number of non-literal string format warnings from LLVM due
to the use of _() that were not fixed in commit 45ff69ffeb.

Fix mismatched int vs. __u64 format warnings in blkmap64_rb.c.
There were also some comparisons of __u64 start or count <= 0.
Change them to be comparisons == 0, or start + count overflow.

Fix operator precedence warning for (value & (value - 1) != 0)
introduced in 11d1116a7c.  It seems "&" is lower precedence
than "!=", so the above didn't fail for power-of-two values,
but only odd values.  Fortunately, either s_desc_size nor
s_inode_size is valid if odd.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-18 12:17:53 -05:00
Zheng Liu c7c3775443 chattr: improve the description for 'j' option in manpage
Ext4 file system also supports to set/clear 'j' attribute, but it just
say that this option is only useful for ext3 in manpage.  This commit
fixes it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
2014-02-12 12:28:41 -05:00
Darrick J. Wong 84593c2ac6 mke2fs: clean up kernel version tests
Refactor the running kernel version checks to hide the details of
version code checking, etc.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-02-06 15:27:57 -05:00
Akira Fujita 9e7294d391 e2fsprogs: Disallow tune2fs enabling sparse_super with ext4 meta_bg enabled
When meta_bg feature is enabled, group descriptor block is allocated
every 128 block group (or every 64 block group if 64bit feature is
enabled).

In such situation, files in block group more than #128 will be removed
if sparse_super feature is enabled with tune2fs and afterwards
necessary e2fsck running.

Because tune2fs does not reallocate group descriptor blocks but just
set sparse_super feature.  If ext4 has sparse_super,
ext2fs_descriptor_block_loc2() called by e2fsck thinks the block group
(e.g. #128) that it has group descriptor block at the head offset. But
that offset is used as backup super block before.  So e2fsck fixes
ext4 based on invalid group descriptor blocks and this cause data
lost.

The patch avoids this problem simply by disallow tune2fs enabling
sparse_super if meta_bg is enabled.

Steps to reproduce:

1. Create ext4 which has meta_bg, ^sparse_super and 129+ block groups.
	# mke2fs -t ext4 -O meta_bg,^resize_inode,^sparse_super DEV 17G
	# mount DEV /MP

2. Create direcotry and files which use block group #128's metadata.
	# echo $((8192*128+1)) > /sys/fs/ext4/DEV/inode_goal
	# mkdir /MP/DIR
	# for i in $(seq 1 100); do dd if=/dev/urandom of=/MP/DIR/file$i bs=1024 count=10; done

3. Enable sparse_super with tune2fs then execute e2fsck.
   Data in block group #128 will be lost!!
	# umount DEV
	# tune2fs -O sparse_super DEV
	# e2fsck/e2fsck -yf DEV

Signed-off-by: Akira Fujita <a-fujita@rs.jp.ne.cocm>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-02-06 15:13:30 -05:00
Theodore Ts'o 71d920e302 mke2fs: minor bugfixes for mk_hugefiles
Interpret "zero_hugefiles" relation in mke2fs.conf as a boolean value,
as documented in the man page.

If the hugefile is larger than 2GB, set the large_file file system
feature so e2fsck doesn't complain.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-06 14:34:12 -05:00
Theodore Ts'o 7efd250757 mke2fs: add support for hugefiles_align
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-04 12:34:17 -05:00
Theodore Ts'o e5397d7ae9 blkid: suppress Coverity warning
The getopt() function will never let optarg be NULL (at least without
using the GNU double-colon extension, which we don't use because it's
not portable), so don't bother checking for that case.  It's harmless,
but it triggers a Coverity warning elsewhere, since it thinks optarg
could in fact be NULL.

Addresses-Coverity-Id: #1049156

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 18:25:15 -05:00
Theodore Ts'o 5bb4d0cec4 blkid: avoid potential integer overflow issues identified by Coverity
Addresses-Coverity-Id: #1049157
Addresses-Coverity-Id: #1049158

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 18:25:15 -05:00
Theodore Ts'o 23a1b98722 mke2fs: add make_hugefile feature
This feature is enabled via settings in /etc/mke2fs.conf.  For
example:

	hugefile = {
		features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
		inode_size = 128
		num_backup_sb = 0
		packed_meta_blocks = 1
		make_hugefiles = 1
		inode_ratio = 4194304
		hugefiles_dir = /database
		hugefiles_uid = 120
		hugefiles_gid = 50
		hugefiles_name = storage
		hugefiles_digits = 4
		hugefiles_size = 1G
		num_hugefiles = 0
	}

Then "mke2fs -T hugefile /dev/sdXX" will create as many 1G files
needed to fill the file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 18:24:57 -05:00
Theodore Ts'o 3c6e91c549 mke2fs: allow metadata blocks to be at the beginning of the file system
Add the extended options packed_meta_blocks and journal_location_front
which causes mke2fs to place the metadata blocks at the beginning of
the file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 13:58:18 -05:00
Theodore Ts'o 65c6c3e06f Add support for new compat feature "sparse_super2"
In practice, it is **extremely** rare for users to try to use more
than the first backup superblock located at the beginning of block
group #1.  (i.e., at block number 32768 for file systems with a 4k
block size).  This new compat feature restricts the backup superblock
to block group #1 and the last block group in the file system.

Aside from reducing the overhead of the file system by a small number
of blocks, by eliminating the rest of the backup superblocks, it
allows us to have a much more flexible metadata layout.  For example,
we can force all of the allocation bitmaps and inode table blocks to
the beginning of the disk, which allows most of the disk to be
exclusively used for contiguous data blocks.

This simplifies taking advantage of certain HDD specific features,
such as Shingled Magnetic Recording (aka Shingled Drives), and the
TCG's OPAL Storage Specification where having a simple mapping between
LBA block ranges and the data blocks used by the file system can make
life much simpler.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 13:58:18 -05:00
Theodore Ts'o b818205feb tune2fs, mke2fs: add the ability to control the location of the journal
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 13:58:17 -05:00
Theodore Ts'o 6e49e6a3e5 mke2fs: optimize fix_cluster_bg_counts()
Instead of iterating over the allocation bitmap using
ext2fs_test_block_bitmap2(), bit by bit, use
ext2fs_find_first_set_block_bitmap2() instead.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-30 13:57:37 -05:00
Theodore Ts'o 7e50795dfa ext4.5: remove duplicate .TP in man page
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
2014-01-13 14:01:58 -05:00
Theodore Ts'o 2fc92dbc59 blkid: fix blkid -o list formatting with columns > 160
This bug is also in the util-linux version of blkid.

Addresses-Coverity-Id: #1049158

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-10 23:25:54 -05:00
Theodore Ts'o 6596c997f3 blkid: fix gcc -Wall nits
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-10 21:40:28 -05:00
Theodore Ts'o 250bf9a703 mke2fs, tune2fs: remove unneeded access() call
Addresses-Coverity-Id: #709536
Addresses-Coverity-Id: #709535

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-10 21:39:27 -05:00
Theodore Ts'o 46802efa15 blkid: add fallthrough comment
Addresses-Coverity-Id: #709484

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-09 15:03:40 -05:00
Theodore Ts'o 56087556e1 badblocks: print warning if set_o_direct() fails
Addresses-Coverity-Id: #1049148

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-08 19:46:05 -05:00
Theodore Ts'o 6c59a665da configure: fix --with-diet-libc
Newer versions of autoconf pull in AC_PROG_GCC as part of
AC_CANONICAL_HOST.  So we need check for WITH_DIET_LIBC earlier in
configure.in.

Also, e2fsprogs now needs functions which are found in diet libc's
compat library.  So add support for autoconf's LIBS function, and
automatically set libs to include -lcompat.

Finally, disable compiling e4defrag by deault if --with-diet-libc is
specified because the program has too many glibc dependencies.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-05 22:58:16 -05:00
Baruch Siach 9a39389185 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>
2014-01-05 22:55:10 -05:00
Theodore Ts'o fa24c8faa1 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>
2014-01-04 19:11:37 -05:00
Theodore Ts'o 781c0df508 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>
2014-01-04 19:11:37 -05:00
Theodore Ts'o e9b5923544 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>
2014-01-04 19:11:37 -05:00
jon ernst e38bfbe912 e2image: mark strings for internationalization
Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-01-04 19:11:36 -05:00
Theodore Ts'o 5c4c38763c mke2fs: use [^]feature instead of just feature in the man page
Addresses-Debian-Bug: #719184

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-31 22:53:52 -05:00
Theodore Ts'o 88ee023be2 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>
2013-12-30 23:03:09 -05:00
Theodore Ts'o d7e6e97871 e2image: fix printf format type match
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-30 16:56:19 -05:00
Theodore Ts'o d055089567 e2freefrag: avoid integer overflow when reporting free space statistics
An integer overflow could happen if the file system is large and has
very large contiguous chunks of free space.

Addresses-Debian-Bug: #718205

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-28 22:25:11 -05:00
Theodore Ts'o 9518b29727 mke2fs: clarify documentation about bigalloc in the man page
Addresses-Debian-Bug: #669730

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-28 17:57:25 -05:00
Theodore Ts'o 886056bd39 mke2fs: clarify the description of the -I option in the man page
Addresses-Debian-Bug: #698076

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-28 17:09:10 -05:00
Theodore Ts'o c003f48b48 e2image: Clarify e2image's usage message
Also reflect a similar change to e2image's man page.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-27 01:14:09 -05:00
Theodore Ts'o c8ee0d60fd e2image: write progress information to stderr
This allows "e2image -rp /dev/sdc1 - | bzip2 > sdc1.img.bz2" to work
correctly, so the progress information doesn't corrupt the image being
sent to stdout.

Also add a diagnostic indicating that the -p option is currently only
implemented for raw mode.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-27 01:04:32 -05:00
Theodore Ts'o 212c994883 e2image: clean up progress reporting
The old progress reporting code would crash on small file systems.
For example:

    cp /dev/null /tmp/foo.img
    mke2fs -t ext4 -F /tmp/foo.img 100
    e2image -o 0 -O 4096 -rap /tmp/foo.img

Fix this, and while we're at it, factor out the code to make it easier
to read and maintain.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 23:45:17 -05:00
Theodore Ts'o 7fcaabf8e8 dumpe2fs: don't try to print the journal info when using image files
If dumpe2fs tries to print journal info when using an image file
created using e2image, it will crash since the journal isn't
available.  So don't even try to print it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00