4949
5050#include "syscall/abi.h"
5151#include "syscall/fd.h"
52+ #include "syscall/fuse.h"
5253#include "syscall/internal.h"
5354#include "syscall/proc.h"
5455#include "syscall/sys.h"
@@ -2000,6 +2001,7 @@ int proc_intercept_open(const guest_t *g,
20002001 "\tproc\n"
20012002 "\tsysfs\n"
20022003 "\tdevtmpfs\n"
2004+ "\tfuse\n"
20032005 "\text4\n"
20042006 "\tvfat\n" );
20052007 }
@@ -2009,23 +2011,35 @@ int proc_intercept_open(const guest_t *g,
20092011 * - type source super_options
20102012 */
20112013 if (!strcmp (path , "/proc/self/mountinfo" )) {
2012- return proc_emit_literal (
2014+ char buf [8192 ];
2015+ size_t off = (size_t ) snprintf (
2016+ buf , sizeof (buf ),
20132017 "1 0 0:1 / / rw,relatime - ext4 /dev/root rw\n"
20142018 "2 1 0:2 / /proc rw,nosuid,nodev,noexec - proc proc rw\n"
20152019 "3 1 0:3 / /tmp rw,nosuid,nodev - tmpfs tmpfs rw\n"
20162020 "4 1 0:4 / /dev rw,nosuid - devtmpfs devtmpfs rw\n"
20172021 "5 4 0:5 / /dev/shm rw,nosuid,nodev - tmpfs tmpfs rw\n" );
2022+ if (off >= sizeof (buf ) ||
2023+ fuse_append_mountinfo (buf , sizeof (buf ), & off ) < 0 )
2024+ return -1 ;
2025+ return proc_synthetic_fd (buf , off );
20182026 }
20192027
20202028 /* /proc/mounts, /etc/mtab -> synthetic mount table */
20212029 if (!strcmp (path , "/proc/mounts" ) || !strcmp (path , "/proc/self/mounts" ) ||
20222030 !strcmp (path , "/etc/mtab" )) {
2023- return proc_emit_literal (
2024- "/ / ext4 rw,relatime 0 0\n"
2025- "proc /proc proc rw,nosuid,nodev,noexec 0 0\n"
2026- "tmpfs /tmp tmpfs rw,nosuid,nodev 0 0\n"
2027- "devtmpfs /dev devtmpfs rw,nosuid 0 0\n"
2028- "tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0\n" );
2031+ char buf [8192 ];
2032+ size_t off =
2033+ (size_t ) snprintf (buf , sizeof (buf ),
2034+ "/ / ext4 rw,relatime 0 0\n"
2035+ "proc /proc proc rw,nosuid,nodev,noexec 0 0\n"
2036+ "tmpfs /tmp tmpfs rw,nosuid,nodev 0 0\n"
2037+ "devtmpfs /dev devtmpfs rw,nosuid 0 0\n"
2038+ "tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0\n" );
2039+ if (off >= sizeof (buf ) ||
2040+ fuse_append_mounts (buf , sizeof (buf ), & off ) < 0 )
2041+ return -1 ;
2042+ return proc_synthetic_fd (buf , off );
20292043 }
20302044
20312045 /* OOM nodes share one stored adjustment.
@@ -2114,12 +2128,15 @@ int proc_intercept_open(const guest_t *g,
21142128 }
21152129 }
21162130
2131+ int mnt_id = 0 ;
2132+ if (fuse_fd_mnt_id (n , & mnt_id ) < 0 )
2133+ mnt_id = 0 ;
21172134 return proc_emit_fmt (
21182135 "pos:\t%lld\n"
21192136 "flags:\t0%o\n"
2120- "mnt_id:\t0 \n"
2137+ "mnt_id:\t%d \n"
21212138 "%s" ,
2122- (long long ) pos , snap .linux_flags , extra );
2139+ (long long ) pos , snap .linux_flags , mnt_id , extra );
21232140 }
21242141
21252142 /* /proc/self/fdinfo -> directory listing. Each open gets its own scratch
@@ -2367,6 +2384,9 @@ int proc_intercept_stat(const char *path, struct stat *st)
23672384 * irrelevant here; callers need stat to succeed before opening the
23682385 * synthetic file.
23692386 */
2387+ if (!strcmp (path , "/dev/fuse" ))
2388+ return fuse_proc_stat (st );
2389+
23702390 /* /dev/shm is a directory */
23712391 if (!strcmp (path , "/dev/shm" ) || !strcmp (path , "/dev/shm/" )) {
23722392 stat_fill_proc_dir (st , 01777 , 2 ,
0 commit comments