Fix 32bit statfs on NFS
Subsystems (3)
PATCH 1/1 Fix 32bit statfs on NFS
Hi Andrew,
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.
Olaf
Signature · 3 lines
Olaf Kirch | The Hardware Gods hate me. [email protected] | ---------------+
fs/open.c renamed from fs/open.c.overflow +9 -2
@@ -57,10 +57,17 @@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;