How do you determine what physical device a file in on?

Lance Hartmann lance at mpd.tandem.com
Wed Jun 26 23:27:56 AEST 1991


In article <1991Jun25.174729.11481 at StarConn.com> dror at starnet.UUCP (Dror Matalon) writes:
>
>	I suspect that there are only machine dependent ways. Given 
>two files x and y. I want to determine if they're on the same PHYSICAL devie.
>(It's pretty easy to find out the logical device, you do an statfs on the 
>file). Is there a portable or a semi-portable way to do this or do I need to 
>go into every machine's disk drivers structures to find out. 
>
>
>Thanks 
>
>	Dror

While perhaps machine dependent, I've found you can do a stat() on the
filename and look at the "st_dev" member of the "struct stat" ptr.
According to 'our' man pages (I'm on a Tandem S2 - using "mips" UNIX),
st_dev is "I.D. of device containing a directory entry for this file."
Unfortunately, this can be a LOGICAL device since Tandem's S2 supports
mirrors.  But, alas, you can determine whether or not that dev no. is
a mirror and figure out the actual physical disk partitions that
the mirror is accessing.
-- 
Lance G. Hartmann - cs.utexas.edu!devnull!lance (Internet)
-------------------------------------------------------------------------------
DISCLAIMER:  All opinions/actions expressed herein reflect those of my VERY OWN
and shall NOT bear any reflection upon Tandem or anyone else for that matter.



More information about the Comp.unix.wizards mailing list