According to coverirty a printf format string contains an unrecognized
format specifier (CWE-628). Lets avoid glibc extension "%m" that is same
as "%s", strerror(errno).
CID: 360699
CID: 360718
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
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>
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>
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>
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>
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>
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>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>