box101:~ # cat /sys/class/net/eno1/carriercat: /sys/class/net/eno1/carrier: Invalid argumentWhat the...? OK, so what does strace say?...open(/sys/class/net/eno1/carrier, O_RDONLY) = 3fstat(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0read(3, 0x19c8000, 65536) = -1 EINVAL (Invalid argument)...So let me get this straight... The file opens perfectly, yet reading from it is somehow an error?What's more annoying is that on box103, the exact same command works perfectly! On box101, I can read every single file in that directory except carrier.Can anyone explain what the hell is going on here?
Reading from sysfs returns EINVAL
sysfs
There are some issues with hardware/driver as explained on this LKML thread. Quoting just a little part of the reply mail:The reason is that most drivers don't even probe the link or negotiate link speed and flow control until the device is brought up.  Many don't even power up the PHY when the device is down, in order to save power.So the behavior you observe is completely expected.Even when you have link(cable connected) it will prompt you the -EINVAL error. Power management configurations may issue this error too on an interface that is already plugged and up.mii-tool and ethtool should be more reliable on giving you information about link state of the ethernet interface(maybe ip l l).