Friday, April 1, 2022

[SOLVED] Why the file named "register" in "/proc/sys/fs/binfmt_misc" directory is "write-only"?

Issue

During learning about Linux file execution mechanism, I found a file in the following directory which is "write-only" (even for root user!):

ebra@him:/proc/sys/fs/binfmt_misc$ ll register 
--w------- 1 root root 0 Aug 19 19:15 register

My question is: What is the usage of this [kind] of file[s]? What is the use of a file that can not be read at all?


Solution

See the documentation. This is not a normal file; it's an interface to the kernel's mechanism for setting up binary formats. You add a new format by writing a string to this "file" in a specific format. The kernel uses that string to set up the new binary format, but there'd be no point in saving the string itself. So you wouldn't be able to read back the string you wrote, and it's not clear what else you might expect to read from that file.

If you want to see what formats have been registered, you look at the other files in that directory.



Answered By - Nate Eldredge
Answer Checked By - Mary Flores (WPSolving Volunteer)