From 06f8a69efa8156517a7b277499fe26f68b183dde Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 7 Jun 2023 21:22:06 +0200 Subject: [PATCH] main: fix check for writeable /proc fix the check for writeable /proc to use statfs instead of statvfs, and use the unitialized statvfs structure to check for the writeable bit. Closes: https://github.com/containers/fuse-overlayfs/issues/397 Signed-off-by: Giuseppe Scrivano --- main.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 65369d8..2a8db29 100644 --- a/main.c +++ b/main.c @@ -296,25 +296,23 @@ inode_to_node (struct ovl_data *lo, ino_t n) static void check_writeable_proc () { - struct statvfs svfs; - struct statfs sfs; - + struct statfs svfs; int ret; - ret = statfs ("/proc", &sfs); + ret = statfs ("/proc", &svfs); if (ret < 0) { fprintf (stderr, "error stating /proc: %m\n"); return; } - if (sfs.f_type != PROC_SUPER_MAGIC) + if (svfs.f_type != PROC_SUPER_MAGIC) { - fprintf (stderr, "invalid file system type found on /proc: %m\n"); + fprintf (stderr, "invalid file system type found on /proc: %d, expected %d\n", svfs.f_fsid, PROC_SUPER_MAGIC); return; } - if (svfs.f_flag & ST_RDONLY) + if (svfs.f_flags & ST_RDONLY) { fprintf (stderr, "/proc seems to be mounted as readonly, it can lead to unexpected failures"); return;