[2.5] unsigned int type for i_nlink field of struct inode
PATCH 1/1 [2.5] unsigned int type for i_nlink field of struct inode
Hello!
Per your suggestion I just changed i_nlink type in include/linux/fs.h to unsigned int. Also just so that userspace people won't see negative st_nlink numbers, I implemented simple conversion in fs/stat.c::generic_fillattr() and define that calculates maximum number that fits into nlink_t in include/linux/stat.h.
Filesystems that both allow i_nlink to be bigger that 15 bit and have their own fillattr implementation should do somethink like I did in generic_fillattr.
Please apply.
Bye,
Oleg
===== fs/stat.c 1.13 vs edited =====
fs/stat.c +1 -1
@@ -21,7 +21,7 @@ stat->dev = inode->i_dev; stat->ino = inode->i_ino; stat->mode = inode->i_mode; - stat->nlink = inode->i_nlink; + stat->nlink = min_t(unsigned int, inode->i_nlink, MAX_NLINK_T); stat->uid = inode->i_uid; stat->gid = inode->i_gid; stat->rdev =kdev_t_to_nr (inode->i_rdev);
===== include/linux/fs.h 1.159 vs edited =====
include/linux/fs.h +1 -1
@@ -368,7 +368,7 @@atomic_t i_count;dev_t i_dev;umode_t i_mode; -nlink_t i_nlink; +unsigned int i_nlink;uid_t i_uid;gid_t i_gid;kdev_t i_rdev;
===== include/linux/stat.h 1.2 vs edited =====
include/linux/stat.h +3 -0
@@ -55,6 +55,9 @@#include <linux/types.h> +/* May be different for different architectures */ +#define MAX_NLINK_T (nlink_t)((((nlink_t) -1) > 0)?~0:((1u<<(sizeof(nlink_t)*8-1))-1)) +struct kstat {unsigned long ino;dev_t dev;