Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=3d9879c4f7e... Commit: 3d9879c4f7e27cad55e30b054ce570e601cf431a Parent: 132c7cbafc706281f2aad97e205883123eb89550 Author: Andrew Price anprice@redhat.com AuthorDate: Tue Apr 5 14:38:03 2016 +0100 Committer: Andrew Price anprice@redhat.com CommitterDate: Tue Apr 5 14:45:04 2016 +0100
mkfs.gfs2: Open the target device with O_EXCL
O_EXCL will let local mounters know that the device is busy while mkfs.gfs2 is running so that they don't try to access it.
Before: # mount /dev/vdc /mnt/test mount: /dev/vdc: can't read superblock
With O_EXCL: # mount /dev/vdc /mnt/test mount: /dev/vdc is already mounted or /mnt/test busy
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/mkfs/main_mkfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index 107d3cc..4436f93 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -854,7 +854,7 @@ static void open_dev(struct mkfs_dev *dev) { int error;
- dev->fd = open(dev->path, O_RDWR | O_CLOEXEC); + dev->fd = open(dev->path, O_RDWR|O_CLOEXEC|O_EXCL); if (dev->fd < 0) { perror(dev->path); exit(1);
cluster-commits@lists.stg.fedorahosted.org