diff options
author | Sami Kerola | 2015-10-31 19:08:27 +0100 |
---|---|---|
committer | Sami Kerola | 2015-11-22 21:56:38 +0100 |
commit | 8a4eb983d845856a48cb03f70f97009af49cc6fc (patch) | |
tree | bf027d581d23439dc79e18b93b444e4d7c26db72 /disk-utils/mkfs.minix.c | |
parent | mkfs.bfs: allow creating file system to a file (diff) | |
download | kernel-qcow2-util-linux-8a4eb983d845856a48cb03f70f97009af49cc6fc.tar.gz kernel-qcow2-util-linux-8a4eb983d845856a48cb03f70f97009af49cc6fc.tar.xz kernel-qcow2-util-linux-8a4eb983d845856a48cb03f70f97009af49cc6fc.zip |
mkfs.minix: fix block device open race
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils/mkfs.minix.c')
-rw-r--r-- | disk-utils/mkfs.minix.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index f2a442e30..471277290 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -695,8 +695,6 @@ static void determine_device_blocks(struct fs_control *ctl, const struct stat *s if (blkdev_get_sector_size(ctl->device_fd, §orsize) == -1) sectorsize = DEFAULT_SECTOR_SIZE; /* kernel < 2.3.3 */ - if (blkdev_is_misaligned(ctl->device_fd)) - warnx(_("%s: device is misaligned"), ctl->device_name); if (MINIX_BLOCK_SIZE < sectorsize) errx(MKFS_EX_ERROR, _("block size smaller than physical " "sector size of %s"), ctl->device_name); @@ -821,10 +819,7 @@ int main(int argc, char ** argv) ctl.device_name); if (stat(ctl.device_name, &statbuf) < 0) err(MKFS_EX_ERROR, _("stat of %s failed"), ctl.device_name); - if (S_ISBLK(statbuf.st_mode)) - ctl.device_fd = open(ctl.device_name, O_RDWR | O_EXCL); - else - ctl.device_fd = open(ctl.device_name, O_RDWR); + ctl.device_fd = open_blkdev_or_file(&statbuf, ctl.device_name, O_RDWR); if (ctl.device_fd < 0) err(MKFS_EX_ERROR, _("cannot open %s"), ctl.device_name); determine_device_blocks(&ctl, &statbuf); |