This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Use correct file info (especially inode number) for newly created files
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 21 Jun 2016 11:39:59 -0000
- Subject: [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 Vinschen <corinna@vinschen.de>
Date: 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 <corinna@vinschen.de>
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,