mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] stat nlink resolution fix
@ 2004-06-15  5:55 Chris Wedgwood
  2004-06-15 14:56 ` Jörn Engel
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Wedgwood @ 2004-06-15  5:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: LKML, viro

(As already discussed)

Linus,

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>

diff -Nru a/fs/stat.c b/fs/stat.c
--- a/fs/stat.c	2004-06-14 17:40:21 -07:00
+++ b/fs/stat.c	2004-06-14 17:40:21 -07:00
@@ -131,6 +131,8 @@
 	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 @@
 	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 -Nru a/include/linux/stat.h b/include/linux/stat.h
--- a/include/linux/stat.h	2004-06-14 17:40:21 -07:00
+++ b/include/linux/stat.h	2004-06-14 17:40:21 -07:00
@@ -60,7 +60,7 @@
 	unsigned long	ino;
 	dev_t		dev;
 	umode_t		mode;
-	nlink_t		nlink;
+	unsigned int	nlink;
 	uid_t		uid;
 	gid_t		gid;
 	dev_t		rdev;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] stat nlink resolution fix
  2004-06-15  5:55 [PATCH] stat nlink resolution fix Chris Wedgwood
@ 2004-06-15 14:56 ` Jörn Engel
  2004-06-15 18:20   ` Chris Wedgwood
  0 siblings, 1 reply; 3+ messages in thread
From: Jörn Engel @ 2004-06-15 14:56 UTC (permalink / raw)
  To: Chris Wedgwood; +Cc: Linus Torvalds, LKML, viro

On Mon, 14 June 2004 22:55:07 -0700, Chris Wedgwood wrote:
> 
> 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>
> 
> diff -Nru a/include/linux/stat.h b/include/linux/stat.h
> --- a/include/linux/stat.h	2004-06-14 17:40:21 -07:00
> +++ b/include/linux/stat.h	2004-06-14 17:40:21 -07:00
> @@ -60,7 +60,7 @@
>  	unsigned long	ino;
>  	dev_t		dev;
>  	umode_t		mode;
> -	nlink_t		nlink;
> +	unsigned int	nlink;
>  	uid_t		uid;
>  	gid_t		gid;
>  	dev_t		rdev;

Just for me to get a clue, what would break if the definition of
nlink_t changed?

Jörn

-- 
Fancy algorithms are buggier than simple ones, and they're much harder
to implement. Use simple algorithms as well as simple data structures.
-- Rob Pike

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] stat nlink resolution fix
  2004-06-15 14:56 ` Jörn Engel
@ 2004-06-15 18:20   ` Chris Wedgwood
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Wedgwood @ 2004-06-15 18:20 UTC (permalink / raw)
  To: J?rn Engel; +Cc: Linus Torvalds, LKML, viro

On Tue, Jun 15, 2004 at 04:56:25PM +0200, J?rn Engel wrote:

> Just for me to get a clue, what would break if the definition of
> nlink_t changed?

It's derived from __kernel_nlink_t which is exported to userspace
(well, glibc headers).


  --cw

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-06-15 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-15  5:55 [PATCH] stat nlink resolution fix Chris Wedgwood
2004-06-15 14:56 ` Jörn Engel
2004-06-15 18:20   ` Chris Wedgwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®