2019-10-18 16:11:39

by Ulrich Windl

[permalink] [raw]
Subject: Issue with reading sysfs files

Hi!

I wrote a simple tool to browse sysfs.

However I noticed that there are some files having "r" (read) permission, but when you actually try to read from those, I get an I/O error.
So I wonder whether the actual read was forgotten to implement, or the read permission should be gone actually.

It seems to be implemented correctly in uevent, like
# ll /sys/module/drm/uevent
--w------- 1 root root 4096 Sep 24 12:24 /sys/module/drm/uevent

but it is not (e.g.) for
# ll /sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input1/event1/power/autosuspend_delay_ms
-rw-r--r-- 1 root root 4096 Sep 26 14:03 /sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input1/event1/power/autosuspend_delay_ms
# cat /sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input1/event1/power/autosuspend_delay_ms
cat: '/sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input1/event1/power/autosuspend_delay_ms': Input/output error

Here's a summary of such candidates:
.../power/autosuspend_delay_ms
# ll /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/host2/rport-2:0-0/target2:0:0/2:0:0:1/block/sdb/queue/wbt_lat_usec
-rw-r--r-- 1 root root 4096 Sep 26 14:03 /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/host2/rport-2:0-0/target2:0:0/2:0:0:1/block/sdb/queue/wbt_lat_usec
# cat /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/host2/rport-2:0-0/target2:0:0/2:0:0:1/block/sdb/queue/wbt_lat_usec
cat: '/sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/host2/rport-2:0-0/target2:0:0/2:0:0:1/block/sdb/queue/wbt_lat_usec': Invalid argument

# ll /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/resource0
-rw------- 1 root root 4096 Sep 26 14:03 /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/resource0
# cat /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/resource0
cat: '/sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/resource0': Input/output error

/sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/resource2_wc

# ll /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/rom
-rw------- 1 root root 262144 Sep 26 14:03 /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/rom
# cat /sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/rom
cat: '/sys/devices/pci0000:00/0000:00:03.1/0000:01:00.0/rom': Invalid argument

# ll /sys/devices/pci0000:80/0000:80:01.1/0000:81:00.0/net/em1/phys_port_id
-r--r--r-- 1 root root 4096 Sep 26 14:03 /sys/devices/pci0000:80/0000:80:01.1/0000:81:00.0/net/em1/phys_port_id
# cat /sys/devices/pci0000:80/0000:80:01.1/0000:81:00.0/net/em1/phys_port_id
cat: '/sys/devices/pci0000:80/0000:80:01.1/0000:81:00.0/net/em1/phys_port_id': Operation not supported

.../net/em1/phys_port_name
.../net/em1/phys_switch_id

# ll /sys/devices/pci0000:80/0000:80:01.2/0000:82:00.0/0000:83:00.0/graphics/fb0/bl_curve
-rw-r--r-- 1 root root 4096 Sep 26 14:03 /sys/devices/pci0000:80/0000:80:01.2/0000:82:00.0/0000:83:00.0/graphics/fb0/bl_curve
# cat /sys/devices/pci0000:80/0000:80:01.2/0000:82:00.0/0000:83:00.0/graphics/fb0/bl_curve
cat: '/sys/devices/pci0000:80/0000:80:01.2/0000:82:00.0/0000:83:00.0/graphics/fb0/bl_curve': No such device

# ll /sys/devices/pci0000:80/0000:80:08.1/0000:86:00.2/ata1/host1/scsi_host/host1/em_buffer
-rw-r--r-- 1 root root 4096 Oct 17 15:25 /sys/devices/pci0000:80/0000:80:08.1/0000:86:00.2/ata1/host1/scsi_host/host1/em_buffer
# cat /sys/devices/pci0000:80/0000:80:08.1/0000:86:00.2/ata1/host1/scsi_host/host1/em_buffer
cat: '/sys/devices/pci0000:80/0000:80:08.1/0000:86:00.2/ata1/host1/scsi_host/host1/em_buffer': Invalid argument

.../em_message

# ll /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/scsi_host/host0/fw_crash_buffer
-rw-r--r-- 1 root root 4096 Sep 26 14:03 /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/scsi_host/host0/fw_crash_buffer
# cat /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/scsi_host/host0/fw_crash_buffer
cat: '/sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/scsi_host/host0/fw_crash_buffer': Invalid argument

# ll /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/target0:2:0/0:2:0:0/block/sda/sda1/trace/act_mask
-rw-r--r-- 1 root root 4096 Sep 26 14:03 /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/target0:2:0/0:2:0:0/block/sda/sda1/trace/act_mask
# cat /sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/target0:2:0/0:2:0:0/block/sda/sda1/trace/act_mask
cat: '/sys/devices/pci0000:c0/0000:c0:01.1/0000:c1:00.0/host0/target0:2:0/0:2:0:0/block/sda/sda1/trace/act_mask': No such device or address

.../block/sda/sda1/trace/enable
.../block/sda/sda1/trace/end_lba
.../block/sda/sda1/trace/pid
.../block/sda/sda1/trace/start_lba

# ll /sys/devices/virtual/net/lo/duplex
-r--r--r-- 1 root root 4096 Sep 24 12:30 /sys/devices/virtual/net/lo/duplex
# cat /sys/devices/virtual/net/lo/duplex
cat: /sys/devices/virtual/net/lo/duplex: Invalid argument

# ll /sys/devices/virtual/net/lo/name_assign_type
-r--r--r-- 1 root root 4096 Sep 24 12:24 /sys/devices/virtual/net/lo/name_assign_type
# cat /sys/devices/virtual/net/lo/name_assign_type
cat: /sys/devices/virtual/net/lo/name_assign_type: Invalid argument

/sys/devices/virtual/net/lo/speed

Found in 4.12.14-95.6-default of SLES SP4 (x86_64)

Regards,
Ulrich