summaryrefslogtreecommitdiffstats
path: root/disk-utils/fsck.cramfs.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused utime.h headerRosen Penev2019-08-081-1/+0Star
| | | | | It is sometimes unavailable and errors on inclusion. For example, when disabled in uClibc-ng.
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: fix utimes() usageKarel Zak2019-01-151-3/+3
| | | | | | The bug has been introduced by untested commit ad7ac3d598e2d541d9eba70975e68dff7e52c7d9 ;-( Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: use utimes() instead of utime() that is obsoleteSami Kerola2019-01-121-4/+4
| | | | | Reference: http://man7.org/linux/man-pages/man3/utime.3p.html#APPLICATION_USAGE Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix typos using codespellRuediger Meier2018-02-161-1/+1
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: fix error messageRuediger Meier2018-01-241-1/+6
| | | | | | errno is invalid in case that we just read(3) too short. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: fix crash when superblock size is too smallRuediger Meier2018-01-241-1/+1
| | | | | | | | | | | This hopefully fixes the original problem addressed by the reverted patch 7cb962c7. The bug was introduced by myself in f991dbd3 "fsck.cramfs: allow smaller superblock sizes" CC: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Revert "fsck.cramfs: Fix bus error on broken file system."Ruediger Meier2018-01-241-7/+6Star
| | | | | | | | | | | | | | | | | | This reverts commit 7cb962c77015e9383b53eeb22ce732cb5216bbc3. It can't be right that we mmap (start + super.size) bytes from a file which is usually only super.size bytes large. The patch "fixed" a problem when super.size is bad but now it fails for the correct case: $ mkdir -p root/subdir $ ./mkfs.cramfs -p root cramfs $ ./fsck.cramfs cramfs Bus error (core dumped) We will fix the original problem later. CC: Tobias Stoeckmann <tobias@stoeckmann.org> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: Fix bus error on broken file system.Tobias Stoeckmann2017-11-021-6/+7
| | | | | | | | | | | | | | | | | The utility fsck.cramfs is prone to a bus error on file systems for big endian systems with non-standard header sizes. While calculating the crc32 checksum, it does not properly handle a possible offset for bootcodes, resulting in out of boundary access of mmap'ed area. You can trigger the issue with the following commands: $ mkdir -p cramfs-poc/root/subdir $ cd cramfs-poc $ mkfs.cramfs -p -N big root cramfs $ echo -ne \\00\\x4c | dd of=cramfs bs=1 seek=518 count=2 conv=notrunc $ fsck.cramfs cramfs Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* 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>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(ERROR)Ruediger Meier2017-06-261-8/+8
| | | | | | | | | | We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix more strutils related exit codesRuediger Meier2017-06-221-0/+2
| | | | | | | | | | | | Found by grep: grep -l "\bEXIT_\|exit *( *[0-9][0-9] *)\|strutils\.h" $(grep -L \ strutils_set_exitcode $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c")) The Command shows also some false positives (fstrim.c, context_mount.c, ...) 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>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-2/+2
| | | | | | | 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-9/+9
| | | | | | | | | | 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>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* cramfs: revert crc32 changesKarel Zak2016-10-191-7/+12
| | | | | | | | We cannot use our crc32 without changes in the code, because our ul_crc32() assumes that post-conditioning (xor) is done by application. The zlib implementation does everything. Signed-off-by: Karel Zak <kzak@redhat.com>
* cramfs: add missing includesKarel Zak2016-10-191-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/crc32: prefix public functionsGustavo Zacarias2016-10-191-6/+6
| | | | | | | | | | | Make the publicly-visible crc32 library functions prefixed by ul_, such as crc32() -> ul_crc32(). This is because it clashes with the crc32() function from zlib. For newer versions of glib (2.50+) zlib and libblkid are required dependencies and otherwise results in build failure when building statically. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
* fsck.cramfs: don't ignore read() result [coverity scan]Karel Zak2016-10-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-7/+4Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: move sys/sysmacros.h to c.hKarel Zak2016-03-081-4/+1Star
| | | | | | | The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary), but needed on many places. It seems better to keep it in c.h. Signed-off-by: Karel Zak <kzak@redhat.com>
* include: check for sys/sysmacros.hRuediger Meier2016-02-181-0/+2
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* sys-utils/disk-utils/lib: fix printf format types [cppcheck]Boris Egorov2015-06-251-3/+3
| | | | | | Fix 'invalidPrintfArgType' cppcheck warnings Signed-off-by: Boris Egorov <egorov@linux.com>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | The message "stat failed %s" seems to say that stat() failed to do something, or failed to pass a test, but of course it means that the statting of something failed. So say so. Also make two very similar messages equal to this one. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* maint: fix shadow declarationSami Kerola2015-01-071-23/+24
| | | | | | | | | | | | | | | | This change fixes all shadow declarations. The worth while to mention fix is with libfdisk sun geometry. It comes from bitops.h cpu_to_be16 macro that further expands from include/bits/byteswap.h that has the shadowing. libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow] libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow] libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow] libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow] That could have caused earlier some unexpected results. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | 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>
* textual: fix some typos and inconsistencies in various messagesBenno Schulenberg2014-07-231-1/+1
| | | | | | | | Fixing plain typos, miswordings, inconsistent periods, some missing angular brackets, and a proper pluralization (even when it involves a constant, because for some languages the precise value matters). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* build: fix some compiler warningsRuediger Meier2014-05-301-2/+2
| | | | | | | | | | | | Most of them catched on 32bit gcc and icc. disk-utils/fsck.cramfs.c: printf format type lib/boottime.c: unused variables misc-utils/cal.c: set but never used sys-utils/losetup.c: set but never used sys-utils/lscpu-dmi.c: defined but not used sys-utils/switch_root.c: comparison between signed and unsigned tests/helpers/test_sysinfo.c: printf format type
* fsck.cramfs: cleanup usage() and warning messagesKarel Zak2014-05-201-7/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: remove define INCLUDE_FS_TESTSRuediger Meier2014-05-191-24/+5Star
| | | | | | | There is only one non-trivial issue where we now print a warning instead of exit error. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: refactor option -x/--extractRuediger Meier2014-05-191-14/+17
| | | | | | | | | | | | | | | | | We want to clean it up to compile it later per default (not only if defined INCLUDE_FS_TESTS). - Rename option --destination to --extract. - DIR argument is now optional because we want to keep the use case "test uncompression without writing files" ... but we don't want it always. - Remove shortopt -x because shortopts with optional args are evil. Changing the cmd interface is no compatibility issue here because all affected options errored out per default in past. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: add option --blocksizeRuediger Meier2014-05-191-3/+12
| | | | | | .. similar to mkfs.cramfs Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: rename variable page_size to blksizeRuediger Meier2014-05-191-11/+11
| | | | | | ... similar to mkfs.cramfs.c Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: ifdef unused outbuffer and page_sizeRuediger Meier2014-05-191-5/+4Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: allow smaller superblock sizesRuediger Meier2014-05-191-1/+2
| | | | | | | | | | We are already fine with checking for different endianess. Now we also succeed if systems's page size does not match. Note that page_size is only really used if INCLUDE_FS_TESTS is defined, see followups. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.cramfs: add LC_CTYPEKarel Zak2013-10-181-0/+1
| | | | | | | Maybe it would be possible to use LC_ALL, but it requires to review the code to check if there is no any sensitive code. Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: standardize some "cannot read" and "seek failed" error messagesBenno Schulenberg2013-10-091-7/+7
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* fsck.cramfs: check writing to a file descriptor was successfulSami Kerola2013-04-261-1/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.cramfs: check returns [coverity scan]Karel Zak2013-03-271-4/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: fix compiler warningsKarel Zak2013-03-151-4/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: add dummy -a -y for compatibilityKarel Zak2013-02-181-2/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: fix compiler warning [-Wpointer-arith]Karel Zak2012-09-041-2/+2
| | | | | | | | disk-utils/fsck.cramfs.c: In function ‘test_crc’: disk-utils/fsck.cramfs.c:231:32: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] disk-utils/fsck.cramfs.c:233:24: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.cramfs: fix compiler warning [-Wmissing-prototypes]Karel Zak2012-07-161-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify stat error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.cramfs: disallow unknown command line optionsSami Kerola2012-06-171-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* disk-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>