minor fixes
This commit is contained in:
parent
588bc8c834
commit
e528e59619
4 changed files with 11 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
/starter/alpine-make-rootfs/
|
/starter/alpine-make-rootfs/
|
||||||
/run
|
/run
|
||||||
|
/starter/shared
|
||||||
/starter/starter
|
/starter/starter
|
||||||
/starter/minrootfs
|
/starter/minrootfs
|
||||||
/pkg/go/gen
|
/pkg/go/gen
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -5,6 +5,7 @@ all:
|
||||||
make generate
|
make generate
|
||||||
init:
|
init:
|
||||||
git clone https://github.com/alpinelinux/alpine-make-rootfs
|
git clone https://github.com/alpinelinux/alpine-make-rootfs
|
||||||
|
rm -rf starter/minrootfs
|
||||||
mv alpine-make-rootfs starter/alpine-make-rootfs
|
mv alpine-make-rootfs starter/alpine-make-rootfs
|
||||||
mkrootfs:
|
mkrootfs:
|
||||||
starter/create_rootfs.sh
|
starter/create_rootfs.sh
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
if [[ $(whoami) != root ]]
|
if [[ $(whoami) != root ]]
|
||||||
then
|
then
|
||||||
echo "run as root please"
|
echo -e "\e[38;5;1mrun as root please\e[0m"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,10 @@ void mnt_prepare(char* rootfs, char* shared_mountpoint) {
|
||||||
if (mount(rootfs,rootfs,"ext4",MS_BIND,"")) die("failed to mount %s: %m", rootfs);
|
if (mount(rootfs,rootfs,"ext4",MS_BIND,"")) die("failed to mount %s: %m", rootfs);
|
||||||
//if (mount(shared_mountpoint,shared_mountpoint,"ext4",MS_BIND,"")) die("failed to mount %s: %m",shared_mountpoint);
|
//if (mount(shared_mountpoint,shared_mountpoint,"ext4",MS_BIND,"")) die("failed to mount %s: %m",shared_mountpoint);
|
||||||
if (chdir(rootfs)) die("falied to cd:%m");
|
if (chdir(rootfs)) die("falied to cd:%m");
|
||||||
if (mount("/sys","sys","sysfs",0,"")) die("failed to mount: %m");
|
//if (mount("/sys","sys","sysfs",0,"")) die("failed to mount sysfs: %m");
|
||||||
//if (mount("/dev","dev","udev",0,"")) die("failed to mount: %m");
|
//if (mount("/dev","dev","udev",0,"")) die("failed to mount: %m");
|
||||||
if (mkdir("shared", 0777) && errno != EEXIST) die("Failed to mkdir %s: %m\n", shared_mountpoint);
|
if (mkdir("shared", 0777) && errno != EEXIST) die("Failed to mkdir %s: %m\n", shared_mountpoint);
|
||||||
if (mount(shared_folder,"shared","ext4",MS_BIND,"")) die("failed to mount: %m");
|
if (mount(shared_folder,"shared","ext4",MS_BIND,"")) die("failed to mount shared folder: %m");
|
||||||
if (mkdir(put_old, 0000) && errno != EEXIST) die("Failed to mkdir %s: %m\n", put_old);
|
if (mkdir(put_old, 0000) && errno != EEXIST) die("Failed to mkdir %s: %m\n", put_old);
|
||||||
if (syscall(SYS_pivot_root, ".", put_old)) die("Failed to pivot_root from %s to %s: %m\n", rootfs, put_old);
|
if (syscall(SYS_pivot_root, ".", put_old)) die("Failed to pivot_root from %s to %s: %m\n", rootfs, put_old);
|
||||||
if (chdir("/")) die("Failed to chdir to new root: %m\n");
|
if (chdir("/")) die("Failed to chdir to new root: %m\n");
|
||||||
|
@ -57,9 +57,9 @@ static int nsrun(void* arg) {
|
||||||
struct params *params = (struct params*) arg;
|
struct params *params = (struct params*) arg;
|
||||||
await_setup(params->fd[0]);
|
await_setup(params->fd[0]);
|
||||||
if(chdir("shared")) die("failed to chdir: %m");
|
if(chdir("shared")) die("failed to chdir: %m");
|
||||||
int out_fd=open("out",O_WRONLY|O_CREAT);
|
//int out_fd=open("out",O_WRONLY|O_CREAT);
|
||||||
if(out_fd==-1) die("unable to open out file:%m");
|
//if(out_fd==-1) die("unable to open out file:%m");
|
||||||
else dup2(out_fd,STDOUT_FILENO);
|
//else dup2(out_fd,STDOUT_FILENO);
|
||||||
if(chdir("..")) die("failed to chdir: %m");
|
if(chdir("..")) die("failed to chdir: %m");
|
||||||
mnt_prepare("minrootfs",params->shared_folder);
|
mnt_prepare("minrootfs",params->shared_folder);
|
||||||
sethostname(hostname,sizeof(hostname));
|
sethostname(hostname,sizeof(hostname));
|
||||||
|
|
Loading…
Reference in a new issue