This is the mail archive of the cygwin-apps 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: cygpath 1.7 wrong


2008/6/13 Corinna Vinschen:
> On Jun 13 17:14, Corinna Vinschen wrote:
>> > char *Cygwin_mount_flags(char *pathname) {
>> >
>> >     char flags[260]; /* I know, I know. stack vs heap */
>> > [...]
>> >     return flags;
>
> And it's returning the content of a local buffer.  Ouch!

It was just an example. The real perl function is correct of course.

>>       char user[260];
>>       char system[260];
>>       char user_flags[260];
>>       char system_flags[260];

>The paths in user and system are potentially PATH_MAX bytes long.
>That's 4K in 1.7.

Thank for the PATH_MAX hint. I almost forgot that.

>>     /* TODO: Check for cygdrive registry setting,
>>      *       and then use CW_GET_CYGDRIVE_INFO
>>      */

>Drop that TODO.  Never test the registry, not even in 1.5, even less
>in 1.7.

To explain:
For now I had the semantic limitation that the magic
  Cygwin::mount_flags("/cygdrive")
is required to return the volume mount settings.
But when a user mounted it to somewhere else, say "/mnt", then
the result for Cygwin::mount_flags("/mnt") might not be what he/she
expected. So the TODO is to check if "/mnt" is the current volume
mount point, and return the volume mount point flags then.

Changed to
    /* TODO: Check if arg is the current volume moint point if not default,
     *       and then use CW_GET_CYGDRIVE_INFO also.
     */
The next perl-5.10 version (this time for cygwin 1.7) will have
this TODO actually implemented.

>From README.cygwin:
=item C<Cygwin::mount_flags>

Returns the mount type and flags for a specified mount point.
A comma-separated string of mntent->mnt_type (always
"system" or "user"), then the mntent->mnt_opts, where
the first is always "binmode" or "textmode".

  system|user,binmode|textmode,exec,cygexec,cygdrive,mixed,
  notexec,managed,nosuid,devfs,proc,noumount

If the argument is "/cygdrive" or equal to the current cygdrive mount
prefix, 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,/cygdrive

-- 
Reini Urban
http://phpwiki.org/ http://murbreak.at/


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