Greetings!
I've run across an issue that I'm surprised I've never run across before. I needed to find the differences between a file and it's counterpart in the snapshot area. When I ran a diff, it reported no differences. That was quite the shock since I knew for a fact the file had changed, albeit ever so slightly. I used cmp(1) on it, and it quickly noted that the files were different.
# diff .snapshot/weekly.0/index.config index.config
# cmp .snapshot/weekly.0/index.config index.config .snapshot/weekly.0/index.config index.config differ: char 2787, line 89
# tail -1 .snapshot/weekly.0/index.config index.config ==> .snapshot/weekly.0/index.config <== path: /home/indy
==> index.config <== path: /home/indy/clients
There were more differences than this, but I knew the last line had a simple difference for this demonstration.
Some observations:
1. If I use sdiff, it shows the files being identical... and always shows the line I know will differ as the one in the first file.
2. If I copy the two files, so neither is in the snapshot area, diff works as one would expect.
3. If I diff two completely different files, it does the right thing.
I have reproduced this with clients running several releases of Solaris/SunOS as well as hosts running FreeBSD.
Our filer is happily running 5.3.2R1P1D1.
On Fri, 15 Mar 2002 mitch@netline.com wrote:
I needed to find the differences between a file and it's counterpart in the snapshot area. When I ran a diff, it reported no differences. That was quite the shock since I knew for a fact the file had changed,
I think many versions of diff and sdiff "cheat" by not checking files if they have the same inode number. If you diff a file and it's snapshot counterpart, it'll never find a difference since the inode numbers match. If you copy the file in the snapshot out, then the copy will have a different inode number, and diff should do it's job correctly.
-Remington remi@netapp.com
No day but today.
----- Original Message ----- From: mitch@netline.com To: toasters@mathworks.com Sent: Friday, March 15, 2002 12:30 PM Subject: Using diff on snapshots
Greetings!
I've run across an issue that I'm surprised I've never run across before. I needed to find the differences between a file and it's counterpart in the snapshot area. When I ran a diff, it reported no differences. That was quite the shock since I knew for a fact the file had changed, albeit ever so slightly. I used cmp(1) on it, and it quickly noted that the files were different.
As someone else pointed out, most if not all diffs "cheat" by assuming if two files in the same filesystem have the same inode number, they point to the same data. This is normally a correct assumption. The way the .snapshot directory works within a filesystem creates such a situation.
Short of changing the source, the best way to work around this issue is not to access .snapshot via the regular filesystem, but to mount the filers .snapshot directory itself as a seperate mount point. This will force diff not to make the assumption (since it thinks it is a different filesystem).
Bruce
you can fool diff by piping one version of the file into it.
cat file | diff - .snapshot/hourly.0/file
for example:
$ diff t.ps .snapshot/hourly.0/t.ps # no diff in snapshot copy $ echo >> t.ps # add a line to file $ diff t.ps .snapshot/hourly.0/t.ps # still no diff found $ cat t.ps | diff - .snapshot/hourly.0/t.ps # diff now found 8d7 < $
-- email: lance_bailey@pmc-sierra.com box: Lance R. Bailey, unix Administrator vox: +1 604 415 6646 PMC-Sierra, Inc fax: +1 604 415 6151 105-8555 Baxter Place http://www.lydia.org/~zaphod Burnaby BC, V5A 4V7 If voting could really make a difference, it would be illegal -- street graffiti seen in Montreal
On Fri, Mar 15, 2002 at 02:19:59PM -0800, Bruce Sterling Woodcock wrote:
----- Original Message ----- From: mitch@netline.com To: toasters@mathworks.com Sent: Friday, March 15, 2002 12:30 PM Subject: Using diff on snapshots
Greetings!
I've run across an issue that I'm surprised I've never run across before. I needed to find the differences between a file and it's counterpart in the snapshot area. When I ran a diff, it reported no differences. That was quite the shock since I knew for a fact the file had changed, albeit ever so slightly. I used cmp(1) on it, and it quickly noted that the files were different.
As someone else pointed out, most if not all diffs "cheat" by assuming if two files in the same filesystem have the same inode number, they point to the same data. This is normally a correct assumption. The way the .snapshot directory works within a filesystem creates such a situation.
Short of changing the source, the best way to work around this issue is not to access .snapshot via the regular filesystem, but to mount the filers .snapshot directory itself as a seperate mount point. This will force diff not to make the assumption (since it thinks it is a different filesystem).
Bruce