Re: ltp getdents syscalls testcases and 2.6.27-rcX

Previous thread: [kernel-abi] symbol versioning vs. out-of-tree modules. by Paweł on Wednesday, September 24, 2008 - 8:07 am. (16 messages)

Next thread: [PATCH] drivers/usb/host: Use an IS_ERR test rather than a NULL test by Julien Brunel on Wednesday, September 24, 2008 - 9:00 am. (1 message)
From: Adrian Bunk
Date: Wednesday, September 24, 2008 - 8:50 am

[ kernel people added to Cc ]


Thanks for your report.

I missed this since the kernel sys_getdents() did not use the
"struct dirent" from the header but an own "struct linux_dirent".

It might be safe since the LTP tests don't seem to care whether 
getdents() returns nonsense.

But it is not correct since the reason why I removed this struct from 
the userspace headers was that the kernel and libc structs are
*different*.

E.g. when I enable the commented out code in getdents01.c I get the 
expected result that using <dirent.h> instead of <linux/dirent.h> 
changes a PASS into a FAIL. [1]

IMHO the solution is something like:
- move "struct linux_dirent" from fs/readdir.c to include/linux/dirent.h
- re-export linux/dirent.h to userspace
- change getdents(2) to consistently use "struct linux_dirent"

Questions to fsdevel:
- Do we need to preserve API compatibility with compatibility #define's
  for struct dirent{,64} here?
- LTP does malloc(sizeof(struct dirent)).

cu
Adrian

[1] I don't know whether the code is valid and guaranteed to pass,
    but it's obvious why it fails after the #include change

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

--

From: Michael Kerrisk
Date: Thursday, October 2, 2008 - 4:37 am

I've made some changes to the readdir(2) and getdents(2) man pages to
make it clearer that the "dirent" structures used by these to syscalls
are different from one another (old_linux_dirent vs linux_dirent), and
also different from that used by glibc's readdir(3). (dirent)  The
changes are already pushed out to man-pages git.

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
--

Previous thread: [kernel-abi] symbol versioning vs. out-of-tree modules. by Paweł on Wednesday, September 24, 2008 - 8:07 am. (16 messages)

Next thread: [PATCH] drivers/usb/host: Use an IS_ERR test rather than a NULL test by Julien Brunel on Wednesday, September 24, 2008 - 9:00 am. (1 message)