]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-111293: Fix DirEntry.inode dropping higher bits on Windows (GH-111294)
authorzcxsythenew <30565051+zcxsythenew@users.noreply.github.com>
Thu, 26 Oct 2023 16:37:52 +0000 (00:37 +0800)
committerGitHub <noreply@github.com>
Thu, 26 Oct 2023 16:37:52 +0000 (17:37 +0100)
Misc/NEWS.d/next/Windows/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst [new file with mode: 0644]
Modules/posixmodule.c

diff --git a/Misc/NEWS.d/next/Windows/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst b/Misc/NEWS.d/next/Windows/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst
new file mode 100644 (file)
index 0000000..4c6b255
--- /dev/null
@@ -0,0 +1 @@
+Fix :data:`os.DirEntry.inode` dropping higher 64 bits of a file id on some filesystems on Windows.
index f9797f6d70817093b41673eb2c7754c014598077..8611f8f73aff05bbabb44c82dd43f4fafd89232a 100644 (file)
@@ -14805,6 +14805,7 @@ typedef struct {
 #ifdef MS_WINDOWS
     struct _Py_stat_struct win32_lstat;
     uint64_t win32_file_index;
+    uint64_t win32_file_index_high;
     int got_file_index;
 #else /* POSIX */
 #ifdef HAVE_DIRENT_D_TYPE
@@ -15134,11 +15135,10 @@ os_DirEntry_inode_impl(DirEntry *self)
         }
 
         self->win32_file_index = stat.st_ino;
+        self->win32_file_index_high = stat.st_ino_high;
         self->got_file_index = 1;
     }
-    static_assert(sizeof(unsigned long long) >= sizeof(self->win32_file_index),
-                  "DirEntry.win32_file_index is larger than unsigned long long");
-    return PyLong_FromUnsignedLongLong(self->win32_file_index);
+    return _pystat_l128_from_l64_l64(self->win32_file_index, self->win32_file_index_high);
 #else /* POSIX */
     static_assert(sizeof(unsigned long long) >= sizeof(self->d_ino),
                   "DirEntry.d_ino is larger than unsigned long long");