www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/23/04:39:07

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Thu, 23 Jul 2009 10:38:44 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: csih: Patch getVolInfo.c
Message-ID: <20090723083844.GY27613@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20090722185402 DOT GS27613 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20090722185402.GS27613@calimero.vinschen.de>
User-Agent: Mutt/1.5.19 (2009-02-20)
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

On Jul 22 20:54, Corinna Vinschen wrote:
> Hi Chuck,
> 
> today I found a filesystem, HGFS, which is sensible against using just
> the READ_CONTROL flag in calls to NtOpenFile.  The result is a
> STATUS_INVALID_PARAMETER status code.
> 
> However, for access to the filesystem information, the READ_CONTROL
> isn't necessary.  A desired access of 0 is sufficient in every case
> I could lay my hands on (NTFS, NFS, Samba, FAT32, HGFS).
> 
> So I just applied a patch to Cygwin to fetch filesystem information
> with access set to 0.
> 
> The same patch should go into getVolInfo in csih.  Patch below.

New patch below.

 	* cygwin/getVolInfo.c: Check ZwOpenFile status code for
	STATUS_INVALID_PARAMETER and retry top open with FILE_READ_DATA
	access.  Simply STATUS_NO_MEDIA_IN_DEVICE condition.

Index: cygwin/getVolInfo.c
===================================================================
RCS file: /sourceware/projects/cygwin-apps-home/cvsfiles/csih/cygwin/getVolInfo.c,v
retrieving revision 1.1
diff -u -p -r1.1 getVolInfo.c
--- cygwin/getVolInfo.c	7 Aug 2008 23:17:32 -0000	1.1
+++ cygwin/getVolInfo.c	23 Jul 2009 08:38:06 -0000
@@ -86,7 +86,10 @@ main (int argc, char **argv)
   InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, NULL, NULL);
   stat = ZwOpenFile (&h, READ_CONTROL, &attr, &io, FILE_SHARE_VALID_FLAGS,
 		     FILE_OPEN_FOR_BACKUP_INTENT);
-  if (!NT_SUCCESS (stat) && stat == STATUS_NO_MEDIA_IN_DEVICE)
+  if (stat == STATUS_INVALID_PARAMETER)
+    status = NtOpenFile (&vol, FILE_READ_DATA, &attr, &io,
+			 FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
+  if (stat == STATUS_NO_MEDIA_IN_DEVICE)
     {
       upath.Length = 6 * sizeof (WCHAR);
       stat = ZwOpenFile (&h, READ_CONTROL, &attr, &io, FILE_SHARE_VALID_FLAGS, 0);


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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

- Raw text -


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