sysfs: bugfix: shorten too long file names

* In old kernels (e.g: 2.6.18) sysfs file names must be shorter
  then KOBJ_NAME_LEN.

* Longer names are truncated and this leads to duplicate names
  which fails device_register()
  Examples: "dahdi!channels!10!10" is truncated to "dahdi!channels!10!1"

* The fix shorten the names and make them fixed length. Example:
            "dahdi!chan!010!010"

* It seems no current userspace tools rely on that name or on
  /dev/dahdi/channels .

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Oron Peled 2013-06-17 16:26:28 +03:00 committed by Tzafrir Cohen
parent 431571b5fc
commit 8ea23535dc
2 changed files with 5 additions and 3 deletions

6
README
View File

@ -646,8 +646,10 @@ or dynamically through the udev system.
* /dev/dahdi/ctl (196:0) - a general device file for various information and * /dev/dahdi/ctl (196:0) - a general device file for various information and
control operations on the DAHDI channels. control operations on the DAHDI channels.
* /dev/dahdi/channels/N/M - A device file for channel M in span N * /dev/dahdi/chan/N/M - A device file for channel M in span N
(M is chanpos - numbering relative to the current span). - Both N and M are zero padded 3 digit numbers
- Both N and M start at 001
- M is chanpos - numbering relative to the current span.
* /dev/dahdi/NNN (196:NNN) - for NNN in the range 1-249. A device file for * /dev/dahdi/NNN (196:NNN) - for NNN in the range 1-249. A device file for
DAHDI channel NNN. It can be used to read data from the channel DAHDI channel NNN. It can be used to read data from the channel
and write data to the channel. It is not generated by default but may and write data to the channel. It is not generated by default but may

View File

@ -247,7 +247,7 @@ int chan_sysfs_create(struct dahdi_chan *chan)
/* /*
* FIXME: the name cannot be longer than KOBJ_NAME_LEN * FIXME: the name cannot be longer than KOBJ_NAME_LEN
*/ */
dev_set_name(dev, "dahdi!channels!%d!%d", span->spanno, chan->chanpos); dev_set_name(dev, "dahdi!chan!%03d!%03d", span->spanno, chan->chanpos);
dev_set_drvdata(dev, chan); dev_set_drvdata(dev, chan);
dev->release = chan_release; dev->release = chan_release;
res = device_register(dev); res = device_register(dev);