Re: [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories.

From: Kay Sievers
Date: Sun May 24 2009 - 08:59:53 EST


On Sat, 2009-05-23 at 23:27 +0200, Kay Sievers wrote:
> On Sat, May 23, 2009 at 22:13, Eric W. Biederman <ebiederm@xxxxxxxxxxxx> wrote:
> > From: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
> >
> > I have looked and I have not found a single legitimate case today where
> > we remove sysfs directories with anything in them. The only case I have
> > found to date was a bug. It was a problem of ownership. The files in
> > the directory where not owned by the directory itself. Leaving open
> > the potential for double deletion of the directory contents.
> >
> > Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxxxxxxxx>
>
> Sounds good to me. We should try that, and see if there was any valid
> use case we didn't think of, and if not, it's good to do what this
> patch does.

I get a bunch of warnings here. The question is if the users should be
fixed, the warning removed, and/or the auto-deletion added back?

I've added:
- WARN(dir_sd->s_dir.children,
- KERN_WARNING "sysfs: removing non-empty dir: %s\n",
- dir_sd->s_name);
+ if (dir_sd->s_dir.children) {
+ struct sysfs_dirent *sd;
+
+ WARN(dir_sd->s_dir.children,
+ KERN_WARNING "sysfs: removing non-empty dir: %s\n",
+ dir_sd->s_name);
+ sd = dir_sd->s_dir.children;
+ while (sd) {
+ printk(KERN_WARNING "%s/%s\n", dir_sd->s_name, sd->s_name);
+ sd = sd->s_sibling;
+ }
+ }

And get non-empty directories from CPU, SCSI, firmware_class, sound, block:
sysfs: removing non-empty dir: state0
state0/name
state0/desc
state0/latency
state0/power
state0/usage
state0/time

sysfs: removing non-empty dir: 0000:03:00.0
0000:03:00.0/data
0000:03:00.0/loading

sysfs: removing non-empty dir: iosched
iosched/quantum
iosched/fifo_expire_sync
iosched/fifo_expire_async
iosched/back_seek_max
iosched/back_seek_penalty
iosched/slice_sync
iosched/slice_async
iosched/slice_async_rq
iosched/slice_idle

sysfs: removing non-empty dir: queue
queue/nr_requests
queue/read_ahead_kb
queue/max_hw_sectors_kb
queue/max_sectors_kb
queue/scheduler
queue/hw_sector_size
queue/rotational
queue/nomerges
queue/rq_affinity
queue/iostats

sysfs: removing non-empty dir: 4:0:0:0
4:0:0:0/queue_depth
4:0:0:0/queue_type
4:0:0:0/max_sectors

sysfs: removing non-empty dir: host4
host4/target4:0:0

sysfs: removing non-empty dir: pcmC1D0c
pcmC1D0c/pcm_class

sysfs: removing non-empty dir: card1
card1/id
card1/number


Thanks,
Kay

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