]> git.hungrycats.org Git - linux/commitdiff
[PATCH] stat nlink resolution fix
authorChris Wedgwood <cw@f00f.org>
Mon, 14 Jun 2004 16:01:29 +0000 (09:01 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 14 Jun 2004 16:01:29 +0000 (09:01 -0700)
Some filesystems can get overflows when their link-count exceeds
65534.  This patch increases the kernels internal resolution for this
and also has a check for the old-system call paths to return and error
(-EOVERFLOW) as required (as suggested by Al Viro).

Signed-off-by: Chris Wedgwood <cw@f00f.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/stat.c
include/linux/stat.h

index f28e994d7b40232749a86c6176068582c7639019..6bda9bfae2fb5c20cb1ce5954fe8be302d9dad86 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -131,6 +131,8 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta
        tmp.st_ino = stat->ino;
        tmp.st_mode = stat->mode;
        tmp.st_nlink = stat->nlink;
+       if (tmp.st_nlink != stat->nlink)
+               return -EOVERFLOW;
        SET_UID(tmp.st_uid, stat->uid);
        SET_GID(tmp.st_gid, stat->gid);
        tmp.st_rdev = old_encode_dev(stat->rdev);
@@ -199,6 +201,8 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
        tmp.st_ino = stat->ino;
        tmp.st_mode = stat->mode;
        tmp.st_nlink = stat->nlink;
+       if (tmp.st_nlink != stat->nlink)
+               return -EOVERFLOW;
        SET_UID(tmp.st_uid, stat->uid);
        SET_GID(tmp.st_gid, stat->gid);
 #if BITS_PER_LONG == 32
index b907fb25a40f67d06a8f05fa25046dc0c624091f..8ff2a122dfefc99a3b02431ef3af63a681016d82 100644 (file)
@@ -60,7 +60,7 @@ struct kstat {
        unsigned long   ino;
        dev_t           dev;
        umode_t         mode;
-       nlink_t         nlink;
+       unsigned int    nlink;
        uid_t           uid;
        gid_t           gid;
        dev_t           rdev;