This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 1.7] Can you have multipe cygdrive path prefixes active at once

Bopp wrote:
> aputerguy wrote:

>> Jeremy Bopp writes:

>>> Well, it's a bit of a hack, but you could try something like the
>>> following:

>>> $ dirname $(cygpath -u C:/)
>>> This assumes that there is always a C: drive and converts the path to
>>> the root of that drive into a POSIX path which will include the cygdrive
>>> prefix. Then dirname is used to effectively chop off the drive letter
>>> leaving you with the cygdrive prefix.
>> This doesn't seem to work in the case where you have mounted the C: drive.
>> For example I mount C: on /c

>> And the above returns:
>> $ dirname $(cygpath -u c:/)
>> /
>> which doesn't tell me what the cygdrive prefix is -- only where 'c' is
>> mounted.

>> Of course, as pointed out in a later reply, one can use an unused disk drive
>> letter like 'x' but that is hardly robust since who knows what drive letters
>> will be unused and/or unmounted.

> Assuming you do find a reliable way to discover the cygdrive prefix, how
> do you plan to handle mapped drives for remote shares?  I ask because
> you mentioned that you might want to be able to run something like find
> on the cygdrive prefix itself, and of course scanning a remote share
> like that may not be desirable.  Also, how do you handle the mounted C:
> case as well?  Even if you mount it to /c as you have done, I think
> /cygdrive/c will also have it.

> -Jeremy

Does this not do what's required (barring spaces in the
"Cygdrive" alternative prefix):


# drives_root: Show the root prefix of the Windows drives
#             (perhaps 'Cygdrive', if the installation default
#             was selected) of the current installation of Cygwin

# By Lee Rothstein, 2009-11-06 11:58:53

#PName=$(basename $0)

mount -p | gawk 'NR==2 { print $1 }'


WRT embedded spaces in the drive prefix: UNIX, GNU, Linux and to
a large extent Perl, et al, are powerful because they demand of
users a lack of abject stupidity. If stupidity is enforced by OS
conventions and style, the results cannot be good.

Similar approaches to the above can be used with other mounting
artifice, and could even be adapted to embedded spaces.

Shares at depths of more than one directory are another story, but
probably could also be dealt with.

Or, perhaps I don't understand the issues?


-- Problem reports: FAQ: Documentation: Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]