hope you can help me: I am trying to determine if the device is removable or not, all I have is the name of the device (/ dev / sdc). In fact, I need to determine when a file is on removable media or on a local drive along the full path to this file.
I tried searching in current-> FS-> PWD and all I could find was a set of flags: * current-> FS-> pwd.mnt-> mnt_sb-> s_bdev-> bd_disk-> flags * where GENHD_FL_REMOVABLE is set for removable devices
But I always get the same flags (as I understand it, s_bdev always points to the same device (/ dev / sda)).
So now I get the name of the device (/ dev / sdc) that contains my file by analyzing mtab, but still I can not find whether to delete it or not.
Is there a way to get the block_device structure by device name? (for example, the structure of the βfileβ can be obtained by calling fd = open ("name") fl = fged (fd) where fl indicates the structure of the "file")
source share