This functionality is fully handled in the library initialization.
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;
return -1;
}
- if (is_smackfs_mounted() != 1)
+ if (!smack_smackfs_path())
return -1;
snprintf(path, sizeof path, "%s/load2", smack_mnt);
#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);
int main(int argc, char **argv)
{
- if (is_smackfs_mounted() != 1) {
+ if (!smack_smackfs_path()) {
fprintf(stderr, "SmackFS is not mounted.\n");
exit(1);
}
*/
#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;
}
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;
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;
}
int clear = 0;
int c;
- if (is_smackfs_mounted() != 1) {
+ if (!smack_smackfs_path()) {
fprintf(stderr, "SmackFS is not mounted.\n");
exit(1);
}