system|user,binmode|textmode,exec,cygexec,cygdrive,mixed,
notexec,managed,nosuid,devfs,proc,noumount
-If the argument is "/cygdrive", just the volume mount settings are returned.
+If the argument is "/cygdrive", then just the volume mount settings,
+and the cygdrive mount prefix are returned.
User mounts override system mounts.
$ perl -e 'print Cygwin::mount_flags "/usr/bin"'
system,binmode,cygexec
$ perl -e 'print Cygwin::mount_flags "/cygdrive"'
- binmode,cygdrive
+ binmode,cygdrive,/cygdrive
=item C<Cygwin::is_binmount>
char flags[260];
if (items != 1)
- Perl_croak(aTHX_ "Usage: Cygwin::mount_flags(mnt_dir)");
+ Perl_croak(aTHX_ "Usage: Cygwin::mount_flags(mnt_dir|'/cygwin')");
pathname = SvPV_nolen(ST(0));
-
- /* TODO: check for cygdrive registry setting. use CW_GET_CYGDRIVE_INFO then
+
+ /* TODO: Check for cygdrive registry setting,
+ * and then use CW_GET_CYGDRIVE_INFO
*/
if (!strcmp(pathname, "/cygdrive")) {
char user[260];
char system[260];
char user_flags[260];
char system_flags[260];
+
cygwin_internal (CW_GET_CYGDRIVE_INFO, user, system, user_flags,
system_flags);
- if (strlen(system) > 0)
- strcpy (flags, system_flags);
- if (strlen(user) > 0)
- strcpy(flags, user_flags);
- if (strlen(flags) > 0)
- strcat(flags, ",");
- strcat(flags, "cygdrive");
+
+ if (strlen(user) > 0) {
+ sprintf(flags, "%s,cygdrive,%s", user_flags, user);
+ } else {
+ sprintf(flags, "%s,cygdrive,%s", system_flags, system);
+ }
+
ST(0) = sv_2mortal(newSVpv(flags, 0));
XSRETURN(1);
+
} else {
struct mntent *mnt;
setmntent (0, 0);
use vars qw(@ISA $VERSION);
require File::Spec::Unix;
-$VERSION = '1.1_02';
+$VERSION = '1.1_03';
@ISA = qw(File::Spec::Unix);
if ($^O ne 'cygwin') {
return 1;
}
- my $drive = shift || "/cygdrive/c";
+ my $drive = shift;
+ if (! $drive) {
+ my @flags = split(/,/, Cygwin::mount_flags('/cygwin'));
+ my $prefix = pop(@flags);
+ if (! $prefix || $prefix eq 'cygdrive') {
+ $drive = '/cygdrive/c';
+ } elsif ($prefix eq '/') {
+ $drive = '/c';
+ } else {
+ $drive = "$prefix/c";
+ }
+ }
my $mntopts = Cygwin::mount_flags($drive);
if ($mntopts and ($mntopts =~ /,managed/)) {
return 0;
}
}
-use Test::More tests => 14;
+use Test::More tests => 16;
is(Cygwin::winpid_to_pid(Cygwin::pid_to_winpid($$)), $$,
"perl pid translates to itself");
ok($binmode ? ($rootmnt =~ /,binmode/) : ($rootmnt =~ /,textmode/), "check / mount_flags");
is(Cygwin::mount_flags("/cygdrive") =~ /,cygdrive/, 1, "check cygdrive mount_flags");
+# Cygdrive mount prefix
+my @flags = split(/,/, Cygwin::mount_flags('/cygdrive'));
+my $prefix = pop(@flags);
+ok($prefix, "cygdrive mount prefix = " . (($prefix) ? $prefix : '<none>'));
+chomp(my $prefix2 = `df | grep -i '^c: ' | cut -d% -f2 | xargs`);
+$prefix2 =~ s/\/c$//i;
+if (! $prefix2) {
+ $prefix2 = '/';
+}
+is($prefix, $prefix2, 'cygdrive mount prefix');
+
my @mnttbl = Cygwin::mount_table();
ok(@mnttbl > 0, "non empty mount_table");
for $i (@mnttbl) {