From 5b2785a167df52499abd52accdcb3a4c9d74451c Mon Sep 17 00:00:00 2001 From: Chris Wedgwood Date: Mon, 14 Jun 2004 09:01:29 -0700 Subject: [PATCH] [PATCH] stat nlink resolution fix 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 Signed-off-by: Linus Torvalds --- fs/stat.c | 4 ++++ include/linux/stat.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/stat.c b/fs/stat.c index f28e994d7b402..6bda9bfae2fb5 100644 --- 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 diff --git a/include/linux/stat.h b/include/linux/stat.h index b907fb25a40f6..8ff2a122dfefc 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -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; -- 2.53.0