Daniel Quinlan quinlan@transmeta.com writes:
It's really annoying when find(1) descends into a .snapshot directory.
Here's a patch against GNU findutils 4.1 tested under Linux and Solaris to fix the problem. It still allows descent into .snapshot, but only if .snapshot is specifically listed on the command line. GNU findutils is available at URL:ftp://prep.ai.mit.edu/pub/gnu.
Here's the same for "du", which is even more annoying because there isn't a "-prune" option for du.
Anyone at NetApp care to comment about whether the inode number for ".snapshot" is constant (and can be counted on)? It always appears to be inode 67.
- Dan
--- fileutils-3.16/src/du.c.orig Mon Feb 16 00:46:43 1998 +++ fileutils-3.16/src/du.c Mon Feb 16 00:56:35 1998 @@ -54,6 +54,10 @@ #include "save-cwd.h" #include "error.h"
+#ifndef S_IRWXUGO +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#endif + #undef convert_blocks #define convert_blocks(b, size) (size == size_kilobytes ? ((b) + 1) / 2 : \ size == size_megabytes ? ((b) + 1024) / 2048 : (b)) @@ -518,7 +522,9 @@
tot_size += size;
- if (S_ISDIR (stat_buf.st_mode)) + if (S_ISDIR (stat_buf.st_mode) && + (!(!strcmp(ent, ".snapshot") && (stat_buf.st_uid == 0) && + (stat_buf.st_gid == 0) && ((stat_buf.st_mode & 0777) == S_IRWXUGO)))) { unsigned pathlen; dev_t dir_dev;