[OpenAFS-devel] Fix for "0 bytes free" problem on winnt client
Yee Jiun Song
yeejiun@cs.berkeley.edu
Fri, 8 Mar 2002 13:40:36 -0800 (PST)
Hi
Jason Garman posted a problem sometime last month
about the fact that the windows client reports "0
bytes free" on drives mapped to AFS. I did a little
snooping around and found that the problem only occurs
on w2k/nt/xp but not on the win9x platforms. There
seems be a little quirk in the way the compiler works
on NT platforms. I'll first describe a hack around
this problem and then describe the problem/solution in
more detail.
To fix this, src\winnt\afsd\smb3.c needs to be
patched. There's a function in there called
"smb_ReceiveTran2QFSInfo". We need to make the
following change:
----------
switch (p->parmsp[0]) {
case 1: responseSize = 18; break;
// case 1: responseSize = sizeof(qi.u.allocInfo);
break;
case 2: responseSize = sizeof(qi.u.volumeInfo);
break;
case 0x102: responseSize =
sizeof(qi.u.FSvolumeInfo); break;
case 0x103: responseSize = sizeof(qi.u.FSsizeInfo);
break;
case 0x104: responseSize =
sizeof(qi.u.FSdeviceInfo); break;
case 0x105: responseSize =
sizeof(qi.u.FSattributeInfo); break;
default: return CM_ERROR_INVAL;
}
----------
The reason for the problem is that the Visual C++
compiler strangely pads all structs to a size that's a
multiple of 4 bytes. For example, consider the
following program:
struct myStruct {
int a;
short b;
};
void main() {
myStruct foo;
printf("size of foo is %d\n", sizeof(foo));
}
Although we expect the program to print "size of foo
is 6", it actually prints "size of foo is 8". This
problem appears to happen only on the NT platforms and
not on the win9x platforms. It causes the size of
qi.u.allocInfo to be reported as 20 instead of 18,
causing problems in returning the allocation
information. The change described above is just a
hack. Since I don't think it's a good idea to hardcode
the size of the structure, I'm still trying to find a
more "proper" solution for this. Setting the compiler
flag "Zp1" or "Zp2" doesn't work because it breaks
some code in other parts of the client. If anyone has
any ideas, please let me know.
Yee Jiun.
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/