// File: establishment[P]sandman/src/lib.hpp
// Function: ProcessInitialiser::setupRoot()
void setupRoot() {
        Base::MakeDir("root", 0750);

        /*
         * Ensure all mounts are private, not shared. We don't want our mounts
         * appearing outside of our namespace.
         * (systemd since version 188 mounts filesystems shared by default).
         */
        if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL) < 0) Die("Cannot privatize mounts: %m");

        /// mount root folder as ramdisk so all writes/reads from files will be fast a.f.
        /// mounts nothing("none") as a folder root which will be seen
        if (mount("none", "root", "tmpfs", 0, "mode=755") < 0) Die("Cannot mount root ramdisk: %m");

        Rules::DirRules dirRules(config.dirRules);
        dirRules.applyRules();

        if (chroot("root") < 0) Die("Chroot failed: %m");

        if (chdir("root/box") < 0) Die("Cannot change current directory: %m");

        /// TODO(@velea) why doesn't Makedir apply permissions mod?
        Base::MakeDir("/tmp", 0777);
        Base::RChmod(" 777 /tmp ");
    }

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0xaf(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x8ca50
movq 0x28(%rsp), %rdx
leaq 0x499d6(%rip), %rsi     # 0xf5f50
leaq 0xb0(%rsp), %rdi
callq 0xa0a90
jmp 0xac589
leaq 0xb0(%rsp), %rdi
movl $0x1e8, %esi            # imm = 0x1E8
callq 0x95000
jmp 0xac59d
leaq 0xb0(%rsp), %rdi
callq 0x8cbd8
leaq 0xaf(%rsp), %rdi
callq 0x8c630
xorl %eax, %eax
movl %eax, %r8d
leaq 0x49cc1(%rip), %rsi     # 0xf6284
movl $0x44000, %ecx          # imm = 0x44000
movq %r8, %rdi
movq %r8, %rdx
callq 0x8cb20
cmpl $0x0, %eax
jge 0xac62f
leaq 0x49bea(%rip), %rdi     # 0xf61c9
movb $0x0, %al
callq 0x94bf0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0xac61d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x8cbd8
leaq 0xaf(%rsp), %rdi
callq 0x8c630
jmp 0xac81f
leaq 0x49baf(%rip), %rdi     # 0xf61e5
leaq 0x49913(%rip), %rsi     # 0xf5f50
leaq 0x49ba6(%rip), %rdx     # 0xf61ea
xorl %eax, %eax
movl %eax, %ecx
leaq 0x49ba1(%rip), %r8      # 0xf61f0
callq 0x8cb20
cmpl $0x0, %eax
jge 0xac667
leaq 0x49b99(%rip), %rdi     # 0xf61f9
movb $0x0, %al
callq 0x94bf0
movq 0x20(%rsp), %rsi
addq $0x128, %rsi            # imm = 0x128
leaq 0x80(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xacf90
movq 0x18(%rsp), %rdi
callq 0xad1e0
jmp 0xac691
leaq 0x498b8(%rip), %rdi     # 0xf5f50
callq 0x8c550
cmpl $0x0, %eax
jge 0xac6cb
leaq 0x49b6e(%rip), %rdi     # 0xf6217
xorl %eax, %eax
callq 0x94bf0
jmp 0xac6b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0xac812
leaq 0x49b57(%rip), %rdi     # 0xf6229
callq 0x8c8d0
cmpl $0x0, %eax
jge 0xac6ec
leaq 0x49b4f(%rip), %rdi     # 0xf6232
xorl %eax, %eax
callq 0x94bf0
jmp 0xac6ec
leaq 0x5f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x8ca50
movq 0x10(%rsp), %rdx
leaq 0x49b4f(%rip), %rsi     # 0xf6256
leaq 0x60(%rsp), %rdi
callq 0xa0a90
jmp 0xac713
leaq 0x60(%rsp), %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x95000
jmp 0xac724
leaq 0x60(%rsp), %rdi
callq 0x8cbd8
leaq 0x5f(%rsp), %rdi
callq 0x8c630
leaq 0x37(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x8ca50
movq 0x8(%rsp), %rdx
leaq 0x49b08(%rip), %rsi     # 0xf625b
leaq 0x38(%rsp), %rdi
callq 0xa0a90
jmp 0xac75f
leaq 0x38(%rsp), %rdi
callq 0x95450
jmp 0xac76b
leaq 0x38(%rsp), %rdi
callq 0x8cbd8
leaq 0x37(%rsp), %rdi
callq 0x8c630
leaq 0x80(%rsp), %rdi
callq 0xad760
addq $0xd8, %rsp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0xac7c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x8cbd8
leaq 0x5f(%rsp), %rdi
callq 0x8c630
jmp 0xac812
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0xac808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x8cbd8
leaq 0x37(%rsp), %rdi
callq 0x8c630
leaq 0x80(%rsp), %rdi
callq 0xad760
movq 0xa0(%rsp), %rdi
callq 0x8ca40
nopl (%rax)