summaryrefslogtreecommitdiffstats
path: root/disk-utils/fsck.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-5/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: cleanup find_fsck()Karel Zak2018-02-191-6/+14
| | | | | | | | * remove static variable * return 0 or 1 * optionally return allocated path to the program Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: coding style cleanupKarel Zak2018-02-161-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: use xasprintf to avoid buffer overruns with an insane fs typeTheodore Ts'o2018-02-161-6/+9
| | | | | | | | | This prevents a crash when running the command: fsck -t AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA /dev/sda Reported-by: Hornseth_Brenan@bah.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-1/+1
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate all --help option descriptionsRuediger Meier2017-06-271-2/+2
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'fix-exit-codes' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-261-2/+1Star
|\ | | | | | | | | | | | | | | | | * 'fix-exit-codes' of https://github.com/rudimeier/util-linux: misc: fix optutils.h related exit codes misc: fix xalloc.h related exit codes misc: fix more strutils related exit codes lib: fix strutils.h, remove STRTOXX_EXIT_CODE misc: fix some broken exit codes
| * lib: fix strutils.h, remove STRTOXX_EXIT_CODERuediger Meier2017-06-221-2/+1Star
| | | | | | | | | | | | | | | | | | As discussed on the mailing list. We fix all places where the non-working define STRTOXX_EXIT_CODE was used. Regarding tunelp, also see 7e3c80a7. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: fix some broken exit codesRuediger Meier2017-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These tools have special exit codes. They got changed mistakenly. See: findfs 0e1fa6b6 fsck 658c0891 fsck.cramfs 922ec175 mkfs.cramfs 16154b1f tunelp 2ab428f6 FIXME: STRTOXX_EXIT_CODE doesn't work as it should. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | fsck: add --help and --versionRuediger Meier2017-06-221-7/+20
|/ | | | | | | | | | Also cleanup usage() function, never write usage to stderr. FIXME: - currently strtou32_or_err() exits with wrong exit code. - option -C does not use a safe strto*_err function Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-12/+12
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include/closestream: define exit codesKarel Zak2016-08-161-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-16/+15Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-3/+3
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* fsck: fix racing between unlock/unlink and openYuriy M. Kaminskiy2016-04-221-1/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | Process A Process B Process C open() [creates file] lock() [succeed] open() [open existing] lock()... running() close() [...succeed] unlink() running() open() [creates file] {BAD!} lock() [succeed] {BAD!} running() {BAD!} close() Cons: leaves empty (unlocked/harmless) .lock files in /run/fsck/ Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
* mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messagesBenno Schulenberg2016-03-161-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* Revert "include sysmacros.h where used"Karel Zak2016-03-081-1/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-081-0/+1
| | | | | | | | BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux libraries have been moving away from including sysmacros.h implicitly via sys/types.h, so include it directly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* misc: safer (and uniform) handling of return valueYuriy M. Kaminskiy2016-03-071-1/+1
| | | | | | When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix some printf format stringsRuediger Meier2016-02-111-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the warnings below for OSX clang and add a few more casts for timeval: lib/at.c:131:27: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'off_t' (aka 'long long') [-Wformat] printf("%16jd bytes ", st.st_size); ~~~~~ ^~~~~~~~~~ lib/strutils.c:522:52: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat] snprintf(buf, sizeof(buf), "%d%s%jd%s", dec, dp, frac, suffix); ~~~ ^~~~ lib/sysfs.c:468:42: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat] len = snprintf(buf, sizeof(buf), "%ju", num); ~~~ ^~~ libuuid/src/gen_uuid.c:316:34: warning: format specifies type 'unsigned long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat] clock_seq, last.tv_sec, last.tv_usec, adjustment); ^~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck: retire stat(3) when access(3) does better jobSami Kerola2015-11-091-2/+1Star
| | | | | | | | The stat(3) and access(3) are in this case almost interchangeable, so choose the lightweight function with additional advantage checking the file is executable. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed linesKarel Zak2015-10-151-1/+1
| | | | | | | | | | | | | | | | | The libmount provides way how to deal with parsing errors in fstab -- on error callback function is executed and according to the return libmount manipulate with the malformed line, possible are three states: 1/ fatal error; all file ignored (callback rc < 0) 2/ recoverable error; malformed line ignored (callback rc > 0) 3/ ignore the error (callback rc == 0) The 2/ is the default if no callback specified. Unfortunately our utils uses 3/. The correct way is to use 2/. Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: adjust grammar and punctuation of some messagesBenno Schulenberg2015-08-031-3/+3
| | | | | | | Also equalize three messages to one other one, and fix a typo in USE_COLORS_BY_DEFAULT. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* fsck: Fix parsing of -rStanislav Brabec2015-05-051-1/+1
| | | | | | | | | | Fix regression introduced by commit 658c089: -r cannot be used as a last option: fsck -r /dev/sda1 fsck: invalid argument -r: '/dev/sda1' Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* fsck: print errors on invalid -r argumentKarel Zak2015-04-281-14/+10Star
| | | | | | The patch also add support for -r 0. Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: implement fsck -r {fd}Stanislav Brabec2015-04-281-12/+52
| | | | | | | | | | | | | | | | | | | | Make possible sending of statistics to a dedicated file descriptor. Rationale: When UI is calling fsck from a remote terminal, fsck progress needs to be sent to stdout. It is mixed there with output of statistics, and it is impossible to parse the output to get the statistics. Now it will be possible e. g. with "fsck -C -r 3 /dev/sda1" Note: Code in if and else is intentionally partially duplicated. Current human readable output of floats does not conform to locale conventions, and may be changed in future. But we want to keep machine readable output exactly same as it is now. [kzak@redhat.com: - don't use report_stats_fd globally] Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: use PATH or fallback to /sbinKarel Zak2015-04-271-12/+4Star
| | | | | | | | | | | It's overkill to support all the obscure paths like /sbin/fs.d. We have PATH for customization, that's enough. It still seems like a good idea to keep fsck robust, because it's used by boot scripts/systemd. For this reason fsck fallbacks to "/sbin" if PATH is undefined or empty. Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: fix fsck -C {fd} parsingStanislav Brabec2015-03-251-1/+1
| | | | | | | | | Both fsck(8) and fsck --help documents progress bar redirection as -C {fd} This did not work, and only -C{fd} and "-C {fd}" worked. Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: fix compiler warning [-Wlogical-not-parentheses]Karel Zak2015-02-161-3/+2Star
| | | | | Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: use monotonic time to fsck run time measurementSami Kerola2015-02-101-7/+7
| | | | | | | | Earlier use of gettimeofday() resulted to wrong measurement if system administrator did manual time changes, or NTP or adjtime(3) adjusment happen during fsck run. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck: deallocate when no cache [coverity scan]Karel Zak2015-01-281-2/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* various: erase all traces of the long-obsolete xiafsBenno Schulenberg2014-07-281-2/+1Star
| | | | | | | | The xiafs filesystem was removed from the kernel fifteen years ago, and any kernel that contained it reached end of life ten years ago. It's time to stop mentioning it in the mount man page and elsewhere. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* fsck: uninitialized argument value [clang-analyze]Karel Zak2014-07-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: use private lock file rather than whole-disk directlyKarel Zak2014-06-091-16/+54
| | | | | | | | | | | It seems overkill to lock directly whole-disk device (for -l) when we use the lock only to synchronize fsck instances. It's fsck private business, so don't use system files, but let's use private /run/fsck/<diskname>.lock file. Addresses: https://bugs.freedesktop.org/show_bug.cgi?id=79576 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add mkdir_p() from libmountKarel Zak2014-06-091-1/+1
|
* fsck: don't return error if fsck.<type> does not existKarel Zak2014-02-061-32/+42
| | | | | | | | | The error message is expected for "really wanted" set of filesystems (extN, ..), otherwise it does not make sense for filesystems like btrfs or xfs. Reported-by: Tom Gundersen <teg@jklm.no> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: equalize four error messages with already existing onesBenno Schulenberg2013-10-141-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: standardize some "cannot read" and "seek failed" error messagesBenno Schulenberg2013-10-091-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* fsck: don't print warning if there is no /etc/fstab at allKarel Zak2013-10-011-4/+8
| | | | | Reported-by: Thomas Bächler <thomas@archlinux.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use libmnt_table reference counterKarel Zak2013-08-211-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use libmnt_cache reference countingKarel Zak2013-08-211-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: use libmount fs reference counterKarel Zak2013-08-211-4/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: cleanup usage()Karel Zak2013-04-051-26/+29
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: add "--" to usage()Karel Zak2013-01-301-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: slice the help text of fsck into strips, for translatorsBenno Schulenberg2013-01-301-20/+20
| | | | | | Also improve the descriptions a bit and alphabetize the options. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* fsck: mark file descriptor for -C as optional in help textBenno Schulenberg2013-01-301-2/+2
| | | | | | Also slightly improve the man page. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: use UTIL_LINUX_VERSION everywhereKarel Zak2013-01-251-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck: use less aggressive method to detect mounted devicesKarel Zak2012-08-241-7/+24
| | | | | | | | | | | | | | | | We should not care about mountpoints in fsck if a device name specified on command line, just check if the device is used somewhere in /proc/self/mountinfo file. Crazy people who use fsck /mountpoint have to specify the mountpoint by the same format as in their fstab -- symlinks canonicalization is not supported. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=850965 Signed-off-by: Karel Zak <kzak@redhat.com>