From 06313f3771f33514f0956b6ae7ba525ec342e252 Mon Sep 17 00:00:00 2001 From: Guozhang Wu <30565051+zcxsythenew@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:25:49 +0800 Subject: [PATCH 1/3] GH-111293: Fix DirEntry.inode dropping higher bits --- Modules/posixmodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index f9797f6d708170..66f21f746fa6a4 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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,12 @@ 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"); From b487a128a0b94eaf0d83bd166cb97897a1411dd7 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 05:01:29 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst diff --git a/Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst b/Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst new file mode 100644 index 00000000000000..be22da178f52be --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst @@ -0,0 +1 @@ +Fix os.DirEntry.inode() dropping higher 64 bits of a file id on Windows. From 0156cae43a5f00e132f470ee72d7617f7fe836fd Mon Sep 17 00:00:00 2001 From: Guozhang Wu <30565051+zcxsythenew@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:44:41 +0800 Subject: [PATCH 3/3] gh-111293: Fix DirEntry.inode dropping higher bits Resolve Conversations --- .../next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst | 1 - .../next/Windows/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst | 1 + Modules/posixmodule.c | 2 -- 3 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst create mode 100644 Misc/NEWS.d/next/Windows/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst diff --git a/Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst b/Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst deleted file mode 100644 index be22da178f52be..00000000000000 --- a/Misc/NEWS.d/next/Library/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst +++ /dev/null @@ -1 +0,0 @@ -Fix os.DirEntry.inode() dropping higher 64 bits of a file id on Windows. 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 index 00000000000000..4c6b255bc44c7b --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2023-10-25-05-01-28.gh-issue-111293.FSsLT6.rst @@ -0,0 +1 @@ +Fix :data:`os.DirEntry.inode` dropping higher 64 bits of a file id on some filesystems on Windows. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 66f21f746fa6a4..8611f8f73aff05 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -15138,8 +15138,6 @@ os_DirEntry_inode_impl(DirEntry *self) 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 _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),