summaryrefslogtreecommitdiff
path: root/misc/util.c
AgeCommit message (Collapse)AuthorFilesLines
2011-09-28mke2fs: set s_max_mnt_count to -1 by defaultTheodore Ts'o1-1/+5
If the enable_periodic_fsck option is false in /etc/mke2fs.conf (which is also the default), s_max_mnt_count needs to be set to -1, instead of 0. Kernels newer than 3.0 will interpret 0 to disable periodic checks, but older kernels will print a warning message on each mount, which will annoy users. Addresses-Debian-Bug: #632637 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-25ext2fs: add multi-mount protection (INCOMPAT_MMP)Andreas Dilger1-0/+14
Multi-mount protection is feature that allows mke2fs, e2fsck, and others to detect if the filesystem is mounted on a remote node (on SAN disks) and avoid corrupting the filesystem. For e2fsprogs this means that it checks the MMP block to see if the filesystem is in use, and marks the filesystem busy while e2fsck is running on the system. This is useful on SAN disks that are shared between high-availability servers, or accessible by multiple nodes that aren't in HA pairs. MMP isn't intended to serve as a primary HA exclusion mechanism, but as a failsafe to protect against user, software, or hardware errors. There is no requirement that e2fsck updates the MMP block at regular intervals, but e2fsck does this occasionally to provide useful information to the sysadmin in case of a detected conflict. For the kernel (since Linux 3.0) MMP adds a "heartbeat" mechanism to periodically write to disk (every few seconds by default) to notify other nodes that the filesystem is still in use and unsafe to modify. Originally-by: Kalpak Shah <kalpak@clusterfs.com> Signed-off-by: Johann Lombardi <johann@whamcloud.com> Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-18Shorten compile commands run by the build systemTheodore Ts'o1-0/+1
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and this was starting to cause some tools heartburn. It also made "make V=1" almost useless, since trying to following the individual commands run by make was lost in the noise of all of the defines. So fix this by putting the configure-generated defines in lib/config.h and the directory pathnames to lib/dirpaths.h. In addition, clean up some vestigal defines in configure.in and in the Makefiles to further shorten the cc command lines. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15e2fsprogs: create open() and stat() helpersLukas Czerner1-8/+2
In many places we are using #ifdef HAVE_OPEN64 to determine if we can use open64() but that's ugly. This commit creates two new helpers ext2fs_open_file() for open() and ext2fs_stat() for stat(). Also we need new typedef ext2fs_struct_stat for struct stat. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-13mke2fs: Use ext2fs_flush() only onceLukas Czerner1-3/+2
We are doing ext2fs_flush() twice right now at the end of the mke2fs. First by directly calling ext2fs_flush() which is intended to write superblock and fs accounting information. And then it is invoked again when we are calling ext2fs_close(), only this time, because the fs is not dirty, we are writing out only superblock. I think it is bad to call it twice because even when writing only super block it takes some time on bigger file systems and moreover ext2fs_close() can fail without any reasonable explanation for the user. Also ext2fs_flush() is printing out progress and it is confusing for the users. Fix all this by removing the ext2fs_flush() and leaving it all to ext2fs_close(). However we need to introduce new variables to store check interval and max mount count, because fs structure is freed on ext2fs_close() and we really want to print those information as the last info for the user. [ Fixed type mismatch in a printf format statement -tytso] Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-06-07Merge branch 'maint' into nextTheodore Ts'o1-0/+4
Conflicts: e2fsck/journal.c e2fsck/pass1.c e2fsck/pass2.c misc/mke2fs.c
2010-05-12mke2fs: be explicit if external journal device is not foundEric Sandeen1-0/+4
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>
2009-09-07Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()Valerie Aurora Henson1-2/+2
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27Remove trailing whitespace for the entire source treeTheodore Ts'o1-8/+8
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-25mke2fs/tune2fs: Fix max journal size in message to be consistent/correctTheodore Ts'o1-1/+1
Addresses-Debian-Bug: #491620 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-10-29Check fgets(3) return valueDmitry V. Levin1-2/+2
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>
2007-08-03Fix gcc -Wall warningsTheodore Ts'o1-2/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-06-21Add default journal size functionTheodore Ts'o1-16/+3
Factor out the code which sets the default journal size and move it into libext2fs. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-07Allow the journal size to up to 10,240,000 blocksAndreas Dilger1-3/+3
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>
2007-03-28[COVERITY] Fix memory leak in tune2fs and mke2fs when parsing journal optionsBrian Behlendorf1-0/+2
Coverity ID: 33: Resource Leak Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-10-02Increase default journal size to guarantee working on-line resizingTheodore Ts'o1-1/+1
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>
2006-08-05Require mke2fs -F -F for really dangerous operationsAndreas Dilger1-2/+2
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>
2006-03-23Change mke2fs to use /etc/mke2fs.conf as a configuration fileTheodore Ts'o1-1/+1
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-06-05On Linux 2.6 systems, mke2fs and badblocks will check to see whetherTheodore Ts'o1-8/+17
the filesystem appears to be busy; if so, the programs will print an error message and abort. (Addresses Debian Bug #308594).
2005-05-09Change the default journal size to be bigger for larger filesystems, Theodore Ts'o1-2/+7
given modern memory sizes. Now, for filesystems greater than 4GB, we use a journal of 128 MB instead 32 MB.
2004-03-30GNU/KFreeBSD portability fixes. (Addresses Debian Bug #239934)Matthias Andree1-1/+1
2003-12-28Re-add FreeBSD support. Matthias Andree1-1/+7
Tested on FreeBSD 5.2-CURRENT as of 2003-12-28. Tested on FreeBSD 4.9-STABLE as of 2003-12-27.
2003-12-07Fix gcc -Wall nitpicksTheodore Ts'o1-12/+12
2003-11-20util.c (check_plausibility): Support 2.6 kernel header files,Theodore Ts'o1-1/+13
instead of having the build to crash. (Addresses Debian bug #221778)
2003-05-03Add Czech translation.Theodore Ts'o1-1/+1
Remove "NYC" translation. Add Czech translation from Miloslav Trmac <mitr@volny.cz> Random NLS and other display fixes from Miloslav.
2003-03-01Minor bug fixes in the blkid library.Theodore Ts'o1-2/+2
Convert mke2fs, fsck, and tune2fs to use the blkid library.
2002-02-25Add check for mkfs.ext3 and create a journal in this case.Andreas Dilger1-0/+14
2001-12-16Fix various gcc -Wall nits. Fixed a bug in mke2fs where a bogusTheodore Ts'o1-4/+3
error message could be printed on an malloc() failure, and e2image was optimized to avoid needless system calls by using the stashed inode functions.
2001-11-13util.c (check_plausibility): Use stat64 if available so thatTheodore Ts'o1-0/+9
check_plausibility() works with files > 2GB.
2001-08-17get_device_by_label.[ch], fsck.c, util.c: New interpret_spec()Andreas Dilger1-2/+3
function in get_device_by_label.c to allow the use of UUID= or LABEL= when creating filesystems which use external journal dev (e.g. mke2fs -J device=LABEL=<journal_label>). tune2fs.c: Use superblock s_journal_uuid to locate an external journal device instead of s_journal_dev when removing it. Allow opening journal devices to set the label and UUID in the ext2 superblock. mke2fs.c, tune2fs.c: Free journal_device after use, as it is malloc'd in interpret spec.
2001-06-14ChangeLog, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:Theodore Ts'o1-0/+9
tune2fs.c, mke2fs.c, util.c, util.h (print_check_message): Move the message which displays how often the filesystem will be checked from mke2fs into a utility subroutine. Then cause tune2fs to call that function to display the message after adding a journal to a filesystem. mke2fs.8.in: Add manual page fixups and explanation for why it's good to check filesystems periodically from Andreas Dilger.
2001-05-14Many files:Theodore Ts'o1-1/+1
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c: Change location of ext2_fs.h to be ext2fs/ext2_fs.h ChangeLog, Makefile.in, resize2fs.h: resize2fs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h ChangeLog, Makefile.in, debugfs.h: debugfs.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h ChangeLog, Makefile.in, e2fsck.h, scantest.c: e2fsck.h, scantest.c: Change location of ext2_fs.h to be ext2fs/ext2_fs.h ChangeLog, Makefile.in, tst_uuid.c, uuid_time.c: tst_uuid.c, uuid_time.c: Remove unneeded #include of ext2_fs.h ChangeLog, Makefile.in, e2p.h: e2p.h: Change location of ext2_fs.h to be ext2fs/ext2_fs.h ChangeLog, Makefile.in, test_icount.c, test_rel.c: test_icount.c, test_rel.c: Change location of ext2_fs.h to be ext2fs/ext2_fs.h
2001-05-07ChangeLog, util.c:Theodore Ts'o1-0/+2
util.c: Use specific check for HAVE_SYS_STAT_H.
2001-04-17ChangeLog, mke2fs.c:Theodore Ts'o1-5/+2
mke2fs.c (create_journal_dev): Call ext2fs_create_journal_superblock() first, so if it's going to error out, the user finds out before waiting for the entire device to get zero'ed. ChangeLog, util.c: util.c (parse_journal_opts): Remove code which allowed a bare number to be treated as a journal size.
2001-03-26ChangeLog, mke2fs.8.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:Theodore Ts'o1-17/+35
ke2fs.8.in, tune2fs.8.in: Change man paegs to document that the journal must be bewteen 1024 and 10,240 file system blocks. mke2fs.c, tune2fs.c: Change to use figure_journal_size() util.c, util.h (figure_journal_size): Change journal_default_size into routine which also converts the requested journal size into filesystem blocks and does bounds checking to make sure the journal is sized reasonably. Renamed function to journal_default_size. parse_journal_opts): Remove bounds check for the journal size, since this is now done in figure_journal_size, and based on the number of filesystem blocks, as opposed to using the absolute size of the journal.
2001-01-18ChangeLog, util.c, util.h:Theodore Ts'o1-2/+23
util.h, util.c (journal_default_size): New function from Andreas Dilger to calculate an appropriate default journal size given a filesystem size. util.c (parse_journal_opts): Allow the creation of a journal as small as 1MB.
2001-01-11ChangeLog, e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c:Theodore Ts'o1-1/+1
e2image.c, mke2fs.c, mklost+found.c, tune2fs.c, util.c, uuidgen.c: Fix gcc -Wall complaints, including one bug in tune2fs caused by a block automatic shadowing version of the variable we really wanted to use, which broke the logic testing to see if the filesystem was mounted. ChangeLog, MCONFIG.in: (gcc-wall-new): Added new target which forgoes the make clean so we only check the newly modified .c files.
2001-01-03ChangeLog, Makefile.in, mke2fs.c, tune2fs.8.in, tune2fs.c, util.c, util.h:Theodore Ts'o1-0/+198
tune2fs.c (update_feature_set, add_journal): Moved to separate functions. Added ability to add and remove the journal while the filesystem is live. Added support for setting a time-based UUID. Removed zero-initialized static variables. mke2fs.c, util.c, util.h (strcasecmp, proceed_question, check_plausibility, parse_journal_opts, check_mount): Moved functions to util.c so they can be used by tune2fs. mke2fs.c (main): Change ext2fs_add_journal_fs() to ext2fs_add_journal_inode() to reflect function renaming.