@@ -176,17 +176,11 @@ _close_fds_by_brute_force(int start_fd, int end_fd, PyObject *py_fds_to_keep)
176176 * This structure is very old and stable: It will not change unless the kernel
177177 * chooses to break compatibility with all existing binaries. Highly Unlikely.
178178 */
179- struct linux_dirent {
180- #if defined(__x86_64__ ) && defined(__ILP32__ )
181- /* Support the wacky x32 ABI (fake 32-bit userspace speaking to x86_64
182- * kernel interfaces) - https://sites.google.com/site/x32abi/ */
179+ struct linux_dirent64 {
183180 unsigned long long d_ino ;
184- unsigned long long d_off ;
185- #else
186- unsigned long d_ino ; /* Inode number */
187- unsigned long d_off ; /* Offset to next linux_dirent */
188- #endif
181+ long long d_off ;
189182 unsigned short d_reclen ; /* Length of this linux_dirent */
183+ unsigned char d_type ;
190184 char d_name [256 ]; /* Filename (null-terminated) */
191185};
192186
@@ -228,16 +222,16 @@ _close_open_fd_range_safe(int start_fd, int end_fd, PyObject* py_fds_to_keep)
228222 _close_fds_by_brute_force (start_fd , end_fd , py_fds_to_keep );
229223 return ;
230224 } else {
231- char buffer [sizeof (struct linux_dirent )];
225+ char buffer [sizeof (struct linux_dirent64 )];
232226 int bytes ;
233- while ((bytes = syscall (SYS_getdents , fd_dir_fd ,
234- (struct linux_dirent * )buffer ,
227+ while ((bytes = syscall (SYS_getdents64 , fd_dir_fd ,
228+ (struct linux_dirent64 * )buffer ,
235229 sizeof (buffer ))) > 0 ) {
236- struct linux_dirent * entry ;
230+ struct linux_dirent64 * entry ;
237231 int offset ;
238232 for (offset = 0 ; offset < bytes ; offset += entry -> d_reclen ) {
239233 int fd ;
240- entry = (struct linux_dirent * )(buffer + offset );
234+ entry = (struct linux_dirent64 * )(buffer + offset );
241235 if ((fd = _pos_int_from_ascii (entry -> d_name )) < 0 )
242236 continue ; /* Not a number. */
243237 if (fd != fd_dir_fd && fd >= start_fd && fd < end_fd &&
0 commit comments