This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: getdents64 problem


Ulrich Drepper wrote:
> 
> Mogens Kjaer <mk@crc.dk> writes:
> 
> > *** getdents.c  Thu Jan 18 14:58:26 2001
> > --- getdents.c.ORIG     Fri Jan 19 12:31:19 2001
> > ***************
> > *** 157,165 ****
> >               if ((sizeof (dp->d_ino) != sizeof (kdp->d_ino)
> >                    && dp->d_ino != d_ino)
> >                   || (sizeof (dp->d_off) != sizeof (kdp->d_off)
> > !                     && (dp->d_off != d_off && dp->d_off != -1)))
> >                 {
> > -                 /* MK patch for d_off == -1 */
> >                   /* Overflow.  If there was at least one entry
> >                      before this one, return them without error,
> >                      otherwise signal overflow.  */
> > --- 157,164 ----
> >               if ((sizeof (dp->d_ino) != sizeof (kdp->d_ino)
> >                    && dp->d_ino != d_ino)
> >                   || (sizeof (dp->d_off) != sizeof (kdp->d_off)
> > !                     && dp->d_off != d_off))
> >                 {
> >                   /* Overflow.  If there was at least one entry
> >                      before this one, return them without error,
> >                      otherwise signal overflow.  */
> 
> I cannot see that this is correct.  Send me the output of `strace -v'
> of a program using getdents.  Please note the -v parameter for strace.

OK, I have the following directory:

$ ls -laF
total 0
drwxr-xr-x    2 mk       carlsber       48 Jan 22 11:09 ./
drwxrwxr-x    3 mk       carlsber      119 Jan 22 11:09 ../
-rw-r--r--    1 mk       carlsber        0 Jan 22 11:09 fil1
-rw-r--r--    1 mk       carlsber        0 Jan 22 11:09 fil2
-rw-r--r--    1 mk       carlsber        0 Jan 22 11:09 fil3

If I run the testprogram with the original glibc library, I get the
following output:

$ t1
.
..
fil1
fil2

And the output from strace -v:

...
getpid()                                = 11643
open("/dev/null", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = -1 ENOTDIR (Not a
directory)
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 4
fstat64(4, {st_dev=makedev(0, 9), st_ino=54707214, st_mode=S_IFDIR|0755,
st_nlink=2, st_uid=500, st_gid=500, st_blksize=65536, st_blocks=0,
st_size=48, st_atime=2001/01/22-11:09:46, st_mtime=2001/01/22-11:09:46,
st_ctime=2001/01/22-11:09:46}) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
brk(0)                                  = 0x80496d8
brk(0x8059720)                          = 0x8059720
brk(0x805a000)                          = 0x805a000
getdents64(4, {{d_ino=54707214, d_off=5934, d_reclen=24, d_type=0,
d_name="."} {d_ino=118079378, d_off=215643697, d_reclen=24, d_type=0,
d_name=".."} {d_ino=54707218, d_off=215643698, d_reclen=24, d_type=0,
d_name="fil1"} {d_ino=54707220, d_off=215643699, d_reclen=24, d_type=0,
d_name="fil2"} {d_ino=54947076, d_off=4294967295, d_reclen=24, d_type=0,
d_name="fil3"}}, 65536) = 120
lseek(4, 215643699, SEEK_SET)           = 215643699
fstat64(1, {st_dev=makedev(0, 5), st_ino=2, st_mode=S_IFCHR|0620,
st_nlink=1, st_uid=500, st_gid=5, st_blksize=1024, st_blocks=0,
st_rdev=makedev(136, 0), st_atime=2001/01/22-11:09:15,
st_mtime=2001/01/22-11:09:15, st_ctime=2001/01/22-11:02:16}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x40017000
ioctl(1, TCGETS, {c_iflags=0x500, c_oflags=0x5, c_cflags=0xbf,
c_lflags=0x8a3b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00\xf7\x06\x00\x00\x00\x00\x00\x00\xd0\x0d\x14\x40\x71"})
= 0
write(1, ".\n", 2)                      = 2
write(1, "..\n", 3)                     = 3
write(1, "fil1\n", 5)                   = 5
write(1, "fil2\n", 5)                   = 5
getdents64(4, {{d_ino=54947076, d_off=4294967295, d_reclen=24, d_type=0,
d_name="fil3"}}, 65536) = 24
close(4)                                = 0
munmap(0x40017000, 4096)                = 0
_exit(0)                                = ?

And with the patched glibc the output is:

$ LD_LIBRARY_PATH=/home/mk/test-glibc/lib
/home/mk/test-glibc/lib/ld-linux.so.2 /usr/bin/strace -v -o/tmp/nfsny
../../t2/t1
.
..
fil1
fil2
fil3

And /tmp/nfsny contains:

...
getpid()                                = 11652
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 4
fstat64(4, {st_dev=makedev(0, 9), st_ino=54707214, st_mode=S_IFDIR|0755,
st_nlink=2, st_uid=500, st_gid=500, st_blksize=65536, st_blocks=0,
st_size=48, st_atime=2001/01/22-10:09:46, st_mtime=2001/01/22-10:09:46,
st_ctime=2001/01/22-10:09:46}) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
brk(0)                                  = 0x80496d8
brk(0x8059720)                          = 0x8059720
brk(0x805a000)                          = 0x805a000
getdents64(4, {{d_ino=54707214, d_off=5934, d_reclen=24, d_type=0,
d_name="."} {d_ino=118079378, d_off=215643697, d_reclen=24, d_type=0,
d_name=".."} {d_ino=54707218, d_off=215643698, d_reclen=24, d_type=0,
d_name="fil1"} {d_ino=54707220, d_off=215643699, d_reclen=24, d_type=0,
d_name="fil2"} {d_ino=54947076, d_off=4294967295, d_reclen=24, d_type=0,
d_name="fil3"}}, 65536) = 120
fstat64(1, {st_dev=makedev(0, 5), st_ino=2, st_mode=S_IFCHR|0620,
st_nlink=1, st_uid=500, st_gid=5, st_blksize=1024, st_blocks=0,
st_rdev=makedev(136, 0), st_atime=2001/01/22-10:09:15,
st_mtime=2001/01/22-10:09:15, st_ctime=2001/01/22-10:02:16}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x40139000
ioctl(1, TCGETS, {c_iflags=0x500, c_oflags=0x5, c_cflags=0xbf,
c_lflags=0x8a3b, c_line=0,
c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00\x0c\xe4\xff\xbf\x4f\x04\x00\x00\x5d\x05\x00\x00\xea"})
= 0
write(1, ".\n", 2)                      = 2
write(1, "..\n", 3)                     = 3
write(1, "fil1\n", 5)                   = 5
write(1, "fil2\n", 5)                   = 5
write(1, "fil3\n", 5)                   = 5
getdents64(4, {}, 65536)                = 0
close(4)                                = 0
munmap(0x40139000, 4096)                = 0
_exit(0)                                = ?

I hope this is of some help...

Mogens
-- 
Mogens Kjaer, Carlsberg Laboratory, Dept. of Chemistry
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Fax: +45 33 27 47 08
Email: mk@crc.dk Homepage: http://www.crc.dk

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]