Ok, so I started looking at the internals of dietlibc, and I noticed the data returned by getdents64 looks as I would expect, but the struct dirent64 does not match it. Apparently the way these things are being compiled it ends up with sizeof(uint64_t) = 4, so the struct fields don't line up.

I think I will be filing a bug against dietlibc in the morning. It seems compiling with "diet gcc -g -D_FILE_OFFSET_BITS=64" causes readdir to break, at least on sparc.

Ivan
(gdb) break getdents64
Breakpoint 2 at 0x116dc
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/ivan/deb/util-vserver-0.30.216-pre2864/src/showattr
vc_get_iattr(): Function not implemented
ERR     .

Breakpoint 2, 0x000116dc in getdents64 ()
(gdb) bt
#0  0x000116dc in getdents64 ()
#1  0x0001114c in readdir64 ()
#2  0x00010230 in Ereaddir (path=0x11730 ".")
    at ./ensc_wrappers/wrappers-dirent.hc:38
#3  iterateFilesystem (path=0x11730 ".") at src/fstool.c:83
#4  0x000106b8 in processFile (path=0x11730 ".") at src/fstool.c:162
#5  0x00010ae8 in main (argc=1, argv=<value optimized out>) at src/fstool.c:236
(gdb) disas
Dump of assembler code for function getdents64:
0x000116dc <getdents64+0>:      b  0x10e44 <__unified_syscall>
0x000116e0 <getdents64+4>:      mov  0x9a, %g1
End of assembler dump.
(gdb) fini
Run till exit from #0  0x000116dc in getdents64 ()
0x0001114c in readdir64 ()
(gdb) print o1
No symbol "o1" in current context.
(gdb) print $o1
$1 = -134234112
(gdb) print/x $o1
$2 = 0xf7ffc000
(gdb) x/10 0xf7ffc000
0xf7ffc000:     0x00000000      0x0000e105      0x00000000      0x033036bc
0xf7ffc010:     0x00200876      0x6c696d69      0x742e6300      0x00000000
0xf7ffc020:     0x00000000      0x0000e0c6
(gdb) print (char*) 0xf7ffc013
$3 = 0xf7ffc013 "vlimit.c"
(gdb) bt
#0  0x0001114c in readdir64 ()
#1  0x00010230 in Ereaddir (path=0x11730 ".")
    at ./ensc_wrappers/wrappers-dirent.hc:38
#2  iterateFilesystem (path=0x11730 ".") at src/fstool.c:83
#3  0x000106b8 in processFile (path=0x11730 ".") at src/fstool.c:162
#4  0x00010ae8 in main (argc=1, argv=<value optimized out>) at src/fstool.c:236
(gdb) fini
Run till exit from #0  0x0001114c in readdir64 ()
Ereaddir (path=0x11730 ".") at ./ensc_wrappers/wrappers-dirent.hc:40
40        FatalErrnoError(res==0 && errno!=0, "readdir()");
(gdb) print res
$4 = <value optimized out>
(gdb) print $o0
$5 = -134234112
(gdb) print $o1
$6 = 71472
(gdb) print/x $o0
$7 = 0xf7ffc000
(gdb) x/10 0xf7ffc000
0xf7ffc000:     0x00000000      0x0000e105      0x00000000      0x033036bc
0xf7ffc010:     0x00200876      0x6c696d69      0x742e6300      0x00000000
0xf7ffc020:     0x00000000      0x0000e0c6
(gdb) bt
#0  Ereaddir (path=0x11730 ".") at ./ensc_wrappers/wrappers-dirent.hc:40
#1  iterateFilesystem (path=0x11730 ".") at src/fstool.c:83
#2  0x000106b8 in processFile (path=0x11730 ".") at src/fstool.c:162
#3  0x00010ae8 in main (argc=1, argv=<value optimized out>) at src/fstool.c:236
(gdb) fini
Run till exit from #0  Ereaddir (path=0x11730 ".")
    at ./ensc_wrappers/wrappers-dirent.hc:40
86          if (ent==0) break;
(gdb) print ent
$8 = (struct dirent64 *) 0xf7ffc000
(gdb) print *ent
$9 = {d_ino = 0, d_off = 57605, d_reclen = 0, d_type = 0 '\000',
  d_name = "\000\003\060\066\274\000 \bvlimit.c", '\000' <repeats 11 
times>"\340, \306\000\000\000\000\003\251~\030\000 \btunctl.c", '\000' <repeats 
11 times>"\341, \b\000\000\000\000\003\254\336\340\000 \butil.h", '\000' 
<repeats 13 times>"\347, \246\000\000\000\000\004\267\204L\000 
\bvreboot.o\000\000\000\000\000\000\000\000\000\000\340\366\000\000\000\000\004\363\344\245\000(\bmask2prefix.c",
 '\000' <repeats 14 times>"\350, \001\000\000\000\000\006\211\325+\000 
\bexec-remount\000\000\000\000\000\000\000\340\356\000\000\000\000\a\242\023\065\000
 \bnattribute.c\000\000\000\000\000\000\000\347\351\000\000\000\000\b"...}
(gdb) print ent->d_name
$10 = "\000\003\060\066\274\000 \bvlimit.c", '\000' <repeats 11 times>"\340, 
\306\000\000\000\000\003\251~\030\000 \btunctl.c", '\000' <repeats 11 
times>"\341, \b\000\000\000\000\003\254\336\340\000 \butil.h", '\000' <repeats 
13 times>"\347, \246\000\000\000\000\004\267\204L\000 
\bvreboot.o\000\000\000\000\000\000\000\000\000\000\340\366\000\000\000\000\004\363\344\245\000(\bmask2prefix.c",
 '\000' <repeats 14 times>"\350, \001\000\000\000\000\006\211\325+\000 
\bexec-remount\000\000\000\000\000\000\000\340\356\000\000\000\000\a\242\023\065\000
 \bnattribute.c\000\000\000\000\000\000\000\347\351\000\000\000\000\b"...
(gdb) print &ent->d_name
$11 = (char (*)[256]) 0xf7ffc00b
(gdb) print &ent->d_ino
$12 = (long unsigned int *) 0xf7ffc000
(gdb) print &ent->d_off
$13 = (long int *) 0xf7ffc004
(gdb) print &ent->d_reclen
$14 = (short unsigned int *) 0xf7ffc008
(gdb) print &ent->d_type
$15 = (unsigned char *) 0xf7ffc00a ""
(gdb) print sizeof(struct dirent64)
$16 = 268
(gdb) print sizeof(struct dirent)
No struct type named dirent.
(gdb) print sizeof(ent->d_ino)
$17 = 4
(gdb) print sizeof(uint64_t)
$18 = 4
(gdb)

Reply via email to