mcexec: support for /sys mounted by mcoverlayfs
This commit is contained in:
@ -44,6 +44,7 @@ fi
|
||||
# Remove mcoverlay if loaded
|
||||
if [ "$enable_mcoverlay" != "" ]; then
|
||||
if [ "`lsmod | grep mcoverlay`" != "" ]; then
|
||||
if [ "`cat /proc/mounts | grep /tmp/mcos/mcos0_sys`" != "" ]; then umount -l /tmp/mcos/mcos0_sys; fi
|
||||
if [ "`cat /proc/mounts | grep /tmp/mcos/mcos0_proc`" != "" ]; then umount -l /tmp/mcos/mcos0_proc; fi
|
||||
if [ "`cat /proc/mounts | grep /tmp/mcos`" != "" ]; then umount -l /tmp/mcos; fi
|
||||
if [ -e /tmp/mcos ]; then rm -rf /tmp/mcos; fi
|
||||
@ -123,5 +124,20 @@ if [ "$enable_mcoverlay" != "" ]; then
|
||||
if [ ! -e /tmp/mcos/mcos0_proc_work ]; then mkdir -p /tmp/mcos/mcos0_proc_work; fi
|
||||
if ! mount -t mcoverlay mcoverlay -o lowerdir=/proc/mcos0:/proc,upperdir=/tmp/mcos/mcos0_proc_upper,workdir=/tmp/mcos/mcos0_proc_work,nocopyupw,nofscheck /tmp/mcos/mcos0_proc; then echo "error: mount /tmp/mcos/mcos0_proc"; exit; fi
|
||||
mount --make-rprivate /proc
|
||||
if [ ! -e /tmp/mcos/mcos0_sys ]; then mkdir -p /tmp/mcos/mcos0_sys; fi
|
||||
if [ ! -e /tmp/mcos/mcos0_sys_upper ]; then mkdir -p /tmp/mcos/mcos0_sys_upper; fi
|
||||
if [ ! -e /tmp/mcos/mcos0_sys_work ]; then mkdir -p /tmp/mcos/mcos0_sys_work; fi
|
||||
if ! mount -t mcoverlay mcoverlay -o lowerdir=/sys/devices/virtual/mcos/mcos0/sys:/sys,upperdir=/tmp/mcos/mcos0_sys_upper,workdir=/tmp/mcos/mcos0_sys_work,nocopyupw,nofscheck /tmp/mcos/mcos0_sys; then echo "error: mount /tmp/mcos/mcos0_sys"; exit; fi
|
||||
mount --make-rprivate /sys
|
||||
for cpuid in `find /sys/devices/system/cpu/* -maxdepth 0 -name "cpu[0123456789]*" -printf "%f "`; do
|
||||
if [ ! -e "/sys/devices/virtual/mcos/mcos0/sys/devices/system/cpu/$cpuid" ]; then
|
||||
rm -rf /tmp/mcos/mcos0_sys/devices/system/cpu/$cpuid
|
||||
fi
|
||||
done
|
||||
for cpuid in `find /sys/bus/cpu/devices/* -maxdepth 0 -name "cpu[0123456789]*" -printf "%f "`; do
|
||||
if [ ! -e "/sys/devices/virtual/mcos/mcos0/sys/bus/cpu/devices/$cpuid" ]; then
|
||||
rm -rf /tmp/mcos/mcos0_sys/bus/cpu/devices/$cpuid
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
@ -1304,6 +1304,7 @@ int main(int argc, char **argv)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
|
||||
__dprintf("mcoverlay enable\n");
|
||||
char mcos_procdir[PATH_MAX];
|
||||
char mcos_sysdir[PATH_MAX];
|
||||
|
||||
error = isunshare();
|
||||
if (error == 0) {
|
||||
@ -1319,6 +1320,13 @@ int main(int argc, char **argv)
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
sprintf(mcos_sysdir, "/tmp/mcos/mcos%d_sys", mcosid);
|
||||
if (mount(mcos_sysdir, "/sys", NULL, MS_BIND, NULL)) {
|
||||
fprintf(stderr, "Error: Failed to mount. (%s)\n",
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
} else if (error == -1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user