Hello.
Is there a linux syscall to get a list of mounted devices?
Thanks,
Luka
Hello.
Is there a linux syscall to get a list of mounted devices?
Thanks,
Luka
Or ... how can I get the used and unused space used space of the mounted device?
I'd suggest getting a copy of the source to /bin/mount (I don't have it myself) and seeing what magic it's doing with the kernel filesystem.
I've done a google search, but have come up empty, and I don't have access to a source distro with the sys utilities at the moment. Perhaps someone else here can point you at where the source lives.
I believe that it all has to do with the virtual file system code (vfs) -- I'm certain that there are internal data structures for that.
If you don't mind using /proc for the information, you might try looking at /proc/mounts (which is actually a symlink to /proc/self/mounts, and /proc/self is a symlink... but reading /proc/mounts should give you the info).
Last edited by filker0; 12-05-2005 at 05:01 PM. Reason: added /proc/mounts info
Insert obnoxious but pithy remark here
Open and read /proc/mounts. Each line looks like this:
<device> <mountpoint> <type> <mode> <integer> <integer>
I think the last two integers are about the checking order.
Nodev filesystems (like rootfs, proc, etc.) have their own name instead of the device.
/proc/mounts ought to be world-readable.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
I believe mount parses /proc/mounts to find out what is mounted. A better way would be to parse /proc/self/mounts which will give you the mounts visible to you or somesuch.
As for the space, I think you need to invoke some filesystem magic there. Get the source for df and see what it does.
SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
I say what I say, I mean what I mean.
IDE: emacs + make + gcc and proud of it.
/proc/mounts is a symlink to /proc/self/mounts (and /proc/self in turn is a symlink to /proc/nnnnn, where nnnnn is the current process id).
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Source is available for all GNU software in the software directory on the gnu.org website. You can find the source for df, du etc. in the fileutils package here: http://ftp.gnu.org/gnu/fileutils/fileutils-4.1.tar.gz
Of course using GPL'd code means your code is GPL'd...
THIS IS NOT JUST A CHRONICLING OF THINGS WE HAVE DONE IN THE PAST BUT OUR RISE TO POWER.
or, use this:
http://www.freebsd.org/projects/index.html
since the bsd license allows for commercial use of the products.
get the appropriate source package from the cvs repository and go from there with your code.
Originally Posted by Jeff Henager
I have NetBSD and getfsstat(2) seems to have everything you need.
I thought that if you looked at the man file for 'fstab' it showed you the functions you can use for gaining info on drives? worth checking anyway, I'm afraid my Slackware box isn't networked, this is a windows box.