From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Subject: Re: [PATCH 25/20] sysfs: Only support removing emtpy sysfs directories. Date: Sun, 24 May 2009 14:59:38 +0200 Message-ID: <1243169978.3502.7.camel@poy> References: <1243109591-21611-5-git-send-email-ebiederm@xmission.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Andrew Morton , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Tejun Heo , Cornelia Huck , linux-fsdevel@vger.kernel.org, "Eric W. Biederman" To: "Eric W. Biederman" Return-path: Received: from mail-bw0-f174.google.com ([209.85.218.174]:40938 "EHLO mail-bw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752772AbZEXM7j (ORCPT ); Sun, 24 May 2009 08:59:39 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sat, 2009-05-23 at 23:27 +0200, Kay Sievers wrote: > On Sat, May 23, 2009 at 22:13, Eric W. Biederman wrote: > > From: Eric W. Biederman > > > > 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 > > 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