summaryrefslogtreecommitdiffstats
path: root/disk-utils/fsck.minix.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | 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: 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(stderr)Ruediger Meier2017-06-261-6/+8
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. 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>
* fsck.minix: add hint for scanners [coverity scan]Karel Zak2017-05-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.minix: fix crashSami Kerola2017-05-161-1/+7
| | | | | | | | | disk-utils/fsck.minix.c:421:30: runtime error: index 513 out of bounds for type 'unsigned short [512]' Addresses: https://github.com/karelzak/util-linux/issues/373 Reported-by: Hanno Bock <hanno@gentoo.org> 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>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-4/+3Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: fix endless loop and out of stackKarel Zak2016-06-011-0/+16
| | | | | | | | | It seems there is no elegant way how to recovery if a directory i_zone (and i_size) is out of reality. Let's require human interaction to avoid endless loop when executed with --auto, etc. Addresses: https://github.com/karelzak/util-linux/issues/228 Signed-off-by: Karel Zak <kzak@redhat.com>
* 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.minix: Verify more fields in super-block.Tobias Stoeckmann2016-05-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | The field s_ninodes in super-block is used for memory allocation and division without verifications. The memory allocation increments the unchecked value by 1, making it vulnerable to an integer overflow on 32 bit systems with minix 3 file systems. I did not find a (good) way to exploit this by crafting a malicious file system, so I consider it as a reliability issue. If it's 0, a division by zero occurs when "-v" has been used. A filesystem without any inodes is definitely wrong, because it means that there's not even the root inode, which is accessed unchecked later on. The field s_firstdatazone has to be checked against s_(n)zones. If it is larger than the highest allowed index, the file system is definitely corrupted -- hard to say which value is wrong though, therefore I decided to simply call die(). A maliciously created file system could do more harm in this way: single bits inside the memory area could be flipped because range checks would fail. Hard to consider it as a security issue though, because these addresses are not arbitrarily accessible without very careful crafting (if at all possible). [kzak@redhat.com: - fix compiler warning (cast get_nzones()) [-Wsign-compare]] Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: again fixing many printf format stringsRuediger Meier2016-03-071-2/+3
| | | | | | | | | | | | | | | | | | | This is again a huge patch regarding printf format strings to fix compiler warnings seen on clang/OSX. I'm trying to follow these rules strictly: #type #format #cast uintmax_t %ju - intmax_t %jd - uint64_t PRIu64 - int64_t PRId64 - size_t %zu - ssize_t %zd - ino_t %ju (uintmax_t) off_t %jd (intmax_t) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fsck.minix: fix v3 version offsetRuediger Meier2016-03-031-2/+3
| | | | | | | Our test-suite discoverd it on big endian systems, but it was also broken on little endian for inode numbers > 0xffff. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* include: remove unused mntent.hRuediger Meier2016-02-181-1/+0Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix shadow declarationsSami Kerola2015-08-241-5/+5
| | | | | | | | | | | | | | | | | | | | | | sys-utils/zramctl.c: In function 'get_mm_stat': sys-utils/zramctl.c:276:58: warning: declaration of 'inbytes' shadows a global declaration [-Wshadow] static char *get_mm_stat(struct zram *z, size_t idx, int inbytes) sys-utils/zramctl.c:119:39: note: shadowed declaration is here static unsigned int raw, no_headings, inbytes; libmount/src/tab.c: In function 'mnt_table_get_fs_root': libmount/src/tab.c:1221:22: warning: declaration of 'fs' shadows a parameter [-Wshadow] struct libmnt_fs *fs = mnt_table_find_mountpoint(tb, libmount/src/tab.c:1197:24: note: shadowed declaration is here struct libmnt_fs *fs, disk-utils/fsck.minix.c: In function 'main': disk-utils/fsck.minix.c:1364:17: warning: declaration of 'i' shadows a previous local [-Wshadow] unsigned long i, free; disk-utils/fsck.minix.c:1250:6: note: shadowed declaration is here int i; Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: be more paranoid with block buffers [coverity scan]Karel Zak2015-08-041-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.minix: introduce long options to the commandSami Kerola2015-07-301-77/+73Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: add minix v3 supportSami Kerola2015-07-301-13/+20
| | | | | Relates-to: a2657ae3ffb56616ac9c921886bcca8ef242499f Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: rename device file descriptor variableSami Kerola2015-07-301-20/+20
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rpmatch: use symbolic value when evaluation return codesSami Kerola2015-02-241-3/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: fix segmentation faultSami Kerola2015-01-071-3/+10
| | | | | | | | | Return from check_file() and check_file2() functions when maximum name depth is reached. The use unsafe strncpy() is also removed just to be on safe side. Addresses: https://bugs.debian.org/773892 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>
* fsck.minix: check writing to a file descriptor was successfulSami Kerola2013-04-261-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* various: fix variable and function declarations [smatch scan]Sami Kerola2013-04-091-1/+2
| | | | | | | | | | | | | | | | | disk-utils/fsck.minix.c:511:9: warning: mixing declarations and code fdisks/sfdisk.c:982:5: warning: mixing declarations and code fdisks/sfdisk.c:1254:5: warning: mixing declarations and code fdisks/sfdisk.c:1564:5: warning: mixing declarations and code lib/mbsalign.c:279:7: warning: mixing declarations and code libblkid/src/devname.c:378:17: warning: mixing declarations and code libfdisk/src/alignment.c:219:9: warning: mixing declarations and code term-utils/wall.c:111:9: warning: mixing declarations and code text-utils/col.c:418:19: warning: non-ANSI function declaration of function 'flush_blanks' text-utils/col.c:553:12: warning: non-ANSI function declaration of function 'alloc_line' text-utils/rev.c:105:9: warning: mixing declarations and code text-utils/tailf.c:245:9: warning: mixing declarations and code Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* add missing rpmatch.h everywhere it needs to beWilliam Pitcock2013-02-201-0/+1
| | | | | Signed-off-by: William Pitcock <nenolod@dereferenced.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: spell and encode the name of Arkadiusz Miśkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: standardize the reporting of program name plus package versionBenno Schulenberg2013-01-301-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* mkfs.minix: fsck:minix: fix compiler warningsKarel Zak2012-12-201-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* minix: replace magic constants with macro namesSami Kerola2012-12-191-7/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* minix: use off_t, size_t, etc appropriate typesSami Kerola2012-12-191-6/+6
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: rename writeall.h to all-io.hPetr Uzel2012-05-151-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* fsck.minix.c: fix compiler warnings [-Wunused-result]Petr Uzel2012-04-271-1/+1
| | | | | | | fsck.minix.c: In function ‘ask’: fsck.minix.c:263:7: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result] Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* disk-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: fix printf format warningSami Kerola2012-03-301-1/+1
| | | | | | fsck.minix.c:1302:3: warning: ISO C does not support the '%m' gnu_printf format [-Wformat] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: clean up coding styleSami Kerola2012-03-301-360/+342Star
| | | | | | $ indent -linux -psl -blf disk-utils/fsck.minix.c Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: align with howto-usage-function.txtSami Kerola2012-03-301-10/+16
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: use rpmatch() for yes/no questionSami Kerola2012-03-301-21/+23
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: use symbolic exit codesSami Kerola2012-03-301-4/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fsck.minix: fix zone_map memory allocation failure checkFrancesco Cosoleto2011-11-101-1/+1
| | | | Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
* fsck.minix: remove unnecessary memset callsFrancesco Cosoleto2011-11-091-4/+2Star
| | | | | | | | | | | | | The program aborts without using this unintialized allocated memory, setting to zero doesn't look needed. memset calls with sizeof() of pointer as argument (reported by clang). [kzak@redhat.com: - replace malloc with calloc for {zone,inode}_count to make code more robust] Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use %m in format string instead of %s and strerror(errno)Petr Uzel2011-09-271-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* mkfs.minix: fix write_all() usageKarel Zak2011-08-171-7/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.minix: fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-33/+49
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fsck.minix: fix "array subscript is above array bounds"Karel Zak2011-07-211-1/+1
| | | | | | | | | fsck.minix.c: In function ‘map_block2’: fsck.minix.c:486:9: warning: array subscript is above array bounds [-Warray-bounds] The 'blknr' has to be bigger than 7 + 256 + (256 * 256) for i_zone[9]. Signed-off-by: Karel Zak <kzak@redhat.com>
* minix: remove unnecessary initializationsKarel Zak2011-07-211-19/+17Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* minix: add MINIX_ prefix to some global macrosKarel Zak2011-07-211-6/+6
| | | | | | ... and remove some tailing whitespaces. Signed-off-by: Karel Zak <kzak@redhat.com>
* minix: cleanup global variables and macrosKarel Zak2011-07-211-0/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* minix: move globals and inline functions to minix_programs.hSami Kerola2011-07-201-0/+1
| | | | | | | | | | Global variables and inline functions are moved from minix.h to minix_programs.h which is included in mkfs.minix and fsck.minix. The minix.h will have only struct definitions etc generic contents which is reasonable to share with utilities and libraries. Signed-off-by: Sami Kerola <kerolasa@iki.fi>