X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=src%2Fclient%2Flufs%2Fmount.captive.in;h=3e0a47f845ef56e0f88a80f83abde9bb35a836f0;hb=a2dd38f86df22c46ae18f3ad7d9850eaacb02b92;hp=d416e537bfebf1783cdd4186fefc6fbc9fa1fa15;hpb=5aa042360b299df05f1129288eecc796d4601ea4;p=captive.git diff --git a/src/client/lufs/mount.captive.in b/src/client/lufs/mount.captive.in index d416e53..3e0a47f 100755 --- a/src/client/lufs/mount.captive.in +++ b/src/client/lufs/mount.captive.in @@ -1,7 +1,7 @@ #! /usr/bin/perl -w # # $Id$ -# External mount command for mount(8) to interface lufsmount(1) +# External mount command for mount(8) to interface lufsd(1) # Copyright (C) 2003 Jan Kratochvil # # This program is free software; you can redistribute it and/or modify @@ -28,17 +28,16 @@ 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; -$lufsmount_bin="/usr/bin/lufsmount" if $lufsmount_bin=~/^@/; -my $captive_sandbox_server_bin='@sbindir@/captive-sandbox-server'; +my $lufsd_bin='@PATH_LUFSD@'; +$lufsd_bin="/usr/bin/lufsd" if $lufsd_bin=~/^@/; +my $captive_sandbox_server_bin='@libexecdir@/captive-sandbox-server'; $captive_sandbox_server_bin=~s#\$\Q{exec_prefix}\E#'@exec_prefix@';#ge; $captive_sandbox_server_bin=~s#\$\Q{prefix}\E#'@prefix@';#ge; -$captive_sandbox_server_bin="/usr/sbin/captive-sandbox-server" if $captive_sandbox_server_bin=~/^@/; +$captive_sandbox_server_bin="/usr/libexec/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"; @@ -72,41 +71,66 @@ if (!-r $ntoskrnl) { die_install(); } +# Keep @opt_captive ordering +# to let the options be overridable by user (such as 'ro'). +my @opt_captive=(); +my @opt_lufs=(); +my $opt_force; +my $opt_rwmode="--blind"; +for (split /,/,$oo) { + $_="--$_" if $_ eq "ro" || $_ eq "rw"; + $opt_rwmode=$_ if /^--(?:ro|rw|blind)$/; + $opt_force=1 if $_ eq "force"; + push @opt_captive,$_ if /^--/; + push @opt_lufs,$_ if !/^--/; + } + # Shameless advertisement: if ($fsname eq "ntfs") { for my $fh (*STDERR,*STDOUT) { if (-t $fh) { - print $fh 'Captive NTFS v@VERSION@. Updates: http://www.jankratochvil.net/project/captive/'."\n"; + print $fh 'Captive NTFS v@VERSION@. Check a new version at: http://www.jankratochvil.net/'."\n"; last; } } } +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; + } + } -# Double-dashes are generally optional here. -# Convert ',' to ';' to prevent its parsing by LUFS to keep its ordering -# to let the options be overridable by user (such as 'ro'). -$oo=";$oo;"; -$oo=~tr/,/;/; -$oo=~s/;(ro|rw);/;--$1;/g; -$oo=~s/;(?:no)?auto;/;/g; # ignore $oo="" + ."fs=captivefs," ."mntent.mnt_fsname=$image,mntent.mnt_type=captive-$fsname," # Double-dashes forbidden. ."dir_cache_entries=0," ."image=$image," + .join(",",@opt_lufs)."," ."captive_options=" .($fsname eq "cdfs" ? "--cdrom;--ro;" : "--disk;--rw;") ."--load-module=$ntoskrnl;--filesystem=$filesystem;" ."--sandbox-server=$captive_sandbox_server_bin;" ."--bug-pathname=$vardir/bug-%FT%T.captivebug.xml.gz;" ."--syslog;" - .$oo; + .join(";",@opt_captive); warn "$0: '-n' not supported - ignored" if $nomtab; # Use "'$oo'" to permit another expansion by bash(1) during lufsmnt(8) execution. -my @argv=($lufsmount_bin,"captivefs://",$dir,"-o","'$oo'"); +my @argv=($lufsd_bin,"none",$dir,"-o",$oo); print STDERR "$0: @argv\n" if $verbose; -exec $lufsmount_bin @argv; +exec $lufsd_bin @argv; die "Failed to execute: @argv";