Subject: Determining if a file is on a local or r
To: '' <tech-kern@NetBSD.ORG>
From: SYD) < (Brian de Alwis>
List: tech-kern
Date: 07/16/1997 01:36:37
Not strictly a NetBSD question, but it will apply.

We want to be able to determine whether a file is on a local or remote (NFS) 
system. Each Unix variant does it differently, and the only sure way seems 
to find the filesystem mount-point and then grovel through the mounted 
filesystems and check it's fstype.

But there does seem to be an easier way using stat(2)'s st_dev field.

According to the Solaris documentation, st_dev should be NODEV (= 
(dev_t)(-1)) on a remote filesystem. AIX seems to agree. The only problem is 
that this isn't true.

But what does seem to be consistent is that if st_dev is treated as a signed 
number, then it will be a negative number for remote filesystems (the 
highest bit is set). This holds on Solaris, AIX, HPUX... But I don't have 
any other systems here to test it on.

I don't know where to look for any sort of confirmation. Is it a fluke, or 
is it undocumented behaviour? What does the BSD4.3 and 4.4 implementation 
say? Is it 'accepted practice'? What do other Unix variants do?

I'd be grateful for any help.