Commit 678736c9 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix 32bit statfs on NFS

From: Olaf Kirch <okir@suse.de>

The attached patch fixes a problem with the 32bit statfs call on NFS file
systems.  Some NFS servers return a value of -1 for the f_files and f_ffree.
The current code would think this is a 64bit value that cannot be converted
to 32bits.  Consequently, the system call would always fail.

The patch adds two special if() to detect a value of -1 for f_files and
f_ffree.
parent a11317b1
......@@ -57,10 +57,19 @@ static int vfs_statfs_native(struct super_block *sb, struct statfs *buf)
memcpy(buf, &st, sizeof(st));
else {
if (sizeof buf->f_blocks == 4) {
if ((st.f_blocks | st.f_bfree |
st.f_bavail | st.f_files | st.f_ffree) &
if ((st.f_blocks | st.f_bfree | st.f_bavail) &
0xffffffff00000000ULL)
return -EOVERFLOW;
/*
* f_files and f_ffree may be -1; it's okay to stuff
* that into 32 bits
*/
if (st.f_files != 0xffffffffffffffffULL &&
(st.f_files & 0xffffffff00000000ULL))
return -EOVERFLOW;
if (st.f_ffree != 0xffffffffffffffffULL &&
(st.f_ffree & 0xffffffff00000000ULL))
return -EOVERFLOW;
}
buf->f_type = st.f_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment