Commit Graph

1509 Commits (master)

Author SHA1 Message Date
Theodore Ts'o 14207cf60e Merge branch 'maint' into next
Conflicts:
	configure
	misc/Makefile.in
2014-08-02 22:05:03 -04:00
Artemiy Volkov bf140bf298 debugfs: fix argument parsing in do_freefrag()
When do_freefrag() is called from debugfs, the value of optind is
not reset. Rectify that by calling reset_getopt().

Signed-off-by: Artemiy Volkov <artemiyv@acm.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 19:53:04 -04:00
Theodore Ts'o 3b9904967b misc: fix Makefile for profiled build
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 19:43:10 -04:00
Andreas Dilger af7dbe3a11 filefrag: minor code fixes and cleanups
Print filefrag_fiemap() error message to stderr instead of stdout.

Only call ioctl(EXT3_IOC_GETFLAGS) for ext{2,3,4} filesystems to
decide if the ext2 indirect block allocation heuristic shold be used.

Properly handle the the force_bmap (-B) option.

Exit with a positive error number instead of a negative one.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-01 22:09:23 -04:00
Andreas Dilger 0befec4e24 misc: quiet signed/unsigned charactr compiler warnings
Quiet warnings about signed vs. unsigned character mismatch.
Use __u8 for storing UUIDs instead of char to match the superblock
s_uuid field.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-01 21:39:27 -04:00
Theodore Ts'o 7d0109c085 tune2fs: fix uninitialized variable in remove_journal_device
This bug was introduced by commit 7dfefaf413 ("tune2fs: update
journal super block when changing UUID for fs").

Fixes-Coverity-Bug: 1229243

Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-31 11:49:48 -04:00
Theodore Ts'o 643fd7e7aa Merge branch 'maint' into next 2014-07-29 10:53:49 -04:00
Azat Khuzhin 9c2c1e9a3d tune2fs: update journal users while updating fs UUID (with external journal)
When we have fs with external journal device, and updating it's UUID, we
should update UUID in users list for that external journal device.

Before:
$ tune2fs -U clear /tmp/dev
tune2fs 1.42.10 (18-May-2014)
$ dumpe2fs /tmp/dev | fgrep UUID
dumpe2fs 1.42.10 (18-May-2014)
Filesystem UUID:          <none>
Journal UUID:             da1f2ed0-60f6-aaaa-92fd-738701418523
$ dumpe2fs /tmp/journal | fgrep users -A10
dumpe2fs 1.42.10 (18-May-2014)
Journal number of users:  2
Journal users:            0707762d-638e-4bc6-944e-ae8ee7a3359e
                          0ad849df-1041-4f0a-b1c1-2f949d6a1e37

After:
$ sudo tune2fs -U clear /tmp/dev
tune2fs 1.43-WIP (18-May-2014)
$ dumpe2fs /tmp/dev | fgrep UUID
dumpe2fs 1.42.10 (18-May-2014)
Filesystem UUID:          <none>
Journal UUID:             da1f2ed0-60f6-aaaa-92fd-738701418523
$ dumpe2fs /tmp/journal | fgrep users -A10
dumpe2fs 1.42.10 (18-May-2014)
Journal number of users:  2
Journal users:            0707762d-638e-4bc6-944e-ae8ee7a3359e
                          00000000-0000-0000-0000-000000000000

Also add some consts to avoid *magic numbers*:
- UUID_STR_SIZE
- UUID_SIZE
- JFS_USERS_MAX
- JFS_USERS_SIZE

Proposed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-28 20:21:59 -04:00
Azat Khuzhin 7dfefaf413 tune2fs: update journal super block when changing UUID for fs.
Using -U option you can change the UUID for fs, however it will not work
for journal device, since it have a copy of this UUID inside jsb (i.e.
journal super block). So copy UUID on change into that block.

Here is the initial thread:
http://comments.gmane.org/gmane.comp.file-systems.ext4/44532

You can reproduce this by executing following commands:
$ fallocate -l100M /tmp/dev
$ fallocate -l100M /tmp/journal
$ sudo /sbin/losetup /dev/loop1 /tmp/dev
$ sudo /sbin/losetup /dev/loop0 /tmp/journal
$ mke2fs -O journal_dev /tmp/journal
$ tune2fs -U da1f2ed0-60f6-aaaa-92fd-738701418523 /tmp/journal
$ sudo mke2fs -t ext4 -J device=/dev/loop0 /dev/loop1
$ dumpe2fs -h /tmp/dev | fgrep UUID
dumpe2fs 1.43-WIP (18-May-2014)
Filesystem UUID:          8a776be9-12eb-411f-8e88-b873575ecfb6
Journal UUID:             e3d02151-e776-4865-af25-aecb7291e8e5
$ sudo e2fsck /dev/vdc
e2fsck 1.43-WIP (18-May-2014)
External journal does not support this filesystem

/dev/loop1: ********** WARNING: Filesystem still has errors **********

Reported-by: Chin Tzung Cheng <chintzung@gmail.com>
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-28 20:21:59 -04:00
Azat Khuzhin 3e077c357c tune2fs: remove_journal_device(): use the correct block to find jsb
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-28 20:21:59 -04:00
Azat Khuzhin 7f33024ac2 journal: use consts instead of 1024 and add helper for journal with 1k blocksize
Use EXT2_MIN_BLOCK_SIZE, JFS_MIN_JOURNAL_BLOCKS, SUPERBLOCK_SIZE, and
SUPERBLOCK_OFFSET instead of hardcoded 1024 when it is okay, and also
add a helper ext2fs_journal_sb_start() that will return start of
journal sb with special case for fs with 1k block size.

Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-28 20:21:47 -04:00
Theodore Ts'o 8f5e2b6045 Merge branch 'maint' into next 2014-07-28 16:03:55 -04:00
Ross Burton c84da2eed0 misc: copy extended attributes in populate_fs
When creating a file system using a source directory, also copy any extended
attributes that have been set.

[ Add configure tests for Linux-specific xattr syscalls and add fallback
  when compiling on non-Linux systems. --tytso ]

Signed-off-by: Ross Burton <ross.burton@intel.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-27 21:19:24 -04:00
Rakesh Pandit 01824c9bbc filefrag: fix block size value
ioctl(FIGETBSZ) was used to get block size earlier but 2508eaa7
(filefrag: improvements to filefrag FIEMAP handling) moved to fstatfs
f_bsize which doesn't work well for many files systems.

Block size returned using fstatfs isn't block size but "optimal
transfer block size" as per man page.  Even stat st_blksize is
"preferred I/O block size" and in may file systems it may even vary
from file to file (POSIX).  This patch changes filefrag to use
FIGETBSZ preferentially over f_bsize.

[ Modified by tytso to add the fallback to f_bsize if FIGETBSZ fails
  for some reason ]

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-27 20:24:23 -04:00
Rakesh Pandit abc4697d5a filefrag: fix -B option and extents calculation for FIBMAP
29758d2 broke -B option which is useful for filesystems not supporting
FIEMAP. Also, fix extents calculation for -B which is broken since
2508eaa7.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-27 19:56:27 -04:00
Theodore Ts'o 22302aa320 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
	e2fsck/pass1.c
2014-07-26 15:57:42 -04:00
Darrick J. Wong 97c607b1a2 libext2fs: provide a function to set inode size
Provide an API to set i_size in an inode and take care of all required
feature flag modifications.  Refactor the code to use this new
function.

[ Moved the function to lib/ext2fs/blk_num.c, which is the rest of
  these sorts of functions live, and renamed it to be
  ext2fs_inode_size_set() instead of ext2fs_inode_set_size() to be
  consistent with the other functions in in blk_num.c -- tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 14:34:56 -04:00
Theodore Ts'o 50972e1f7d Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
	e2fsck/pass5.c
2014-07-26 09:46:50 -04:00
Theodore Ts'o 1e33a8b408 Fix 32/64-bit overflow when multiplying by blocks/clusters per group
There are a number of places where we need convert groups to blocks or
clusters by multiply the groups by blocks/clusters per group.
Unfortunately, both quantities are 32-bit, but the result needs to be
64-bit, and very often the cast to 64-bit gets lost.

Fix this by adding new macros, EXT2_GROUPS_TO_BLOCKS() and
EXT2_GROUPS_TO_CLUSTERS().

This should fix a bug where resizing a 64bit file system can result in
calculate_minimum_resize_size() looping forever.

Addresses-Launchpad-Bug: #1321958

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 07:40:36 -04:00
Andreas Dilger 8b90ab2b1c build: fix unused/uninitialized variable warnings
Fix a few warnings about unused and uninitialized variables.

Also fix util/subst.c to include <sys/time.h> to avoid using
undeclared functions gettimeofday() and futimes().

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 22:48:01 -04:00
Darrick J. Wong bf191f274b e2fuzz: Create a tool to fuzz ext* filesystems
Creates a program that fuzzes only the metadata blocks (or optionally
all in-use blocks) of an ext* filesystem.  There's also a script to
automate fuzz testing of the kernel and e2fsck in a loop.

[ Modified by tytso to add e2fuzz to the clean makefile rule ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 09:15:28 -04:00
Darrick J. Wong cd32129d89 mke2fs: set error behavior at initialization time
Port tune2fs' -e flag to mke2fs so that we can set error behavior at
format time, and introduce the equivalent errors= setting into
mke2fs.conf.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 08:58:29 -04:00
Theodore Ts'o 60203cb171 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2014-07-25 08:38:39 -04:00
Darrick J. Wong c3470fcd60 misc: fix problems with strncat
The third argument to strncat is the maximum number of characters to
copy out of the second argument; it is not the maximum length of the
first argument.

Therefore, code in a check just in case we ever find a /sys/block/X
path long enough to hit the end of the buffer.  FWIW the longest path
I could find on my machine was 133 bytes.

Fixes-Coverity-Bug: 1252003
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 07:21:47 -04:00
Theodore Ts'o f9f3050a0a Merge branch 'maint' into next
Conflicts:
	debian/changelog
	e2fsck/pass1.c
	lib/ext2fs/Makefile.in
2014-07-22 14:57:40 -04:00
Darrick J. Wong c7c539e8fd e4defrag: backwards-allocated files should be defragmented too
Currently, e4defrag avoids increasing file fragmentation by comparing
the number of runs of physical extents of both the original and the
donor files.  Unfortunately, there is a bug in the routine that counts
physical extents, since it doesn't look at the logical block offsets
of the extents.  Therefore, a file whose blocks were allocated in
reverse order will be seen as only having one big physical extent, and
therefore will not be defragmented.

Fix the counting routine to consider logical extent offset so that we
defragment backwards-allocated files.  This could be problematic if we
ever gain the ability to lay out logically sparse extents in a
physically contiguous manner, but presumably one wouldn't call defrag
on such a file.

Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-22 12:40:56 -04:00
Theodore Ts'o 30db7954c7 mke2fs: fix fencepost error when calling strncat
There were other protections which would prevent a buffer overflow
from happening, but we should fix this nevertheless.

Addresses-Coverity-Bug: #1225003
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-10 15:33:57 -04:00
Theodore Ts'o f10554e1c2 Merge remote-tracking branch 'origin/maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2014-07-10 01:07:39 -04:00
Theodore Ts'o a93a4c724f Fix nroff macro issue in chattr man page
The single quote character must not be in the first character in a
line, or else it can get mistaken as a macro call.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-10 00:48:57 -04:00
Theodore Ts'o c42de75b2f mke2fs: add support to align hugefiles relative to beginning of the disk
Add the mke2fs.conf configuration option which causes the hugefiles to
be aligned to the beginning of the disk.  This is important if the the
reason for aligning the hugefiles is to support hard-drive specific
features such as Shingled Magnetic Recording (SMR).

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-09 10:42:13 -04:00
Theodore Ts'o 7f7d1cb462 Merge branch 'maint' into next
Conflicts:
	debugfs/set_fields.c
	tests/f_mmp/script
	tests/f_mmp_garbage/script
	tests/m_mmp/script
	tests/t_mmp_1on/script
	tests/t_mmp_2off/script
2014-07-06 00:09:27 -04:00
Akira Fujita d0de4c9540 mke2fs: add get_uint_from_profile to mke2fs.c
We can set flex_bg count only up to 2^30 with profile
because get_int_from_profile can handle it to 2^31-1.
Add get_uint_from_profile to read unsigned int value
so that mke2fs with profile can handle up to 2^31 flex_bg same as -G option.

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-05 22:34:54 -04:00
Akira Fujita a131053ef0 mke2fs: set upper limit to flex_bg count
mke2fs -G option allows root user to set flex_bg count (power of 2).
However ext4 has bad metadata layout if we specify more than or equal to
2^32 to mke2fs -G, because of the 32bit shift operation
in ext2fs_allocate_group_table().

And the maximum block group count of ext4 is 2^32 -1 (ext4_group_t
s_groups_count), so diallow more than 2^32 flex_bg count.

Steps to reproduce:

   # mke2fs -t ext4 -G 4294967296 DEV

   # dumpe2fs DEV
   ...
   Flex block group size:    1          <----- flex_bg is 1!
   ...
   Group 0: (Blocks 0-32767)
     Checksum 0x4afd, unused inodes 7541
     Primary superblock at 0, Group descriptors at 1-1
     Reserved GDT blocks at 2-59
     Block bitmap at 60 (+60), Inode bitmap at 61 (+61)
     Inode table at 62-533 (+62)
     32228 free blocks, 7541 free inodes, 2 directories, 7541 unused inodes
     Free blocks: 540-32767
     Free inodes: 12-7552
   Group 1: (Blocks 32768-65535) [INODE_UNINIT]
     Checksum 0xc890, unused inodes 7552
     Backup superblock at 32768, Group descriptors at 32769-32769
     Reserved GDT blocks at 32770-32827
     Block bitmap at 32828 (+60), Inode bitmap at 32829 (+61)
     Inode table at 32830-33301 (+62)
     32234 free blocks, 7552 free inodes, 0 directories, 7552 unused inodes
     Free blocks: 33302-65535
     Free inodes: 7553-15104
   ...

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: "Darrick J. Wong" <darrick.wong@oracle.com>
2014-07-05 22:14:57 -04:00
Lukas Czerner 7584b8db32 mke2fs: enable lazy_itable_init on newer kernel by default
Currently is used did not specified lazy_itable_init option we rely on
information from ext4 module exported via sysfs interface. However if
the ext4 module is not loaded it will not be enabled even though kernel
might support it.

With this commit we set the default according to the kernel version,
however we still allow it to be set manually via extended option or be
enabled in case that ext4 module advertise that it supports this
feature.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2014-07-05 21:08:38 -04:00
Lukas Czerner d27a559c71 mke2fs: add revision to the is_before_linux_ver()
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-05 21:08:02 -04:00
Lukas Czerner 47fee2ef6a e2fsprogs: introduce ext2fs_close_free() helper
Currently there are many uses of ext2fs_close() which might be wrong.
First of all ext2fs_close() does not set the ext2_filsys pointer to NULL
so the caller is responsible for clearing it, however there are some
cases there we do not do it.

Second of all very small number of users of ext2fs_close() actually
check the return value. If there is a problem in ext2fs_close() it will
not even free the ext2_filsys structure, but majority of users expect it
to do so.

To fix both problems this commit introduces a new helper
ext2fs_close_free() which will not only check for the return value and
free the ext2_filsys structure if the call to ext2fs_close2() failed,
but it will also set the ext2_filsys pointer to NULL.

Replace every use of ext2fs_close() in e2fsprogs tools with
ext2fs_close_free() - there is no real reason to keep using
ext2fs_close().

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2014-07-05 21:06:48 -04:00
Eric Sandeen 3e500a8f11 e2fsprogs: add mount options to ext4.5
This is a straight cut and paste from the util-linux
mount manpage to ext4.5 (with commented-out lines
removed).

It's pretty much impossible for util-linux to keep up
with every filesystem out there, and Karel has more than
once expressed a wish that mount options move into fs-specific
manpages.

So, here we go.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 23:59:45 -04:00
Eric Sandeen 272258e1df e2fsprogs: revise and extend chattr(1) and chattr usage()
The chattr(1) manpage and chattr usage() output were missing some flags.

Add those, and make some other minor cosmetic fixes.

(I've left out the 'B' (EXT2_COMPRBLK_FL) flag, because
it's not actually used anywhere, and I can't figure out
how it differs from 'c' (EXT2_COMPR_FL))

Also, because the matrix of filesystems & flags is quite large,
refer to filesystem-specific manpages for detailed discussion
of flags supported by those filesystems, rather than trying to
cover it all in this manpage.  I'll send those manpage
updates to the appropriate lists a bit later.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2014-07-04 23:59:45 -04:00
Eric Sandeen 5b9aaae742 e2fsprogs: reorder flags in chattr(1)
The flags described in chattr usage() and the chattr(1) manpage
were in semi-random order, which makes it hard to ascertain
which flags might be missing or undocumented, and to locate
flags within the manpage.

Re-order the list of flags in alphanumeric order, and do
the same for the flag descriptions in the body of the manpage.

There should be no content changes here, just reordering
for consistency.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2014-07-04 23:59:45 -04:00
Frank Sorenson 4b59352edb mke2fs: prevent creation of filesystem with unsupported revision
It's a bit strange to accept revision levels higher than
the code creating the filesystem can understand, so don't
allow it.

At least the kernel will mount the fs readonly if it's too
high, but no other utility will touch it, so you can't
fix the error.

Just reject anything > EXT2_MAX_SUPP_REV at mkfs time.

Signed-off-by: Frank Sorenson <fsorenso@redhat.com>
[sandeen@redhat.com: Add more verbose commit log]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 23:59:44 -04:00
Andreas Dilger 3120a50e1a misc: quiet minor build warnings, ignore generated files
Quiet a couple of build warnings in tst_libext2fs.c
Add missing unistd.h header for misc/util.c.

Ignore generated files for lib/ext2fs/tst_libext2fs and intl/ files.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 16:39:44 -04:00
Theodore Ts'o bb9cca2ca9 Merge branch 'maint' into next 2014-06-01 21:49:21 -04:00
Eric Sandeen f2ca701c1c filefrag: fix issues with 29758d2
29758d2 filefrag: exit with error code if an error is hit

introduced a couple errors; in one case it missed returning
a value, and possibly picked up errno from (unchecked) close(),
and in the other used a test where it needed an
assignment.  So capture the error, move perror() directly
after the failed call in both cases, and fix the assignment.

Also fix a precedence problem with:

	if (fe_flags & mask == 0)

which is equivalent to:

	if (fe_flags & (mask == 0))

but we need:

	if ((fe_flags & mask) == 0)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
2014-06-01 21:27:43 -04:00
Benno Schulenberg d7f786c893 mke2fs: gettextize an overlooked error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-06-01 21:23:44 -04:00
Benno Schulenberg 35a0bdd7e2 mke2fs: fix a typo in an error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-06-01 21:12:47 -04:00
Andreas Dilger bbccc6f3c6 misc: fix compile warnings on master branch
Fix compile warnings found on the master branch when using LLVM.

- Add missing format string when using the libintl _() macro
- include <limits.h> header to get PATH_MAX definition
- fix format vs. variable mismatches
- add header block for create_inode.c file
- remove use of bzero(), use ext2fs_get_memzero() instead

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 13:14:18 -04:00
Theodore Ts'o 4230096682 Merge branch 'maint' into next 2014-05-27 13:08:52 -04:00
Darrick J. Wong ec3a42b192 Misc coverity fixes
Fix various small resource leaks and error code handling issues that
Coverity pointed out.

Fixes-Coverity-Bugs: 1215250, 1193379, 119194[2-4], 1049160
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 13:02:19 -04:00
Andreas Dilger 29758d2fc5 filefrag: exit with error code if an error is hit
If an error is hit during filefrag operation, it will continue to run
(if multiple files are specified on the command-line), but will exit
with a non-zero value, so that callers can determine that some error
was hit.

Clean up the printing of FIEMAP flags and print some newer flags that
were missing.  Also print unknown flags as hex values.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 12:56:45 -04:00
Andreas Dilger 3cbb51f91d misc: fix create_inode warnings with LLVM
Fix name clash in do_mknod_internal() due to local variables named
"major" and "minor" shadowing identical macro names.

Also, no need to set the major and minor device for a FIFO inode.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2014-05-27 12:50:48 -04:00
Theodore Ts'o 6bb8845953 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
2014-05-27 12:38:23 -04:00
Vitaliy Filippov 7133644eec misc: use unsigned long long for file block count in filefrag
This patch fixes incorrect reporting of file block count on 32-bit platforms.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 12:12:05 -04:00
Eric Sandeen a7b0f770b0 mke2fs: use ext2fs_open_file() in check_plausibility()
The commit:

802146c mke2fs: create a regular file if necessary

caused a regression on 32-bit machines; the open() fails if
the file size is > 4G.

Using ext2fs_open_file() fixes it.

Addresses-Red-Hat-Bugzilla: #1099892

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-22 13:43:46 -04:00
Theodore Ts'o ba08cb996a Merge branch 'maint' into next
Conflicts:
	debugfs/Makefile.in
	debugfs/debug_cmds.ct
	debugfs/debugfs.c
	debugfs/debugfs.h
	e2fsck/Makefile.in
	misc/Makefile.in
	misc/mke2fs.c
2014-05-13 11:01:07 -04:00
Darrick J. Wong 35a7a5769a mke2fs: set gdt csum when creating packed fs
When we're creating a fs with metadata blocks packed at the beginning
(packed_meta_blocks=1 in mke2fs.conf), set the group descriptor
checksum or else we create DOA filesystems with checksum errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2014-05-13 10:13:40 -04:00
Theodore Ts'o 1c358e6e12 quota: remove mke2fs's and tune2fs's warning messages regarding quota
We no longer need to reference https://ext4.wiki.kernel.org/index.php/Quota
since we've fixed the nasty bugs associated with e2fsck and the quota
feature.  The wiki page will be updated once we've done a release that
includes these fixes indicated the verison which these problems have
been fixed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
2014-05-13 10:13:33 -04:00
Theodore Ts'o d37178bb87 quota: integrate mkquota.h into quotaio.h
There are interfaces that are used by mke2fs.c and tune2fs.c which are
in quotaio.h, and some future changes will be much simpler if we can
combine the two header files together.  Also the guard #ifdef for
mkquota.h was incorrect, which caused problems when both header files
needed to be included.

Also remove quota.pc and installation rules for libquota, since this
library is never going to be something that we can export externally
anyway.  Eventually we'll want to clean up the interfaces and move the
external publishable interfaces to the libext2fs library, and then
rename what's left from libquota.a to libsupport.a for internal use
only.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
2014-05-13 10:13:04 -04:00
Darrick J. Wong c6bab65122 mke2fs: always warn if 128-byte inode and inline_data
The combination of 128-byte inodes and inline_data is silly, since
there's no room in the inode table.  Unfortunately, if neither
mke2fs.conf nor the mkfs command line options specify an inode size,
the default inode size is set to 128 bytes (by libext2fs) and the
warning isn't printed.  Therefore, always do the check-and-warning.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-11 20:26:01 -04:00
Darrick J. Wong c61e00680f libext2fs: create sockets when populating filesystem
Since the code to copy-in a socket when creating a filesystem is
fairly simple, just do it here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:44:16 -04:00
Darrick J. Wong 1bad6f4624 misc: coverity fixes
Fix various small resource leaks and error code handling issues that
Coverity pointed out.

Fixes-Coverity-Bugs: 11919{39-45}, 1174118, 1049160, 1049144
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:40:20 -04:00
Darrick J. Wong a46300fe70 misc: create better-packaged static analysis reports
Fix some minor bugs relating to passing CFLAGS to cppcheck, and
package the cppcheck output into nicer looking reports.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:32:07 -04:00
Theodore Ts'o c9bc7484cc Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2014-05-11 18:30:11 -04:00
Theodore Ts'o 2de2628b2d mke2fs: check for a partition table and warn if present
This supercedes the "whole disk" check, since it does a better job and
there are times when it is quite legitimate to want to use the whole
disk.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-07 10:51:50 -04:00
Theodore Ts'o 352fbedb21 mke2fs: print extra information about existing ext2/3/4 file systems
The basic idea is to provide a bit more context in this situation:

% ./misc/mke2fs -t ext4 /dev/sdc3
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdc3 contains a ext4 file system
Proceed anyway? (y,n)

... by adding this bit of context:

% ./misc/mke2fs -t ext4 /dev/sdc3
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdc3 contains a ext4 file system
	last mounted on /SOX-backups on Mon May  5 08:59:53 2014
Proceed anyway? (y,n)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-07 10:51:39 -04:00
Theodore Ts'o a11ccebd89 mke2fs: print a message when creating a regular file
We've added the ability to automatically recreate a file if it doesn't
exist prior to creating the file system, since this is often used (for
example) when managing file system images for use in virtual machines.
We should at least notify the user that this is going on to avoid
surprises in the case of misspelled device/file names.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-05 10:29:35 -04:00
Mark Fasheh bd1413d499 e2fsprogs/filefrag: print shared extent flag
Filefrag doesn't catch and print the shared extent flag. Add this for
users of filefrag on file systems with shared extents (such as btrfs).

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-04 23:15:48 -04:00
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
Theodore Ts'o 71715a5a9a Merge branch 'maint' into next 2014-04-20 08:31:24 -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
Robert Yang 2af0221537 mke2fs.c: return error when failed to populate fs
We need return retval when "mke2fs -d" failed, otherwise the "$?"
would be 0 which is misleading.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
2014-04-14 11:43:27 -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 7a5081dc30 Merge branch 'maint' into next 2014-04-08 19:26:45 -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
Darrick J. Wong f1605243a4 all: Introduce cppcheck static checking for make C=1
Introduce more static checking via cppcheck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:32:50 -04:00
Theodore Ts'o 3aec816ff6 create_inode: fix gcc -Wall complaints
We had several functions that were not returning zero on success.  Fix
this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:40:17 -04:00
Darrick J. Wong b99888a070 create_inode: handle hard link inum mappings per populate_fs invocation
When calling populate_fs, the map for hardlink detection is not
cleaned up between populate_fs invocations, which could lead to
unexpected results if anyone calls populate_fs twice in the same
client program).  This doesn't happen right now, but we might as well
clean it up.

The detctor fails if the external directory crosses mountpoints,
so fix that too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:34:46 -04:00
Darrick J. Wong a3111e80b8 create_inode: move debugfs internal state back to debugfs
Since create_inode.c is shared between debugfs and mke2fs, don't
spread debugfs internal state into mke2fs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-11 23:30:17 -04:00
Darrick J. Wong 9c891f7e6b create_inode: whitespace fixes
Fix a ton of whitespace issues.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:27:03 -04:00
Darrick J. Wong 8f8d8a575b create_inode: minor cleanups
Fix a couple of small style issues in the create_inode files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:25:08 -04:00
Darrick J. Wong 117b54c35a create_inode: clean up return mess in do_write_internal
do_write_internal returns errno when ext2 library calls fail; since
errno only reflects the outcome of the last C library call, this will
result in confused callers.  Eliminate the naked return since
this results in an undefined return value.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:24:12 -04:00
Theodore Ts'o cecc79ac3f Update Makefile dependencies
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-06 11:26:41 -05:00
Theodore Ts'o d23b1965f3 Merge branch 'ry/mke2fs-populate' into next
Conflicts:
	debugfs/debugfs.c
2014-03-06 11:22:42 -05:00
Robert Yang 5ad810ecb2 mke2fs.8.in: update the manual for the -d option
Update the manual for the -d option

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:25 -05:00
Robert Yang f84894bc04 misc/create_inode.c: handle hardlinks
Create the inode and save the native inode number when we meet the hard
link (st_nlink > 1) at the first time, use ext2fs_link() to link the
name to the target inode number when we meet the same native inode
number again.

This algorithm is referred this from the genext2fs.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:25 -05:00
Robert Yang 217c0bdf17 mke2fs.c: add an option: -d root-directory
This option is used for adding the files from a given directory (the
root-directory) to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:25 -05:00
Robert Yang b696065425 misc/create_inode.c: set owner/mode/time for the inode
Set the uid, gid, mode and time for inode.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:24 -05:00
Robert Yang 3068f03f1c misc/create_inode.c: create directory
The do_mkdir_internal() is used for making dir on the target fs, most of
the code are from debugfs/debugfs.c, the debugfs/debugfs.c will be
modified to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:24 -05:00
Robert Yang ce600dc4aa misc/create_inode.c: copy regular file
The do_write_internal() is used for copying file from native fs to
target, most of the code are from debugfs/debugfs.c, the
debugfs/debugfs.c will be modified to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:24 -05:00
Robert Yang b25ddc5ed5 misc/create_inode.c: create symlink
The do_symlink_internal() is used for creating symlinks, most of the
code are from debugfs/debugfs.c, the debugfs/debugfs.c will be modified
to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:24 -05:00
Robert Yang b234611897 misc/create_inode.c: create special file
The do_mknod_internal() is used for creating special file which is
block, character and fifo, most of the code are from debugfs/debugfs.c,
the debugfs/debugfs.c will be modified to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:24 -05:00
Robert Yang 052064b919 misc/create_inode.c: copy files recursively
Use opendir() and readdir() to read the native directory, then use
lstat() to identify the file type and call the corresponding function to
add the file to the filesystem, call the populate_fs() recursively if it
is a directory.

NOTE: the libext2fs can't create the socket file.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:24 -05:00
Robert Yang 0d4deba22e mke2fs: add the ability to copy files from a given directory
We will add a -d option which will be used for adding the files from a
given directory to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.

* We already have the basic operations in debugfs:
  - Copy regular file
  - Create directory
  - Create symlink
  - Create special file

  We will move these operations into create_inode.h and create_inode.c,
  then let both mke2fs and debugfs use them.

* What we need to do are:
  - Copy the given directory recursively, this will be done by the
    populate_fs()
  - Set the owner, mode and other informations
  - Handle the hard links

TODO:
  - The libext2fs can't create the socket file (S_IFSOCK), do we have a
    plan to support it ?

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-03-06 11:00:23 -05:00
Theodore Ts'o 46d2a26683 Merge branch 'maint' into next 2014-03-06 10:53:34 -05: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
Zheng Liu 3c1388d99c mke2fs: enable inline_data feature on ext4dev filesystem
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:15 -05:00
Zheng Liu b451c8dd39 mke2fs: add inline_data support in mke2fs
Now inline_data doesn't depend on ext_attr.  Hence we don't need to do
this sanity check.  But if the inode size is too small (128 bytes),
inline_data will be useless because we couldn't save data in ibody
extented attribute.  So we need to report this error.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:15 -05:00
Zheng Liu 716a3c3536 libext2fs: handle inline_data in block iterator function
After applied this commit (a7f4c635), we have banned to traverse blocks
for an inode which has inline data because no block belongs to it.  But
before calling this function, we need to check inline data flag.  This
commit add a sanity check ext2fs_inode_has_valid_blocks2() to fix them
except that ext2fs_expand_dir because it will be fixed by another patch.

Meanwhile in this commit it fixes a bug that when we kill a file we
could leak an inode.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:13 -05:00
Theodore Ts'o 3ba59bf649 Merge branch 'maint' into next 2014-02-23 23:07:38 -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
Theodore Ts'o dc084ab7b1 Merge branch 'maint' into next 2014-02-20 21:39:29 -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
Theodore Ts'o d5fc19fc96 Merge branch 'maint' into next 2014-02-06 15:39:28 -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 f70a347dba Merge branch 'maint' into next
Conflicts:
	debian/changelog
	debian/e2fslibs.symbols
	version.h
2014-02-05 15:16:11 -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 f0996c12d5 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/alloc.c
	misc/mke2fs.c
2014-01-30 19:05:16 -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 abbf95c739 tune2fs: add error checking to ext2fs_read_bitmaps() calls
Addresses-Coverity-Id: #1153628
Addresses-Coverity-Id: #1153629

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-01-10 23:26:12 -05:00
Theodore Ts'o 72958b6670 Merge branch 'maint' into next 2014-01-10 23:26:00 -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 81eca9afc0 Merge branch 'maint' into next 2014-01-10 17:44:17 -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 bc82f39437 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
	lib/ext2fs/csum.c
2014-01-09 12:25:37 -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 d2dce124dd Merge branch 'maint' into next
Conflicts:
	debian/changelog
	e2fsck/Makefile.in
2014-01-06 06:58:58 -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 9c846766fd Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2013-12-28 23:27:39 -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 2ffccc82c4 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/csum.c
2013-12-26 00:30:56 -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
Theodore Ts'o 737a88673d e2image: make sure all strings are marked for internationalization
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00
Theodore Ts'o 0155e77021 e2image: add -n option to show what blocks would have been written
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00
Theodore Ts'o 38c771d6dd e2image: add -c option to optimize file system copying for flash devices
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:21:13 -05:00
Theodore Ts'o aa2c743331 e2image: only skip writing zero blocks when writing to a new file
The e2image progam was originally intended to create image files.
However, some people have started using e2image to copy a file system
from one block device to another, since it is more efficient than
using dd because it only copies the blocks which are in use.  If we
are doing this, however, we must not skip writing blocks which are all
zero in the source device, since they may not be zero in the
destination device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Phillip Susi <psusi@ubuntu.com>
2013-12-26 00:21:08 -05:00
Theodore Ts'o d28759b223 e2image: clean up gcc -Wall and sparse nits
Fix up the gcc -Wall and sparse nits introduced by Phillip Susi's
e2image patches.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Phillip Susi <psusi@ubuntu.com>
2013-12-26 00:20:43 -05:00
Theodore Ts'o 80fe25a2d7 e2image: refactor calls to ext2fs_llseek()
Refactor calls to ext2fs_llseek().  This makes the code more compact,
easier to read, and it also fixes a number of places where we call
ext2fs_llseek() without doing proper error checking.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:43 -05:00
Phillip Susi ecc859b281 e2image: handle SIGINT safely
When doing an in place move, interrupting it past the
point of no return will destroy the filesystem since
parts of it have been overwritten.  Catch SIGINT the
first time and issue a warning if this is the case.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:43 -05:00
Phillip Susi c40c7ceffe e2image: add progress indicator
When given the -p switch, print progress information, including
block counts, percentage complete, estimated time remaining, and
throughput.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:43 -05:00
Phillip Susi 22b83f6280 e2image: perform in-place move
If given at least one offset and only one file, assume source
and dest are the same, and do an in place move.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:40 -05:00
Phillip Susi 6b5535f409 e2image: add offset switches
Add -o and -O switches to specify the offset where the source
and destination filesystems start.  This is useful if you have
an image of a partitioned disk or wish to create one.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 23:34:04 -05:00
Theodore Ts'o 3c22bf7e70 Add ext4 man page and update and clean up the other man pages
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:23 -05:00
Andreas Dilger b769aaec1a mke2fs: further updates for mke2fs(8) man page
The mke2fs(8) man page was updated in 4727c67dc2, but needs some
more clear descriptions for extra_isize and metadta_csum features.
The uninit_bg feature is supported by all ext4-capable kernels,
and does have a slow e2fsck pass for newly-formatted filesystems,
so remove the caveat.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:23 -05:00
Andreas Dilger 2bc3041754 debugfs, e2fsck: fix s_desc_size handling
The s_desc_size in the superblock specifies the group descriptor
size in bytes, but in various places the EXT4_FEATURE_INCOMPAT_64BIT
flag implies that the descriptor size is EXT2_MIN_DESC_SIZE_64BIT
(64 bytes) instead of checking the actual size.  In other places,
the s_desc_size field is used without checking for INCOMPAT_64BIT.

In the case of ext2fs_group_desc() the s_desc_size was being ignored,
and assumed to be sizeof(struct ext4_group_desc), which would result
in garbage for any but the first group descriptor.  Similarly, in
ext2fs_group_desc_csum() and print_csum() they assumed that the
maximum group descriptor size was sizeof(struct ext4_group_desc).
Fix these functions to use the actual superblock s_desc_size if
INCOMPAT_64BIT.

Conversely, in ext2fs_swap_group_desc2() s_desc_size was used
without checking for INCOMPAT_64BIT being set.

The e2fsprogs behaviour is different than that of the kernel,
which always checks INCOMPAT_64BIT, and only uses s_desc_size to
determine the offset of group descriptors and what range of bytes
to checksum.

Allow specifying the s_desc_size field at mke2fs time with the
"-E desc_size=NNN" option.  Allow a power-of-two s_desc_size
value up to s_blocksize if INCOMPAT_64BIT is specified.  This
is not expected to be used by regular users at this time, so it
is not currently documented in the mke2fs usage or man page.

Add m_desc_size_128, f_desc_size_128, and f_desc_bad test cases to
verify mke2fs and e2fsck handling of larger group descriptor sizes.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:19 -05:00
Theodore Ts'o f404167dda Clean up sparse warnings
Mostly by adding static and removing excess extern qualifiers.  Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-16 18:56:36 -05:00
Theodore Ts'o e4681bca17 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.8.in
2013-12-16 01:35:56 -05:00
Uri Corin 4727c67dc2 e2fsprogs: mke2fs manpage updates
I've added documentation for all available filesystem features
settable by mke2fs.
* Features now include the kernel constant attached to the function.
* Some pre-existing feature explanations have been expanded based on
ext4.wiki.kernel.org.

[ Edited by tytso for stylistic and correctness. ]

Addresses-Debian-Bug: #586218

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-12-16 01:26:53 -05:00
Kazuya Mio 82896cbe0e mke2fs: fix force option to create filesystem on mounted device
According to mke2fs man, we can create a filesystem on the mounted
device when -FF option is specified.

However, currently we have to specify -F option third to force mke2fs.
This patch fixes the problem.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-16 00:42:44 -05:00
Andreas Dilger 269da3b806 ext2fs: quiet compiler warnings
Include ext2fsP.h in fileio.c for ext2fs_file_block_offset_too_big()
declaration.  Fix up the declaration to mark it extern in the header.

Include <strings.h> header for strcasecmp() in tune2fs.c if available,
as described in the strcasecmp(3) man page, instead of doing this
indirectly by declaring _BSD_SOURCE and getting it from <string.h>.

If CONFIG_QUOTA is undefined, parse_quota_opts() is unused in
tune2fs.c so #ifdef it out.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-15 23:26:31 -05:00
Andreas Dilger 45ff69ffeb build: quiet LLVM non-literal string format warning
Compiling with LLVM generates a large number of warnings due
to the use of _() for wrapping strings for i18n:

    warning: format string is not a string literal
          (potentially insecure) [-Wformat-security]
    ./nls-enable.h:4:14: note: expanded from macro '_'
    #define _(a) (gettext (a))
                 ^~~~~~~~~~~~

These warnings are fixed by using "%s" as the format string,
and then _() is used as the string argument.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-15 22:12:16 -05:00
Andreas Dilger 3a941bef3b build: use long long for __u64 by default
Don't print a verbose configure error in parse-types.h if
<asm/types.h> missing and __[SU]*_TYPEDEF is unset.  This is
always the case for non-Linux builds.

The printf formatting strings all use "%llu" for printing 64-bit
values and this it produces a large number of warnings if __u64
is defined as "unsigned long".  If __U64_TYPEDEF isn't set use
"unsigned long long" for __u64 in ext2-types.h and blkid-types.h
by default instead of using "unsigned long".

Fix a few places where "%d" or "%u" or "%Lu" were used to print a
64-bit value, by converting them to use "%lld" or "%llu" instead.

Fix a few places where "%lu" was used to print .tv_usec, by casting
the variable to "(long)" since .tv_usec is "int" on some systems.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-15 22:10:09 -05:00
Theodore Ts'o 2b24aadee8 Merge branch 'maint' into next
Conflicts:
	misc/tune2fs.c
2013-12-14 20:56:29 -05:00
Darrick J. Wong 66457fcb84 tune2fs: forbid changing uuid on an uninit_bg filesystem
The old uninit_bg checksums depend on the UUID, so prohibit changes to
the UUID if a checksumming filesystem is mounted, because this
introduces a nasty race where the kernel and tune2fs are both trying
to rewrite group descriptors at the same time, with different ideas
about what the UUID is.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-14 20:51:04 -05:00
Darrick J. Wong 22cde0096d misc: use the checksum predicate function, not raw flag tests
metadata_csum implies uninit_bg, and in fact forces the bit off for
rocompat with older implementations.  Therefore, to detect the
presence of checksums, we should use the predicate function to decide
if group descriptor checksums are turned on, not open-coded flag
tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 23:33:48 -05:00
Theodore Ts'o 2d3df8dc7f Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/newdir.c
2013-12-12 15:39:14 -05:00
Darrick J. Wong 6908c0c391 dumpe2fs: check return values
Check the return values from ext2fs_get_block_bitmap_range2(); if an
error happened, print that and don't print garbage bitmap.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:10:31 -05:00
Darrick J. Wong b399382586 e2image: check return value from check_if_mounted()
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:09:29 -05:00
Darrick J. Wong b1667425f8 e4defrag: defensively check results of sysconf(_SC_PAGESIZE)
sysconf(_SC_PAGESIZE) will probably never return an error, but just in
case it does, we shouldn't pass what looks like a huge number to
sync_file_range() and posix_fadvise().

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:08:49 -05:00
Darrick J. Wong e661d28151 e4defrag: don't crash if umounts the filesystem races with us
If someone umounts the filesystem between statfs64() and the getmntent()
iteration, we can exit the loop having never set mnt_type, and strcmp
can crash.  Fix the potential NULL dereference.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:07:34 -05:00
Darrick J. Wong 80a1806d61 mke2fs: don't leak memory (on error path)
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:06:46 -05:00
Darrick J. Wong e39082e2e8 misc: don't leak file descriptors (on error paths)
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 13:05:52 -05:00
Darrick J. Wong d20403df47 mke2fs: load configfile blocksize setting before 64bit checks
mke2fs has a series of checks to ensure that we don't create a
filesystem too big for its blocksize -- if auto-64bit is on, then it
turns on 64bit; otherwise it complains.  Unfortunately, it performs
these checks before looking in mke2fs.conf for a blocksize, which
means that the checks are incorrect if the user specifies a non-4096
blocksize in the config file and says nothing on the command line.
The bug also has the effect of mandating a 4k block size on any block
device larger than 4T in that situation.  Therefore, read the block
size from the config file before performing the 64bit checks.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-12 12:26:29 -05:00
Theodore Ts'o 2fae17697a Merge branch 'maint' into next
Conflicts:
	e2fsck/pass2.c
	e2fsck/pass3.c
2013-12-03 00:24:39 -05:00
Theodore Ts'o 26da661447 dumpe2fs: fix printing of block offsets for 64-bit file systems
Use ext2fs_group_first_block2() instead of ext2fs_group_first_block()
to avoid dumpe2fs from printing crazy block offsets when we have block
numbers which are larger than 32 bits.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-02 21:51:24 -05:00
Theodore Ts'o 4c2ae57d38 e2image: pass the correct size write_header
Commit bf0449b1a6, which added the ability to write qcow2 files,
generalized the write_header() file to take the size of the header
structure which it writes out.  Unfortunately, it changed the call
which supported original e2image format to pass in fs->blocksize,
instead of the actual size of the e2image header structure (which is
substantially smaller than fs->blocksize).  This meant that we copied
in stack garbage into the e2image file, and it made valgrind quite
unhappy.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-02 13:14:43 -05:00
Theodore Ts'o 7e0337ed74 Merge branch 'maint' into next 2013-10-23 20:17:35 -04:00
Darrick J. Wong d87f198ca3 libext2fs: reject 64bit badblocks numbers
Don't accept block numbers larger than 2^32 for the badblocks list,
and don't run badblocks on them either.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-10-23 19:56:21 -04:00
Theodore Ts'o cecfb4c042 mke2fs: don't let resize= turn on resize_inode when meta_bg is set
Passing the "-E resize=NNN" option to mke2fs sets the resize_inode
feature.  However, resize_inode and meta_bg are mutually exclusive;
unfortunately, we check this constraint before we parse the extended
options.  Fix this by moving this check after the calls
parse_extended_opts().

Reported-by: "Darrick J. Wong" <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-23 19:39:42 -04:00
Phillip Susi e2883e2792 mke2fs: clarify inode ratio in man page
The man page still said it was not possible to change the number of
inodes on a filesystem after creating it.  You actually can by
resizing the fs, so clarify this language a bit.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-10-15 23:37:54 -04:00
Theodore Ts'o 1586850bcd Merge branch 'maint' into next 2013-10-14 09:57:23 -04:00
Eric Sandeen d82445e903 tune2fs: more respect for quota config option
Commit 44a2cca3 disabled tune2fs -O quota when the build
didn't have --enable-quota at configure time, but that
wasn't quite enough.

We need to exclude the "-Q" option as well from tune2fs
when --enable-quota isn't specified at configure time.

Otherwise, tune2fs -Q can set the quota feature, but no other
utility will touch the filesystem due to the unknown flag,
if buitl w/o --enable-quota.

So put everything related to "-Q" under #ifdef CONFIG_QUOTA;
usage output (was missing before) and option parsing.

Addresses-Red-Hat-Bugzilla: #1010709
Reported-by: Bert DeKnuydt <Bert.Deknuydt@esat.kuleuven.be>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-14 09:03:20 -04:00
Eric Sandeen f5589f4c18 mke2fs: remove quota docs if not configured in
If quota isn't turned on with --enable-quota, then comment
quota documentation out of the mke2fs manpage.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-14 08:57:17 -04:00
Darrick J. Wong 45e9ccdbb3 tune2fs: don't convert block # to cluster # when clearing uninit_bg
When we're constructing the initial block bitmap as part of removing
the gdt_csum (i.e. uninit_bg) feature, we mustn't convert the block
numbers to cluster numbers because ext2fs_mark_block_bitmap2() does
this for us.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-12 23:05:36 -04:00
Theodore Ts'o e337e7fad8 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/rehash.c
	e2fsck/super.c
2013-10-12 22:26:28 -04:00
Darrick J. Wong 832cb612f8 e2fsprogs: add (optional) sparse checking to the build
Run sparse against source files when building e2fsprogs with 'make C=1'.  If
instead C=2, it configures basic ext2 types for bitwise checking with sparse,
which can help find the (many many) spots where conversion errors are
(possibly) happening.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-11 23:12:40 -04:00
Carlos Maiolino 6c327e9ca4 e2image: complain if running e2image -r or -Q on a mounted filesystem
Several users have used e2image on a mounted RW filesystem, resulting in
inconsistent, useless e2images for debugging purposes.

This commit will forbid this and print an error message, although the
user can override this using a new force option.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-10-11 21:49:16 -04:00
Darrick J. Wong d11f92af35 mke2fs: complain about creating 64bit filesystems without extents
A 64bit filesystem without extents is not terribly useful, because the
old block map format does not support pointing to high block numbers.
Warn the user who tries to create such an animal.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-11 21:20:22 -04:00
Darrick J. Wong 4dbfd79d14 e2fsprogs: fix blk_t <- blk64_t assignment mismatches
Fix all the places where we should be using a blk64_t instead of a
blk_t.  These fixes are more severe because 64bit values could be
truncated silently.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-07 09:51:48 -04:00
Darrick J. Wong fa58fa530a tune2fs: zero inode table when removing checksums
When disabling group checksums, we have to initialize the inode table.  Right
now tune2fs doesn't do this; it merely punts to e2fsck to clean up the mess.
Unfortunately, if the "uninitialized" inode table contains things that look
like inodes (i_link_count > 0, specifically), the e2fsck tries to recover these
inodes.  This leads to it misinterpreting i_blocks as a block map, at which
point it needlessly resurrects phantom inodes and crosslinked file repairs.  As
part of initializing the block bitmaps, we must also mark block group metadata
blocks in use.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-09-16 09:41:15 -04:00
Theodore Ts'o 93061ea0f4 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	version.h
2013-06-20 23:20:51 -04:00
Ashish Sangwan fd73a1d254 mke2fs: calculate journal blocks just after fs initialize
We can calculate journal blocks as soon as blocksize is set.
It will help to figure out wrong journal blocks count earlier.
This will save some un-necessary initialization.

Without patch output =>
mke2fs /dev/sdc1 -J size=1048576
mke2fs 1.42.7 (21-Jan-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61312 inodes, 244936 blocks
12246 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=251658240
8 block groups
32768 blocks per group, 32768 fragments per group
7664 inodes per group
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done

The requested journal size is 268435456 blocks; it must be
between 1024 and 10240000 blocks.  Aborting.

With patch output =>
mke2fs /dev/sdc1 -J size=1048576
mke2fs 1.42.7 (21-Jan-2013)

The requested journal size is 268435456 blocks; it must be
between 1024 and 10240000 blocks.  Aborting.

Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-20 22:53:49 -04:00
Theodore Ts'o 8b9eb12807 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	e2fsck/Makefile.in
	lib/config.h.in
	version.h
2013-06-16 18:54:01 -04:00
Andreas Dilger dc9cc7006a mke2fs: don't set root dir UID/GID automatically
Don't change the root directory's UID/GID automatically just because
mke2fs was run as a non-root user.  This can be confusing for users,
and is not flexible for non-root installation tools that need to
create a filesystem with different ownership from the current user.

Add the "-E root_owner[=uid:gid]" option to mke2fs so that the user
and group can be explicitly specified for the root directory.  If
the "=uid:gid" argument is not specified, the current UID and GID
are extracted from the running process, as was done in the past.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-15 21:51:33 -04:00
Theodore Ts'o 626a2e7468 mke2fs: clarify mke2fs and mke2fs.conf man pages
Addresses-Debian-Bug: #712429
Addresses-Debian-Bug: #712430

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-06-15 21:19:39 -04:00
Theodore Ts'o e7f983bfb2 e2image: fix crash when using e2image -I with a 64-bit file system
Addresses-Debian-Bug: #703067

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-06-15 20:52:08 -04:00
Andreas Dilger 2a83b3c374 mke2fs: sort option parsing, deprecate "-R"
A minor cleanup to order the command-line option parsing in
alphabetical order, except for "-E" and "-R", which need to
be co-located.

Print a message that the "-R" option is deprecated.  It has
been deprecated since 2005 (commit c6a44136b9).

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-15 18:47:30 -04:00
Jan Kara 70f4632b62 libext2fs: provide functions to safely access name_len and file_type
Accessing name_len (and file_type) in ext4_dir_entry structure is
somewhat problematic because on big endian architecture we need to now
whether we are really dealing with ext4_dir_entry (which has u16
name_len which needs byte swapping) or ext4_dir_entry_2 (which has u8
name_len which must not be byte swapped).

Currently the code is somewhat surprising and name_len is always
treated as u16 and byte swapped (flag EXT2_DIRBLOCK_V2_STRUCT isn't
ever used) and then masking of name_len is used to access real
name_len or file_type. Doing things this way in applications using
libext2fs is unexpected to say the least (more natural is to type
struct ext4_dir_entry * to struct ext4_dir_entry_2 * but that gives
wrong results on big endian architectures. So provide helper functions
that give endian-safe access to these fields. Also convert users in
e2fsprogs to use these functions.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-08 17:03:05 -04:00
Theodore Ts'o 4cf7a7014a misc: fix gcc -Wall nits
[For 1.43 branch]

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-20 09:21:34 -04:00
Theodore Ts'o 581ecb6d88 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1b.c
	e2fsck/rehash.c
	lib/ext2fs/crc32c.c
	lib/ext2fs/gen_bitmap64.c
	misc/tune2fs.c
2013-05-19 21:45:16 -04:00
Theodore Ts'o 577c773a60 misc: fix gcc -Wall warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-05-19 20:03:48 -04:00
Theodore Ts'o 29f6dfea52 Merge branch 'maint' into next 2013-05-16 11:05:37 -04:00
Theodore Ts'o 25399080c5 chattr: clarify that the compression flags are not supported by ext4
... or indeed by any mainline kernel, since the compression patches
were never stablized.

Addresses-Debian-Bug: #707609

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: "Creidieki M. Crouch" <creidieki@gmail.com>
2013-05-13 09:10:16 -04:00
Theodore Ts'o 07bcd90f3d Merge branch 'maint' into next 2013-04-22 00:07:08 -04:00
Tomas Racek fdaf34f8c0 e2image: require that -a option is used only with raw or QCOW2 image
All data cannot be included in normal image file so e2image should exit
in this case.

Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2013-04-21 23:21:46 -04:00
Tomas Racek ef21356fc0 e2image: man: fix typo
Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-04-21 23:21:32 -04:00
Tomas Racek d55e68a660 e2image: remove useless exit call
Exit is called right after the install_image anyway so this one can
be removed.

Signed-off-by: Tomas Racek <tracek@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-04-21 23:21:32 -04:00
Akira Fujita fab0d286ec tune2fs: disallow tune2fs to set inode size larger than block size
Disallow tune2fs command to set the inode size to be larger than the
block size.  Without this patch, tune2fs makes the file system to be
unmountable.

Steps to reproduce:

1.Create ext4 without flex_bg (or just create ext3)
  # mke2fs -t ext4 -O ^flex_bg DEV

2.Set inode size larger than block size
  # tune2fs -I 8192 DEV

3. We failed to mount FS
  # mount DEV MP
    mount: wrong fs type, bad option, bad superblock on /dev/sda7,
           missing codepage or helper program, or other error
           In some cases useful info is found in syslog - try
           dmesg | tail  or so

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-21 23:14:28 -04:00
Theodore Ts'o 447da244eb mke2fs: don't display bigalloc/quota fs feature warnings in quiet mode
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-31 20:41:22 -04:00
Theodore Ts'o 8c236c62c9 Merge branch 'maint' into next 2013-03-13 16:17:34 -04:00
Theodore Ts'o bb21ddf596 chattr: allow clearing the extent flag
In order to support kernels which support conversion of extent-mapped
files to direct/indirect mapped files, remove the sanity check which
prevented clearing the extent flag in chattr.  Kernels which don't
support this will simply give an Operation Not Supported error.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-02-22 22:23:05 -05:00
Andreas Dilger 1b8c4c1b45 build: quiet build warnings for "gcc -Wall"
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-27 22:31:03 -05:00
Theodore Ts'o fca8b1b241 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	version.h
2013-01-21 22:06:16 -05:00
Theodore Ts'o a713a7fe5a mke2fs, tune2fs, resize2fs: add warning messages for bigalloc and quota
The bigalloc and quota features have some known issues, so issue
warnings in case users try to use them.

More information can be found here:
	https://ext4.wiki.kernel.org/index.php/Bigalloc
	https://ext4.wiki.kernel.org/index.php/Quota

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-21 19:07:38 -05:00
Theodore Ts'o 7b68fa38b8 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	lib/ext2fs/ext2_err.et.in
	version.h
2013-01-16 14:14:09 -05:00
Theodore Ts'o 3bbb613ccb Update misc/Makefile.in using "make depend"
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-16 14:09:21 -05:00
Phillip Susi 0e51f5ae16 e2image: add -a switch to include all data
Normally the raw and QCOW2 images only contain fs metadata.
Add a new switch ( -a ) to include all data.  This makes it
possible to use e2image to clone a whole filesystem.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-16 14:09:20 -05:00
Zheng Liu 0f680ee8f2 mke2fs: document bigalloc and cluster-size
Bigalloc feature has been used for a long time, but the documentation
in mke2fs is still missing.  So add it.

Addresses-Debian-Bug: #669730

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-01-15 14:13:10 -05:00
Theodore Ts'o 86a985e749 mke2fs: teach mke2fs to understand -b 4k and -C 256M
The -b and -C options now use parse_num_blocks2() instead of strtol,
so that users can specify -C 256M instead of the much less convenient
-C 268435456.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
2013-01-15 14:06:55 -05:00
Theodore Ts'o 2a3b1c6ea2 mke2fs: the -g option will now specify the clusters per block group
If bigalloc is enabled, then -g will specify the clusters per block
group.  (If bigalloc is not enabled, then a cluster == a block, so the
meaning of -g is not changed.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
2013-01-15 14:05:48 -05:00
Theodore Ts'o 4b20ea2691 mke2fs: enforce that the cluster size must be greater that the block size
In addition, do not allow a cluster size of 1024, since that will be
interpreted by ext2fs_initialize() as requesting the default cluster
size.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Reported-by: Zheng Liu <wenqing.lz@taobao.com>
2013-01-15 14:03:53 -05:00
Zheng Liu 9cf69bb825 mke2fs: require the bigalloc feature explicity if the cluster size is set
When cluster-size is specified without the bigalloc feature, mke2fs
will ignore this argument silently.  But user might think bigalloc
feature has been enabled unless they use the dumpe2fs command.  So now
we ask user to set bigalloc feature explicity when cluster-size is
enabled.  This can make sure that users understand what they are doing
because bigalloc might impact the performance for some workloads.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-14 16:54:09 -05:00
Theodore Ts'o df5e35fd63 Merge branch 'maint' into next
Conflicts:
	misc/mke2fs.c
2013-01-08 21:14:25 -05:00
Zheng Liu f45011df2b mke2fs: check extents feature when bigalloc feature is enabled
When bigalloc feature is enabled in mkfs, extents feature also needs
to be enabled.  But now when bigalloc feature is enabled without
extents feature, users will not get any warning messages until they
try to mount this file system.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-08 10:35:45 -05:00
Theodore Ts'o b9b5e43ea8 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	lib/ext2fs/crc32c.c
	lib/ext2fs/rw_bitmaps.c
	resize/resize2fs.c
	version.h
2013-01-01 18:50:26 -05:00
Theodore Ts'o e3507739e4 Fix gcc -Wall nits
This fixes the last set of gcc -Wall complaints.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-01 13:28:27 -05:00
Andreas Dilger 2508eaa71e filefrag: improvements to filefrag FIEMAP handling
Update the filefrag program to allow displaying the extents in
some different formats.  Try and stay within 80 columns.
* add -k option to print extents in kB-sized units (like df -k)
* add -b {blocksize} to print extents in blocksize units
* add -e option to print extent format, even when FIBMAP is used
* add -X option to print extents in hexadecimal format

Internally, the FIBMAP handling code has been moved into its own
function like FIEMAP, so that the code is more modular.  Extent
offsets are now handled in bytes instead of in blocks, to allow
printing extents with arbitrary block sizes.  The extent header
printing also moved into its own function so that it can be shared
between the FIEMAP and FIBMAP handling routines, since it got more
complex with the different output options.

Only print error about FIBMAP being root-only a single time.
Print the filesystem type if it changes between specified files.
Add fsync() for FIBMAP if "-s" is given.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-12-29 22:41:41 -05:00
Andreas Dilger 00eb0eee0a build: quiet some "gcc -Wall" compiler warnings
Quiet a number of simple compiler warnings:
- pointers not initialized by ext2fs_get_mem()
- return without value in non-void function
- dereferencing type-punned pointers
- unused variables

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-12-29 17:39:45 -05:00
Andreas Dilger 1d6fd6d0c3 misc: cleanup unused variables on MacOS
Clean up unused variables found by GCC on MacOS.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-12-29 17:28:37 -05:00
Theodore Ts'o 49cdefd331 mke2fs: fix crash when parsing "-E resize=NNN" with "-O 64bit"
If the 64-bit file system feature is enabled, then mke2fs would crash
due to a divide-by-zero error caused by s_desc_size not being
initialized yet.

Reported-by: George Spelvin <linux@horizon.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-28 18:26:12 -05:00
Theodore Ts'o ccea20f62d Merge branch 'maint' into next
Conflicts:
	misc/tune2fs.c
2012-11-29 19:54:46 -05:00
Theodore Ts'o 0f8186598c tune2fs: fix a compile-time bug if quota is not enabled
Commit 44a2cca35e introduced a compile-time failure if --enable-quota
is not passed to the configure script.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-11-29 14:58:29 -05:00
Eric Sandeen 44a2cca35e tune2fs: respect quota config option
If we haven't turned --enable-quota on at config time,
I don't think tune2fs should know about the feature either.

Today we can actually tune2fs -O quota even if not
configured on, and then the rest of the tools will
refuse to touch it:

# tune2fs -O quota /dev/sda1
# tune2fs -O ^quota /dev/whatever complains
tune2fs 1.42.3 (14-May-2012)
tune2fs: Filesystem has unsupported read-only feature(s) while trying to open /dev/sda1
# fsck /dev/sda1
fsck from util-linux 2.21.2
e2fsck 1.42.3 (14-May-2012)
/dev/sda1 has unsupported feature(s): quota
e2fsck: Get a newer version of e2fsck!

Ok, so turn it off?
# tune2fs -O ^quota /dev/whatever complains
tune2fs 1.42.3 (14-May-2012)
tune2fs: Filesystem has unsupported read-only feature(s) while trying to open /dev/sda1

Nope.  Debugfs?  Nope.

# debugfs -w /dev/sda1
debugfs 1.42.3 (14-May-2012)
/dev/sda1: Filesystem has unsupported read-only feature(s) while opening filesystem

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reported-by: Bert DeKnuydt <Bert.Deknuydt@esat.kuleuven.be>
Addresses-Red-Hat-Bugzilla: #880596
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-11-28 22:52:52 -05:00
Theodore Ts'o 3a4fd4c84d Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/blkmap64_rb.c
2012-10-11 07:38:01 -04:00
Theodore Ts'o 51fb43dd27 Fix makefiles to compile e2freefrag with profiling
Also fix a bug caused by a stray continuation backslash which caused
the e2fsck/Makefile to fail when profiling is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2012-10-11 07:35:58 -04:00
Theodore Ts'o ea2d378862 e2freefrag: use 64-bit rbtree bitmaps
Enable the use of 64-bit bitmaps, so e2freefrag will work on file
systems with the 64-bit feature enabled.  In addition, enable the
rbtree-based bitmaps, which significantly saves the amount of memory
required (from 97 megs to 1.7 megs for an empty 3T file system) at the
cost of additional CPU overhead (but we will claw back some of the
additional CPU overhead in the next commit).

Addresses-Google-Bug: 7269948

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-04 23:30:23 -04:00
Theodore Ts'o 2f2a048b1d Merge branch 'maint' into next 2012-09-22 21:35:46 -04:00
Theodore Ts'o c498cb11d3 mke2fs: fix progress suppression to make regression tests reliable
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-22 21:26:48 -04:00