This question is Linux specific; the solution does not need to be portable.
I am looking for a library function/syscall, or some combination thereof which will give me either the device (eg: /dev/sdb1
) or mount point (eg: /home
) for any arbitrary file. It would appear the f_fsid
field of a statfs
struct would do the trick, but it is not used on Linux.
I can find this info easily using the shell:
df "$filename" | awk 'NR==1 {next} {print $6; exit}'
but it would seem none of the exec
family of functions return output from the command that was run, and I would prefer to keep my solution pure C anyway.