Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Jun 1 15:39 /dev/sda
Logically, I'd say that it should be stored in the inode's structure, but when reading the documentation it isn't mentioned anywhere.
Thus my question is: Where am I supposed to store the major/minor numbers?
Same as small symlinks, device file major and minor numbers are stored in the bytes that would normally make up the first direct block pointer in the inode (i_block at offset 40).
klange wrote:Same as small symlinks, device file major and minor numbers are stored in the bytes that would normally make up the first direct block pointer in the inode (i_block at offset 40).
In the inode's structure itself?
Am I supposed to put the major first, then the minor, or the opposite?
What happens if a symlink is too big to fit in the structure? I guess it would then be written into blocks directly, but how is the fs driver supposed to know if it should interpret the bytes into the inode's structure as block addresses or as the link's data itself?
Crumble14 wrote:Am I supposed to put the major first, then the minor, or the opposite?
I can't find it specified in my copy of the spec...
Crumble14 wrote:What happens if a symlink is too big to fit in the structure? I guess it would then be written into blocks directly, but how is the fs driver supposed to know if it should interpret the bytes into the inode's structure as block addresses or as the link's data itself?
The size available within the inode is fixed at 60 bytes and the length of the symlink contents is the size of the file, so the filesystem implementation would be able know whether the i_block data is pointers or characters based on that size.
Random aside: I kinda despise the whole system of device special files. A pair of bytes is terribly insufficient for identifying interfaces to the myriad devices represented on a modern system. I opted not to implement them at all, instead implementing all device files as virtual files in the same way as a /proc or /sys.