Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2012-02-16 15:02:05 +0400
committerCorinna Vinschen <corinna@vinschen.de>2012-02-16 15:02:05 +0400
commit9de04619852a9e83433b311e5d7ca60d0587d385 (patch)
treef5a38797fdce787d787faf582f4891ade56c724b /winsup/cygwin/fhandler_disk_file.cc
parentfb97e87479ea60a6c3ce21b193b83991a0fc0fc9 (diff)
* autoload.cc (NetUseGetInfo): Define.
* fhandler_disk_file.cc (fhandler_cygdrive::opendir): Rename flptst to drive. Call new get_disk_type function rather than is_floppy and check SMB drives with the NetUseGetInfo function. Explain why. * mount.cc (get_disk_type): New function to evaluate disk type from native NT device name. (is_floppy): Remove. * mount.h (enum disk_type): Define. (get_disk_type): Declare. * path.h (is_floppy): Drop declaration.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 13b9d6919..1fe12b0a2 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -25,6 +25,7 @@ details. */
#include "tls_pbuf.h"
#include "pwdgrp.h"
#include <winioctl.h>
+#include <lm.h>
#define _COMPILING_NEWLIB
#include <dirent.h>
@@ -2412,7 +2413,7 @@ fhandler_cygdrive::opendir (int fd)
int
fhandler_cygdrive::readdir (DIR *dir, dirent *de)
{
- char flptst[] = "X:";
+ WCHAR drive[] = L"X:";
while (true)
{
@@ -2426,8 +2427,29 @@ fhandler_cygdrive::readdir (DIR *dir, dirent *de)
}
return ENMFILE;
}
- if (!is_floppy ((flptst[0] = *pdrive, flptst))
- && GetFileAttributes (pdrive) != INVALID_FILE_ATTRIBUTES)
+ disk_type dt = get_disk_type ((drive[0] = *pdrive, drive));
+ if (dt == DT_SHARE_SMB)
+ {
+ /* Calling NetUseGetInfo on SMB drives allows to fetch the
+ current state of the drive without trying to open a file
+ descriptor on the share (GetFileAttributes). This avoids
+ waiting for SMB timeouts. Of course, there's a downside:
+ If a drive becomes availabe again, it can take a couple of
+ minutes to recognize it. As long as this didn't happen,
+ the drive will not show up in the cygdrive dir. */
+ PUSE_INFO_1 pui1;
+ DWORD status;
+
+ if (NetUseGetInfo (NULL, drive, 1, (PBYTE *) &pui1) == NERR_Success)
+ {
+ status = pui1->ui1_status;
+ NetApiBufferFree (pui1);
+ if (status == USE_OK)
+ break;
+ }
+ }
+ else if (dt != DT_FLOPPY
+ && GetFileAttributes (pdrive) != INVALID_FILE_ATTRIBUTES)
break;
pdrive = strchr (pdrive, '\0') + 1;
}