l4vfs and opendir()/readdir()
Valery V. Sedletski
_valerius at mail.ru
Sun Jun 20 12:36:09 CEST 2010
Hi all.
I am trying to mount a flat file system by simple_file_server in l4vfs tree and then navigating over the file
systen, i.e. opening/reading the root directory by opendir()/readdir(), searching the files in the directory and
then opening them by open().
Doing this, I found that opendir() sometimes fails, trying to allocate a big (almost 2 gigabytes) dataspace at
dm_phys. When I tried to compile my program and l4vfs servers with debug output, I had seen that this is
done by calloc() function in opendir() function in l4\pkg\uclibc\lib\contrib\uclibc\libc\misc\dirent\opendir.c:
if (!(ptr->dd_buf = calloc(1, ptr->dd_max))) {
free(ptr);
nomem_close_and_ret:
close(fd);
__set_errno(ENOMEM);
return NULL;
}
before that, it makes fstat() and assigns ptr->dd_max to a FS block size from the stat buffer. After looking into
l4vfs backends and simple_file_server, I had seen that the FS block size is left undefined, so it tried to use a
big random value which appeared to be in a stat buffer.
So, the fix can be simple -- set FS blksize to something (I set it to 512 bytes). And also, I added copying of that
size from the stat buffer in stat() and fstat() functions in libc l4vfs io backend.
So, my patch is attached to this letter
WBR,
valery
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stat.diff
Type: application/octet-stream
Size: 1398 bytes
Desc: not available
URL: <http://os.inf.tu-dresden.de/pipermail/l4-hackers/attachments/20100620/39c59396/attachment.obj>
More information about the l4-hackers
mailing list