diff --git a/main.c b/main.c index b6241da..27dcc95 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,9 @@ #include #include #include +#include #include +#include #include #ifdef HAVE_SYS_SENDFILE_H # include @@ -291,6 +293,34 @@ inode_to_node (struct ovl_data *lo, ino_t n) return lookup_inode (lo, n)->node; } +static void +check_writeable_proc () +{ + struct statvfs svfs; + struct statfs sfs; + + int ret; + + ret = statfs ("/proc", &sfs); + if (ret < 0) + { + fprintf (stderr, "error stating /proc: %m\n"); + return; + } + + if (sfs.f_type != PROC_SUPER_MAGIC) + { + fprintf (stderr, "invalid file system type found on /proc: %m\n"); + return; + } + + if (svfs.f_flag & ST_RDONLY) + { + fprintf (stderr, "/proc seems to be mounted as readonly, it can lead to unexpected failures"); + return; + } +} + static void check_can_mknod (struct ovl_data *lo) { @@ -5617,6 +5647,7 @@ main (int argc, char *argv[]) set_limits (); check_can_mknod (&lo); + check_writeable_proc (); if (lo.debug) {