Re: [PATCH] sysfs: Optionally count subdirectories to support buggy applications

From: Linus Torvalds
Date: Wed Feb 01 2012 - 18:15:32 EST


On Wed, Feb 1, 2012 at 2:21 PM, Eric W. Biederman <ebiederm@xxxxxxxxxxxx> wrote:
>
> lm_sensors and possibly other applications get confused if all sysfs
> directories return nlink == 1.  The lm_sensors code that got confused
> was just wrong and a fixed version of lm_sensors should be released
> shortly.

I think this patch is horrible, and broken.

And making the feature a config option is just stupid.

The simple approach is to

- implement a inode->i_op->getattr function for sysfs

- make it call generic_fillattr()

- after filling in the generic fields, count the number of sysfs
children it has and update stat->nlink appropriately.

No extra "keep track of inode counts by hand" crap, and no idiotic
config options that just make it easy to (conditionally) get things
wrong. Just do it right, and do it *unconditionally* right.

The Linux VFS layer is smart, and allows filesystems to do these kinds
of fixups.

Linus
--
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/