Commit Graph

843 Commits

Author SHA1 Message Date
Sami Kerola d0a050e0f9 fsck: retire stat(3) when access(3) does better job
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>
2015-11-09 09:56:14 +01:00
Karel Zak 1cd9d0d746 mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed lines
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>
2015-10-15 12:01:48 +02:00
Karel Zak 24b7db7e4e partx: prevent code duplication
Reported-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 12:18:28 +02:00
Karel Zak aab9be66c4 sfdisk: add --delete
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-17 13:57:44 +02:00
Karel Zak 31c79e1823 sfdisk: fix -N return code detection, add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-17 11:45:02 +02:00
Karel Zak d85a7fa744 sfdisk: cleanup and optimize --move-data
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-09 14:48:33 +02:00
Karel Zak f42205d89a sfdisk: add --move-data
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-08 16:37:08 +02:00
Karel Zak 9a17d9460a sfdisk: add --reorder
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1232707
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-07 10:18:46 +02:00
Yuri Chornoivan 75a8e726e9 Fix trivial typos 2015-08-25 20:02:53 +03:00
Sami Kerola 624e147ba2 misc: fix shadow declarations
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>
2015-08-24 10:55:37 +02:00
Karel Zak ffab025db8 cfdisk, sfdisk: remove unused variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 12:41:46 +02:00
Ian Wienand 11aa2aa290 sfdisk: clarification for sfdisk man page
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1249893
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 09:21:27 +02:00
Karel Zak 70e0513563 mkfs.minix: add hint for scanners [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 11:42:27 +02:00
Karel Zak cd16685e94 mkfs.minix: use xalloc
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 11:39:49 +02:00
Karel Zak 101c80f316 mkfs.cramfs: remove dead code [coverity scan]
There two possible ways, print error and exit on too long names or
truncate the filename -- but it's impossible to do both in the same
code :-) It seems that code already assumes warning on long names, so
let's remove errx() and keep the behavior in dependence on -E.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 11:33:57 +02:00
Karel Zak 1e9d849b8d fsck.minix: be more paranoid with block buffers [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 11:15:53 +02:00
Karel Zak 4c166c2200 cfdisk: check return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 10:59:52 +02:00
Sami Kerola 98f8b800dc tests: add way to control mkfs.minix time stamps
Needed in order to create reproducable file systems image files, so that
out come of mkfs.minix can be checksum'ed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-03 11:27:37 +02:00
Sami Kerola 3e56e36291 mkfs.minix: re-fix block count maths
Error, that Joshua Hudson already pointed out, creapped back to commit
da41ff5 when changes were applied from mailbox rather than git remote, as
the corrected change had included some accidental rubbish.

Reference: http://www.spinics.net/lists/util-linux-ng/msg11764.html
Reference: http://www.spinics.net/lists/util-linux-ng/msg11848.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-03 11:27:36 +02:00
Benno Schulenberg 62eea9ce12 textual: adjust grammar and punctuation of some messages
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>
2015-08-03 11:18:56 +02:00
Karel Zak 901f85fe54 sfdisk: don't print extra linebreaks on --quiet
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-30 13:22:35 +02:00
Sami Kerola e87a6ee0f5 docs: make fsck.minix(8) more pretty
Use real table to device list, add missing new paragraph markers, remove
braces that cause reader to wonder if test is meant or not, squeeze error
code list, move references to bottom of the manual, and use mail or web
address macro when possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:18 +02:00
Sami Kerola 158b8d6918 fsck.minix: introduce long options to the command
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:17 +02:00
Sami Kerola 86a9f3dad5 fsck.minix: add minix v3 support
Relates-to: a2657ae3ff
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:16 +02:00
Sami Kerola e1df9d4cd6 fsck.minix: rename device file descriptor variable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:16 +02:00
Sami Kerola ed7f9c5d96 mkfs.minix: refactor root block content creation
This does not belong to main() function.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:15 +02:00
Sami Kerola a232cfdc0a mkfs.minix: check requested blocks will not exceed available on device
Earlier user could define more blocks than device, or backing file for
loopback file system, had available.  That lead to a system crash with
following commands;

fallocate --length 64KiB test-file
mkfs.minix -3 -i 842160 test-file 104882174
mkdir test-file.d
mount test-file test-file.d
cp /etc/service test-file.d
Killed
sudo umount test-file.d

The minix driver should probably not hang the whole kernel, but the least
that mkfs.minix ought to do is not to let users to get that condition
quite as easily.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:15 +02:00
Sami Kerola 2159dbf365 mkfs.minix: check user input carefully
File name lenght and version input needs to be checked against each
other, which will determine what version of file system is in question.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:14 +02:00
Sami Kerola 77799d7c38 mkfs.minix: add fs_control structure, and remove most global variables
This allows better code structure in future.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:14 +02:00
Sami Kerola 3bb74a3ada mkfs.minix: remove unuseful code
Checks about inodes vs block sizes does not add much robustness.  Both
values are derived at compilation time from struct minix_inode size, and
they form full definition circle.

Bad block check for none-block devices should not be supressed, user
requested it so let him have it.

Check for st_rdev == 0x0300 || st_rdev == 0x0340 was unreachable.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:13 +02:00
Sami Kerola c99128bcf5 mkfs.minix: use is_mounted() from libcommon
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:13 +02:00
Sami Kerola b59c5925ce mkfs.minix: introduce long options to the command
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-30 11:39:12 +02:00
Joshua Hudson da41ff553a mkfs.minix: increase maximum minix v2 and v3 file system sizes
mkfs.minix misbehaves when attempting to create a large v2 or v3
filesystem.  I finally traced it down to attempting to create too many
inodes so that the first zone is past 65535 blocks in.  This obviously
doesn't work as the on-disk superblock says this is a 16 bit integer.

I wrote a patch that catches this, clamps to the absolute v2/v3 limit
(like it already does for v1), and sets the blocks per inode to a more
reasonable ratio when exceeding half a gigabyte.  Having a half-gig
filesystem with most files being smaller than 3k isn't really reasonable.

I suppose if you don't want to adjust inode sizes automatically you could
take that part out, and it will just crab sooner.

Given the non-attention in the code, I suspect nobody ever had cause to
try such a big minix filesystem.  Well I have my reasons involving some
deeply embedded work where ext2 would place too much strain on the
hardware.

Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Joshua Hudson <joshudson@gmail.com>
2015-07-30 11:39:12 +02:00
Karel Zak 4df892812b fdisk: value is never read [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 13:59:19 +02:00
Karel Zak e5161deefb fdisk: value is never read [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 13:57:28 +02:00
Karel Zak f45f5c83f9 fdisk: value is never read [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 13:51:05 +02:00
Karel Zak 8abdb91211 sfdisk: add --list-free
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-28 15:54:07 +02:00
Karel Zak 0efd951c80 fdisk: add 'F' command to list free unpartitioned space
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-28 15:53:42 +02:00
Karel Zak 1b2e9dd01d cfdisk: don't print obsolete CHS addresses
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27 15:49:14 +02:00
Karel Zak ed99eac0e2 cfdisk: make sure that output fits to terminal width
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27 15:29:37 +02:00
Karel Zak 053939a45a fdisk: init libsmartcols debug
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27 13:33:09 +02:00
Karel Zak 6e07b904e7 cfdisk: remove extra line between menu and info line
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-27 12:37:15 +02:00
Benno Schulenberg d48fc38307 cfdisk: spell "label" in lower case
To be less shouty.  It is not an abbreviation like "UUID".

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-07-27 11:57:11 +02:00
Benno Schulenberg 80351b1f4a cfdisk: allow an uppercase X to toggle the extra info
To make true the help text line that says that all commands
can be entered with either upper or lower case.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-07-27 11:57:08 +02:00
Karel Zak cbcafba2bb cfdisk: make sure that extra info is refreshed/removed
For example when you move from a Partition to the FreeSapce then we
need to remove old extra info and draw nothing.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-22 14:28:33 +02:00
Karel Zak a2d0dbb433 cfdisk: properly toggle extra info window, make it more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-22 14:11:27 +02:00
Karel Zak 4bd02cdfdf libfdisk: fix fdisk_label_parse_parttype() for unknown types
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-15 15:42:22 +02:00
Sami Kerola 55034ed00e docs: unify mkswap(8) with swapon(8) about holes warning
Reviewed-by: Dave Rutherford <dave@evilpettingzoo.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 12:06:00 +02:00
Boris Egorov 13c551f259 cfdisk: fix condition logic [cppcheck]
[disk-utils/cfdisk.c:1181] -> [disk-utils/cfdisk.c:1181]: (warning)
Possible null pointer dereference: data - otherwise it is redundant to
check it against null.

Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-25 12:08:53 +02:00
Boris Egorov e3ca1312a2 sys-utils/disk-utils/lib: fix printf format types [cppcheck]
Fix 'invalidPrintfArgType' cppcheck warnings

Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-25 12:08:45 +02:00