cmatthew / Lind-misc

Misc files for the Lind project
3 stars 3 forks source link

getdirents does not respect requested size #32

Closed cmatthew closed 12 years ago

cmatthew commented 12 years ago

getdirents has a size parameter which is the size of the buffer it has allocated for directory entires. Currently we do not respect that value.

The reason that it is hard to actually do is that you hace to return the number of entires that creates the number of dirent structs which will be smaller than the buffer size. But at the lind fs level, we don't normally keep much information about C sizes.

I think the dirent size is something like 20bytes + length of C string. Where 20 bytes is all the header stuff in the dirent struct.

To rectify this, we need to integrate some knowledge of the size of dirents into the getdirents_syscall function.

NitinJami commented 12 years ago

The size of dirent is : 20 + len(filename) + zero padding,

where the total size is of multiple of 8 which is either 24, 32 or 40 bytes etc.

So, the starting size that should be given as 24bytes. Anything less than that EINVAL is raised

NitinJami commented 12 years ago

I think it respects now, also I am returning size of each dirent.