From 691f74d3bb6a06e56f895a5b844ad7dad297a860 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Wed, 31 Oct 2018 13:38:07 +1100 Subject: Add check for configfs filesystem Check /proc/filesystems for the configfs filesystem. If the kernel does not support configfs, we cannot use AVIRT Signed-off-by: Mark Farrugia --- src/avirt-config.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/avirt-config.c b/src/avirt-config.c index 96c9cd4..e1b60b9 100644 --- a/src/avirt-config.c +++ b/src/avirt-config.c @@ -61,7 +61,30 @@ static bool card_sealed = false; static int mount_configfs() { int err; + char fsline[100]; + bool configfs_supported = false; + FILE *procfs; struct stat st = {0}; + + // Check for /proc/filesystem for configfs support + procfs = fopen("/proc/filesystems", "r"); + if (!procfs) + return -1; + + while (fgets(fsline, 100, procfs)) + { + if (!strstr(fsline, "configfs")) + continue; + configfs_supported = true; + } + + if (!configfs_supported) + { + AVIRT_ERROR("configfs is not supported !"); + return -1; + } + + // Check whether /config dir exists, if not, create it if (stat("/config", &st) == -1) mkdir("/config", S_IRWXU | S_IRWXG | S_IRWXO); -- cgit 1.2.3-korg