Commit Graph

76 Commits

Author SHA1 Message Date
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
Maurizio Lombardi 3c5075e37b mkfs.minix: In Minix V3 filesystems the maximum filename lenght is 60
chars and the dirsize is 64 bytes.
2011-11-21 19:46:26 +01:00
Maurizio Lombardi 75ab0b36a3 mkfs.minix: Fix super_set_nzones()
Write the total number of zones in Super3.n_zones when
dealing with v3 filesystems.
2011-11-21 19:42:42 +01:00
Maurizio Lombardi 01a1fcc85e mkfs.minix: remove redundant code 2011-11-21 19:35:40 +01:00
Karel Zak 832410da7b mkfs.minix: fix write_all() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-17 00:29:39 +02:00
Karel Zak d9d88e3162 mkfs.minix: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 14:51:58 +02:00
Karel Zak 9ae45d23de Merge branch 'cramfs' of https://github.com/kerolasa/lelux-utiliteetit
* 'cramfs' of https://github.com/kerolasa/lelux-utiliteetit:
  include: move fsck return values to exitcodes.h
  include: move disk-utils/mkfs.h -> include/exitcodes.h
  mkfs.cramfs: coding style
  mkfs.cramfs: include-what-you-use header check
  mkfs.cramfs: error printing fixes
  mkfs.cramfs: convert spaces to tabs
  mkfs.cramfs: validate numeric user inputs
  mkfs.cramfs: few symbolic exit codes where missing
  md5: use symbolical digest length
  mkfs.cramfs: use program_invocation_short_name
  mkfs.cramfs: use xalloc.h
  fsck.cramfs: add missed strings to translation
  fsck.cramfs: coding style
  fsck.cramfs: use xalloc.h
  fsck.cramfs: retire die function
  cramfs.h: coding style
  cramfs: use stdint.h instead of u{8,16,32}
  cramfs_common: coding style

Conflicts:
	disk-utils/Makefile.am

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-26 14:41:28 +02:00
Sami Kerola b8f040cdd4 include: move disk-utils/mkfs.h -> include/exitcodes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-22 00:30:04 +02:00
Karel Zak 0dca7bd54a minix: remove unnecessary initializations
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 12:41:25 +02:00
Karel Zak c1d26b1981 minix: add MINIX_ prefix to some global macros
... and remove some tailing whitespaces.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 12:23:01 +02:00
Karel Zak 058cda4c1d minix: cleanup global variables and macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-21 12:13:33 +02:00
Sami Kerola 7cc112d927 minix: move globals and inline functions to minix_programs.h
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>
2011-07-20 20:43:16 +02:00
Sami Kerola 63883af765 libblkid: use MINIX_BLOCK_SIZE from minix.h
In the minix.h two definitions where renamed, so that the single
definition is reusable in fsck.minix, mkfs.minix and libblkid.

BLOCK_SIZE_BITS -> MINIX_BLOCK_SIZE_BITS
BLOCK_SIZE      -> MINIX_BLOCK_SIZE

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-20 20:13:08 +02:00
Davidlohr Bueso 3ca43386bd minix: remove fs state
For v3 minix superblocks the state flag (s_state) has been removed, so drop it
from the structure in accordance with the kernel's representation.

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-07-14 11:15:55 +02:00
Davidlohr Bueso a2657ae3ff mkfs.minix: add minix v3 support
We can now create minix v3 filesystems. Support for this fs was added a few
years ago in the Linux kernel. One of the most important benefits is the
ability to handle file names up to 60 characters long.  With this change we
also introduce the -3 option which naturally indicates which version to create.
Version 1 is still left as the default one for backwards compatibility reasons.

[kzak@redhat.com: - fix gcc warnings:

	mkfs.minix.c: In function ‘super_set_state_ptr’:
	mkfs.minix.c:174:1: warning: no return statement in function returning non-void [-Wreturn-type]
	mkfs.minix.c: In function ‘write_tables’:
	mkfs.minix.c:182:7: warning: unused variable ‘state’ [-Wunused-variable]
	mkfs.minix.c: At top level:
	mkfs.minix.c:111:27: warning: ‘blksz’ defined but not used [-Wunused-variable]
]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-11 10:40:26 +02:00
Davidlohr Bueso 4f1384353e mkfs.minix: check for misalignment
Produce a warning if the device is misaligned.

[kzak@redhat.com: - use it for block devices only]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27 16:13:02 +02:00
Karel Zak c2e05a498c lib: [blkdev.c] remove kernel version check from blkdev_get_sector_size()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27 16:09:56 +02:00
Davidlohr Bueso 4bc4653e2a mkfs.minix: add fs version options
Like the original minix mkfs, add the -1 and -2 argument options to specify the
version of the filesystem to create.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-06-14 16:39:13 +02:00
Davidlohr Bueso 7a173d7f5c mkfs.minix: standardize superblock attribute settings
Because of the dependence of fs_version, some superblock attributes will vary,
so simplify the logic of assigning values to maxsize and the amount of zones
related to each filesystem, thus making setup_tables() more readable.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-06-14 16:39:04 +02:00
Davidlohr Bueso 37ebb48be0 mkfs.minix: use inode wrappers
Use a common function for creating the root and bad inode, without worring
about the fs version.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-06-08 13:38:50 +02:00
Davidlohr Bueso 50758d0e40 mkfs.minix: use common functionality
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-06-02 13:27:22 +02:00
Davidlohr Bueso 9fae6c27d3 mkfs.minix: remove die()
Get rid of this function and use errx(3) instead. This patch also
introduces a mkfs.h header and defines general purpose mkfs related
exit codes.

[kzak@redhat.com: - fix "warning: too many arguments for format" errors]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-04 14:56:41 +02:00
Davidlohr Bueso c80790440e mkfs.minix: general cleanups
This patch provides some minor code fixes: add/remove some macros and close the device after usage.
Also modifies usage() and changes main()'s indentation to 8-characters.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-02-14 14:41:35 +01:00
Benno Schulenberg e6b0611b46 messages: gettextize a few skipped or forgotten ones
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2010-06-14 11:19:19 +02:00
Karel Zak dfea25692c mkfs.minix: fix strict-aliasing bugs
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-10-17 00:19:23 +02:00