]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afsd: Make mountdir check kernel-specific
authorAndrew Deason <adeason@sinenomine.net>
Thu, 17 Feb 2011 21:47:00 +0000 (15:47 -0600)
committerDerrick Brashear <shadow@dementia.org>
Fri, 18 Feb 2011 00:41:03 +0000 (16:41 -0800)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/afs/UKERNEL/afsd_uafs.c
src/afsd/afsd.c
src/afsd/afsd.h
src/afsd/afsd_kernel.c

index b1b0fd27826d8bd5c8cca52227c5123984344e24..97994a8023a8af97553d173497c45c07bcc4cede 100644 (file)
@@ -43,6 +43,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)
index c5efb65f5fb02d9b32b719ffd4f47e7e3a35511d..d0c3c1daab394efa12b1207f4cd1faadf8b9e06a 100644 (file)
@@ -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;
        }
     }
 
index bb965a89ee6a85573a73f269f2d7120ef2e9878d..1b66b727757f801f722b1674612a9d33ba1dd9d2 100644 (file)
@@ -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();
index 7f1c874954582b78ccc915dddf0507ff7b0993e9..c0b9531fb09d3e2393dc172875ba8f65b03aeb8d 100644 (file)
@@ -540,6 +540,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)
 {