aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <JBottomley@Parallels.com>2013-02-27 14:58:14 +0000
committerJames Bottomley <JBottomley@Parallels.com>2013-02-27 09:06:29 -0600
commit89e7f773a9c6124c161171a6b4a466c98c75ffce (patch)
treebcf7dfbb8ead23bdb3e715967988e66567bf5d9b
parent14530e59d752a8d14fe4c4b3fb21815b0ced29e2 (diff)
downloadefitools-89e7f773a9c6124c161171a6b4a466c98c75ffce.tar.gz
kernel_efivars: fix check for fedora
For some weird reason, mount -l -t efivarfs is illegal on fedora. Just do mount -l and grep for efivarfs.
-rw-r--r--lib/kernel_efivars.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/kernel_efivars.c b/lib/kernel_efivars.c
index a00a794..4c20a9b 100644
--- a/lib/kernel_efivars.c
+++ b/lib/kernel_efivars.c
@@ -34,12 +34,13 @@ kernel_variable_init(void)
if (kernel_efi_path)
return;
mktemp(fname);
- snprintf(cmdline, sizeof(cmdline), "mount -l -t efivarfs > %s", fname);
+ snprintf(cmdline, sizeof(cmdline), "mount -l > %s", fname);
ret = system(cmdline);
if (WEXITSTATUS(ret) != 0)
/* hopefully stderr said what was wrong */
exit(1);
fd = open(fname, O_RDONLY);
+ unlink(fname);
if (fd < 0) {
fprintf(stderr, "Failed to open output of %s\n", cmdline);
exit(1);
@@ -54,10 +55,20 @@ kernel_variable_init(void)
}
buf = malloc(st.st_size);
read(fd, buf, st.st_size);
- char dummy[512], path[512], type[512];
- sscanf(buf, "%s on %s type %s ", dummy, path, type);
+ close(fd);
+
+ char *ptr = buf;
+ char path[512], type[512];
+ while (ptr < buf + st.st_size) {
+ int count;
+
+ sscanf(ptr, "%*s on %s type %s %*s\n%n", path, type, &count);
+ ptr += count;
+ if (strcmp(type, "efivarfs") != 0)
+ continue;
+ }
if (strcmp(type, "efivarfs") != 0) {
- fprintf(stderr, "error with mount -l output: %s\n", buf);
+ fprintf(stderr, "No efivarfs filesystem is mounted\n");
exit(1);
}
kernel_efi_path = malloc(strlen(path) + 1);