Received: (from majordomo@localhost) by oss.sgi.com (8.11.2/8.11.3) id f8KFsYi26656 for linux-xfs-outgoing; Thu, 20 Sep 2001 08:54:34 -0700 Received: from ntserv1.vytalnet.com (vytalnet.com [209.121.88.10]) by oss.sgi.com (8.11.2/8.11.3) with SMTP id f8KFsLe26629 for ; Thu, 20 Sep 2001 08:54:22 -0700 Received: from pcminy ([209.121.88.254]) by ntserv1.vytalnet.com (Post.Office MTA v3.5.3 release 223 ID# 0-54530U100L2S100V35) with SMTP id com for ; Thu, 20 Sep 2001 11:54:10 -0400 Message-ID: <02af01c141ec$db39cc50$4201a8c0@vytalnet.com> From: Min.Yuan@VytalNet.com (Min Yuan) To: Subject: readdir() problem when using -D_FILE_OFFSET_BITS=64 in gcc Date: Thu, 20 Sep 2001 11:56:42 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_02AC_01C141CB.507F6FA0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Sender: owner-linux-xfs@oss.sgi.com Precedence: bulk This is a multi-part message in MIME format. ------=_NextPart_000_02AC_01C141CB.507F6FA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Redhat7.1 supports large file(>2GB), but you have to add = -D_FILE_OFFSET_BITS=3D64 to gcc =20 The following is a very simple program: #include #include #include int main() { DIR *dr; struct dirent *dent; dr =3D opendir("/var/run"); while ((dent =3D readdir(dr)) !=3D 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=3D64, readdir() works = fine. ./a.out 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=3D64, then readdir() has = problem in getting file name. ./a.out 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=20 ------=_NextPart_000_02AC_01C141CB.507F6FA0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Redhat7.1 supports large file(>2GB), = but you=20 have to add -D_FILE_OFFSET_BITS=3D64 to gcc
 
The following is a very simple=20 program:
 
#include = <sys/types.h>
#include=20 <stdio.h>
#include <dirent.h>
 
int main() {
DIR *dr;
struct = dirent=20 *dent;
dr =3D opendir("/var/run");
while ((dent =3D readdir(dr)) = !=3D NULL)=20 {
 printf("inode:%d and d_name:%s\n", dent->d_ino,=20 dent->d_name);
}
return 0;
}
 
if it is compiled without=20 -D_FILE_OFFSET_BITS=3D64, readdir() works fine.
./a.out
inode:293788 and = d_name:.
inode:97921 and=20 d_name:..
inode:881483 and d_name:netreport
inode:294131 and=20 d_name:utmp
inode:392276 and d_name:news
inode:115000 and=20 d_name:named
inode:115290 and d_name:sudo
inode:1355948 and=20 d_name:mysqld
inode:115698 and d_name:pvm3
inode:296305 and=20 d_name:runlevel.dir
inode:296306 and = d_name:syslogd.pid
inode:296307 and=20 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=20 d_name:xinetd.pid
inode:296312 and = d_name:sendmail.pid
inode:296314 and=20 d_name:crond.pid
inode:296313 and d_name:gpm.pid
inode:296315 and=20 d_name:xfs.pid
inode:296316 and d_name:gdm.pid
 
But if it is compiled = with=20 -D_FILE_OFFSET_BITS=3D64, then readdir() has problem in getting file=20 name.
./a.out
inode:293788 and = d_name:(null)
inode:97921 and=20 d_name:(null)
inode:881483 and d_name:(null)
inode:294131 and=20 d_name:(null)
inode:392276 and d_name:(null)
inode:115000 and=20 d_name:(null)
inode:115290 and d_name:(null)
inode:1355948 and=20 d_name:(null)
inode:115698 and d_name:(null)
inode:296305 and=20 d_name:(null)
inode:296306 and d_name:(null)
inode:296307 and=20 d_name:(null)
inode:296308 and d_name:(null)
inode:296309 and=20 d_name:(null)
inode:296310 and d_name:(null)
inode:296311 and=20 d_name:(null)
inode:296312 and d_name:(null)
inode:296314 and=20 d_name:(null)
inode:296313 and d_name:(null)
inode:296315 and=20 d_name:(null)
inode:296316 and d_name:(null)
 
WHY? Is there any way to solve = it?

 
Min Yuan =
------=_NextPart_000_02AC_01C141CB.507F6FA0--