[Python-checkins] cpython (merge 3.3 -> default): Fixes Issue #16962: Use getdents64 instead of the obsolete getdents syscall
gregory.p.smith
python-checkins at python.org
Sun Mar 3 19:53:35 CET 2013
http://hg.python.org/cpython/rev/7ab1c55fcf82
changeset: 82461:7ab1c55fcf82
parent: 82459:f1d3fbcd837d
parent: 82460:30e643e36bae
user: Gregory P. Smith <greg at krypto.org>
date: Sun Mar 03 10:53:27 2013 -0800
summary:
Fixes Issue #16962: Use getdents64 instead of the obsolete getdents syscall
in the subprocess module on Linux.
files:
Misc/NEWS | 3 +++
Modules/_posixsubprocess.c | 22 ++++++++--------------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -273,6 +273,9 @@
Library
-------
+- Issue #16962: Use getdents64 instead of the obsolete getdents syscall
+ in the subprocess module on Linux.
+
- Issue #16935: unittest now counts the module as skipped if it raises SkipTest,
instead of counting it as an error. Patch by Zachary Ware.
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -176,17 +176,11 @@
* This structure is very old and stable: It will not change unless the kernel
* chooses to break compatibility with all existing binaries. Highly Unlikely.
*/
-struct linux_dirent {
-#if defined(__x86_64__) && defined(__ILP32__)
- /* Support the wacky x32 ABI (fake 32-bit userspace speaking to x86_64
- * kernel interfaces) - https://sites.google.com/site/x32abi/ */
+struct linux_dirent64 {
unsigned long long d_ino;
- unsigned long long d_off;
-#else
- unsigned long d_ino; /* Inode number */
- unsigned long d_off; /* Offset to next linux_dirent */
-#endif
+ long long d_off;
unsigned short d_reclen; /* Length of this linux_dirent */
+ unsigned char d_type;
char d_name[256]; /* Filename (null-terminated) */
};
@@ -228,16 +222,16 @@
_close_fds_by_brute_force(start_fd, end_fd, py_fds_to_keep);
return;
} else {
- char buffer[sizeof(struct linux_dirent)];
+ char buffer[sizeof(struct linux_dirent64)];
int bytes;
- while ((bytes = syscall(SYS_getdents, fd_dir_fd,
- (struct linux_dirent *)buffer,
+ while ((bytes = syscall(SYS_getdents64, fd_dir_fd,
+ (struct linux_dirent64 *)buffer,
sizeof(buffer))) > 0) {
- struct linux_dirent *entry;
+ struct linux_dirent64 *entry;
int offset;
for (offset = 0; offset < bytes; offset += entry->d_reclen) {
int fd;
- entry = (struct linux_dirent *)(buffer + offset);
+ entry = (struct linux_dirent64 *)(buffer + offset);
if ((fd = _pos_int_from_ascii(entry->d_name)) < 0)
continue; /* Not a number. */
if (fd != fd_dir_fd && fd >= start_fd && fd < end_fd &&
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list