[Top] [All Lists]

readdir() problem when using -D_FILE_OFFSET_BITS=64 in gcc

To: <linux-xfs@xxxxxxxxxxx>
Subject: readdir() problem when using -D_FILE_OFFSET_BITS=64 in gcc
From: Min.Yuan@xxxxxxxxxxxx (Min Yuan)
Date: Thu, 20 Sep 2001 11:56:42 -0400
Sender: owner-linux-xfs@xxxxxxxxxxx
Redhat7.1 supports large file(>2GB), but you have to add -D_FILE_OFFSET_BITS=64 to gcc
The following is a very simple program:
#include <sys/types.h>
#include <stdio.h>
#include <dirent.h>
int main() {
DIR *dr;
struct dirent *dent;
dr = opendir("/var/run");
while ((dent = readdir(dr)) != NULL) {
 printf("inode:%d and d_name:%s\n", dent->d_ino, dent->d_name);
return 0;
if it is compiled without -D_FILE_OFFSET_BITS=64, readdir() works fine.
inode:293788 and d_name:.
inode:97921 and d_name:..
inode:881483 and d_name:netreport
inode:294131 and d_name:utmp
inode:392276 and d_name:news
inode:115000 and d_name:named
inode:115290 and d_name:sudo
inode:1355948 and d_name:mysqld
inode:115698 and d_name:pvm3
inode:296305 and d_name:runlevel.dir
inode:296306 and d_name:syslogd.pid
inode:296307 and d_name:klogd.pid
inode:296308 and d_name:apmd.pid
inode:296309 and d_name:atd.pid
inode:296310 and d_name:sshd.pid
inode:296311 and d_name:xinetd.pid
inode:296312 and d_name:sendmail.pid
inode:296314 and d_name:crond.pid
inode:296313 and d_name:gpm.pid
inode:296315 and d_name:xfs.pid
inode:296316 and d_name:gdm.pid
But if it is compiled with -D_FILE_OFFSET_BITS=64, then readdir() has problem in getting file name.
inode:293788 and d_name:(null)
inode:97921 and d_name:(null)
inode:881483 and d_name:(null)
inode:294131 and d_name:(null)
inode:392276 and d_name:(null)
inode:115000 and d_name:(null)
inode:115290 and d_name:(null)
inode:1355948 and d_name:(null)
inode:115698 and d_name:(null)
inode:296305 and d_name:(null)
inode:296306 and d_name:(null)
inode:296307 and d_name:(null)
inode:296308 and d_name:(null)
inode:296309 and d_name:(null)
inode:296310 and d_name:(null)
inode:296311 and d_name:(null)
inode:296312 and d_name:(null)
inode:296314 and d_name:(null)
inode:296313 and d_name:(null)
inode:296315 and d_name:(null)
inode:296316 and d_name:(null)
WHY? Is there any way to solve it?

Min Yuan
<Prev in Thread] Current Thread [Next in Thread>