lsd
lsd copied to clipboard
Noncompliant posix edge case
Running
# lsd -l /dev
crw-r--r-- root root - Thu Jul 9 06:18:07 2020 autofs
drwxr-xr-x root root - Thu Jul 9 06:18:13 2020 block
drwxr-xr-x root root - Thu Jul 9 06:17:49 2020 bsg
# ls -l /dev
crw-r--r-- 1 root root 10, 235 Jul 9 06:18 autofs
drwxr-xr-x 2 root root 360 Jul 9 06:18 block
drwxr-xr-x 2 root root 80 Jul 9 06:17 bsg
In the case of a device file, instead of file size we should be getting Driver Major, Driver Minor
Is my understanding correct that rust::os::unix::fs::metadata does not have functions which return major and minor driver numbers?
std::os::unix::fs::MetadataExt::rdev
You are correct in that it doesn't have functions "which return major and minor driver numbers", because it only returns a single 32-bit integer. There are functions in libc
that convert the 32-bit result into minor and major numbers. Unfortunately, if you wanted to avoid a libc
dependency, the exact mapping between 32-bit id and major:minor id appears to be far less portable and consistent.