util-linux/util-linux-2.12r-disk_utils_mkfs_open_exclusive.patch

40 lines
1.5 KiB
Diff

Index: util-linux-ng-2.12r+git20070330/disk-utils/mkswap.c
===================================================================
--- util-linux-ng-2.12r+git20070330.orig/disk-utils/mkswap.c
+++ util-linux-ng-2.12r+git20070330/disk-utils/mkswap.c
@@ -660,7 +660,7 @@ main(int argc, char ** argv) {
usage();
}
- DEV = open(device_name,O_RDWR);
+ DEV = open(device_name, O_RDWR | O_EXCL);
if (DEV < 0 || fstat(DEV, &statbuf) < 0) {
perror(device_name);
exit(1);
Index: util-linux-ng-2.12r+git20070330/disk-utils/mkfs.minix.c
===================================================================
--- util-linux-ng-2.12r+git20070330.orig/disk-utils/mkfs.minix.c
+++ util-linux-ng-2.12r+git20070330/disk-utils/mkfs.minix.c
@@ -699,7 +699,7 @@ main(int argc, char ** argv) {
tmp += dirsize;
*(short *)tmp = 2;
strcpy(tmp+2,".badblocks");
- DEV = open(device_name,O_RDWR );
+ DEV = open(device_name,O_RDWR | O_EXCL);
if (DEV<0)
die(_("unable to open %s"));
if (fstat(DEV,&statbuf)<0)
Index: util-linux-ng-2.12r+git20070330/disk-utils/mkfs.bfs.c
===================================================================
--- util-linux-ng-2.12r+git20070330.orig/disk-utils/mkfs.bfs.c
+++ util-linux-ng-2.12r+git20070330/disk-utils/mkfs.bfs.c
@@ -170,7 +170,7 @@ main(int argc, char *argv[]) {
if (!S_ISBLK(statbuf.st_mode))
fatal(_("%s is not a block special device"), device);
- fd = open(device, O_RDWR);
+ fd = open(device, O_RDWR | O_EXCL);
if (fd == -1) {
perror(device);
fatal(_("cannot open %s"), device);