Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to tell if path crosses a filesystem boundary?

45 views
Skip to first unread message

Busirane

unread,
Nov 21, 2017, 3:31:09 PM11/21/17
to
I find myself wondering how to tell if a given path crosses to a different filesystem, i.e., another filesystem mounted on the local filesystem.

Under Windows I can detect when a path is on another volume, but is there a portable way to do this under unix? If /path/to/local/file is in the local filesystem, that's OK, but if /path/to/remote/file is in a remotely mounted filesystem I'd like to take some action.

I checked file and fileutil but didn't find anything that seemed applicable.

Matthew Hiles

unread,
Nov 21, 2017, 3:35:14 PM11/21/17
to
I think your best bet will be tclx's fstat.

Rich

unread,
Nov 21, 2017, 4:35:18 PM11/21/17
to
Busirane <john....@gmail.com> wrote:
> I find myself wondering how to tell if a given path crosses to a
> different filesystem, i.e., another filesystem mounted on the local
> filesystem.
> ...
> I checked file and fileutil but didn't find anything that seemed
> applicable.

Use "file stat"

Check for changes in the "dev" key's value.

Files on a different file systems will have different "dev" numbers.

Ralf Fassel

unread,
Nov 22, 2017, 5:12:32 AM11/22/17
to
* Rich <ri...@example.invalid>
% file stat / tmp ; puts $tmp(dev)
2050
% file stat /home tmp ; puts $tmp(dev)
39
% file stat /home/user tmp ; puts $tmp(dev)
39

/homes is indeed mounted from the remote file server...

% file stat /data tmp ; puts $tmp(dev)
2050
% file stat /data/hdd tmp ; puts $tmp(dev)
2065
% file stat /data/ssd tmp ; puts $tmp(dev)
2051

These are locally mounted from different discs.

If "local vs remote mount" is important (rather than just "different
file system") I guess there is no way of distinguishing local vs remote
mounts short of parsing 'mount' output (or the equivalent in
/proc/mounts)? On windows I could ask "net use", or some registry
setting...

R'

Busirane

unread,
Nov 22, 2017, 2:08:31 PM11/22/17
to
On Tuesday, November 21, 2017 at 4:35:18 PM UTC-5, Rich wrote:
> Use "file stat"
>
> Check for changes in the "dev" key's value.

Thanks, Rich! This is the approach I will use.

Busirane

unread,
Nov 22, 2017, 2:10:05 PM11/22/17
to
On Tuesday, November 21, 2017 at 3:35:14 PM UTC-5, Matthew Hiles wrote:
> I think your best bet will be tclx's fstat.

Thanks, Matthew. This *is* an option, because Tclx is available in the KBS tclkit that I'm using, but the regular "file stat" command works, so I'll use that.

Busirane

unread,
Nov 22, 2017, 4:23:28 PM11/22/17
to
On Wednesday, November 22, 2017 at 5:12:32 AM UTC-5, Ralf Fassel wrote:
> If "local vs remote mount" is important

It's not. I have implemented a solution using "file stat" and it works like a charm!

Thanks to Ralf and everyone else who answered.
0 new messages