Article View: comp.unix.shell
Article #1737Re: finding the filesystem of a file
From: Jeff Beadles
Date: Thu, 08 Nov 1990 00:50
Date: Thu, 08 Nov 1990 00:50
39 lines
1626 bytes
1626 bytes
dt@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@onion.pdx.com
Technical Details
Message-ID:
<1990Nov8.005050.16732@onion.pdx.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!zephyr.ens.tek.com!tektronix!nosun!qiclab!onion!jeffReferences:
<6495@emory.mathcs.emory.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!uw-beaver!zephyr.ens.tek.com!tektronix!nosun!qiclab!onion!jeff From: jeff@onion.pdx.com (Jeff Beadles) Newsgroups: comp.unix.shell Subject: Re: finding the filesystem of a file Keywords: filesystem search find file Message-ID: <1990Nov8.005050.16732@onion.pdx.com> Date: 8 Nov 90 00:50:50 GMT References: <6495@emory.mathcs.emory.edu> Distribution: usa Lines: 39