aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2006-03-01 13:47:49 +0000
committerCorinna Vinschen <corinna@vinschen.de>2006-03-01 13:47:49 +0000
commite817fd3c8b91f66b4365eeda0ae2afb457f15271 (patch)
treeef26b01ddafcbdd7bf6113796f989c26c848f294 /winsup/cygwin/path.cc
parent0e3befd6786a4768629e0fb4958106eac77510a0 (diff)
downloadnewlib-e817fd3c8b91f66b4365eeda0ae2afb457f15271.zip
newlib-e817fd3c8b91f66b4365eeda0ae2afb457f15271.tar.gz
newlib-e817fd3c8b91f66b4365eeda0ae2afb457f15271.tar.bz2
* include/sys/dirent.h (struct __DIR): Rename __d_unused to
__d_internal. * fhandler_disk_file.cc (struct __DIR_cache): Remove useless "typedef". (d_dirname): Remove useless "struct". (d_cachepos): Ditto. (d_cache): Ditto. (class __DIR_mounts): New class, implementing mount point tracking for readdir. (d_mounts): New macro for easy access to __DIR_mounts structure. (fhandler_disk_file::opendir): Allocate __DIR_mounts structure and let __d_internal element of dir point to it. (fhandler_disk_file::readdir_helper): Add mount points in the current directory, which don't have a real directory backing them. Don't generate an inode number for /dev. Add comment, why. (fhandler_disk_file::readdir): Move filling fname to an earlier point. Check if current entry is a mount point and evaluate correct inode number for it. (fhandler_disk_file::readdir_9x): Ditto. (fhandler_disk_file::rewinddir): Set all mount points in this directory to "not found" so that they are listed again after calling rewinddir(). (fhandler_disk_file::closedir): Deallocate __DIR_mounts structure. * path.cc (mount_info::get_mounts_here): New method to evaluate a list of mount points in a given parent directory. * shared_info.h (class mount_info): Declare get_mounts_here.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index e2480c2..44ceb6c 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -1718,6 +1718,30 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
return rc;
}
+int
+mount_info::get_mounts_here (const char *parent_dir, int parent_dir_len,
+ char **mount_points)
+{
+ int n_mounts = 0;
+
+ for (int i = 0; i < nmounts; i++)
+ {
+ mount_item *mi = mount + posix_sorted[i];
+ char *last_slash = strrchr (mi->posix_path, '/');
+ if (!last_slash)
+ continue;
+ if (last_slash == mi->posix_path)
+ {
+ if (parent_dir_len == 1 && mi->posix_pathlen > 1)
+ mount_points[n_mounts++] = last_slash + 1;
+ }
+ else if (parent_dir_len == last_slash - mi->posix_path
+ && strncasematch (parent_dir, mi->posix_path, parent_dir_len))
+ mount_points[n_mounts++] = last_slash + 1;
+ }
+ return n_mounts;
+}
+
/* cygdrive_posix_path: Build POSIX path used as the
mount point for cygdrives created when there is no other way to
obtain a POSIX path from a Win32 one. */