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:
authorCorinna Vinschen <corinna@vinschen.de>2016-06-21 14:39:04 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-06-21 14:39:04 +0300
commit4965cdc9ad2753f7aa91711e2862d7e350168bef (patch)
tree26e238303825a1cc00bd6b1a5ea02a84efbe70d5
parent36d4eb12b5f23093ae1285d0725f4930235a07e5 (diff)
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>
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 3da519129..f4b528446 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,