This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Improve encapsulation of FS type behind path_conv cover
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 21 Jun 2016 11:39:48 -0000
- Subject: [newlib-cygwin] Improve encapsulation of FS type behind path_conv cover
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f91865c8cf85c4c4309c64ded42c847a64872b1e
commit f91865c8cf85c4c4309c64ded42c847a64872b1e
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Jun 21 13:24:41 2016 +0200
Improve encapsulation of FS type behind path_conv cover
Rather than having to check for the FS type in the caller and having
to call different functions whether FS is NFS or not, encapsulate the
info in path_conv_handle/path_conv methods to allow FS type agnostic
calling from upper level functions.
This patch only implements the methods.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/path.h | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 23139a6..ad29590 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -90,6 +90,8 @@ enum path_types
PATH_SOCKET = 0x40000000
};
+NTSTATUS file_get_fai (HANDLE, PFILE_ALL_INFORMATION);
+
class symlink_info;
class path_conv_handle
@@ -117,10 +119,25 @@ public:
hdl = NULL;
}
inline HANDLE handle () const { return hdl; }
- inline PFILE_ALL_INFORMATION fai ()
+ inline PFILE_ALL_INFORMATION fai () const
{ return (PFILE_ALL_INFORMATION) &attribs._fai; }
- inline struct fattr3 *nfsattr ()
+ inline struct fattr3 *nfsattr () const
{ return (struct fattr3 *) &attribs._fattr3; }
+ inline NTSTATUS get_finfo (HANDLE h, bool nfs)
+ {
+ return nfs ? nfs_fetch_fattr3 (h, nfsattr ()) : file_get_fai (h, fai ());
+ }
+ inline ino_t get_ino (bool nfs) const
+ {
+ return nfs ? nfsattr ()->fileid
+ : fai ()->InternalInformation.IndexNumber.QuadPart;
+ }
+ inline DWORD get_dosattr (bool nfs) const
+ {
+ if (nfs)
+ return (nfsattr ()->type & 7) == NF3DIR ? FILE_ATTRIBUTE_DIRECTORY : 0;
+ return fai ()->BasicInformation.FileAttributes;
+ }
};
class path_conv
@@ -380,6 +397,11 @@ class path_conv
HANDLE handle () const { return conv_handle.handle (); }
PFILE_ALL_INFORMATION fai () { return conv_handle.fai (); }
struct fattr3 *nfsattr () { return conv_handle.nfsattr (); }
+ inline NTSTATUS get_finfo (HANDLE h)
+ {
+ return conv_handle.get_finfo (h, fs.is_nfs ());
+ }
+ inline ino_t get_ino () const { return conv_handle.get_ino (fs.is_nfs ()); }
void reset_conv_handle () { conv_handle.set (NULL); }
void close_conv_handle () { conv_handle.close (); }
@@ -432,7 +454,6 @@ bool __reg2 has_dot_last_component (const char *dir, bool test_dot_dot);
int __reg3 path_prefix_p (const char *path1, const char *path2, int len1,
bool caseinsensitive);
-NTSTATUS file_get_fai (HANDLE, PFILE_ALL_INFORMATION);
int normalize_win32_path (const char *, char *, char *&);
int normalize_posix_path (const char *, char *, char *&);
PUNICODE_STRING __reg3 get_nt_native_path (const char *, UNICODE_STRING&, bool);