Re: How to check if same partition



Nils O. Selåsdal wrote:
Michel Bardiaux wrote:
I have to check whether 2 directories are on the same filesystem. I built a test case on a Linux debian woody (3.0) with kernel 2.4.28 with 1 directory on a local drive, the other on an NFS-mounted tree.

I tried statfs and statvfs, both reply that f_fsid is zero for both directories. I also tried plain stat, here st_dev is not zero, but still it is the same (very large number) for both.

I suppose parsing /proc/mounts would be a way, but that doesnt appeal at all!

Now I'm out of ideas. Suggestions? TIA.
Odd.
Verify your code with the stat command atleast.
$ stat /proc
$ stat /
$ stat /your/nfs/directory

The line saying "Device: ... " are different for me.

Good advice. Have installed stat, it gives different "Device" for local and NFS directory, proving that *some* system call works. I'll have a look at the source code to see what "Device" is exactly. Thanks.

--
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux@xxxxxxxxxxx

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/
.



Relevant Pages

  • Re: [9fans] Fwd: Reading from FS with inaccurate file sizes?
    ... When you cat>> file and file has zero length in stat, ... then the write happens at an offset of zero. ... This is perhaps the only time that the stat size should ... do not map one-to-one with FUSE file handles. ...
    (comp.os.plan9)
  • Re: How to check if same partition
    ... built a test case on a Linux debian woody with kernel 2.4.28 ... both reply that f_fsid is zero for both ... Verify your code with the stat command atleast. ... have a look at the source code to see what "Device" is exactly. ...
    (comp.os.linux.development.apps)
  • Re: How to check if same partition
    ... built a test case on a Linux debian woody with kernel 2.4.28 with 1 directory on a local drive, the other on an NFS-mounted tree. ... I also tried plain stat, here st_dev is not zero, but still it is the same for both. ...
    (comp.os.linux.development.apps)
  • Re: How to detect an empty file?
    ... how are you don´t want to use a beatiful way (stat) try it: ... x = lseek (pFile, 0, SEEK_END); ... and test if x is igual top zero ou -1. ...
    (comp.lang.c)
  • Re: How to check if same partition
    ... Michel Bardiaux wrote: ... I also tried plain stat, here st_dev is not zero, but still it is the same for both. ... I'll have a look at the source code to see what "Device" is exactly. ...
    (comp.os.linux.development.apps)