From bcba3216f8c0cf2559a72c566bded1e55140ac41 Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Mon, 30 Sep 2013 14:56:34 +0300 Subject: [PATCH] Removed redundant is_smackfs_mounted(). This functionality is fully handled in the library initialization. --- utils/common.c | 27 +-------------------------- utils/common.h | 1 - utils/smackcipso.c | 2 +- utils/smackctl.c | 36 ++++++++++++------------------------ utils/smackload.c | 2 +- 5 files changed, 15 insertions(+), 53 deletions(-) diff --git a/utils/common.c b/utils/common.c index 0ff1e78..6b0f270 100644 --- a/utils/common.c +++ b/utils/common.c @@ -37,31 +37,6 @@ 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); diff --git a/utils/common.h b/utils/common.h index dece553..4eb7df2 100644 --- a/utils/common.h +++ b/utils/common.h @@ -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); diff --git a/utils/smackcipso.c b/utils/smackcipso.c index 6fa323d..6e500d2 100644 --- a/utils/smackcipso.c +++ b/utils/smackcipso.c @@ -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); } diff --git a/utils/smackctl.c b/utils/smackctl.c index b8b8282..69b5b9a 100644 --- a/utils/smackctl.c +++ b/utils/smackctl.c @@ -19,14 +19,15 @@ */ #include "common.h" +#include #include #include #include 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 \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; } diff --git a/utils/smackload.c b/utils/smackload.c index 0fe0319..cc62a66 100644 --- a/utils/smackload.c +++ b/utils/smackload.c @@ -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); } -- 2.7.4