[comp.unix.questions] Determining if a given path is a file system.

PETERS%MSSTATE.BITNET@cunyvm.cuny.edu (Frank Peters) (07/04/88)

Please forgive what is probably a childishly simple question.

Given a complete path, how do I determine if that path identifies
the mount point of a file system (from within a C program).  So
far the only solution I can find is to read the system mount
table.  It seems as if there should be a simpler way but I can't
seem to find one in my programmer reference manual.

Thanks in advance for any help.  Please send replies to me and I
will summarize to the list if interest warrents.

                        Frank Peters

friedl@vsi.UUCP (Stephen J. Friedl) (07/05/88)

In article <16377@brl-adm.ARPA>, PETERS%MSSTATE.BITNET@cunyvm.cuny.edu (Frank Peters) writes:
< Please forgive what is probably a childishly simple question.
< 
< Given a complete path, how do I determine if that path identifies
< the mount point of a file system (from within a C program).  So
< far the only solution I can find is to read the system mount
< table.  It seems as if there should be a simpler way but I can't
< seem to find one in my programmer reference manual.
< 
< Thanks in advance for any help.  Please send replies to me and I
< will summarize to the list if interest warrents.
< 
<                         Frank Peters


     It would really help if those requesting email responses
would include an email address.  My knowledge of UNIX questions
is much better than my knowledge of the various network
addressing schemes, and my history of successful [R]eplies to
paths that include all of @ % . ! and BITNET is very poor.  Hey,
short .signatures are nice, but... :-)

     To answer the question (while I'm at it), stat the full
path, then stat path/.. and see if st_dev is different.  If they
are, it's a mount point.  Disclaimer: I don't know how this works
for network mounts (NFS or RFS or whatever).

     Steve

-- 
Steve Friedl     V-Systems, Inc. (714) 545-6442     3B2-kind-of-guy
friedl@vsi.com     {backbones}!vsi.com!friedl    attmail!vsi!friedl
-----------Nancy Reagan on John DeLorean: "Just say snow"----------