mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 12:29:32 +08:00
* fhandler.h (dirent_states): Add dirent_isroot, dirent_saw_cygdrive,
dirent_saw_dev. * dir.cc (opendir): Don't zero __flags here. Push that responsibility to opendir methods. (seekdir): Preserve dirent_isrrot in __flags. (rewinddir): Ditto. * fhandler_disk_file.cc (fhandler_disk_file::opendir): Set dirent_isroot appropriately. (fhandler_disk_file::readdir): Fill in "cygdrive" and "dev" if it is the root dir and they are missing. * fhandler_process.cc (fhandler_process::opendir): Set __flags here. * fhandler_virtual.cc (fhandler_virtual::opendir): Set __flags here.
This commit is contained in:
parent
82ef66c933
commit
358063ace3
@ -1,3 +1,18 @@
|
|||||||
|
2005-08-19 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* fhandler.h (dirent_states): Add dirent_isroot, dirent_saw_cygdrive,
|
||||||
|
dirent_saw_dev.
|
||||||
|
* dir.cc (opendir): Don't zero __flags here. Push that responsibility
|
||||||
|
to opendir methods.
|
||||||
|
(seekdir): Preserve dirent_isrrot in __flags.
|
||||||
|
(rewinddir): Ditto.
|
||||||
|
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Set
|
||||||
|
dirent_isroot appropriately.
|
||||||
|
(fhandler_disk_file::readdir): Fill in "cygdrive" and "dev" if it is
|
||||||
|
the root dir and they are missing.
|
||||||
|
* fhandler_process.cc (fhandler_process::opendir): Set __flags here.
|
||||||
|
* fhandler_virtual.cc (fhandler_virtual::opendir): Set __flags here.
|
||||||
|
|
||||||
2005-08-19 Christopher Faylor <cgf@timesys.com>
|
2005-08-19 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* winsup.h (create_pipe): Declare new function.
|
* winsup.h (create_pipe): Declare new function.
|
||||||
|
@ -59,7 +59,7 @@ opendir (const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
res->__flags = 0;
|
/* nothing */;
|
||||||
else if (fh)
|
else if (fh)
|
||||||
delete fh;
|
delete fh;
|
||||||
return res;
|
return res;
|
||||||
@ -169,7 +169,7 @@ seekdir64 (DIR *dir, _off64_t loc)
|
|||||||
|
|
||||||
if (dir->__d_cookie != __DIRENT_COOKIE)
|
if (dir->__d_cookie != __DIRENT_COOKIE)
|
||||||
return;
|
return;
|
||||||
dir->__flags = 0;
|
dir->__flags &= dirent_isroot;
|
||||||
return ((fhandler_base *) dir->__fh)->seekdir (dir, loc);
|
return ((fhandler_base *) dir->__fh)->seekdir (dir, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ rewinddir (DIR *dir)
|
|||||||
|
|
||||||
if (dir->__d_cookie != __DIRENT_COOKIE)
|
if (dir->__d_cookie != __DIRENT_COOKIE)
|
||||||
return;
|
return;
|
||||||
dir->__flags = 0;
|
dir->__flags &= dirent_isroot;
|
||||||
return ((fhandler_base *) dir->__fh)->rewinddir (dir);
|
return ((fhandler_base *) dir->__fh)->rewinddir (dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,13 @@ struct __acl32;
|
|||||||
|
|
||||||
enum dirent_states
|
enum dirent_states
|
||||||
{
|
{
|
||||||
dirent_ok = 0,
|
dirent_ok = 0x0000,
|
||||||
dirent_saw_dot = 1,
|
dirent_saw_dot = 0x0001,
|
||||||
dirent_saw_dot_dot = 2,
|
dirent_saw_dot_dot = 0x0002,
|
||||||
dirent_saw_eof = 4
|
dirent_saw_eof = 0x0004,
|
||||||
|
dirent_isroot = 0x0008,
|
||||||
|
dirent_saw_cygdrive = 0x0010,
|
||||||
|
dirent_saw_dev = 0x0020
|
||||||
};
|
};
|
||||||
|
|
||||||
enum conn_state
|
enum conn_state
|
||||||
|
@ -1287,6 +1287,7 @@ fhandler_disk_file::opendir ()
|
|||||||
DIR *dir;
|
DIR *dir;
|
||||||
DIR *res = NULL;
|
DIR *res = NULL;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
path_conv rootdir ("/");
|
||||||
|
|
||||||
if (!pc.isdir ())
|
if (!pc.isdir ())
|
||||||
set_errno (ENOTDIR);
|
set_errno (ENOTDIR);
|
||||||
@ -1332,7 +1333,7 @@ fhandler_disk_file::opendir ()
|
|||||||
dir->__d_dirhash = get_namehash ();
|
dir->__d_dirhash = get_namehash ();
|
||||||
|
|
||||||
res = dir;
|
res = dir;
|
||||||
|
dir->__flags = strcasematch (pc, rootdir) ? dirent_isroot : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
syscall_printf ("%p = opendir (%s)", res, get_name ());
|
syscall_printf ("%p = opendir (%s)", res, get_name ());
|
||||||
@ -1370,15 +1371,36 @@ fhandler_disk_file::readdir (DIR *dir)
|
|||||||
return res;
|
return res;
|
||||||
else if (!FindNextFileA (dir->__handle, &buf))
|
else if (!FindNextFileA (dir->__handle, &buf))
|
||||||
{
|
{
|
||||||
DWORD lasterr = GetLastError ();
|
bool added = false;
|
||||||
FindClose (dir->__handle);
|
if (!(dir->__flags & dirent_isroot))
|
||||||
dir->__handle = INVALID_HANDLE_VALUE;
|
/* nothing */;
|
||||||
/* POSIX says you shouldn't set errno when readdir can't
|
else if (!(dir->__flags & dirent_saw_dev))
|
||||||
find any more files; so, if another error we leave it set. */
|
{
|
||||||
if (lasterr != ERROR_NO_MORE_FILES)
|
strcpy (buf.cFileName, "dev");
|
||||||
seterrno_from_win_error (__FILE__, __LINE__, lasterr);
|
added = true;
|
||||||
syscall_printf ("%p = readdir (%p)", res, dir);
|
}
|
||||||
return res;
|
else if (!(dir->__flags & dirent_saw_cygdrive)
|
||||||
|
&& mount_table->cygdrive_len > 1)
|
||||||
|
{
|
||||||
|
strcpy (buf.cFileName, mount_table->cygdrive + 1);
|
||||||
|
buf.cFileName[mount_table->cygdrive_len - 2] = '\0';
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (added)
|
||||||
|
buf.dwFileAttributes = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DWORD lasterr = GetLastError ();
|
||||||
|
FindClose (dir->__handle);
|
||||||
|
dir->__handle = INVALID_HANDLE_VALUE;
|
||||||
|
/* POSIX says you shouldn't set errno when readdir can't
|
||||||
|
find any more files; so, if another error we leave it set. */
|
||||||
|
if (lasterr != ERROR_NO_MORE_FILES)
|
||||||
|
seterrno_from_win_error (__FILE__, __LINE__, lasterr);
|
||||||
|
syscall_printf ("%p = readdir (%p)", res, dir);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for Windows shortcut. If it's a Cygwin or U/WIN
|
/* Check for Windows shortcut. If it's a Cygwin or U/WIN
|
||||||
@ -1403,11 +1425,22 @@ fhandler_disk_file::readdir (DIR *dir)
|
|||||||
fnunmunge (dir->__d_dirent->d_name, buf.cFileName);
|
fnunmunge (dir->__d_dirent->d_name, buf.cFileName);
|
||||||
else
|
else
|
||||||
strcpy (dir->__d_dirent->d_name, buf.cFileName);
|
strcpy (dir->__d_dirent->d_name, buf.cFileName);
|
||||||
|
if (!(dir->__flags && dirent_isroot))
|
||||||
|
/* nothing */;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (strcasematch (dir->__d_dirent->d_name, "dev"))
|
||||||
|
dir->__flags |= dirent_saw_dev;
|
||||||
|
if (strlen (dir->__d_dirent->d_name) == mount_table->cygdrive_len - 2
|
||||||
|
&& strncasematch (dir->__d_dirent->d_name, mount_table->cygdrive + 1,
|
||||||
|
mount_table->cygdrive_len - 2))
|
||||||
|
dir->__flags |= dirent_saw_cygdrive;
|
||||||
|
}
|
||||||
|
|
||||||
dir->__d_position++;
|
dir->__d_position++;
|
||||||
res = dir->__d_dirent;
|
res = dir->__d_dirent;
|
||||||
syscall_printf ("%p = readdir (%p) (%s)",
|
syscall_printf ("%p = readdir (%p) (%s)", &dir->__d_dirent, dir,
|
||||||
&dir->__d_dirent, dir, buf.cFileName);
|
buf.cFileName);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +200,12 @@ DIR *
|
|||||||
fhandler_process::opendir ()
|
fhandler_process::opendir ()
|
||||||
{
|
{
|
||||||
DIR *dir = fhandler_virtual::opendir ();
|
DIR *dir = fhandler_virtual::opendir ();
|
||||||
if (dir && fileid == PROCESS_FD)
|
if (dir)
|
||||||
fill_filebuf ();
|
{
|
||||||
|
if (fileid == PROCESS_FD)
|
||||||
|
fill_filebuf ();
|
||||||
|
dir->__flags = 0;
|
||||||
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ fhandler_virtual::opendir ()
|
|||||||
dir->__d_dirhash = get_namehash ();
|
dir->__d_dirhash = get_namehash ();
|
||||||
dir->__flags = dirent_saw_dot | dirent_saw_dot_dot;
|
dir->__flags = dirent_saw_dot | dirent_saw_dot_dot;
|
||||||
res = dir;
|
res = dir;
|
||||||
|
res->__flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user