|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Advanced file system question
The df command has the option "df filename" which shows information for the file system on which the file resides. Does anyone know how df in this case finds out on which file system the specified file exists?. I'm writing a tool which needs to do that, given a file name, find out its file system (without using df).
Any help will be greatly appreciated. Thanks in advance |
|
#2
|
|||
|
|||
|
Short verion of what GNU df does:
lstat for the file in the current directory, see if it is a link, use the link directory to find the mount point otherwise it attempts several things getcwd to find a filename a directory name Then it searches for mount points, going upward from the current directory To do this is needs a list of mounted filesystems as well. When it finds a mount point, it then knows which filesystem applies. You can also work against a device list using the device number in struct stat - st_dev You can relate that to mounted filesystems list as well. IMO, you'd be better off getting code for df.c and mountpoint.c in the coreutils: http://linux.softpedia.com/progDown...nload-6964.html Last edited by jim mcnamara : March 18th, 2008 at 01:38 PM. |
|
#3
|
|||
|
|||
|
Thanks for that Jim.
That's what I call a good answer. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Advanced file system question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|