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>
This commit is contained in:
Corinna Vinschen 2016-06-21 13:39:04 +02:00
parent 36d4eb12b5
commit 4965cdc9ad
1 changed files with 9 additions and 3 deletions

View File

@ -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,