Commit Graph

100 Commits

Author SHA1 Message Date
Karel Zak e57cbfe0aa mkfs.minix: add --lock and LOCK_BLOCK_DEVICE
Addresses: https://github.com/karelzak/util-linux/issues/921
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-14 11:33:13 +02:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Sami Kerola 4813a5210f various: fix 'uninitialized when used' warnings [clang]
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:19:24 +01:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 778ca2a0d4 misc: fix xalloc.h related exit codes
Found by:

grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \
    $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:27 +02:00
Ruediger Meier 0b2b32e8a7 misc: fix more strutils related exit codes
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>
2017-06-22 22:40:21 +02:00
Nate Clark b7b26945d1 disk-utils/mkfs.minix: Set ninodes after checking max
ninodes in the superblock needs to be set after inodes is checked
against MINIX_MAX_INODES otherwise a value larger than MINIX_MAX_INODES
can be attempted to be stored in the superblock.

Without this change the command "mkfs.minix -2 -i 65530 <dev>" would
write a minix superblock with ninodes set to 0.

Signed-off-by: Nate Clark <nate@neworld.us>
2017-01-04 14:42:59 -05:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
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>
2016-12-19 13:13:34 +01:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Ruediger Meier fdbd7bb940 misc: again fixing many printf format strings
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>
2016-03-07 23:16:04 +01:00
Ruediger Meier 7252874a48 mkfs.minix: fix v2/v3 .badblocks inode number for big endian
For minix v2/v3 on big endian systems the inode number of the unwanted
".badblocks" file was not set to zero. This was introduced when v3 was
added in a2657ae3.

Actually it did not seem to cause any problems but since we zero it out
at all we should do it correctly. Now we zero out the whole directory
entry (inclusive ".badblocks" file name, also for v1). Unfortunately we
have to update the test data checksums.

CC: Davidlohr Bueso <davidlohr@hp.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-03 09:25:10 +01:00
Ruediger Meier f3e0213aa4 include: remove unused mntent.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 16:54:23 +01:00
Sami Kerola 8a4eb983d8
mkfs.minix: fix block device open race
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-22 20:56:38 +00: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
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
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
Benno Schulenberg fc14ceba5e textual: grammarize and harmonize the stat error message
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>
2015-02-02 11:27:10 +01:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Sami Kerola e9b0ac10f2 mkfs.minix: fix couple compiler warnings
disk-utils/mkfs.minix.c:366:3: warning: ISO C forbids 'return' with
expression, in function returning void [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Karel Zak 33cac1003a mkfs.minix: fix fscanf() format string [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-18 10:58:41 +01:00
Benno Schulenberg c2fcffd5ad mkfs.minix: properly pluralize four messages
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-10-08 15:27:31 +02:00
Benno Schulenberg 97b820bffd textual: improve clarity of some error messages
Reported-by: Petr Písař <petr.pisar@atlas.cz>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-06-07 12:29:44 +02:00
Sami Kerola 616fbb3af8 mkfs.minix: check writing to a file descriptor was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:07 +02:00
Karel Zak b4ee2cacca mkfs.minix: fix compiler warning [-Wformat]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 14:44:59 +01:00
Karel Zak 248b8101a0 mkfs.minix: fsck:minix: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 20:01:35 +01:00
Sami Kerola 65ca6f8382 minix: replace magic constants with macro names
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:38:56 +01:00
Sami Kerola a180dc6c54 minix: use off_t, size_t, etc appropriate types
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:38:53 +01:00
Sami Kerola f150ac37bc mkfs.minix: check numeric user inputs
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-15 16:01:42 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola add1b8afd0 translation: unify stat error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Sami Kerola 45ca68ece7 disk-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 20:04:39 +02:00
Karel Zak 70b604b827 include/exitcodes: clean up names, add _EX_ suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:08 +01:00
Maurizio Lombardi 57ba4027a5 mkfs.minix: The total number of zones is limited to 65536 only on V1 filesystems 2011-11-21 20:30:40 +01:00
Maurizio Lombardi de5326095a mkfs.minix: Some bug fixes:
- Fix root inode initialization
- In V3 filesystems the maximum number of inodes is not 65536 but 2^32.
2011-11-21 20:16:57 +01:00
Maurizio Lombardi a54d258f8c mkfs.minix: The s_blocksize field of the MinixV3 superblock must be
initialized with a valid block size, not the total number of blocks
of the device!
2011-11-21 20:00:48 +01:00
Maurizio Lombardi caa9cc8613 mkfs.minix: inode numbers are 32-bit wide in V3 filesystems 2011-11-21 19:52:03 +01:00