Excess spaces in sysfs files
Hi,
I have met a minor issue when writing udev rules.
Some text-like files in /sys have a load of spaces appended onto the text.
Example below, part of the udevinfo for my camera (notice the model field):
follow the class device's "device"
looking at the device chain at
'/sys/devices/pci0000:00/0000:00:02.1/usb3/3-3/3-3:1.0/host0/0:0:0:0':
BUS="scsi"
ID="0:0:0:0"
SYSFS{detach_state}="0"
SYSFS{max_sectors}="240"
SYSFS{device_blocked}="0"
SYSFS{queue_depth}="1"
SYSFS{type}="0"
SYSFS{scsi_level}="3"
SYSFS{vendor}=" "
SYSFS{model}="USB 2.0M DSC "
SYSFS{rev}="1.00"
SYSFS{online}="1"Second example, an iPod:
http://marc.theaimsgroup.com/?l=gentoo-user&m7773927301652&w=2
Of course, udevinfo makes it nice and clear that the extra spaces are there. But if you are simply cat'ing the files in /sys its not that obvious.
My questions:
1. Should these spaces be here? Are devices really identifying themselves with spaces on the end? Or is this an issue with sysfs/similar.
2. Should udev trim whitespace from the end of SYSFS{..} values (files), so that keys such as
SYSFS{model} = "iPod"
would match a file containing
"iPod "
If the above behaviour is implemented, I would suggest having a second key type, SYSFS_RAW{..} where whitespace is not trimmed. I am prepared to write a patch for this.
Daniel.
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 2 lines · Daniel Drake
1. Should these spaces be here? Are devices really identifying themselves with spaces on the end? Or is this an issue with sysfs/similar.
It's common. Seems like vendors are just filling fixed length fields. A lot of fields are 8 characters total length.
Quoted 9 lines
2. Should udev trim whitespace from the end of SYSFS{..} values (files), so that keys such as
SYSFS{model} = "iPod"
would match a file containing
"iPod "If the above behaviour is implemented, I would suggest having a second key type, SYSFS_RAW{..} where whitespace is not trimmed. I am prepared to write a patch for this.
Hey, udevinfo is so cute :)
I don't like the idea to try to be smart with the matching, but if we really want this, I prefer to have it configurable in the config file.
thanks,
Kay
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 2 lines · Daniel Drake
1. Should these spaces be here? Are devices really identifying themselves with spaces on the end? Or is this an issue with sysfs/similar.
This is a device issue. Seems like a lot of them have spaces in odd places. Nothing sysfs or udev can do about it.
Go complain to the device manufacturer :)
Quoted 5 lines
2. Should udev trim whitespace from the end of SYSFS{..} values (files), so that keys such as
SYSFS{model} = "iPod"
would match a file containing
"iPod "
No, I don't think so. That's one reason udevinfo was created to show you that those spaces are really there.
thanks,
greg k-h
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel