marsadm: 'create-resource' --force no longer checks for exclusive access

This commit is contained in:
Thomas Schoebel-Theuer 2013-07-18 14:48:47 +02:00
parent 72a2537c6d
commit 0d8d637dee
1 changed files with 6 additions and 2 deletions

View File

@ -863,8 +863,12 @@ sub create_res {
my $size = 0;
if (-b $dev) {
ldie "block device '$dev' must be an absolute path starting with '/'\n" unless $dev =~ m/^\//;
use Fcntl 'SEEK_END', 'O_RDWR', 'O_EXCL';
sysopen(TEST, $dev, O_RDWR|O_EXCL) or ldie "cannot open device '$dev' for exclusive rw access\n";
use Fcntl 'SEEK_END', 'O_RDONLY', 'O_RDWR', 'O_EXCL';
my $flags = O_RDWR | O_EXCL;
if (!$force) {
$flags = O_RDONLY;
}
sysopen(TEST, $dev, $flags) or ldie "cannot open device '$dev' for exclusive rw access\n";
$size = sysseek(TEST, 0, SEEK_END);
close(TEST);
lprint "block device '$dev': determined size = $size bytes\n";