Do not get confused by the captive default 'noauto' mount(8) option.
[captive.git] / src / client / lufs / mount.captive.in
index 4850e0f..d416e53 100755 (executable)
@@ -42,6 +42,8 @@ my $fsname=($0=~m#([^/]*)$#)[0] or die "Cannot detetect my basename from: $0";
 $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";
+warn "warning: '-o loop' is not neccessary for Captive filesystem mounts"
+               if $image=~m#^/dev/loop#;
 my $dir=shift @ARGV or die "Missing argv[2]: mount point directory";
 -d $dir or die "Mount point directory not a valid directory: $dir";
 shift @ARGV if my $nomtab =$ARGV[0] && $ARGV[0] eq "-n";
@@ -50,20 +52,55 @@ my $oo="";
 do { shift @ARGV; $oo=shift @ARGV; } if $ARGV[0] && $ARGV[0] eq "-o";
 die "Excessive arguments: @ARGV" if @ARGV;
 
+sub die_install
+{
+       die
+"You should run captive-install-acquire(1) of 'captive-install' package,
+otherwise you can also acquire this file from URL:
+http://www.microsoft.com/WindowsXP/pro/downloads/servicepacks/sp1/checkedbuild.asp
+";
+}
+
 my $filesystem=$vardir."/".$fsname.".sys";
--r $filesystem or die "W32 filesystem .sys module not readable: $filesystem";
+if (!-r $filesystem) {
+       warn "W32 filesystem .sys module not found: $filesystem";
+       die_install();
+       }
 my $ntoskrnl=$vardir."/ntoskrnl.exe";
--r $ntoskrnl or die "W32 ntoskrnl.exe not readable: $ntoskrnl";
+if (!-r $ntoskrnl) {
+       warn "W32 ntoskrnl.exe not found: $ntoskrnl";
+       die_install();
+       }
+
+# 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";
+                       last;
+                       }
+               }
+       }
+
 
 # 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=""
-               .($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,"
                ."mntent.mnt_fsname=$image,mntent.mnt_type=captive-$fsname,"    # Double-dashes forbidden.
+               ."dir_cache_entries=0,"
                ."image=$image,"
-               .$oo;
+               ."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;
 
 warn "$0: '-n' not supported - ignored" if $nomtab;