Throughout, remove __d_u.__d_data fields from DIR structure.

* include/sys/dirent.h (dirent): Remvoe old_d_ino.
(DIR): Make __d_dirhash a 64 bit value.  Remove __d_data and __d_u.  Add
__flags.
* dir.cc (opendir_states): New enum.
(opendir): Clear new DIR __flags field.
(readdir): Fill in '.' and '..' entries if we hit EOF and we haven't seen them
already.  Nuke setting of old_d_ino.
(rewinddir): Reset DIR __flags field.
(seekdir64): Ditto.
* fhandler_disk_file.cc (fhandler_cygdrive::fhandler_cygdrive): Remove special
handling of "." and ".." since they are now handled automatically.
This commit is contained in:
Christopher Faylor
2003-09-08 04:04:19 +00:00
parent d31c5928dd
commit 0c7b55727a
6 changed files with 93 additions and 57 deletions

View File

@ -593,7 +593,7 @@ fhandler_disk_file::opendir (path_conv& real_name)
fd = this;
fd->set_nohandle (true);
dir->__d_dirent->d_fd = fd;
dir->__d_u.__d_data.__fh = this;
dir->__fh = this;
/* FindFirstFile doesn't seem to like duplicate /'s. */
len = strlen (dir->__d_dirname);
if (len == 0 || isdirsep (dir->__d_dirname[len - 1]))
@ -601,7 +601,7 @@ fhandler_disk_file::opendir (path_conv& real_name)
else
strcat (dir->__d_dirname, "\\*"); /**/
dir->__d_cookie = __DIRENT_COOKIE;
dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
dir->__handle = INVALID_HANDLE_VALUE;
dir->__d_position = 0;
dir->__d_dirhash = get_namehash ();
@ -622,25 +622,25 @@ fhandler_disk_file::readdir (DIR *dir)
HANDLE handle;
struct dirent *res = NULL;
if (dir->__d_u.__d_data.__handle == INVALID_HANDLE_VALUE
if (dir->__handle == INVALID_HANDLE_VALUE
&& dir->__d_position == 0)
{
handle = FindFirstFileA (dir->__d_dirname, &buf);
DWORD lasterr = GetLastError ();
dir->__d_u.__d_data.__handle = handle;
dir->__handle = handle;
if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES))
{
seterrno_from_win_error (__FILE__, __LINE__, lasterr);
return res;
}
}
else if (dir->__d_u.__d_data.__handle == INVALID_HANDLE_VALUE)
else if (dir->__handle == INVALID_HANDLE_VALUE)
return res;
else if (!FindNextFileA (dir->__d_u.__d_data.__handle, &buf))
else if (!FindNextFileA (dir->__handle, &buf))
{
DWORD lasterr = GetLastError ();
(void) FindClose (dir->__d_u.__d_data.__handle);
dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
(void) 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)
@ -697,10 +697,10 @@ fhandler_disk_file::seekdir (DIR *dir, _off64_t loc)
void
fhandler_disk_file::rewinddir (DIR *dir)
{
if (dir->__d_u.__d_data.__handle != INVALID_HANDLE_VALUE)
if (dir->__handle != INVALID_HANDLE_VALUE)
{
(void) FindClose (dir->__d_u.__d_data.__handle);
dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
(void) FindClose (dir->__handle);
dir->__handle = INVALID_HANDLE_VALUE;
}
dir->__d_position = 0;
}
@ -709,8 +709,8 @@ int
fhandler_disk_file::closedir (DIR *dir)
{
int res = 0;
if (dir->__d_u.__d_data.__handle != INVALID_HANDLE_VALUE &&
FindClose (dir->__d_u.__d_data.__handle) == 0)
if (dir->__handle != INVALID_HANDLE_VALUE &&
FindClose (dir->__handle) == 0)
{
__seterrno ();
res = -1;
@ -728,14 +728,10 @@ fhandler_cygdrive::fhandler_cygdrive (int unit) :
void
fhandler_cygdrive::set_drives ()
{
const int len = 1 + 26 * DRVSZ;
char *p = (char *) crealloc ((void *) win32_path_name,
sizeof (".") + sizeof ("..") + len);
const int len = 2 + 26 * DRVSZ;
char *p = (char *) crealloc ((void *) win32_path_name, len);
win32_path_name = pdrive = p;
strcpy (p, ".");
strcpy (p + sizeof ("."), "..");
p += sizeof (".") + sizeof ("..");
ndrives = GetLogicalDriveStrings (len, p) / DRVSZ;
}