LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* filenames with spaces in /sys?
@ 2008-04-27 18:35 Christian Kujau
  2008-04-27 18:54 ` David Woodhouse
  2008-04-28 15:31 ` Scott Wood
  0 siblings, 2 replies; 5+ messages in thread
From: Christian Kujau @ 2008-04-27 18:35 UTC (permalink / raw)
  To: dwmw2; +Cc: linuxppc-dev

Hi,

I was a bit puzzled today when I came across
/sys/devices/platform/pmu-battery.0/power_supply/PMU battery 0/power
and thought to myself: why are there spaces in "PMU battery 0"? Wouldn't
../pmu-battery.0/power_supply/PMU_battery_0/power be feasible too? I find 
it rather annoying to special case the spaces whenever to look for 
something in /sys, when I'm so used not to when doing the same 
find/grep/xargs stuff in /usr/src/linux.

There are ~2000 directories in my /sys but only a handful contain spaces:

# find /sys/ -type d -regex '.*\ .*' | sort -u
/sys/bus/mdio_bus/drivers/Broadcom BCM5411
/sys/bus/mdio_bus/drivers/Broadcom BCM5421
/sys/bus/mdio_bus/drivers/Broadcom BCM5461
/sys/bus/mdio_bus/drivers/Broadcom BCM5464
/sys/bus/mdio_bus/drivers/Broadcom BCM5481
/sys/bus/mdio_bus/drivers/Broadcom BCM5482
/sys/bus/mdio_bus/drivers/Generic PHY
/sys/devices/platform/pmu-battery.0/power_supply/PMU battery 0
/sys/devices/platform/pmu-battery.0/power_supply/PMU battery 0/power

