/// Executes 'mount -t tmpfs' (or a similar variant). /// /// This function must be called from a subprocess, as it never returns. /// /// \param mount_point Location on which to mount a tmpfs. static void run_mount_tmpfs(const char* mount_point) { const char* mount_args[16]; size_t last = 0; switch (current_os) { case os_freebsd: mount_args[last++] = "mdmfs"; mount_args[last++] = "-s16m"; mount_args[last++] = "md"; mount_args[last++] = mount_point; break; case os_linux: mount_args[last++] = "mount"; mount_args[last++] = "-ttmpfs"; mount_args[last++] = "tmpfs"; mount_args[last++] = mount_point; break; case os_netbsd: mount_args[last++] = "mount"; mount_args[last++] = "-ttmpfs"; mount_args[last++] = "tmpfs"; mount_args[last++] = mount_point; break; case os_sunos: mount_args[last++] = "mount"; mount_args[last++] = "-Ftmpfs"; mount_args[last++] = "tmpfs"; mount_args[last++] = mount_point; break; default: err(123, "Don't know how to mount a file system for testing " "purposes"); } mount_args[last] = NULL; const char** arg; printf("Mounting tmpfs onto %s with:", mount_point); for (arg = &mount_args[0]; *arg != NULL; arg++) printf(" %s", *arg); printf("\n"); const int ret = execvp(mount_args[0], KYUA_DEFS_UNCONST(mount_args)); assert(ret == -1); err(EXIT_FAILURE, "Failed to exec %s", mount_args[0]); };
/// Subprocess that validates the disconnection from any terminal. /// /// \param unused_cookie NULL. /// /// \post Exits with success if the environment is clean; failure otherwise. static void check_no_terminal(const void* KYUA_DEFS_UNUSED_PARAM(cookie)) { const char* const args[] = { "/bin/sh", "-i", "-c", "echo success", NULL }; execv("/bin/sh", KYUA_DEFS_UNCONST(args)); abort(); }