From fe524cc1a401e9c8ee57a00960bf47a24d29251e Mon Sep 17 00:00:00 2001 From: Jason Edgecombe Date: Fri, 6 Apr 2012 20:58:13 -0400 Subject: [PATCH] Fileserver: Add the /vicepXX/NeverAttach flag to skip mounting a partition FIXES 130561 LICENSE MIT Reviewed-on: http://gerrit.openafs.org/7108 Reviewed-by: Derrick Brashear Tested-by: Jason Edgecombe (cherry picked from commit 35becabed870d4bfe49abaa499d99a3ffb0a2d31) Change-Id: If14e0145404dcb81fb5d2184c0991fa3ca64a1df Reviewed-on: http://gerrit.openafs.org/9470 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Reviewed-by: Stephan Wiesand Reviewed-by: Andrew Deason Tested-by: Stephan Wiesand --- .../pod8/fragments/fileserver-description.pod | 9 ++-- src/vol/partition.c | 42 +++++++++++++++++++ src/vol/partition.h | 5 +++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/doc/man-pages/pod8/fragments/fileserver-description.pod b/doc/man-pages/pod8/fragments/fileserver-description.pod index 09edd3496..1f2792ddd 100644 --- a/doc/man-pages/pod8/fragments/fileserver-description.pod +++ b/doc/man-pages/pod8/fragments/fileserver-description.pod @@ -127,9 +127,12 @@ or C where XX is "a" through "z" or "aa" though "iv". Up to 255 partitions are allowed. The File Server expects that the /vicepXX directories are each on a dedicated filesystem. The File Server will only use a /vicepXX if it's a mountpoint for another filesystem, -unless the file C exists. The data in the -partition is a special format that can only be access using OpenAFS -commands or an OpenAFS client. +unless the file C exists. A partition will not be +mounted if the file C exists. If both +C and C are present, then +C wins. The data in the partition is a special +format that can only be access using OpenAFS commands or an OpenAFS +client. The File Server generates the following message when a partition is nearly full: diff --git a/src/vol/partition.c b/src/vol/partition.c index 4118241cd..a8edaf185 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -445,6 +445,28 @@ VIsAlwaysAttach(char *part, int *awouldattach) #endif /* AFS_NAMEI_ENV */ } +/* VIsNeverAttach() checks whether a /vicepX directory should never be + * attached (return value 1), or follow the normal mounting logic. The + * Always Attach flag may override the NeverAttach flag. + */ +static int +VIsNeverAttach(char *part) +{ + struct afs_stat st; + char checkfile[256]; + int ret; + + if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) + return 0; + + strncpy(checkfile, part, 100); + strcat(checkfile, OS_DIRSEP); + strcat(checkfile, VICE_NEVERATTACH_FILE); + + ret = afs_stat(checkfile, &st); + return (ret < 0) ? 0 : 1; +} + /* VAttachPartitions2() looks for and attaches /vicepX partitions * where a special file (VICE_ALWAYSATTACH_FILE) exists. This is * used to attach /vicepX directories which aren't on dedicated @@ -525,6 +547,10 @@ VAttachPartitions(void) || (strncmp(mnt.mnt_mntopts, "ro,ignore", 9) == 0)) continue; + /* Skip this Partition? */ + if (VIsNeverAttach(mntent->mnt_dir)) + continue; + /* If we're going to always attach this partition, do it later. */ if (VIsAlwaysAttach(mnt.mnt_mountp, NULL)) continue; @@ -564,6 +590,10 @@ VAttachPartitions(void) if (!hasmntopt(mntent, MNTOPT_RW)) continue; + /* Skip this Partition? */ + if (VIsNeverAttach(mntent->mnt_dir)) + continue; + /* If we're going to always attach this partition, do it later. */ if (VIsAlwaysAttach(mntent->mnt_dir, NULL)) continue; @@ -667,6 +697,10 @@ VAttachPartitions(void) #endif #endif + /* Skip this Partition? */ + if (VIsNeverAttach(mntent->mnt_dir)) + continue; + /* If we're going to always attach this partition, do it later. */ if (VIsAlwaysAttach(part, NULL)) continue; @@ -697,6 +731,10 @@ VAttachPartitions(void) if (strcmp(fsent->fs_type, "rw") != 0) continue; + /* Skip this Partition? */ + if (VIsNeverAttach(mntent->mnt_dir)) + continue; + /* If we're going to always attach this partition, do it later. */ if (VIsAlwaysAttach(fsent->fs_file, NULL)) continue; @@ -881,6 +919,10 @@ VAttachPartitions(void) } } while ((mntent = getmntent(mfd))) { + /* Skip this Partition? */ + if (VIsNeverAttach(mntent->mnt_dir)) + continue; + /* If we're going to always attach this partition, do it later. */ if (VIsAlwaysAttach(mntent->mnt_dir, NULL)) continue; diff --git a/src/vol/partition.h b/src/vol/partition.h index 4050b2951..ed38d9f84 100644 --- a/src/vol/partition.h +++ b/src/vol/partition.h @@ -50,6 +50,11 @@ #define VICE_ALWAYSATTACH_FILE "AlwaysAttach" #endif +/* If a file by this name exists in a /vicepX directory, it means that + * this directory should NOT be used as an AFS partition. + */ +#define VICE_NEVERATTACH_FILE "NeverAttach" + /** * abstraction for files used for file-locking. */ -- 2.39.5