Hm, OTOH /proc also does contain some elements with spaces in it (e.g. 
/proc/irq/47/GPIO1 ADB)...so, in short: would patches be accepted to
turn ' ' into '_' again (if they don't break too much userspace stuff)?

Thanks,
Christian.
-- 
BOFH excuse #373:

Suspicious pointer corrupted virtual machine

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filenames with spaces in /sys?
  2008-04-27 18:35 filenames with spaces in /sys? Christian Kujau
@ 2008-04-27 18:54 ` David Woodhouse
  2008-04-27 19:44   ` [PATCH] " Christian Kujau
  2008-04-28 15:31 ` Scott Wood
  1 sibling, 1 reply; 5+ messages in thread
From: David Woodhouse @ 2008-04-27 18:54 UTC (permalink / raw)
  To: Christian Kujau; +Cc: linuxppc-dev

On Sun, 2008-04-27 at 20:35 +0200, Christian Kujau wrote:
> 
> /sys/devices/platform/pmu-battery.0/power_supply/PMU battery 0
> /sys/devices/platform/pmu-battery.0/power_supply/PMU battery 0/power
> 
> Hm, OTOH /proc also does contain some elements with spaces in it (e.g. 
> /proc/irq/47/GPIO1 ADB)...so, in short: would patches be accepted to
> turn ' ' into '_' again (if they don't break too much userspace stuff)?

I see no reason not to for the battery class, certainly.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Re: filenames with spaces in /sys?
  2008-04-27 18:54 ` David Woodhouse
@ 2008-04-27 19:44   ` Christian Kujau
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Kujau @ 2008-04-27 19:44 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linuxppc-dev

On Sun, 27 Apr 2008, David Woodhouse wrote:
>> Hm, OTOH /proc also does contain some elements with spaces in it (e.g.
>> /proc/irq/47/GPIO1 ADB)...so, in short: would patches be accepted to
>> turn ' ' into '_' again (if they don't break too much userspace stuff)?
>
> I see no reason not to for the battery class, certainly.

Thanks. By changing drivers/power/pmu_battery.c I now have '_' instead of 
' ' (spaces) in /sys:

/sys/devices/platform/pmu-battery.0/power_supply/PMU_battery_0
/sys/class/power_supply/PMU_battery_0

I'm still not sure if some userspace tool out there uses the 
old paths and will break now.

Signed-off-by: Christian Kujau <lists@nerdbynature.de>

--- linux-2.6-git/drivers/power/pmu_battery.c.orig	2008-04-27 20:26:34.000000000 +0200
+++ linux-2.6-git/drivers/power/pmu_battery.c	2008-04-27 20:31:19.000000000 +0200
@@ -159,7 +159,7 @@ static int __init pmu_bat_init(void)
  		if (!pbat)
  			break;

-		sprintf(pbat->name, "PMU battery %d", i);
+		sprintf(pbat->name, "PMU_battery_%d", i);
  		pbat->bat.name = pbat->name;
  		pbat->bat.properties = pmu_bat_props;
  		pbat->bat.num_properties = ARRAY_SIZE(pmu_bat_props);


C.
-- 
BOFH excuse #189:

SCSI's too wide.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filenames with spaces in /sys?
  2008-04-27 18:35 filenames with spaces in /sys? Christian Kujau
  2008-04-27 18:54 ` David Woodhouse
@ 2008-04-28 15:31 ` Scott Wood
  2008-04-29 21:54   ` Christian Kujau
  1 sibling, 1 reply; 5+ messages in thread
From: Scott Wood @ 2008-04-28 15:31 UTC (permalink / raw)
  To: Christian Kujau; +Cc: linuxppc-dev, dwmw2

On Sun, Apr 27, 2008 at 08:35:51PM +0200, Christian Kujau wrote:
> I was a bit puzzled today when I came across
> /sys/devices/platform/pmu-battery.0/power_supply/PMU battery 0/power
> and thought to myself: why are there spaces in "PMU battery 0"?

Why not?

> Wouldn't ../pmu-battery.0/power_supply/PMU_battery_0/power be feasible too? 

Feasible, yes, but uglier, and as you point out, changing it now would
risk breaking userspace for little gain.

> I find it rather annoying to special case the spaces whenever to look
> for something in /sys, when I'm so used not to when doing the same
> find/grep/xargs stuff in /usr/src/linux.

If userspace tools make it awkward to deal with filenames with spaces,
let's fix the userspace tools.  /sys is certainly not the only place
they'll be found, and waging war against them is a battle best left for
a couple decades ago.

-Scott

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filenames with spaces in /sys?
  2008-04-28 15:31 ` Scott Wood
@ 2008-04-29 21:54   ` Christian Kujau
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Kujau @ 2008-04-29 21:54 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, dwmw2

On Mon, 28 Apr 2008, Scott Wood wrote:
>> Wouldn't ../pmu-battery.0/power_supply/PMU_battery_0/power be feasible too?
>
> Feasible, yes, but uglier

I did not want to argue about "ugliness", as this is a matter of 
personal taste.

> If userspace tools make it awkward to deal with filenames with spaces,
> let's fix the userspace tools.

Usually I would agree. I was only puzzled that filenames in /sys have 
spaces at all - I was under the impression spaces should be omitted in 
/sys (and /proc, too) for ease of handling (userspace has to specialcase 
spaces). And looking at these directories only very few filenames contain 
spaces, so it looked like ../PMU battery 0/ somehow "slipped through", as 
there's no point in having spaces when almost everything else was using 
an unserscore.

> /sys is certainly not the only place they'll be found, and waging war 
> against them is a battle best left for a couple decades ago.

Hm, I guess the real solution would be a statement about special 
characters in special filesystems in CodingStyle ....and a travel back in 
time to have this rule applied of course :)

C.
-- 
BOFH excuse #190:

Proprietary Information.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-04-29 21:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-27 18:35 filenames with spaces in /sys? Christian Kujau
2008-04-27 18:54 ` David Woodhouse
2008-04-27 19:44   ` [PATCH] " Christian Kujau
2008-04-28 15:31 ` Scott Wood
2008-04-29 21:54   ` Christian Kujau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox