[OpenAFS-devel] afs_buffer.c:DRead()
Nickolai Zeldovich
kolya@MIT.EDU
Tue, 12 Nov 2002 18:42:52 -0500
> tfile = afs_CFileOpen(fid[0]);
> sizep = (afs_int32 *)tfile;
> if (page * AFS_BUFFER_PAGESIZE >= *sizep) {
> give_up...
>
> Since tfile is really a struct osi_file *, this can't possibly work except
> by accident.
This does seem very backwards, but as far as I can tell, it actually does
work. As afs_osi.h says:
struct osi_file {
afs_int32 size; /* file size in bytes XXX Must be first field XXX */
...
}
so sizep points at osi_file.size, and dereferencing it should infact give
you the size value. I'm really unclear on why they decided to manually
decode struct fields, instead of using, oh, say, tfile->size. Oh, I guess
tfile is void*; but casting it to osi_file seems like a much better way
to do it than this..
-- kolya