Here the major_device for the /tmp folder is 66310.
Is there any way to get the disksup’s corresponding partition from this id?
For better understanding: I need to keep an eye on disk usage to invalidate cached objects when it reaches a certain threshold, and the directory is provided by the user (for instance /tmp/my_caching_directory/). I’ve though of identifying the partition by matching disksup:get_disk_data/0 output with user-provided path, but that’s surprisingly error-prone (I haven’t found functions to work with directory paths in the standard library).
If you look at the source code for disksup, you’ll see that it doesn’t care about partitions. It just runs df (with switches depending on the detected OS).
What you want to do is find the mount point for the user-provided path. Unfortunately, there doesn’t seem to be a reliable way to do that across different OSes. Most of the Stackoverflow suggestions, well, run df /whatever/path, which returns the name and space for the mount point containing the specified path.
You could, maybe, run mount, which gives you a list of mounted disks (parsing the output’s probably fragile). Then for each mounted /dev/whatever, you can use file:read_file_info to get the major/minor device IDs. On macOS, these seem to be the same as a file on that volume.
Of course, if you’re using the information to purge the cache, you can cut out disksup and just run df /tmp/my_caching_directory yourself.
These are neat ideas, but since I want to support all platforms (including Windows) I’d better go with the solution consisting in determining the partition from disksup output and the provided path. Note that disksup will soon allow checking disk usage with a frequency less than a minute (PR was merged not long ago).