All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olaf Kirch <okir@suse.de>
To: akpm@osdl.org
Cc: nfs@lists.sourceforge.net
Subject: [PATCH] Fix 32bit statfs on NFS
Date: Mon, 5 Apr 2004 17:09:14 +0200	[thread overview]
Message-ID: <20040405150914.GT11477@suse.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

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
-- 
Olaf Kirch     |  The Hardware Gods hate me.
okir@suse.de   |
---------------+ 

[-- Attachment #2: statfs-no-eoverflow --]
[-- Type: text/plain, Size: 771 bytes --]

--- linux-2.6.4/fs/open.c.overflow	2004-04-01 22:22:25.000000000 +0200
+++ linux-2.6.4/fs/open.c	2004-04-01 22:27:13.000000000 +0200
@@ -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;

                 reply	other threads:[~2004-04-05 15:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040405150914.GT11477@suse.de \
    --to=okir@suse.de \
    --cc=akpm@osdl.org \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.