From: Andrew Deason Date: Thu, 17 Feb 2011 21:47:00 +0000 (-0600) Subject: afsd: Make mountdir check kernel-specific X-Git-Tag: openafs-devel-1_7_1~915 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=fd010651194f4c9f1324ea7aa8d84426ce9827e4 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. Change-Id: Ic0b524e23f518c4f3c9954e6b9614bca984306a3 Reviewed-on: http://gerrit.openafs.org/3980 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/UKERNEL/afsd_uafs.c b/src/afs/UKERNEL/afsd_uafs.c index b1b0fd2..97994a8 100644 --- a/src/afs/UKERNEL/afsd_uafs.c +++ b/src/afs/UKERNEL/afsd_uafs.c @@ -44,6 +44,15 @@ afsd_set_afsd_rtpri(void) } 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 c5efb65..d0c3c1d 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -1918,7 +1918,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() */ @@ -1953,14 +1952,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 bb965a8..1b66b72 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 7f1c874..c0b9531 100644 --- a/src/afsd/afsd_kernel.c +++ b/src/afsd/afsd_kernel.c @@ -541,6 +541,21 @@ afsd_daemon(int nochdir, int 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) { int code;