serenity icon indicating copy to clipboard operation
serenity copied to clipboard

Kernel+Userland: Expose partition metadata in SysFS, add printed info in lsblk about that metadata

Open supercomputer7 opened this issue 2 years ago • 6 comments

Relies on #14661. Another nice step towards building a udev-like program in Serenity :)

supercomputer7 avatar Jul 23 '22 16:07 supercomputer7

Looks good! I took a quick look through the code and nothing really stands out, though I'm not super familiar with kernel stuff, so maybe take that with a grain of salt. :^)

Looking ahead, to integrate this into a future PartitionEditor that does writes, we'll need a way to discover corresponding raw block device files. I would suggest adding a symlink that points to the device file in /dev, but that may be problematic since it'd be crossing a filesystem boundary and DevFS and SysFS could hypothetically be mounted to locations other than /dev and /sys respectively. Maybe we could just add a second block device file in /sys/devices/storage/physical/LUN/ with the same major and minor numbers instead?

The kernel can't assume where userspace wants to mount devtmpfs nor sysfs. Therefore, the only sane thing to do is to expose a node for the major number and another for the minor number in each /sys/devices/storage/physical/LUN/ directory. Device files should not be allowed to be created in the sysfs at all.

supercomputer7 avatar Jul 25 '22 17:07 supercomputer7

Looks good! I took a quick look through the code and nothing really stands out, though I'm not super familiar with kernel stuff, so maybe take that with a grain of salt. :^)

Looking ahead, to integrate this into a future PartitionEditor that does writes, we'll need a way to discover corresponding raw block device files. I would suggest adding a symlink that points to the device file in /dev, but that may be problematic since it'd be crossing a filesystem boundary and DevFS and SysFS could hypothetically be mounted to locations other than /dev and /sys respectively. Maybe we could just add a second block device file in /sys/devices/storage/physical/LUN/ with the same major and minor numbers instead?

We could also (in relation to the previous comment of mine) just add a device_identifier symbolic link in each /sys/devices/storage/physical/LUN/ to /sys/dev/block/DEVICE_DIRECTORY_SYMLINK. It is not a problem because unless you go and try to resolve this link endlessly, you won't have to encounter the ELOOP error...

supercomputer7 avatar Jul 25 '22 17:07 supercomputer7

This has conflicts

linusg avatar Aug 23 '22 18:08 linusg

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

stale[bot] avatar Sep 14 '22 06:09 stale[bot]

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

stale[bot] avatar Sep 21 '22 16:09 stale[bot]

Let's reopen this.

supercomputer7 avatar Oct 16 '22 18:10 supercomputer7

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

stale[bot] avatar Nov 06 '22 20:11 stale[bot]

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

stale[bot] avatar Nov 14 '22 09:11 stale[bot]