From 8c25d98cce08280348b5d948758932ac2f56cc46 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Sun, 3 Oct 2010 18:27:19 -0500 Subject: [PATCH] vol: Log ignored dirs that look like partitions If we see a /vicep*-like directory when we VAttachPartitions, and we ignore it because it lacks an AlwaysAttach, log that we ignored it. This may make things less confusing to admins that just try to create a /vicep* directory and don't know why it doesn't work. Feature suggested by Jason Edgecombe. FIXES 128221 Reviewed-on: http://gerrit.openafs.org/2893 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear Tested-by: BuildBot (cherry picked from commit 4803d50bdb8cdeae2c3f86b5c09e853573bc49eb) Change-Id: I5d26d0b0edbd5eb11345c4be937d7ff986f46855 Reviewed-on: http://gerrit.openafs.org/3047 Tested-by: Derrick Brashear --- src/vol/partition.c | 54 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/src/vol/partition.c b/src/vol/partition.c index faa6861d6..d3f0a8006 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -401,18 +401,34 @@ VCheckPartition(char *part, char *devname) * attached (return value 1), or only attached when it is a separately * mounted partition (return value 0). For non-NAMEI environments, it * always returns 0. + * + * *awouldattach will be set to 1 if the given path at least looks like a vice + * partition (that is, if we return 0, the only thing preventing this partition + * from being attached is the existence of the AlwaysAttach file), or to 0 + * otherwise. *awouldattach is set regardless of whether or not the partition + * should always be attached or not. */ static int -VIsAlwaysAttach(char *part) +VIsAlwaysAttach(char *part, int *awouldattach) { #ifdef AFS_NAMEI_ENV struct afs_stat st; char checkfile[256]; int ret; +#endif /* AFS_NAMEI_ENV */ + if (awouldattach) { + *awouldattach = 0; + } + +#ifdef AFS_NAMEI_ENV if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) return 0; + if (awouldattach) { + *awouldattach = 1; + } + strncpy(checkfile, part, 100); strcat(checkfile, "/"); strcat(checkfile, VICE_ALWAYSATTACH_FILE); @@ -436,6 +452,7 @@ VAttachPartitions2(void) DIR *dirp; struct dirent *de; char pname[32]; + int wouldattach; dirp = opendir("/"); while ((de = readdir(dirp))) { @@ -445,8 +462,31 @@ VAttachPartitions2(void) /* Only keep track of "/vicepx" partitions since automounter * may hose us */ - if (VIsAlwaysAttach(pname)) + if (VIsAlwaysAttach(pname, &wouldattach)) { VCheckPartition(pname, ""); + } else { + struct afs_stat st; + if (wouldattach && VGetPartition(pname, 0) == NULL && + afs_stat(pname, &st) == 0 && S_ISDIR(st.st_mode)) { + + /* This is a /vicep* dir, and it has not been attached as a + * partition. This probably means that this is a /vicep* dir + * that is not a separate partition, so just give a notice so + * admins are not confused as to why their /vicep* dirs are not + * being attached. + * + * It is possible that the dir _is_ a separate partition and we + * failed to attach it earlier, making this message a bit + * confusing. But that should be rare, and an error message + * about the failure will already be logged right before this, + * so it should be clear enough. */ + + Log("VAttachPartitions: not attaching %s; either it is not a " + "separate partition, or it failed to attach (create the " + "file %s/" VICE_ALWAYSATTACH_FILE " to force attachment)\n", + pname, pname); + } + } } closedir(dirp); #endif /* AFS_NAMEI_ENV */ @@ -480,7 +520,7 @@ VAttachPartitions(void) continue; /* If we're going to always attach this partition, do it later. */ - if (VIsAlwaysAttach(mnt.mnt_mountp)) + if (VIsAlwaysAttach(mnt.mnt_mountp, NULL)) continue; #ifndef AFS_NAMEI_ENV @@ -525,7 +565,7 @@ VAttachPartitions(void) continue; /* If we're going to always attach this partition, do it later. */ - if (VIsAlwaysAttach(mntent->mnt_dir)) + if (VIsAlwaysAttach(mntent->mnt_dir, NULL)) continue; if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0) @@ -628,7 +668,7 @@ VAttachPartitions(void) #endif /* If we're going to always attach this partition, do it later. */ - if (VIsAlwaysAttach(part)) + if (VIsAlwaysAttach(part, NULL)) continue; if (VCheckPartition(part, vmt2dataptr(vmountp, VMT_OBJECT)) < 0) @@ -658,7 +698,7 @@ VAttachPartitions(void) continue; /* If we're going to always attach this partition, do it later. */ - if (VIsAlwaysAttach(fsent->fs_file)) + if (VIsAlwaysAttach(fsent->fs_file, NULL)) continue; if (VCheckPartition(fsent->fs_file, fsent->fs_spec) < 0) @@ -842,7 +882,7 @@ VAttachPartitions(void) } while ((mntent = getmntent(mfd))) { /* If we're going to always attach this partition, do it later. */ - if (VIsAlwaysAttach(mntent->mnt_dir)) + if (VIsAlwaysAttach(mntent->mnt_dir, NULL)) continue; if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0) -- 2.39.5