afsd_kernel: remove gratuitous OS dependence
[openafs.git] / src / afsd / afsd_kernel.c
index 2346ee6..b15df74 100644 (file)
 #include <roken.h>
 
 #ifdef IGNORE_SOME_GCC_WARNINGS
-# pragma GCC diagnostic warning "-Wdeprecated-declarations"
+# ifdef __clang__
+#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+# else
+#  pragma GCC diagnostic warning "-Wdeprecated-declarations"
+# endif
 #endif
 
 #define VFS 1
@@ -225,7 +229,7 @@ os_syscall(struct afsd_syscall_args *args)
 static int
 os_syscall(struct afsd_syscall_args *args)
 {
-    int retval;
+    int retval, error;
 
     error = ioctl_sun_afs_syscall(AFSCALL_CALL, args->syscall,
                                 args->params[0], args->params[1],
@@ -270,14 +274,14 @@ afsd_call_syscall(struct afsd_syscall_args *args)
     error = os_syscall(args);
 
     if (afsd_debug) {
-#ifdef AFS_NBSD40_ENV
-        char *s = strerror(errno);
-        printf("SScall(%d, %d, %d)=%d (%d, %s)\n", AFS_SYSCALL, AFSCALL_CALL,
-                (int)args->params[0], error, errno, s);
-#else
-       printf("SScall(%d, %d, %d)=%d ", AFS_SYSCALL, AFSCALL_CALL,
-              (int)args->params[0], error);
-#endif
+       if (error == -1) {
+           char *s = strerror(errno);
+           printf("SScall(%d, %d, %d)=%d (%d, %s)\n", AFS_SYSCALL, AFSCALL_CALL,
+                  (int)args->params[0], error, errno, s);
+       } else {
+           printf("SScall(%d, %d, %d)=%d\n", AFS_SYSCALL, AFSCALL_CALL,
+                  (int)args->params[0], error);
+       }
     }
 
     return error;
@@ -485,8 +489,8 @@ afsd_mount_afs(const char *rn, const char *cacheMountDir)
        printf("%s: Mounting the AFS root on '%s', flags: %d.\n", rn,
            cacheMountDir, mountFlags);
 #if defined(AFS_FBSD60_ENV)
-    /* data must be non-NULL but is otherwise ignored */
-    if ((mount(MOUNT_AFS, cacheMountDir, mountFlags, rn)) < 0) {
+    /* data must be non-const non-NULL but is otherwise ignored */
+    if ((mount(MOUNT_AFS, cacheMountDir, mountFlags, &mountFlags)) < 0) {
 #elif defined(AFS_FBSD_ENV)
     if ((mount("AFS", cacheMountDir, mountFlags, (caddr_t) 0)) < 0) {
 #elif defined(AFS_AIX_ENV)
@@ -551,6 +555,9 @@ afsd_check_mount(const char *rn, const char *mountdir)
     } else if (!S_ISDIR(statbuf.st_mode)) {
        printf("%s: Mountpoint %s is not a directory.\n", rn, mountdir);
        return -1;
+    } else if (mountdir[0] != '/') {
+       printf("%s: Mountpoint %s is not an absolute path.\n", rn, mountdir);
+       return -1;
     }
     return 0;
 }
@@ -563,7 +570,10 @@ main(int argc, char **argv)
     afsd_init();
 
     code = afsd_parse(argc, argv);
-    if (code) {
+    if (code == CMD_HELP) {
+       return 0; /* Displaying help is not an error. */
+    }
+    if (code != 0) {
        return -1;
     }