Mistakes on the commandline can lead to odd error messages:
# mke2fs -t ext4 -E stride=128 stripe-width=512 /dev/sda1
mke2fs: invalid blocks count - /dev/sda1
Making it a bit more explicit is more obvious:
mke2fs: invalid blocks count '/dev/sda1' on device 'stripe-width=512'
(hint, the mistake was no comma separation for -E)
Reported-by: Adam Huffman <bloch@verdurin.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If a device supports discard -and- returns 0s for discarded blocks,
then we can skip the inode table initialization -and- the inode table
zeroing at mkfs time, and skip the lazy init as well since they are
already zeroed out.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This bit of the mke2fs manpage is slightly confusing:
-b block-size
Specify the size of blocks in bytes. <snip>
If block-size is negative, then mke2fs will use heuristics
to determine the appropriate block size, with the constraint
that the block size will be at least block-size bytes.
because it sounds like the block size will be at least a negative
number. Clarify just what the negative sign means.
Reported-by: Chris Frost <chris@frostnet.net>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The getopt() function returns an int, not a char. On systems where the
default char is unsigned (like ppc), we get weird behavior where -1 is
truncated to 0xff but compared to (int)-1.
Also fix this same bug for two test programs, test_rel and iscan,
which aren't currently used at the moment.
Addresses-Gentoo-Bug: #299386
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
We need to defer setting the blocks count field in the fs_param
structure until it is known whether 64-bit feature will be enabled
(and whether the blocks count is valid).
We also add a new mke2fs.conf configuration parameter,
auto_64-bit_support which will automatically enable the 64-bit feature
if the number of blocks requires it.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use 64-bit interfaces in mke2fs. This should be most most of whats
needed to support creating a 64-bit filesystem.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Allow the uninit_bg feature to be set without requiring an fsck. The
first full fsck will require scanning all of the inode table blocks,
but subsequent fsck's will be fast. This allows flexibility over
requiring a full fsck after setting this feature, which is what
tune2fs previously mandated.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Some devices, notably 4k sector drives, may have a 512 logical
sector size, mapped onto a 4k physical sector size.
When mke2fs is ratcheting down the blocksize for small filesystems,
or when a blocksize is specified on the commandline, we should not
willingly go below the physical sector size of the device.
When a blocksize is specified, we -must- not go below
the logical sector size of the device.
Add a new library function, ext2fs_get_device_phys_sectsize()
to get the physical sector size if possible, and adjust the
logic in mke2fs to enforce the above rules.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
These options allow e2fsprogs to be built using symlinks instead of
hard links, and to be installed using symlinks instead of hard links,
respectively.
Addresses-Sourceforge-Bug: #1436294
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This for RH bug #572935 -
RFE: Misleading error message from mke2fs -J option
If the journal device UUID is typo'd or otherwise not found,
the error message looks like it's a usage() type of problem.
It'd be helpful to explicitly say that the device requested
could not be found.
Addresses-Red-Hat-Bug: #572935
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Just print the warning message in this case.
Addresses-Red-Hat-Bug: #569021
Addresses-Launchpad-Bug: #530071
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
mkfsing a plain file would lead to a warning about being unable
to determine geometry; we should just skip the topology-getting
if we see that we have a regular file.
This was breaking "make check" but I had missed it since I
inadvertently stopped running the checks during the Fedora
RPM build.
Also, add a newline to the warning.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
On 32-bit platforms where the file system block size is 8k or greater,
the calculation bpib*bpib*bpib* will overflow a 32-bit calculation,
leading to a divide by zero error. Fix this.
Thanks to Mikulas Patocka for pointing this out.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Sorry about that, the discard ioctl doesn't actually work
unless you open the file with write capabilities...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Try calling the BLKDISCARD ioctl at mkfs time to pre-discard all blocks
on an ssd, or a thinly-provisioned storage device.
No real error checking; if it fails, it fails, and that's ok - it's
just an optimization. Also, it cannot work in conjunction with
the undo io manager, for obvious reasons.
Optionally disabled with a "-K" (mnemonic: Keep) option.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Try calling the BLKDISCARD ioctl at mkfs time to pre-discard all blocks
on an ssd, or a thinly-provisioned storage device.
No real error checking; if it fails, it fails, and that's ok - it's
just an optimization. Also, it cannot work in conjunction with
the undo io manager, for obvious reasons.
Optionally disabled with a "-K" (mnemonic: Keep) option.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The ext2fs_bg_flag* functions were confusing.
Currently we have this:
void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags);
void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags);
(_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags)
and these, which can twiddle individual bits in bg_flags:
void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag);
A better interface, after the patch below, is just:
ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */
ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */
ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */
and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Handle automatic selection of stride/stripe:
mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=16 blocks, Stripe width=32 blocks
...
And warn on block device misalignment:
mke2fs 1.41.9 (22-Aug-2009)
/dev/sdc1 alignment is offset by 32256 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Proceed anyway? (y,n)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit forces the use of the system-provided blkid or uuid header
files if we are using the system-provided blkid or uuid libraries.
This avoids using the in-tree header files with the system libraries.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fsck leaks fds when invoked with -R -A -M -a -t noopts=nofail
Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add a more explicit description of how specifying the flex_bg file
system feature changes the layout of the per-block group metadata.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
With 64-bit file systems, mke2fs can take a long time to do things
other than write inode tables. I exported the mke2fs numeric progress
meter and used it for allocating group tables and the final file
system flush.
Signed-off-by: Valerie Aurora (Henson) <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
ppc glibc seems to be missing sync_file_range, so we fell back
to the local define, and there ppc differs as well, so the
build was failing.
Thanks to Kyle for the patch w/ the tidy solution.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The feature name "extent" is documented in mke2fs.conf, although both
"extent" and "extents" are accepted by e2fsprogs.
Addreses-Debian-Bug: #540111
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When increasing inode size if we find that the new block
that we needed to increase the inode table size is a bad
block we fail. This make sure we don't end up with a corrupt
file system when doing inode resize on a file system having
bad blocks.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
With file system formated for RAID arrays we can have inode bitmap
and block bitmap after inode table. Make sure we move them around
properly when doing inode resize.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This removes the metadata block bitmap and makes the error handling
simpler. It also check for the enospc with the correct number needed
blocks. Also added specific error messages. We need to run e2undo
only if we start modiyfing inode, group desc and inode table.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The extent list header gets printed before we fall back to bmap:
# filefrag -v /mnt/test/bar
Filesystem type is: 58465342
File size of /mnt/test/bar is 12288 (3 blocks, blocksize 4096)
ext logical physical expected length flags <---- HERE
Discontinuity: Block 2 is at 17 (was 16)
/mnt/test/bar: 2 extents found
so delay printing it until we know fiemap is working.
(though ideally it'd be nice to have the same verbose output
regardless of the interface we used, I think).
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The fragmentation count in the bmap case seems to be
off by one:
/mnt/test/bar: 0 extents found
Addresses-Debian-Bug: #540376
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix a bug in e2freefrag where if the last free extent is at the very
end of the filesystem, it would be disregarded.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If the file system has a non-zero s_first_data_block, as is the case
when the block size is 1kb, e2freefrag would incorrectly try to
reference invalid data blocks in the block allocation bitmap.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
"Free chunks" is confusing since it has nothing to do with the
chunksize; use "free extents" instead.
Also add a missing newline in an error message.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e4defrag.c had a lot of stuff copied into it from other
places, redefinitions of existing interfaces, etc.
We should be able to remove most of this, as the tool only
works on recent kernels anyway, we should just pick up
definitions from recent kernel headers whenever possible.
I've left the local definitions of fallocate, fadvise
(changed to posix_fadvise) and sync_file_range, and
wrapped them in #ifdef configure-time tests - though
really it seems like only fallocate should be necessary
by now, and perhaps the others can be dropped.
We still need some Makefile work so that it won't try to
build e4defrag if the right pieces aren't there (and
if the local definitions won't work...)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The FIEMAP support added in e2fsprogs 1.41.6 broke the "perfection
would be XXX expects" calculation restore it.
Also fix some gcc -Wall warnings as well. (Cleaning up gcc -Wall is
what caused me to notice this regression).
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When used with -v and the targeted file has more than 144
extents(double of the length of fm_extents array provided by buf),
filefrag_fiemap loops and calls fiemap ioctl() multiple times to
calculate the actual number of extents in a file. Each call to fiemap
ioctl() uses fm_start as the starting logical offset. The patch fixes
fm_start in each loop( except for the first one) and makes the extent
calculation correct for files with more that 144 extents.
To produce the problem, first run filefrag -v on a highly fragmented
file. Then change the buf size in filefrag_fiemap to make it large
enough to have all the extent mapped in a single loop and run filefrag
-v after recompiling. The former will produce a much smaller extent
count because of the false fm_start used in the loop. And the two will
produce different extent output since the 145th extent.
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want. Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.
(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.
Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.
Addresses-Sourceforge-Patches: #2813809
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If for some reason the uuidd daemon or the process calling uuidd
exited unexpectely, the read_all() function would end up looping
forever, either in uuidd or in libuuid. Fix this terminating the loop
if no data can be read after five tries to read from the file
descriptor.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In the event that file descriptors 0-2 are closed when uuidd is
started, the server socket could be created as a file descriptor that
will get closed when create_daemon() tries detaching the uuidd daemon
from its controlling tty. Avoid this case by using dup(2).
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Some terminal programs may print wierd characters when they see the
\001 or \002 characters. So filter them out if the -s option
(skip_mode) is enabled.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lsattr doesn't return an error if you point it at a file that
doesn't exist.
This is slightly trickier because it can take more than one
file as an arg, but ls seems to report an error if any occurred,
so this does the same, it'll report the last error that was
encountered.
Addresses-RedHat-Bugzilla: #489841
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536. The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.
We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When compile e2fsprogs git tree with gcc-wall option, we get some warnings about
e4defrag. This patch fixes them.
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
To make it easier to maintain changes and fixes to the e4defrag
program, check it into the e2fsprogs source tree.
Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The e2fsprogs programs have historically just said that they operate
on ext2 and ext3 file system in their man pages. Update them to say
that they also operate on ext4 file systems.
Addresses-Launchpad-bug: #381854
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Tidy up the chattr(1) manpage to completely document all
available options, and differentiate those which are read-only
early in the manpage as well.
* Remove "I" from settable attribute list
* add "e" to 2nd list of settable attributes & descriptions
* Note that h/E/I/X/Z are readonly
* Correct "H" to "h" for huge file attribute description
* fix long_name for indexed directory in flags_array
Addresses-Red-Hat-Bugzilla: BZ#502971
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch adds new option, +e to chattr. The +e option
is used to convert the ext3 format (non extent) file
to ext4 (extent) format. This can be used to migrate
the ext3 file system to ext4 file system.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The FIEMAP ioctl is more efficient and doesn't require root
privileges. So if it is available, use it in preference to repeated
FIBMAP calls.
Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fixed a potential bug where by partial returns from the write(2)
system call could some bytes to be lost when writing to the log file.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add an option to switch between the private (in-tree) libblkid and
public (in-system installed) library. The private version is still
enabled by default.
If --disable-libblkid is specified the findfs(8) program, which is a
variant of tune2fs, is also not built or installed.
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Hurd doesn't define PATH_MAX, so calculate the exact size needed for
the tdb filename, and allocate it dynamically.
Addresses-Debian-Bug: #521602
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fixed a potential bug caused by partial returns from the write system
call (especially possible for network connections).
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Nice for testing w/o needing to swizzle around system
libraries...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add a check to make sure the argument to the -m option (which
specifies the reserved ratio) is greater than zero.
Addresses-Debian-Bug: #517015
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This field tracks the lifetime amount of writes to the filesystem. It
will be updated by the kernel as well as by e2fsprogs programs which
write to the filesystem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Mandriva apparently uses "mke3fs" as an alias for mkfs.ext3. I'm not
particularly fond of that practice, but we'll include it as legacy
support.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If a filesystem is built with the stride extended-option (which is
often used in RAID filesystems to make sure the block and inode
allocation bitmaps don't end up hitting one disk platter harder than
the rest), this can cause tune2fs -I to corrupt the filesystem because
it fails to handle the case where the allocation bitmaps are located
after the inode table, where the inode table needs to grow. Handle
this case correctly.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
With flex_bg usually the inode table for most block groups are packed
right against each other, so expanding the inode table size needs
special handling that's not currently in tune2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When running "tune2fs -I 256" on moderate to large filesystems, the
time required to run tune2fs can take many hours (20+ before some
users gave up in disgust). This was due to some O(n**2) and O(n*m)
algorithms in move_block() and inode_scan_and_fix(), respectively.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Since the block group checksums depend on the UUID, we need to update
the block group checksums when setting the UUID. We only do so if all
of the checksums are correct, however.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Always initialize the starting time so that badblocks -sw works.
Thanks Jelle de Jong (jelledejong at powercraft.nl) for reporting this
bug.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Thanks to A. Costa for pointing these out.
Addresses-Debian-Bug: #498100
Addresses-Debian-Bug: #498101
Addresses-Debian-Bug: #498102
Addresses-Debian-Bug: #498103
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
... especially when using ELF shared libraries. We only need to link
with a library if the executable uses that library directly.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Pass in -rpath-link option to the linker so that blkid will build
correctly on systems that don't have libcom_err.so.2 installed.
Fix debugfs to only try to link with -ldl when building without shared
libraries; with ELF shared libraries, the library which requires -ldl
(libss.so) can required the library dependency itself.
Fix how we build tune2fs.static so that we use @LDFLAG_STATIC@, via
$(LDFLAGS_STATIC), instead of hard-coding the use of -static.
Addresses-Sourceforge-Bug: #2088537
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Linux doesn't enforce the Large File Support API requirements on block
devices, but in case someone wants to run badblocks on a normal file,
open the device file with O_LARGEFILE.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix calculation of the ideal number of extents needed for a file to
take into account sparse files.
In addition, suppress the "this file is extent-based" message unless
verbose mode is enabled.
Addresses-Debian-Bug: #458306
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In order to make it possible for the test_io manager to be compiled in
by default, make all of the programs that might try to use it to only
do so if the environment variables TEST_IO_FLAGS and TEST_IO_DEBUG are
set.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The rec_len field in the directory entry is 16 bits, so if the
filesystem is completely empty, rec_len of 0 is used to designate
65536, for the case where the directory entry takes the entire 64k
block.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Option specifiers must be escaped so the are printed as minus signs
(U+002D) instead of hyphens (U+2010). Hence "mke2fs -t ext4" must be
expressed as "mke2fs \-t ext4" instead.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Many people are forgetting to update their mke2fs.conf file, and this
means that filesystems aren't getting created with the proper features
enabled. So detect this case and issue a warning.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also rephrase two sentences and add a comma or two.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Also add the missing argument of the -M option, replace the mistaken
[libdefaults] section header with [defaults], and slightly rephrase
two or three sentences.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the current inode size is less than or equal to the requested inode
size, either explain that shrinking the inode size is not supported,
or that the inode is already the requested size. Also, open the
filesystem provisionally first to do the inode size check and don't
setup up the undo log until we know that we're actually going to
perform the inode resizing operation.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also use complete sentences, instead of separate words filled
into a phrase. And gettextize the main output message.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Take the opportunity to wrap the string to be more readable,
and sort the options somewhat alphabetically.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix typo; instead of checking for s_feature_incompat twice, add check
for s_feature_ro_compat.
Thanks to Benno Schulenberg for noticing this problem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
These were caused by multi-line strings missing a space at the line
break. Thanks to translator Phillipp Thomas for noticing these typo's.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
For people who are compiling mke2fs for their own use outside of a
package manager, we need to make sure the system /etc/mke2fs.conf is
sufficiently up-to-date that it won't cause problems, but at the same
time we don't want to blow away any user-specific customizations.
So if /etc/mk2fs.conf exists, but does not mention ext4dev, we will
move it aside to /etc/mke2fs.conf.e2fsprogs-old and then install the
new mke2fs.conf. If the /etc/mke2fs.conf file exists but does mention
ext4dev, we install the new mke2fs.conf file as
/etc/mke2fs.conf.e2fsprogs-new. In both cases we print a warning
mesage to the user so they can manually update /etc/mke2fs.conf with
any changes if they so desire.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Solaris C99 apparently doesn't support it. We should report the
program name, not the internal function name, when printing an error
in any case.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Solaris's header files are very picky about which C compiler can be
used for SUSv3 conformance. Use of C99 is not compatible with SUSv2
(_XOPEN_SOURCE=500), and C89 is not compatible with SUSv3
(_XOPEN_SOURCE=600). Since we need some SUSv3 functions, consistently
use SUSv3 so that e2fsprogs will build on Solaris using c99.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also accessed via -o list, this new output format is much more
user-friendly and lists whether or not a particular device is mounted.
Addresses-Debian-Bug #490527
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also change mke2fs.conf to enable huge_file,dir_nlink,extra_isize, and
uninit_bg by default for ext4 filesystems, and enable extra_isize in
the library as well.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use consistent and standard terminology for the starting and ending
blocks for the badblocks test in the man page and in the messages
printed by the program.
Addresses-Debian-Bug: #440983, #440981
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The Hurd only supports filesystems with a blocksize of 4096 bytes, and
128 byte inodes. It also doesn't understand the journal. So force
the defaults to be something which the Hurd can handle if "-o hurd" is
specified on the command line.
Addresses-Debian-Bug: #471977
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Print a message when mke2fs uses a default blocksize from an external
journal device, and print a more self-explanatory message so that if
that blocksize is used and ext2fs_get_device_size() returns EFBIG, the
user has a better chance of understanding why mke2fs issued that error
message.
Addresses-Debian-Bug: #488663
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If creating a an external journal via "mke2fs -O journal_dev",
override the fs_type list (i.e., "ext2", "small"), and replace it with
an fs_type list of "journal". This will prevent external journals
smaller than 512MB from being created with a block size of 1k, which
is not very useful and leads to much confusion.
Addresses-Debian-Bug: #488663
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
With more than 8 -t patterns given, badblocks will overwrite the
t_patts array boundary due to realloc not taking into account the size
of an int. Oops.
Addresses-Debian-Bug: 487298
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We need to use list_for_each_safe in case a device gets removed from
the list during garbage collection.
Also make the manpage slightly more informative about
what the -g garbage collection option does.
Addresses-Debian-Bug: #487758, #487783
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The previous patch was missing an #include and thus the compiler didn't
catch the (now obvious) error.
Signed-off-by: Iustin Pop <iustin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
When calculating the number reserved blocks, use floating point for
better accuracy, since for big filesystems it really makes a
difference. In addition, mke2fs and tune2fs accepts a floating point
number from the user, so they should provide that level of accuracy.
Addresses-Debian-Bug: #452639
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Currently, badblocks will read as fast as it can from the drive. While
this is what one wants usually, if badblocks is run in read-only mode on
a drive that is in use, it will greatly degrade the other users of this
disk.
This patch adds a throttling mode for reads where each read will be
delayed by a percentage of the time the previous read took; i.e., an
invocation of '-d 100' will cause the sleep to be the same as the read
took, a value of 200 will cause the sleep to be twice as high, and a
value of 50 will cause it to be half. This will not be done if the
previous read had errors, since then the hardware will possibly have
timeouts and that would decrease the speed too much.
This algorithm helps when the disk is used by other processes as then,
due to the increased load, the time spent doing the reads will be
higher, and correspondingly badblocks will sleep even more and thus it
will use less of the drive's bandwidth. This is different from using
ionice, as it is a voluntary (and partial) throttling.
Signed-off-by: Iustin Pop <iustin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Currently, the parse_uint() function checks errno after the strtoul()
call. But, according to the man page of strtoul():
Since strtoul() can legitimately return 0 or LONG_MAX (LLONG_MAX for
strtoull()) on both success and failure, the calling program
should set errno to 0 before the call, and then determine if an error
occurred by checking whether errno has a nonzero value after the call.
When using locales, it can happen that looking for the locale files is
not successful, and therefore errno will have a nonzero value from this.
And since the argument parsing is one of the first things done after
startup, parse_uint() will wrongly report errors.
The fix is to simply reset errno to zero before calling strtoul().
Signed-off-by: Iustin Pop <iustin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Currently, badblocks will continue scanning the device until it reaches
last_block, even though it might be that the drive is not responding
at all anymore.
This patch introduces a new parameter ('-e') that allows one to specify
the maximum bad block count; if badblocks sees more than this number, it
will abort the test.
While this is not useful for testing a device that will need to be used
as a filesystem (because we don't get an exhaustive list of bad blocks),
it is useful for testing if a device has bad blocks at all: for example,
with a count of 1, it will finish after the first error thus not needing
to test the whole device if the only purpose of the test is to check for
any bad blocks.
Signed-off-by: Iustin Pop <iustin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add new option -I <inode_size> to tune2fs. This is used to change the
inode size. The size need to be multiple of 2 and we don't allow to
decrease the inode size.
As a part of increasing the inode size we increase the inode table
size. We also move the used data blocks around and update the
respective inodes to point to the new block
tune2fs uses the undo I/O manager when migrating to large inode. This
helps in reverting the changes if end results are not correct. The
environment variable TUNE2FS_UNDO_DIR is used to indicate the
directory within which the tdb file need to be created. The file will
be named tune2fs-<device-name> If TUNE2FS_UNDO_DIR is not set
/var/lib/e2fsprogs is used
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When running mke2fs, if a file system is detected
on the device, we use Undo I/O manager as the io manager.
This helps in reverting the changes made to the filesystem
in case we wrongly selected the device.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The e2undo command can be used to replay the transaction saved in the
transaction file using undo I/O Manager.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The combination of meta_bg and resize_inode leads to a corrupt
filesystem, and it's not really clear it makes any logical sense.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change the way we allocate bitmaps and inode tables if the FLEX_BG
feature is used at mke2fs time. It places calculates a new offset for
bitmaps and inode table base on the number of groups that the user
wishes to pack together using the new "-G" option. Creating a
filesystem with 64 block groups in a flex group can be done by:
mke2fs -j -I 256 -O flex_bg -G 32 /dev/sdX
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This fixes some bugs which I introduced recently while revamping the
uninit_bg code. Since mke2fs is no longer calling
ext2fs_set_gdt_csum(), it's important that ext2fs_initialize()
correctly initialize bg_itable_unused for all block group descriptors.
In addition, mke2fs needs to zero out the the reserved inodes based on
the values of bg_itable_unused set by ext2fs_initialize().
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Mke2fs used to have special case, ugly code in
setup_lazy_bg/setup_uninit_bg flag which set the flags based on all
sorts of special cases. Change it so that it is done in libext2fs,
and fix mke2fs to use alloc_stats functions which will take care of
clearing the *_UNINIT flags automatically as needed.
This is preparatory work to make the flex_bg allocation patch much
cleaner.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This simplifies the code, and using the uninit_bg with the inode table
lazily initialized is just as good.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Instead of using -O lazy_bg,uninit_bg as the way of requesting that
the inode table be lazy unitialized, use the parameter
lazy_itable_init, which can either be set via mke2fs's -E option, or
via /etc/mke2fs.conf.
Also fix some random problems in mke2fs's man page, including
documenting the extent feature, which had been missing.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Allow the old name of uninit_groups when converting feature names for
backwards compatibility for scripts running mke2fs and tune2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Provide mke2fs with a much more sophisticated system for controlling
configuration parameters of a newly created filesystem based on a
split filesystem and usage type system. The -t option to mke2fs was a
deprecated alias to -c; it now specifies a filesystem type (ext2,
ext3, ext4, etc.), while the -T option can now be a comma separated
usage list.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change the function signature so that ext2fs_set_gdt_csum() returns an
error code.
If the inode bitmap hasn't been loaded return EXT2_ET_NO_INODE_BITMAP.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Previously, fsck was only passing in -Cn to the first e2fsck process
to start up, and enabling the progress information by sending a
SIGUSR1 signal. This didn't work if the progress information was
intended to go to file descriptor, since the information was never
passed to e2fsck.
So we now pass the progress fd in as a negative number if the progress
information is intended to be initially suppressed.
Addresses-Launchpad-Bug: #203323
Addresses-Sourceforge-Bug: #1926023
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The exiting fsck instance wasn't marked as DONE, so the safety checks
thought a progress bar was still in progress, and so we didn't enable
another filesystem's checking.
Addresses-Debian-Bug: #432865
Addresses-Launchpad-Bug: #203323
Addresses-Sourceforge-Bug: #1926023
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
We need to set tm_isdst to -1 so that mktime will automatically
determine whether or not daylight savings time (DST) is in effect.
Previously tm_isdst was set to 0, which caused mktime to interpret the
time as if it was always not using DST.
Addresses-Debian-Bug: #471882
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
SuSE's security team audited uuidd and came up with these issues.
None of them are serious given that uuidd runs setuid as a
unprivileged user which has no special access other than libuuid
directory, but it's good to get them fixed.
Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Clearing SPARSE_SUPER is dangerous; it can result in a filesystem
which e2fsck can't fix easily. Since there is very few good reasons
for wanting to turn this feature off, disable tune2fs's abiity to do
this. Users who really want this can use debugfs.
Also, deprecate the tune2fs -s option. Remove it from the man page
and usage message.
Addresses-Sourceforge-Bug: #1840286
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Make debugfs and tune2fs reference each other in the "SEE ALSO"
section.
Addresses-Sourceforge-Patches: #1399325
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Previously we just let the kernel and e2fsck do this automatically,
but e2fsck will no longer automatically clear the large_file feature.
It still isn't really necessary to worry about this feature flag
explicitly, but some users seem to care.
Addresses-Red-Hat-Bugzilla: #258381
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The dumpe2fs syntax documented in the man page has been broken for
some time due to getopt() changes. Change the option syntax in
dumpe2fs to be one which is more extensible and consistent with the
format for extended options in mke2fs and tune2fs.
Addresses-Sourceforge-Bug: #1830994
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This requires an fsck aftwards. We don't allow setting the
resize_inode feature because extensive work to tune2fs or e2fsck to
safely relocate blocks is necessary in order to reserve the blocks
needed by the resize inode.
Addresses-Red-Hat-Bugzilla: #167816
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use a more abstract set of feature tests to avoid merge conflicts as
we add support for new features in the maint, master, next, and pu git
branches.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This is useful for mballoc to align block allocation on the RAID
stripe boundaries.
Signed-off-by: Rupesh Thakare <rupesh@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Pass BLOCK_FLAG_READ_ONLY to ext2fs_block_iterate2() so that debugfs,
e2image, and tune2fs will work well with filesystems containing
extents.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Adapted from the SuSE patch, but fixes a number of very serious
problems with the patch in SLES:
1) This changeset uses -M instead of -m; most lowercase options are
reserved for use by the filesystem-specific fsck programs. All new
fsck options must be upper case.
2) This changeset will skip the root filesystem in "fsck -AM", which
the SLES patch will not do.
3) Loading /proc/mounts into the fs_info can cause -t opts matching to
malfuction. So this changeset uses a simplified version of the
ismounted.c function from the ext2fs library.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The pid file was getting created before the fork(), so it had the
incorrect pid number. No one noticed for a while, since "uuidd -k"
will kill the daemon and it has enough automatic convenience functions
that it's usually not necessary to refer to the pid file except as a
convenient place for uuidd to lock against multiple instances of the
daemon starting up.
Addresses-Sourceforge-Bug: #1893244
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This isn't necessary since we don't install the init.d script (and
it's not the recommended way to start uuidd anyway).
Addresses-Sourceforge-Bug: #1885085
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Since recent kernels have a tendency to set this feature willy-nilly,
let's just enable by default. It's only very old kernels that don't
support it any more.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This makes it easier to upgrade to ext4 in the future, and it speeds
up extended attributes handling --- important on SELinux systems!
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The test_fs flag is an "ok to be used with test kernel code" flag. It
makes it easier for us to determine whether a filesystem should be
mounted using ext4 or not.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Make sure lost+found has always at least 2 disk blocks. This will provide at
least elementary test that we have not screwed-up support for 64KB blocks since
the second directory block will be empty.
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If the disk fills while e2image is writing its output file, it will
spew a large number of error messages instead of exiting with a
non-zero status code after the first failure.
Addresses-Sourceforge-Feature-Request: #606508
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add a configure option which causes the uuidd helper daemon not to be
built or used by the uuid library.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Use an improved locking protocol based on the pid file to assure that
only one uuidd is started. Apparently the kernel does not prevent
multiple processes from racing to bind to a Unix domain socket.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Also store the clock sequence information in a state file in
/var/lib/misc/uuid-clock so that if the time goes backwards the clock
sequence counter can get bumped. This allows us to completely
correctly generate time-based (version 1) UUID's according to the
algorithm specified RFC 4122.
Addresses-Sourceforge-Bug: #1529672
Addresses-Red-Hat-Bugzilla: #233471
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fuse and ssh fstab lines such as:
wdfs#https://dav.hoster.com/foo/bar /mnt/hoster fuse user,noauto 0 0
will cause fsck to issue warnings about invalid fstab lines, because
fsck was previously treating '#' as a comment when it appeared
anywhere in an fstab line, not just at the beginning of the line.
Addresses-Gentoo-bug: #195405
Addresses-Sourceforge-bug: #1826147
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When printing the value of tags in a formatted format, print control
characters and characters with the high eight bit set using the ^ and
M- notation, respectively. This prevents a filesystem with a garbage
label from potentially screwing up the user's screen (for example,
putting it into graphical mode).
Addresses-Ubuntu-Bug: #78087
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In raw mode (-r), e2image appends an extra byte to the image-file's
end if the last block requires a sparse write. Consequently, the
resulting image-file is one byte larger than the original in
size. This patch fixes the problem by seeking to one less than the
given offset, so that the byte write does not overflow into the next
block.
This problem can be reproduced by doing an e2image -r dev image-file
and comparing the original and resulting image sizes. This assumes the
image is sparse at the end. For my tests, I created a 100MB sparse
image with two files.
Signed-off-by: Arun Thomas <thomasar@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add FLEX_BG as a supported feature bit.
Add support to mke2fs to create filesystems with FLEX_BG.
Add support to tune2fs to add (and remove, if it won't break
filesystem consistency) the FLEX_BG feature.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
--
lib/e2p/feature.c | 2 ++
lib/ext2fs/ext2fs.h | 6 ++++--
misc/mke2fs.c | 7 ++++++-
3 files changed, 12 insertions(+), 3 deletions(-)
When fgets() function fails, contents of the buffer is undefined. That
is, fgets() return value needs to be checked, to avoid undefined behavior.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The strtoul() function has a lot of messy error checking that needs to
be done; by factoring it out into one place we can make sure it's done
right in all of the places where it is called.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This will make it easier for us to support 64-bit block numbers when
the time comes. Not that running badblocks on a > 4TB machine is
anything I want to contemplate!
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix chattr so that if there are errors, it will report it via a
non-zero exit code. It will now explicitly give errors when
attempting to set files that are not files or directories (which are
currently not supported under Linux). The -f flag will suppress error
messages from being printed, although the exit status will still be
non-zero.
Addresses-Red-Hat-Bugzilla: #180596
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
The -R option is only used for backwards compatibility, and -E is
preferred, so change the usage message accordingly.
Signed-off-by: Coly Li <coyli@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add macros to support variable-length group descriptors for ext4.
Signed-off-by: Valerie Clement <valerie.clement@bull.net>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If a user specifies a bind mount with a non-zero fsck pass number, for
example:
/foo /bar ext3 bind,defaults 1 3
print a warning and ignore the fstab entry.
Addresses-Red-Hat-Bugzilla: #151533
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix up $(root_sysconfdir) handling misc/Makefile.in so that
make install and make uninstall works correctly when $prefix != /.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Create new functions ext2fs_{set,get}_{inode,block}_bitmap_range()
which allow programs like e2fsck, dumpe2fs, etc. to get and set chunks
of the bitmap at a time.
Move the representation details of the 32-bit old-style bitmaps into
gen_bitmap.c.
Change calls in dumpe2fs, mke2s, et. al to use the new abstractions.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
People are getting surprised by mke2fs creating filesystems with
different defaults than earlier versions of mke2fs if mke2fs.conf is
not present. Having gotten two complaints about ramdisks getting
created by with 4k blocksizes which then blow up when the ramdisk is
mounted with a "Magic mismatch, very weird" error message from the
kernel, let's fix this by making sure mke2fs has a built-in version of
mke2fs.conf file. People can still override the built-in version of
mke2fs.conf by editing /etc/mke2fs.conf, but this maintains the
previous behavior.
Addresses-Sourceforge-Bug: #1745818
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This patch changes ext2fs_open() to set EXT2_FLAG_MASTER_SB_ONLY by
default. This avoids some problems in e2fsck (reported by Jim Garlick)
where a corrupt journal can end up writing the bad superblock to the
backups. In general, only e2fsck (after the filesystem is clean),
tune2fs, and resize2fs should change the backup superblocks by default.
Most callers of ext2fs_open() should not be touching anything where the
backups should be touched. So let's change the defaults to avoid
potential problems.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
A quick patch to sanity check the inode ratio vs the inode size. In
some cases Lustre users have tried specifying an inode size of 4096
bytes, while keeping an inode ratio of one inode per 4096 bytes. I'm
sure more people will do this now that large inodes are available in
ext4 and documented in e2fsprogs.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Store the RAID stride value when a filesystem is created with a requested
RAID stride, and then use it automatically in resize2fs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Mke2fs is supposed to set the uid/gid ownership of the root directory when
a non-rooot user creates the filesystem. This wasn't working correctly
if the uid/gid was > 16 bits. In additional, debugfs wasn't displaying
large uid/gid's correctly. This patch fixes these two programs.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
One of our testers filed a bug that said "mkfs.ext3 is much slower
when mke2fs.conf is missing..."
This is because the shipped defaults in mke2fs.conf do not match the
shipped defaults in the mkfs code itself; he wound up making a 1k
block filesystem on a very large block device, for example.
So - How about this patch, to bring them back into line? Which makes
me wonder; having "defaults" in 2 different places is bound to get out
of sync; should we instead generate both code & config file defaults
(and maybe man page defaults) from a common source?
Anyway, here's a patch to bring mke2fs.conf and mke2fs.c into line for
current defaults...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Increase the maximum size of the journal to 100 times the previous
maximum, but add a restriction that it can be no more than half the size
of the filesystem.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The memory allocated by inst is not reclaimed. There also was a
call to exit that coverity did not catch the resource leak. This
might not really be a big issue since the memory will be freed when
fsck exits, but it should be done anyway imho.
Coverity ID: 32: Resource Leak
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
zero_buf and buf must be freed on return from the
output_meta_data_blocks() function.
Coverity ID: 26+27: Resource Leak
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
If the fs_type is not specified and we are creating a journal device, to
use a fs_type of "journal"; this used to be the behavior before we added
support for the /etc/mke2fs.conf file, so let's fix it to restore the
old behavior.
Coverity ID: 4: Deadcode
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change all of the e2fsprogs programs to use the newer add_error_table()
and remove_error_table() interfaces instead of the much older
initialize_*_error_table() function.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Add support for the new flag EXT2_FLAG_SOFTSUPP_FEATURES flag to
ext2fs_open() , which allows application to open filesystes with features
which are currently only partially supported by e2fsprogs.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Badblocks now interprets last_block argument as the last block to check,
instead of the number of blocks to check, to be consistent with the
badblocks man page.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fix revision 0 error checking so that it doesn't give spurious error
when the user gives a command-line option of "-O none".Add error
checking so that "-r 0 -j", "-r 0 -s 1", and "-r 0 -E resize=XXX" will
print an explanatory error message and abort.
Addresses Debian bug: #392107
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Make the smallest journal be 1400 blocks instead of 1024 blocks to
make sure there is enough room to support on-line resizing.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Create new ext2fs library inline functions in order to calculate
the starting and ending blocks in a block group.
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
There were still some %d's lurking when we print blocks & inodes; also
many of the counters in the e2fsck_struct were signed, and probably
need to be unsigned to avoid overflows.
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
For loops iterating over all group descriptors, consistently define
first_block and last_block in a way that they are inclusive of the
range, and do not overflow.
Previously on the last block group we did a test of <= first +
dec_blocks; this would actually wrap back to 0 for a total block count
of 2^32-1
Also add handling of last block group which may be smaller.
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Add a new functiom, e2p_percent(), which correct calculates the percentage
of a number based on a given percentage, without worrying about overflow
issues. This is used where we calculate the number of reserved blocks using
a percentage of the total number of blocks in a filesystem.
Based on patches from Eric Sandeen, but generalized to use this new function.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Add a new function, ext2fs_div_ceil(), which correctly calculates a division
of two unsigned integer where the result is always rounded up the next
largest integer. This is used everywhere where we might have
previously caused an overflow when the number of blocks
or inodes is too close to 2**32-1.
Based on patches from Eric Sandeen, but generalized to use this new function
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
This patch fixes the blkid.8.in description of the "-l" option. The man
page gives the impression that the first match is the one that is returned.
However, the blkid_find_dev_with_tag() function returns the device with
the highest priority (which is good, because that is what people really want).
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Improve the findsuper program by printing the uuid and label from the
superblocks, as well as the starting and ending offsets of the
filesystem given the information in the superblock. Omit by
default printing superblocks that are likely found in located in an ext3
journal unless an explicit -j option is given.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Disambiguate the use of "-F" (force) flag for mke2fs to avoid dangerous
situations. The use of -F is needed for regular backing files and
for filesystems on whole block devices. It should NOT be confused
with mke2fs on an apparently-mounted or in-use filesystem.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This patch allows "inode_size" to be specified in the mke2fs.conf file,
and always compiles in the "-I" option. In addition, it disallows
specifying the inode size on rev 0 filesystems, though I don't think
this was much of a danger anyways.
Clean up dead lines in ext2fs.h.
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>