Bug 1265315 - Some "available" attributes returned by udev_device_get_sysattr have no value
Some "available" attributes returned by udev_device_get_sysattr have no value
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd (Show other bugs)
7.2
Unspecified Unspecified
unspecified Severity medium
: rc
: ---
Assigned To: systemd-maint
qe-baseos-daemons
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-22 12:09 EDT by mulhern
Modified: 2015-11-10 08:06 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1267584 (view as bug list)
Environment:
Last Closed: 2015-11-10 08:06:56 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Simple test file illustrating an example device (1.95 KB, text/plain)
2015-09-22 12:09 EDT, mulhern
no flags Details
Simple python script that reports attributes that are listed but have no value (635 bytes, text/plain)
2015-09-23 15:35 EDT, mulhern
no flags Details

  None (edit)
Description mulhern 2015-09-22 12:09:51 EDT
Created attachment 1075902 [details]
Simple test file illustrating an example device

Description of problem:

udev_device_get_sysattr_list_entry returns a list of attribute, value pairs.
The values are NULL, the attributes are said to be "available".

From the docs:
"""
 Retrieve the list of available sysattrs, with value being empty; This just return all available sysfs attributes for a particular device without reading their values. 
"""

I dunno what "available" is supposed to mean, but if these attributes are
further looked up by "udev_device_get_sysattr_value" they may have no value,
i.e., this method may return NULL. (This is not the same as having a value
like the empty string, which fits the specification just fine.)


Version-Release number of selected component (if applicable):

Any.

How reproducible:

Consistently, for a given device.

Steps to Reproduce:
1. Loop over all devices returned by udevadm.
2. List the attributes using udev_device_get_sysattr_list_entry().
3. Look up the listed attributes using udev_device_get_sysattr_value(). Observe that some of these attributes are NULL.

Actual results:

Some "available" attributes have no values. Generally speaking, these attributes seem to be symlinks to directories. It is not true that all attributes that correspond to symlinks to directories have no value, only some.

Expected results:

"Available" attributes should have a value or documentation should define clearly that "available" means fits some criteria which does not necessarily include actually having a value.

Additional info:

It is normal to think of attribute name/value pairs as being like keys in a map.
If they are not, that is, if a key can simultaneously be in the map and not be
in the map, that should get better documentation then by the single word "available".

Also, in documentation, the ';' is followed by a capital letter, should be lowercase.
Comment 1 mulhern 2015-09-22 12:11:50 EDT
Output of new.c on my Fedora desktop. This is just an example, similar things
happen on my RHEL 7.2 box.

[mulhern@localhost reproducers]$ ./a.out
udev_list_entry_get_value()
Correct behavior, values are not obtained.
adr: (null)
path: (null)
subsystem: (null)
uevent: (null)
physical_node: (null)

udev_device_get_sysattr_value()
Incorrect behavior; physical_node should have a value.
adr: 0x00000000
path: \_SB_.PCI0.EHC2.HUBN
subsystem: acpi
uevent: 
physical_node: (null)

udev_device_get_sysattr_value(bogus)
correct behavior, value of non-existant attribute is null.
bogus: (null)

Should be like the first.
adr: (null)
path: (null)
subsystem: (null)
uevent: (null)
physical_node: (null)
Comment 2 mulhern 2015-09-23 15:35 EDT
Created attachment 1076292 [details]
Simple python script that reports attributes that are listed but have no value
Comment 3 mulhern 2015-09-23 17:03:36 EDT
The attached file printed SURPRISE a few times on both systems, indicating that some of the attributes with no value were not symlinked directories. What characteristics they do have I do not know.
Comment 4 mulhern 2015-11-09 10:28:38 EST
Given that I have an answer to my question in bz#1267584 this bug can not be said to block it. The only outstanding issue really is that these methods should be documented better, to avoid the same confusion arising for someone else in the future.
Comment 5 mulhern 2015-11-09 11:30:41 EST
PR at: https://github.com/systemd/systemd/pull/1818.
Comment 6 mulhern 2015-11-10 08:06:56 EST
Probably a thorough understanding of the architecture and underlying assumptions of this component would allow a user to infer the most important consequences of the relations between the methods involved from the existing documentation.

Note You need to log in before you can comment on or make changes to this bug.