0

I have just installed the latest version of openSuse Tumbleweed and was going through the file system familiarising myself with it when I found a file in /dev/lightnvm called 'control'. I attempted to run cat on the file (cat control) but when I did so I got the following error:

cat: control: Invalid argument

I should have all the appropriate permissions to access the file. Any ideas as to why I can't view the contents of the 'control' file?

  • what is result of ls -l /de/lightnvm/control ? – Archemar Apr 9 '16 at 21:24
  • 1
    crw------- 1 root root 10, 62 Apr 9 21:23 control – Peter David Carter Apr 9 '16 at 23:04
1

The c in the first column of the ls output means this is a character device file. It is not a regular file and it doesn't really have "contents".

When you open and read from a regular file, the kernel runs standard code that fetches the file's data from your hard drive (or similar storage). But when you access a device file, the kernel runs code (the "device driver") that is specific to that device. Apparently, the authors of the lightnvm device driver designed their code in such a way that it doesn't make sense to read from this particular device, and so their code says that trying to do so should fail with an error.

(Most likely, code that needs to use this device is supposed to write to that file - the name control suggests that you are supposed to write to it to send commands to the device. It may also be intended to be neither read nor written, but accessed using the ioctl() system call.)

It's generally not a good idea to mess with the "files" in /dev, unless you really know what you are doing. Writing to arbitrary device files can be very dangerous; for instance, echo hello >/dev/sda would make your system unbootable, and it would be very difficult to recover your files. Even reading device files can be dangerous in some cases, or at least cause unexpected behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.