X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=src%2Fclient%2Flufs%2Fmount.captive.in;h=5bf664e74b51604f1b5ec40866be7d3438e66746;hb=3a85d9b24dcc938913259cf9b2e20513e6a01429;hp=b01ba33ca73974f35a53626bd737ede602a83957;hpb=f64491e76db054a67e69d2a4939940fb50bf4325;p=captive.git diff --git a/src/client/lufs/mount.captive.in b/src/client/lufs/mount.captive.in index b01ba33..5bf664e 100755 --- a/src/client/lufs/mount.captive.in +++ b/src/client/lufs/mount.captive.in @@ -28,9 +28,7 @@ use Getopt::Long; my $vardir='@localstatedir@/lib/captive'; $vardir=~s#\$\Q{prefix}\E#'@prefix@';#ge; $vardir="/var/lib/captive" if $vardir=~/^@/; -my $lufsmount_bin='@bindir@/lufsmount'; -$lufsmount_bin=~s#\$\Q{exec_prefix}\E#'@exec_prefix@';#ge; -$lufsmount_bin=~s#\$\Q{prefix}\E#'@prefix@';#ge; +my $lufsmount_bin='@PATH_LUFSMOUNT@'; $lufsmount_bin="/usr/bin/lufsmount" if $lufsmount_bin=~/^@/; my $captive_sandbox_server_bin='@sbindir@/captive-sandbox-server'; $captive_sandbox_server_bin=~s#\$\Q{exec_prefix}\E#'@exec_prefix@';#ge; @@ -38,7 +36,8 @@ $captive_sandbox_server_bin=~s#\$\Q{prefix}\E#'@prefix@';#ge; $captive_sandbox_server_bin="/usr/sbin/captive-sandbox-server" if $captive_sandbox_server_bin=~/^@/; -my $fsname=($0=~m#([^/]*)$#)[0] or die "Cannot detetect my basename from: $0"; +my $ME=($0=~m#([^/]*)$#)[0] or die "Cannot detetect my basename from: $0"; +my $fsname=$ME; $fsname=~s/^mount[.]captive-// or die "Cannot detect captive filesystem module from my name: $fsname"; my $image=shift @ARGV or die "Missing argv[1]: device or image pathname"; -r $image or die "Image pathname not readable: $image"; @@ -87,11 +86,31 @@ if ($fsname eq "ntfs") { # to let the options be overridable by user (such as 'ro'). my @opt_captive=(); my @opt_lufs=(); +my $opt_force; for (split /,/,$oo) { $_="--$_" if $_ eq "ro" || $_ eq "rw"; + $opt_force=1 if $_ eq "force"; push @opt_captive,$_ if /^--/; push @opt_lufs,$_ if !/^--/; } + +if (!$opt_force) { + local *MTAB; + if (!open MTAB,"/etc/mtab") { + warn "Cannot open /etc/mtab: $!"; + } + else { + local $/=undef(); + my $mtab=; + close MTAB; + die "" + ."$ME: $image already mounted\n" + ."$ME: according to mtab, $image is mounted on $1\n" + ."$ME: Use '-o force' to mount the image notwithstanding.\n" + if $mtab=~/^\Q$image\E\s+(\S+)/m; + } + } + $oo="" ."mntent.mnt_fsname=$image,mntent.mnt_type=captive-$fsname," # Double-dashes forbidden. ."dir_cache_entries=0,"