From 35becabed870d4bfe49abaa499d99a3ffb0a2d31 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 Change-Id: Ib465a978d08238d83c4c0a03813f5ec240f9bd9b Reviewed-on: http://gerrit.openafs.org/7108 Reviewed-by: Derrick Brashear Tested-by: Jason Edgecombe --- .../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 d4ebb64ae..155505fba 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 0e3e44831..95bb8a8cf 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -398,6 +398,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 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 @@ -478,6 +500,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; @@ -517,6 +543,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; @@ -620,6 +650,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; @@ -650,6 +684,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; @@ -834,6 +872,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 8fe774da3..28c96cfb4 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