[systemd-devel] [PATCH] smack: check smack cache after /sys mount
WaLyong Cho
walyong.cho at samsung.com
Wed Jul 16 09:29:38 PDT 2014
use_smack_cached is capability of smack. That is not changed on
runtime. So that should be a cache for performance. But the cache is
updated as wrong value(maybe 0) upon calling first mount_one. At this
time, until v210 "/proc" will be tried. After v211 "/sys" will be
tried. But both of first trial of mount_one "/sys" is NOT mounted
yet. Because even if the first trial is "/sys", use_smack is called
before mount by label_mkdir. So the cache will always have 0.
To avoid, smack cache should be updated when only "/sys" is mounted
and smack cache is have initial value.
---
src/shared/smack-util.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c
index 8f83562..1887ab8 100644
--- a/src/shared/smack-util.c
+++ b/src/shared/smack-util.c
@@ -31,7 +31,8 @@ bool use_smack(void) {
#ifdef HAVE_SMACK
static int use_smack_cached = -1;
- if (use_smack_cached < 0)
+ if (use_smack_cached < 0 &&
+ path_is_mount_point("/sys", false) > 0)
use_smack_cached = access("/sys/fs/smackfs/", F_OK) >= 0;
return use_smack_cached;
--
1.9.3
More information about the systemd-devel
mailing list