* devices.in (dev_cygdrive_storage): Map to \Device\Null.

(dev_storage): Map /dev and /dev/windows to \Device\Null.
	* devices.cc: Regenerate.
	* dir.cc (opendir): Create unique id.  Explain why.
	* fhandler.h (fhandler_dev::get_dev): Implement inline.
	(fhandler_cygdrive::close): Drop declaration.
	(fhandler_cygdrive::get_dev): Implement inline.
	(fhandler_windows::get_hwnd): Ditto.
	(fhandler_windows::set_close_on_exec): Drop declaration.
	(fhandler_windows::fixup_after_fork): Ditto.
	* fhandler_dev.cc (fhandler_dev::open): Call fhandler_disk_file::open
	without O_CREAT flag.  Explain why.  Create \Device\Null handle if
	/dev/ doesn't actually exist.
	(fhandler_dev::close): Drop nohandle case.
	(fhandler_dev::fstatvfs): Drop nohandle check.  Test for fs_got_fs
	instead.  Set ST_RDONLY fs flag for simulated /dev.
	(fhandler_dev::opendir): If /dev doesn't exist, call open() to create
	fake \Device\Null handle.  Don't set nohandle.  Set dir_exists
	correctly.
	(fhandler_dev::rewinddir): Call fhandler_disk_file::rewinddir only if
	/dev is a real directory.
	* fhandler_disk_file.cc (fhandler_disk_file::opendir): If called for
	the cygdrive dir, call open() to create fake \Device\Null handle.
	Only attach __DIR_mounts buffer to dir if not called for cygdrive dir.
	Don't set nohandle.
	(fhandler_cygdrive::open): Create \Device\Null handle.
	(fhandler_cygdrive::close): Remove.
	(fhandler_cygdrive::fstatvfs): Set ST_RDONLY fs flag.
	* fhandler_windows.cc (fhandler_windows::open): Create \Device\Null
	handle.
	(fhandler_windows::read): Don't add io_handle to WFMO handle array.
	Change subsequent test for return value accordingly.  Fix test for
	"message arrived".
	(fhandler_windows::set_close_on_exec): Remove.
	(fhandler_windows::fixup_after_fork): Remove.
	* path.h (path_conv::set_path): Make sure wide_path is NULL when
	setting a new path.
	* select.cc (peek_windows): Use correct hWnd value, not io_handle.
	(fhandler_windows::select_read): Don't use io_handle as wait object.
	(fhandler_windows::select_write): Ditto.
	(fhandler_windows::select_except): Ditto.
This commit is contained in:
Corinna Vinschen
2013-10-30 09:44:47 +00:00
parent 0160e166ee
commit 751bbaf96a
10 changed files with 141 additions and 102 deletions

View File

@@ -1833,11 +1833,17 @@ fhandler_disk_file::opendir (int fd)
dir->__d_position = 0;
dir->__flags = (get_name ()[0] == '/' && get_name ()[1] == '\0')
? dirent_isroot : 0;
dir->__d_internal = (uintptr_t) new __DIR_mounts (get_name ());
d_cachepos (dir) = 0;
dir->__d_internal = 0;
if (!pc.iscygdrive ())
if (pc.iscygdrive ())
{
if (fd < 0 && !open (O_RDONLY, 0))
goto free_mounts;
}
else
{
dir->__d_internal = (uintptr_t) new __DIR_mounts (get_name ());
d_cachepos (dir) = 0;
if (fd < 0)
{
/* opendir() case. Initialize with given directory name and
@@ -1918,8 +1924,6 @@ fhandler_disk_file::opendir (int fd)
time on exit. Nasty, nasty... */
cfd = this;
dir->__d_fd = cfd;
if (pc.iscygdrive ())
cfd->nohandle (true);
}
set_close_on_exec (true);
dir->__fh = this;
@@ -2380,16 +2384,16 @@ fhandler_cygdrive::open (int flags, mode_t mode)
set_errno (EISDIR);
return 0;
}
flags |= O_DIROPEN;
set_flags (flags);
nohandle (true);
return 1;
}
int
fhandler_cygdrive::close ()
{
return 0;
/* Open a fake handle to \\Device\\Null, but revert to the old path
string afterwards, otherwise readdir will return with an EFAULT
when trying to fetch the inode number of ".." */
tmp_pathbuf tp;
char *orig_path = tp.c_get ();
stpcpy (orig_path, get_win32_name ());
pc.set_path (dev ().native);
int ret = fhandler_base::open (flags, mode);
pc.set_path (orig_path);
return ret;
}
void
@@ -2416,6 +2420,7 @@ fhandler_cygdrive::fstatvfs (struct statvfs *sfs)
set to something useful. Just as on Linux. */
memset (sfs, 0, sizeof (*sfs));
sfs->f_bsize = sfs->f_frsize = 4096;
sfs->f_flag = ST_RDONLY;
sfs->f_namemax = NAME_MAX;
return 0;
}