From: corinna DOT vinschen AT cityweb DOT de (Corinna Vinschen) Subject: Re: Patch to 990126: Handling of directories and i-node-numbers 29 Jan 1999 17:01:43 -0800 Message-ID: <36B2555A.C8E4FF12.cygnus.cygwin32.developers@cityweb.de> References: <36B19184 DOT F89F7FD5 AT cityweb DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Christopher Faylor , cygwin32-developers AT cygnus DOT com Christopher Faylor wrote: > > I actually submitted a patch like this a couple of times before > I started with Cygnus. It was never incorporated, I think because > that it doesn't work correctly with SMB directories. > > Is there any way to check if the directory is located on a remote > share? > > -chris Yes, there is a way. Thanks for the hint, I have patched my patch. I've sent it again with this mail. Regards, Corinna ChangeLog: ========== Sat Jan 30 1:31:00 Corinna Vinschen * fhandler.cc (fhandler_disk_file::fstat): Handles directories, returns unique i-node number. * syscalls.cc (stat_worker): On WinNT, stat_worker calls fhandler_disk_file::fstat for directories, too. Index: fhandler.cc =================================================================== RCS file: /src/cvsroot/winsup-990126/fhandler.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -1 -r1.1 -r1.2 --- fhandler.cc 1999/01/29 09:33:41 1.1 +++ fhandler.cc 1999/01/29 09:49:20 1.2 @@ -804,3 +804,3 @@ fhandler_disk_file::fstat (struct stat * buf->st_size = local.nFileSizeLow; - buf->st_ino = local.nFileIndexLow ^ get_namehash (); + buf->st_ino = local.nFileIndexHigh | local.nFileIndexLow; buf->st_blksize = S_BLKSIZE; @@ -814,2 +814,4 @@ fhandler_disk_file::fstat (struct stat * buf->st_mode |= S_IFLNK; + else if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + buf->st_mode |= S_IFDIR; else @@ -836,3 +838,6 @@ fhandler_disk_file::fstat (struct stat * case FILE_TYPE_DISK: - buf->st_mode |= S_IFREG; + if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + buf->st_mode |= S_IFDIR; + else + buf->st_mode |= S_IFREG; if (get_execable_p ()) Index: syscalls.cc =================================================================== RCS file: /src/cvsroot/winsup-990126/syscalls.cc,v retrieving revision 1.1 diff -u -p -1 -r1.1 syscalls.cc --- syscalls.cc 1999/01/29 09:33:44 1.1 +++ syscalls.cc 1999/01/30 00:04:46 @@ -1209,2 +1209,25 @@ stat_worker (const char *caller, const c debug_printf ("%d = GetFileAttributesA (%s)", atts, win32_name); - if (atts == -1 || !(atts & FILE_ATTRIBUTE_DIRECTORY)) + + static char drive[4] = "X:\\"; + drive[0] = win32_name[0]; + UINT dtype; + + if (os_being_run == winNT + && (!(atts & FILE_ATTRIBUTE_DIRECTORY) + || ((dtype = GetDriveType (drive)) != DRIVE_NO_ROOT_DIR + && dtype != DRIVE_REMOTE + && dtype != DRIVE_UNKNOWN))) + { + fhandler_disk_file fh (NULL); + + if (fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN | + (nofollow ? O_NOSYMLINK : 0), 0)) + { + res = fh.fstat (buf); + fh.close (); + if (atts != -1 && (atts & FILE_ATTRIBUTE_DIRECTORY)) + buf->st_nlink = num_entries (win32_name); + } + } + else if (atts == -1 || !(atts & FILE_ATTRIBUTE_DIRECTORY)) {