mkfs.minix: add sectorsize check

Minix filesystem until version 2 has a fixed blocksize of 1024 bytes.
If you try to create a filsystem on a device with a physical sectorsize
larger than 1024 bytes, this resulting minix fs cannot be mounted,
because the physical sectorsize must be smaller than the filesystem
blocksize.
This patch adds a check for this and will refuse to create a filesystem
if the sectorsize is bigger than the blocksize.

Signed-off-by: Matthias Koenig <mkoenig@suse.de>
This commit is contained in:
Matthias Koenig 2007-11-13 16:28:38 +01:00 committed by Karel Zak
parent 313c2fbe1f
commit a28a3ad26d
2 changed files with 13 additions and 3 deletions

View File

@ -1,11 +1,13 @@
include $(top_srcdir)/config/include-Makefile.am
utils_common = ../lib/linux_version.c ../lib/blkdev.c
man_MANS = blockdev.8 isosize.8 mkfs.8 mkswap.8 \
fsck.minix.8 mkfs.minix.8 mkfs.bfs.8
sbin_PROGRAMS = mkfs mkswap blockdev fsck.minix mkfs.minix mkfs.bfs
fsck_minix_SOURCES = fsck.minix.c bitops.h minix.h
mkfs_minix_SOURCES = mkfs.minix.c bitops.h minix.h
mkfs_minix_SOURCES = mkfs.minix.c bitops.h minix.h $(utils_common)
mkfs_bfs_SOURCES = mkfs.bfs.c
mkswap_SOURCES = mkswap.c swapheader.h ../lib/linux_version.c ../lib/blkdev.c
blockdev_SOURCES = blockdev.c ../lib/linux_version.c ../lib/blkdev.c

View File

@ -72,6 +72,7 @@
#include <mntent.h>
#include <getopt.h>
#include "blkdev.h"
#include "minix.h"
#include "nls.h"
@ -710,9 +711,16 @@ main(int argc, char ** argv) {
DEV = open(device_name,O_RDWR);
if (DEV<0)
die(_("unable to open %s"));
if (!S_ISBLK(statbuf.st_mode))
if (S_ISBLK(statbuf.st_mode)) {
int sectorsize;
if (blkdev_get_sector_size(DEV, &sectorsize) == -1)
die(_("cannot determine sector size for %s"));
if (BLOCK_SIZE < sectorsize)
die(_("block size smaller than physical sector size of %s"));
} else if (!S_ISBLK(statbuf.st_mode)) {
check=0;
else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
} else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
die(_("will not try to make filesystem on '%s'"));
setup_tables();
if (check)