From 2018629905d3d881ff3fddf76552b6e79091f2b8 Mon Sep 17 00:00:00 2001 From: Matthias Koenig Date: Wed, 18 Jul 2007 16:15:46 +0200 Subject: disk-utils: let mkfs tools open with O_EXCL Let mkswap, mkfs.bfs, mkfs.minix open with O_EXCL if used on block devices to prevent writing to the device even if they are busy (mounted). Unfortunately, O_EXCL has zero effect for 2.4 kernels where in-kernel code doesn't use O_EXCL-like access locks. (Tested on RHEL3.) Signed-off-by: Matthias Koenig Signed-off-by: Karel Zak --- disk-utils/mkfs.bfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'disk-utils/mkfs.bfs.c') diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c index 8221f3b7e..557cde480 100644 --- a/disk-utils/mkfs.bfs.c +++ b/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); -- cgit v1.2.3-55-g7522