+if (!-r $ntoskrnl) {
+ warn "W32 ntoskrnl.exe not found: $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@. 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=<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;
+ }
+ }