From de1158431ad3308886c54c8ff3d8b6dc8259c41b Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 17 Feb 2011 15:47:00 -0600 Subject: [PATCH] afsd: Make mountdir check kernel-specific Checking if the /afs directory exists only makes sense for the kernel afsd. The libuafs afsd does not care if the mount directory actually exists on the machine or not, since it may not interact with the mount directory path on the local machine at all. So, make the mountdir check code be a new afsd function (afsd_check_mount), and have it stat() the mount directory only in the kernels-specific afsd. Reviewed-on: http://gerrit.openafs.org/3980 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit fd010651194f4c9f1324ea7aa8d84426ce9827e4) Change-Id: Ib4f4fe3a6072f9aea4683bb1ba531da8d965b156 Reviewed-on: http://gerrit.openafs.org/3983 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/UKERNEL/afsd_uafs.c | 9 +++++++++ src/afsd/afsd.c | 11 ++--------- src/afsd/afsd.h | 1 + src/afsd/afsd_kernel.c | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/afs/UKERNEL/afsd_uafs.c b/src/afs/UKERNEL/afsd_uafs.c index 06c61df0c..925ea8cc6 100644 --- a/src/afs/UKERNEL/afsd_uafs.c +++ b/src/afs/UKERNEL/afsd_uafs.c @@ -42,6 +42,15 @@ afsd_set_afsd_rtpri(void) /* noop */ } +int +afsd_check_mount(const char *rn, const char *mountdir) +{ + /* libuafs could provide a callback of some kind to let the user code + * specify a "is this mount point valid?" function, but for now there's + * no need for it. */ + return 0; +} + int afsd_call_syscall(long param1, long param2, long param3, long param4, long param5) diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index e611ca941..5421eca26 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -1923,7 +1923,6 @@ afsd_run(void) { static char rn[] = "afsd"; /*Name of this routine */ struct afsconf_dir *cdir; /* config dir */ - struct stat statbuf; int lookupResult; /*Result of GetLocalCellName() */ int i; afs_int32 code; /*Result of fork() */ @@ -1958,14 +1957,8 @@ afsd_run(void) } if (!enable_nomount) { - if (stat(afsd_cacheMountDir, &statbuf)) { - printf("afsd: Mountpoint %s missing.\n", afsd_cacheMountDir); - exit(1); - } else { - if (!S_ISDIR(statbuf.st_mode)) { - printf("afsd: Mountpoint %s is not a directory.\n", afsd_cacheMountDir); - exit(1); - } + if (afsd_check_mount(rn, afsd_cacheMountDir)) { + return -1; } } diff --git a/src/afsd/afsd.h b/src/afsd/afsd.h index bb965a89e..1b66b7277 100644 --- a/src/afsd/afsd.h +++ b/src/afsd/afsd.h @@ -27,6 +27,7 @@ typedef void* (*afsd_callback_func) (void *rock); /* afsd.c expects these to be implemented; it does not implement them itself! */ void afsd_mount_afs(const char *rn, const char *mountdir); +int afsd_check_mount(const char *rn, const char *mountdir); void afsd_set_rx_rtpri(void); void afsd_set_afsd_rtpri(void); int afsd_call_syscall(); diff --git a/src/afsd/afsd_kernel.c b/src/afsd/afsd_kernel.c index cf8661d7d..750221216 100644 --- a/src/afsd/afsd_kernel.c +++ b/src/afsd/afsd_kernel.c @@ -538,6 +538,21 @@ afsd_daemon(int nochdir, int noclose) return daemon(nochdir, noclose); } +int +afsd_check_mount(const char *rn, const char *mountdir) +{ + struct stat statbuf; + + if (stat(mountdir, &statbuf)) { + printf("%s: Mountpoint %s missing.\n", rn, mountdir); + return -1; + } else if (!S_ISDIR(statbuf.st_mode)) { + printf("%s: Mountpoint %s is not a directory.\n", rn, mountdir); + return -1; + } + return 0; +} + int main(int argc, char **argv) { -- 2.39.5