aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsakaki <sakaki@deciban.com>2014-05-18 20:12:46 +0100
committerJames Bottomley <JBottomley@Parallels.com>2014-05-27 11:07:50 +0400
commitc33fc28e6be00ac0bfae7fcff48170830a4730d8 (patch)
tree167d02b39dc33c2d21e1d93fe9639646e0d5c8b1
parent9af07a90a3e2246be5a7d01e3a037cfa731eb5dc (diff)
downloadefitools-c33fc28e6be00ac0bfae7fcff48170830a4730d8.tar.gz
safer mount output parsing
When trying it recently on a Gentoo box (running LVM), I encountered a problem - all the programs would exit with "No efivarfs filesystem is mounted" Tracking this down, it turns out that the output of the mount command contains an extra field (in Gentoo anyway) when it is an LVM mount - so for example, I get: # mount -l proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) none on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755) udev on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=995888,mode=755) devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) /dev/mapper/vg1-root on / type ext4 (rw,noatime,discard,errors=remount-ro,data=ordered) *[root]* tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /tmp type tmpfs (rw) fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime) /dev/mapper/vg1-home on /home type ext4 (rw,relatime,discard,data=ordered) *[home]* Note the entries in bold ('[root]' and '[home]'). These mess up the sscanf parsing in the kernel_variable_init() function, getting it out of step, and ultimately meaning that it fails to recognize the efivarfs entry. Hence the error. The enclosed small patch fixes this, by switching the final "%*s\n" in the sscanf to "%*[^\n]\n", which will consume anything up to the newline. Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--lib/kernel_efivars.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/kernel_efivars.c b/lib/kernel_efivars.c
index 7c42ac4..07af225 100644
--- a/lib/kernel_efivars.c
+++ b/lib/kernel_efivars.c
@@ -66,7 +66,7 @@ kernel_variable_init(void)
while (ptr < buf + st.st_size) {
int count;
- sscanf(ptr, "%*s on %s type %s %*s\n%n", path, type, &count);
+ sscanf(ptr, "%*s on %s type %s %*[^\n]\n%n", path, type, &count);
ptr += count;
if (strcmp(type, "efivarfs") == 0)
break;