diff options
author | Alasdair Kergon <agk@redhat.com> | 2005-10-03 21:10:41 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2005-10-03 21:10:41 +0000 |
commit | 9b02bdbce0c661b78eb1ad42423771a71d27ffc2 (patch) | |
tree | 0a58dca8e1151eebe0a01c9117badee865abc57b /tools/pvcreate.c | |
parent | 9c9e30cd6d97089aa7ee6e16c553edc7c3a43988 (diff) | |
download | lvm2-9b02bdbce0c661b78eb1ad42423771a71d27ffc2.tar.gz lvm2-9b02bdbce0c661b78eb1ad42423771a71d27ffc2.tar.xz lvm2-9b02bdbce0c661b78eb1ad42423771a71d27ffc2.zip |
Refuse to run pvcreate/pvremove on devices we can't open exclusively.
Diffstat (limited to 'tools/pvcreate.c')
-rw-r--r-- | tools/pvcreate.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/pvcreate.c b/tools/pvcreate.c index a0b7807a..75995dd3 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -82,6 +82,12 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name) return 0; } + if (!dev_test_excl(dev)) { + log_error("Can't open %s exclusively. Mounted filesystem?", + name); + return 0; + } + /* Wipe superblock? */ if (dev_is_md(dev, &md_superblock) && ((!arg_count(cmd, uuidstr_ARG) && @@ -218,8 +224,12 @@ static int pvcreate_single(struct cmd_context *cmd, const char *pv_name, log_error("%s not opened: device not zeroed", pv_name); goto error; } - - dev_zero(dev, UINT64_C(0), (size_t) 2048); + + if (!dev_zero(dev, UINT64_C(0), (size_t) 2048)) { + log_error("%s not wiped: aborting", pv_name); + dev_close(dev); + goto error; + } dev_close(dev); } |