lsd icon indicating copy to clipboard operation
lsd copied to clipboard

Noncompliant posix edge case

Open Skarlett opened this issue 4 years ago • 2 comments

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

Skarlett avatar Jul 12 '20 13:07 Skarlett

Is my understanding correct that rust::os::unix::fs::metadata does not have functions which return major and minor driver numbers?

Photon9 avatar Feb 10 '23 02:02 Photon9

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.

boomshroom avatar Jan 29 '24 09:01 boomshroom