]> sourceware.org Git - newlib-cygwin.git/commitdiff
* syscalls.cc (rename): Use volume serial numbers stored in path_conv
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 29 Apr 2008 09:24:54 +0000 (09:24 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 29 Apr 2008 09:24:54 +0000 (09:24 +0000)
rather than fetching them here for the "same file" test.  Change
comment to reflect this.

winsup/cygwin/ChangeLog
winsup/cygwin/syscalls.cc

index 0dfb396af47fc4bb013a0b575fd857a35598a0a1..d095fe14d147798435227fbe3d94def007991602 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * syscalls.cc (rename): Use volume serial numbers stored in path_conv
+       rather than fetching them here for the "same file" test.  Change
+       comment to reflect this.
+
 2008-04-28  Corinna Vinschen  <corinna@vinschen.de>
 
        * path.cc (symlink_info::check): Avoid special handling for
index 7da929efae61a6e2fffec9d58ab7a4c192c140f9..b323da203b0d332edfd6f26058f6592c6c3bb1a3 100644 (file)
@@ -1740,12 +1740,14 @@ rename (const char *oldpath, const char *newpath)
   /* SUSv3: If the old argument and the new argument resolve to the same
      existing file, rename() shall return successfully and perform no
      other action.
-     The test tries to be as quick as possible.  First it tests if oldpath
-     has more than 1 hardlink, then it opens newpath and tests for identical
-     file ids.  If so, it tests for identical volume serial numbers,  If so,
-     oldpath and newpath refer to the same file. */
+     The test tries to be as quick as possible.  First it tests for identical
+     volume serial numbers because that information is available anyway.
+     Then it tests if oldpath has more than 1 hardlink, then it opens newpath
+     and tests for identical file ids.  If so, oldpath and newpath refer to
+     the same file. */
   if ((removepc || dstpc->exists ())
       && !oldpc.isdir ()
+      && dstpc->fs_serial_number () == oldpc.fs_serial_number ()
       && NT_SUCCESS (NtQueryInformationFile (fh, &io, &ofsi, sizeof ofsi,
                                             FileStandardInformation))
       && ofsi.NumberOfLinks > 1
@@ -1756,23 +1758,13 @@ rename (const char *oldpath, const char *newpath)
                     | ((removepc ?: dstpc)->is_rep_symlink ()
                        ? FILE_OPEN_REPARSE_POINT : 0))))
     {
-      static const size_t vsiz = sizeof (FILE_FS_VOLUME_INFORMATION)
-                                + 32 * sizeof (WCHAR);
       FILE_INTERNAL_INFORMATION ofii, nfii;
-      PFILE_FS_VOLUME_INFORMATION opffvi, npffvi;
 
       if (NT_SUCCESS (NtQueryInformationFile (fh, &io, &ofii, sizeof ofii,
                                              FileInternalInformation))
          && NT_SUCCESS (NtQueryInformationFile (nfh, &io, &nfii, sizeof nfii,
                                                 FileInternalInformation))
-         && ofii.FileId.QuadPart == nfii.FileId.QuadPart
-         && (opffvi = (PFILE_FS_VOLUME_INFORMATION) alloca (vsiz))
-         && (npffvi = (PFILE_FS_VOLUME_INFORMATION) alloca (vsiz))
-         && NT_SUCCESS (NtQueryVolumeInformationFile (fh, &io, opffvi, vsiz,
-                                                   FileFsVolumeInformation))
-         && NT_SUCCESS (NtQueryVolumeInformationFile (nfh, &io, npffvi, vsiz,
-                                                   FileFsVolumeInformation))
-         && opffvi->VolumeSerialNumber == npffvi->VolumeSerialNumber)
+         && ofii.FileId.QuadPart == nfii.FileId.QuadPart)
        {
          debug_printf ("%s and %s are the same file", oldpath, newpath);
          NtClose (nfh);
This page took 0.038737 seconds and 5 git commands to generate.