Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devmon drive metadata is missing important fields #99

Open
lukehutch opened this issue Nov 22, 2020 · 0 comments
Open

devmon drive metadata is missing important fields #99

lukehutch opened this issue Nov 22, 2020 · 0 comments

Comments

@lukehutch
Copy link

lukehutch commented Nov 22, 2020

There are several missing fields in drive metadata.

(1) mountpoint

Currently a Mounted ... line looks like this:

Mounted /dev/sdb1 at /media/pi/FREEDOS

whereas all the other metadata looks like this

device: [/dev/sdb1]
    systeminternal: [0]
    usage:          [filesystem]
    type:           [vfat]
    label:          [FREEDOS]
    ismounted:      [1]
    nopolicy:       [0]
    hasmedia:       [1]
    opticaldisc:    []
    numaudiotracks: []
    blank:          []
    media:          []
    partition:      [1]

And (importantly), if you start devmon when drives are already mounted, you never get the Mounted ... line in the devmon output, so you never get the mountpoint info in the drive metadata.

Presumably the mount point can be deduced by appending the label to the end of the standard mount directory (/media/pi in this case), but nobody should be guessing paths in that way. One example of how this can break is if there are two drives that have the same disk label (then .2 is appended, etc.). Currently the user has to manually look in /etc/mtab to get the current mount point info, which requires extra effort.

For consistency there should be another field:

device: [/dev/sdb1]
    ...
    mountpoint:      [/media/pi/FREEDOS]

(2) udevpath

If you unplug a drive, you get the line

removed:   /org/freedesktop/UDisks/devices/sdb1

However the regular metadata does not list the UDisks device path, so you have to manually figure out which drive to update metadata for, by converting e.g. /org/freedesktop/UDisks/devices/sdb1 into /dev/sdb1 (which presumably works, but seems dicey). There should be a metadata field:

device: [/dev/sdb1]
    ...
    udevpath:      [/org/freedesktop/UDisks/devices/sdb1]

(3) usbport

USB port number is also missing. You have to make a separate call to udevadm:

$ udevadm info -q path -n /dev/sdh
/devices/pci0000:00/0000:00:1d.0/usb3/3-1/3-1.1/3-1.1.3/3-1.1.3.2/3-1.1.3.2:1.0/host7/target7:0:0/7:0:0:0/block/sdh

Explanation of this path is here:

https://unix.stackexchange.com/a/406096/340704

There needs to be a metadata field like

device: [/dev/sdb1]
    ...
    usbport:     [3-1.1.3.2]

(4) size

It would be really helpful to have the partition size and free space reported in the metadata too, saving a call to df:

device: [/dev/sdb1]
    ...
    size:       [1010235]
    used:       [10368]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant