delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/06/13/12:56:59

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <6910a60806130956h1eca2351ka7ed06d96abf2176@mail.gmail.com>
Date: Fri, 13 Jun 2008 18:56:14 +0200
From: "Reini Urban" <rurban AT x-ray DOT at>
To: cygwin-apps AT cygwin DOT com, cygwin AT cygwin DOT com
Subject: Re: cygpath 1.7 wrong
In-Reply-To: <20080613151927.GS731@calimero.vinschen.de>
MIME-Version: 1.0
References: <4845A725 DOT 4090706 AT x-ray DOT at> <20080609142427 DOT GW731 AT calimero DOT vinschen DOT de> <20080613082926 DOT GM731 AT calimero DOT vinschen DOT de> <48527025 DOT 3080709 AT x-ray DOT at> <20080613143051 DOT GP731 AT calimero DOT vinschen DOT de> <48528BCB DOT 1000009 AT x-ray DOT at> <20080613151439 DOT GR731 AT calimero DOT vinschen DOT de> <20080613151927 DOT GS731 AT calimero DOT vinschen DOT de>
X-Google-Sender-Auth: 948057ec853a5262
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019