Removed redundant is_smackfs_mounted().
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 30 Sep 2013 11:56:34 +0000 (14:56 +0300)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Mon, 30 Sep 2013 12:00:18 +0000 (15:00 +0300)
This functionality is fully handled in the library initialization.

utils/common.c
utils/common.h
utils/smackcipso.c
utils/smackctl.c
utils/smackload.c

index 0ff1e78..6b0f270 100644 (file)
 static int apply_rules_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf);
 static int apply_cipso_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf);
 
-int is_smackfs_mounted(void)
-{
-       struct statfs sfs;
-       int ret;
-       const char * smack_mnt;
-
-       smack_mnt = smack_smackfs_path();
-       if (!smack_mnt) {
-               errno = EFAULT;
-               return -1;
-       }
-
-       do {
-               ret = statfs(smack_mnt, &sfs);
-       } while (ret < 0 && errno == EINTR);
-
-       if (ret)
-               return -1;
-
-       if (sfs.f_type == SMACK_MAGIC)
-               return 1;
-
-       return 0;
-}
-
 int clear(void)
 {
        int fd;
@@ -75,7 +50,7 @@ int clear(void)
                return -1;
        }
 
-       if (is_smackfs_mounted() != 1)
+       if (!smack_smackfs_path())
                return -1;
 
        snprintf(path, sizeof path, "%s/load2", smack_mnt);
index dece553..4eb7df2 100644 (file)
@@ -25,7 +25,6 @@
 #define CIPSO_D_PATH "/etc/smack/cipso.d"
 
 int clear(void);
-int is_smackfs_mounted(void);
 int apply_rules(const char *path, int clear);
 int apply_cipso(const char *path);
 int apply_rules_file(int fd, int clear);
index 6fa323d..6e500d2 100644 (file)
@@ -25,7 +25,7 @@
 
 int main(int argc, char **argv)
 {
-       if (is_smackfs_mounted() != 1) {
+       if (!smack_smackfs_path()) {
                fprintf(stderr, "SmackFS is not mounted.\n");
                exit(1);
        }
index b8b8282..69b5b9a 100644 (file)
  */
 
 #include "common.h"
+#include <sys/smack.h>
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 
 static int apply_all(void)
 {
-       if (is_smackfs_mounted() != 1) {
-               fprintf(stderr, "ERROR: SmackFS is not mounted.\n");
+       if (!smack_smackfs_path()) {
+               fprintf(stderr, "SmackFS is not mounted.\n");
                return -1;
        }
 
@@ -42,24 +43,9 @@ static int apply_all(void)
        return 0;
 }
 
-static int status(void)
-{
-       int ret = is_smackfs_mounted();
-
-       switch (ret) {
-       case 1:
-               printf("SmackFS is mounted.\n");
-               return 0;
-       case 0:
-               printf("SmackFS is not mounted.\n");
-               return 0;
-       default:
-               return -1;
-       }
-}
-
 int main(int argc, char **argv)
 {
+       const char *tmp = smack_smackfs_path();
        if (argc < 2) {
                fprintf(stderr, "Usage: %s <action>\n", argv[0]);
                return 1;
@@ -72,12 +58,14 @@ int main(int argc, char **argv)
                if (clear())
                        return 1;
        } else if (!strcmp(argv[1], "status")) {
-               if (status())
-                       return 1;
-       } else {
-               fprintf(stderr, "Uknown action: %s\n", argv[1]);
-               return 1;
+               if (smack_smackfs_path())
+                       printf("SmackFS is mounted to %s.\n",
+                              smack_smackfs_path());
+               else
+                       printf("SmackFS is not mounted.\n");
+               return 0;
        }
 
-       return 0;
+       fprintf(stderr, "Uknown action: %s\n", argv[1]);
+       return 1;
 }
index 0fe0319..cc62a66 100644 (file)
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
        int clear = 0;
        int c;
 
-       if (is_smackfs_mounted() != 1) {
+       if (!smack_smackfs_path()) {
                fprintf(stderr, "SmackFS is not mounted.\n");
                exit(1);
        }