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:
authorChristopher Faylor <me@cgf.cx>2002-06-01 06:45:38 +0400
committerChristopher Faylor <me@cgf.cx>2002-06-01 06:45:38 +0400
commit28af03faed3f79e2d8e284f1fc83adb6a0c4f193 (patch)
treedf5520d12016cbf330bddfdb9f832efd80486be9 /winsup/cygwin/dir.cc
parent548e208b82268e8d4411a0ca6fc3424046cdd9a9 (diff)
* fhandler_disk_file.cc (readdir): Move inode calculation into caller.
(fhandler_cygdrive::readdir): Add "." and "..". * dir.cc (readdir): Move inode calculation here so that fhandler readdirs can benefit.
Diffstat (limited to 'winsup/cygwin/dir.cc')
-rw-r--r--winsup/cygwin/dir.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index ef8b67d5b..94e2802cb 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -113,7 +113,42 @@ readdir (DIR *dir)
return NULL;
}
- return ((fhandler_base *) dir->__d_u.__d_data.__fh)->readdir (dir);
+ dirent *res = ((fhandler_base *) dir->__d_u.__d_data.__fh)->readdir (dir);
+
+ if (res)
+ {
+ /* Compute d_ino by combining filename hash with the directory hash
+ (which was stored in dir->__d_dirhash when opendir was called). */
+ if (res->d_name[0] == '.')
+ {
+ if (res->d_name[1] == '\0')
+ dir->__d_dirent->d_ino = dir->__d_dirhash;
+ else if (res->d_name[1] != '.' || res->d_name[2] != '\0')
+ goto hashit;
+ else
+ {
+ char *p, up[strlen (dir->__d_dirname) + 1];
+ strcpy (up, dir->__d_dirname);
+ if (!(p = strrchr (up, '\\')))
+ goto hashit;
+ *p = '\0';
+ if (!(p = strrchr (up, '\\')))
+ dir->__d_dirent->d_ino = hash_path_name (0, ".");
+ else
+ {
+ *p = '\0';
+ dir->__d_dirent->d_ino = hash_path_name (0, up);
+ }
+ }
+ }
+ else
+ {
+ hashit:
+ ino_t dino = hash_path_name (dir->__d_dirhash, "\\");
+ dir->__d_dirent->d_ino = hash_path_name (dino, res->d_name);
+ }
+ }
+ return res;
}
extern "C" __off64_t