Re: [PATCH] sysfs: Optionally count subdirectories to support buggyapplications

From: Jiri Slaby
Date: Wed Feb 01 2012 - 17:35:29 EST


On 02/01/2012 11:21 PM, Eric W. Biederman wrote:
> --- a/fs/sysfs/Kconfig
> +++ b/fs/sysfs/Kconfig
> @@ -21,3 +21,18 @@ config SYSFS
> example, "root=03:01" for /dev/hda1.
>
> Designers of embedded systems may wish to say N here to conserve space.
> +
> +config SYSFS_COUNT_LINKS
> + bool "sysfs count subdirectoires to support buggy applications"
> + default n
> + help
> +
> + Increase the memory and cpu untilization of sysfs by maintaining
> + by maintaining a count of how hard links from subdirectories a

by maintaining only once.

of how "many"?

> + directory has. This allows sysfs to report the directory nlink
> + as the number of subdirectories plus two. With out this enabled
> + sysfs will report the nlink of all directories as 1, which is
> + the standard way of indicating that the number of subdirectoires
> + is not tracked.
> +
> + Unless you know you need this say N here.

You should put the opposite here. "If you are sure you don't need it,
say N."

> --- a/fs/sysfs/sysfs.h
> +++ b/fs/sysfs/sysfs.h
...
> @@ -127,6 +130,41 @@ do { \
> #define sysfs_dirent_init_lockdep(sd) do {} while(0)
> #endif
>
> +#ifdef CONFIG_SYSFS_COUNT_LINKS
> +static inline void sysfs_init_nlink(struct sysfs_dirent *sd)
> +{
> + if (sysfs_type(sd) == SYSFS_DIR)
> + sd->s_nlink = 2;
> + else
> + sd->s_nlink = 1;
> +}
> +static inline void sysfs_inc_nlink(struct sysfs_dirent *sd)
> +{
> + sd->s_nlink++;
> +}
> +static inline void sysfs_dec_nlink(struct sysfs_dirent *sd)
> +{
> + sd->s_nlink++;
> +}

Minus minus.

thanks,
--
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/