finding the filesystem of a file
Jeff Beadles
jeff at onion.pdx.com
Thu Nov 8 11:50:50 AEST 1990
dt at mathcs.emory.edu (Dave Taylor {guest}) writes:
>Curious to know if anyone can tell me the fastest way to find out which
>filesystem a given file is on if the entire pathname is given. I have only
Well, I didn't see the entire question, but if you're trying this from the
shell (This is comp.unix.shell, ya know... :-), and have a newer version of
df, then you might be able to do something like this:
% df /usr2/jeff/.newsrc
Filesystem kbytes used avail capacity Mounted on
/dev/ds08a 279922 32566 219363 13% /usr2
>From that, you could do something like:
------------------------snip here-----------------------------
#!/bin/sh
if [ -z "$1" -o ! -r "$1" -o $# -ne 1 ] ; then
echo "Usage: $0 filename"
exit 1
fi
## Do the df, print the 6th field of a line starting with '/'.
df $1 | awk '/^\// { print $6 } '
exit 0
------------------------snip here-----------------------------
Of course if your output of df is different, you may have to change the $6
to something else.
If you're trying to do this from 'C', then look at the statfs(2) man page.
Hope this helps!
-Jeff
--
Jeff Beadles jeff at onion.pdx.com
More information about the Comp.unix.shell
mailing list