[newlib-cygwin] Add release message for commit 2c83227
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=94e3a561d053ca1b00f16d81d4ade2884ea45b54 commit 94e3a561d053ca1b00f16d81d4ade2884ea45b54 Author: Corinna VinschenDate: Tue Jun 21 13:43:53 2016 +0200 Add release message for commit 2c83227 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.5.2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/winsup/cygwin/release/2.5.2 b/winsup/cygwin/release/2.5.2 index 64e08ba..fe4a869 100644 --- a/winsup/cygwin/release/2.5.2 +++ b/winsup/cygwin/release/2.5.2 @@ -28,3 +28,6 @@ Bug Fixes - Return at most one line of input in canonical mode and fix tcflush. Addresses: https://cygwin.com/ml/cygwin/2016-05/msg00318.html + +- Fix using wrong inode number on newly created files. + Addresses: https://cygwin.com/ml/cygwin/2016-06/msg00269.html
[newlib-cygwin] Drop useless calls to path_conv.isgood_inode
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2c832271127f2ae7eea4245dc940d8a5c1fe7498 commit 2c832271127f2ae7eea4245dc940d8a5c1fe7498 Author: Corinna VinschenDate: Tue Jun 21 13:39:35 2016 +0200 Drop useless calls to path_conv.isgood_inode Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler_disk_file.cc | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index f4b5284..5148dd7 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -334,8 +334,7 @@ fhandler_base::fstat_by_handle (struct stat *buf) return -1; } } - if (pc.hasgood_inode () - && pc.isgood_inode (pc.fai ()->InternalInformation.IndexNumber.QuadPart)) + if (pc.isgood_inode (pc.fai ()->InternalInformation.IndexNumber.QuadPart)) ino = pc.fai ()->InternalInformation.IndexNumber.QuadPart; return fstat_helper (buf); } @@ -463,10 +462,7 @@ fhandler_base::fstat_helper (struct stat *buf) buf->st_nlink = pc.fai()->StandardInformation.NumberOfLinks; /* Enforce namehash as inode number on untrusted file systems. */ - if (ino && pc.isgood_inode (ino)) -buf->st_ino = (ino_t) ino; - else -buf->st_ino = get_ino (); + buf->st_ino = ino ?: get_ino (); buf->st_blksize = PREFERRED_IO_BLKSIZE;
[newlib-cygwin] Use new path_conv_handle functions to access file info
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=36d4eb12b5f23093ae1285d0725f4930235a07e5 commit 36d4eb12b5f23093ae1285d0725f4930235a07e5 Author: Corinna VinschenDate: Tue Jun 21 13:28:12 2016 +0200 Use new path_conv_handle functions to access file info This avoids having to call nfs_fetch_fattr3/file_get_fai depending on FS type as well as having to extract the info FS dependent. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler_disk_file.cc | 4 ++-- winsup/cygwin/path.cc | 16 +++- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 2cf738f..3da5191 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -254,7 +254,7 @@ fhandler_base::fstat_by_nfs_ea (struct stat *buf) NFS client. */ if (get_access () & GENERIC_WRITE) FlushFileBuffers (get_io_handle ()); - nfs_fetch_fattr3 (get_io_handle (), nfs_attr); + pc.get_finfo (get_io_handle ()); } buf->st_dev = nfs_attr->fsid; buf->st_ino = nfs_attr->fileid; @@ -326,7 +326,7 @@ fhandler_base::fstat_by_handle (struct stat *buf) on the information stored in pc.fai. So we overwrite them here. */ if (get_io_handle ()) { - status = file_get_fai (h, pc.fai ()); + status = pc.get_finfo (h); if (!NT_SUCCESS (status)) { debug_printf ("%y = NtQueryInformationFile(%S, FileAllInformation)", diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 18d5c1d..72b152c 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2794,19 +2794,9 @@ restart: This speeds up path_conv noticably (~10%). */ && (fs.inited () || fs.update (, h))) { - if (fs.is_nfs ()) - { - status = nfs_fetch_fattr3 (h, conv_hdl.nfsattr ()); - if (NT_SUCCESS (status)) - fileattr = ((conv_hdl.nfsattr ()->type & 7) == NF3DIR) - ? FILE_ATTRIBUTE_DIRECTORY : 0; - } - else - { - status = file_get_fai (h, conv_hdl.fai ()); - if (NT_SUCCESS (status)) - fileattr = conv_hdl.fai ()->BasicInformation.FileAttributes; - } + status = conv_hdl.get_finfo (h, fs.is_nfs ()); + if (NT_SUCCESS (status)) + fileattr = conv_hdl.get_dosattr (fs.is_nfs ()); } if (!NT_SUCCESS (status)) {
[newlib-cygwin] Use correct file info (especially inode number) for newly created files
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4965cdc9ad2753f7aa91711e2862d7e350168bef commit 4965cdc9ad2753f7aa91711e2862d7e350168bef Author: Corinna VinschenDate: Tue Jun 21 13:39:04 2016 +0200 Use correct file info (especially inode number) for newly created files fhandler_base::open_fs has two problems: - When newly creating a file, the file info in the path_conv is incorrect. It points to info for the parent dir, not to info for the file itself (which, naturally, wasn't available before). - Fetching the file's inode number only worked for non-NFS. Both problems should be fixed now by reloading file info if the file has just been created, as well as using the new FS-agnostic path_conv::get_ino method. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/fhandler_disk_file.cc | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 3da5191..f4b5284 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1461,6 +1461,8 @@ fhandler_base::open_fs (int flags, mode_t mode) return 0; } + bool new_file = !exists (); + int res = fhandler_base::open (flags | O_DIROPEN, mode); if (!res) goto out; @@ -1479,9 +1481,13 @@ fhandler_base::open_fs (int flags, mode_t mode) return 0; } - if (pc.hasgood_inode () - && pc.isgood_inode (pc.fai ()->InternalInformation.IndexNumber.QuadPart)) -ino = pc.fai ()->InternalInformation.IndexNumber.QuadPart; + /* The file info in pc is wrong at this point for newly created files. + Refresh it before fetching any file info. */ + if (new_file) +pc.get_finfo (get_io_handle ()); + + if (pc.isgood_inode (pc.get_ino ())) +ino = pc.get_ino (); out: syscall_printf ("%d = fhandler_disk_file::open(%S, %y)", res,
[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 VinschenDate: 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 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 = 0x4000 }; +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) _fai; } - inline struct fattr3 *nfsattr () + inline struct fattr3 *nfsattr () const { return (struct fattr3 *) _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);