From be916b0f009e3c643da5cd928907a28629cc9726 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 18 Jan 2010 19:25:02 -0500 Subject: [PATCH] macos set don't backup attribute on cache files hint to time machine that cache files should not be backed up Change-Id: I098c9231139b91ff093be74d8a39f94c185d478c Reviewed-on: http://gerrit.openafs.org/1122 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afsd/afsd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index adc6bec..60372ad 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -158,6 +158,7 @@ void set_staticaddrs(void); #ifdef AFS_DARWIN_ENV #ifdef AFS_DARWIN80_ENV #include +#include #endif #include #ifndef AFS_DARWIN100_ENV @@ -794,6 +795,24 @@ CreateCacheSubDir(char *basename, int dirNum) return (0); } +static void +SetNoBackupAttr(char *fullpn) +{ +#ifdef AFS_DARWIN80_ENV + int ret; + + ret = setxattr(fullpn, "com.apple.metadata:com_apple_backup_excludeItem", + "com.apple.backupd", strlen("com.apple.backupd"), 0, + XATTR_CREATE); + if(ret < 0) + { + if(errno != EEXIST) + fprintf(stderr, "afsd: Warning: failed to set attribute to preclude cache backup: %s\n", strerror(errno)); + } +#endif + return; +} + static int MoveCacheFile(char *basename, int fromDir, int toDir, int cacheFile, int maxDir) @@ -827,6 +846,7 @@ MoveCacheFile(char *basename, int fromDir, int toDir, int cacheFile, from, to, ret, errno); return -1; } + SetNoBackupAttr(to); /* Reset directory pointer; fix file counts */ dir_for_V[cacheFile] = toDir; @@ -1072,16 +1092,19 @@ doSweepAFSCache(int *vFilesFound, * Found the file holding the dcache entries. */ missing_DCacheFile = 0; + SetNoBackupAttr(fullpn_DCacheFile); } else if (dirNum < 0 && strcmp(currp->d_name, VOLINFOFILE) == 0) { /* * Found the file holding the volume info. */ missing_VolInfoFile = 0; + SetNoBackupAttr(fullpn_VolInfoFile); } else if (dirNum < 0 && strcmp(currp->d_name, CELLINFOFILE) == 0) { /* * Found the file holding the cell info. */ missing_CellInfoFile = 0; + SetNoBackupAttr(fullpn_CellInfoFile); } else if ((strcmp(currp->d_name, ".") == 0) || (strcmp(currp->d_name, "..") == 0) || #ifdef AFS_DECOSF_ENV @@ -1161,6 +1184,7 @@ doSweepAFSCache(int *vFilesFound, cache_dir_list[thisDir]++; (*vFilesFound)++; } + SetNoBackupAttr(fullpn_VFile); } } else if (dir_for_V[vFileNum] >= maxDir -- 1.9.4