in reply to How to Determine If A File Is On NFS? Local? Etc?

my $d = (stat($filename))[0]; if ( $d < 0 ) { print "$filename is nfs file\n"; }
Boris

Replies are listed 'Best First'.
Re^2: How to Determine If A File Is On NFS? Local? Etc?
by Anonymous Monk on Sep 21, 2004 at 13:39 UTC
    Looking at the first element returned by stat() doesn't seem to work. I tried:
    my $nfs_file = '/auto/somewhere/testfile.txt'; my $local_file = '/tmp/testfile.txt'; my @stat_stuff = stat("$nfs_file"); print "Device for nfs file is $stuff[0]."; @stat_stuff = stat("$local_file"); print "Device for local file is $stuff[0].\n";
    When I ran it, I got 14 for the NFS mounted file and 10 for the local file. Both greater than 0. Have I misunderstood something?
      This method depends on the way devices are numbered in your
      OS. All it means is that you're using an OS which does
      not list NFS as a negative device number.

      No big deal, just adapt the code to fit.
        Hmmm....rats, I was hoping for a method that would be more portable between systems. Any other ideas?
      Hmm, no that was what borisz wrote. /me goes to read perldoc -f stat.