Changeset View
Changeset View
Standalone View
Standalone View
fs/common/fstest_nfs.c
/* $NetBSD: fstest_nfs.c,v 1.9 2011/02/28 21:08:46 pooka Exp $ */ | /* $NetBSD: fstest_nfs.c,v 1.12 2020/06/17 00:16:21 kamil Exp $ */ | ||||
/* | /* | ||||
* Copyright (c) 2010 The NetBSD Foundation, Inc. | * Copyright (c) 2010 The NetBSD Foundation, Inc. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
Show All 31 Lines | |||||
#include <puffs.h> | #include <puffs.h> | ||||
#include <puffsdump.h> | #include <puffsdump.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <rump/rump.h> | #include <rump/rump.h> | ||||
#include <rump/rump_syscallshotgun.h> | |||||
#include <rump/rump_syscalls.h> | #include <rump/rump_syscalls.h> | ||||
#include "h_fsmacros.h" | #include "h_fsmacros.h" | ||||
#include "mount_nfs.h" | #include "mount_nfs.h" | ||||
#include "../../net/config/netconfig.c" | #include "../../net/config/netconfig.c" | ||||
#define SERVERADDR "10.3.2.1" | #define SERVERADDR "10.3.2.1" | ||||
#define SERVERROADDR "10.4.2.1" | #define SERVERROADDR "10.4.2.1" | ||||
Show All 25 Lines | donewfs(const atf_tc_t *tc, void **argp, | ||||
pid_t childpid; | pid_t childpid; | ||||
int pipes[2]; | int pipes[2]; | ||||
int devnull; | int devnull; | ||||
/* | /* | ||||
* First, we start the nfs service. | * First, we start the nfs service. | ||||
*/ | */ | ||||
srcdir = atf_tc_get_config_var(tc, "srcdir"); | srcdir = atf_tc_get_config_var(tc, "srcdir"); | ||||
sprintf(nfsdpath, "%s/../nfs/nfsservice/rumpnfsd", srcdir); | snprintf(nfsdpath, sizeof nfsdpath, | ||||
sprintf(ethername, "/%s/%s.etherbus", getcwd(cwd, sizeof(cwd)), image); | "%s/../nfs/nfsservice/rumpnfsd", srcdir); | ||||
sprintf(ethername_ro, "%s_ro", ethername); | snprintf(ethername, sizeof ethername, | ||||
sprintf(imagepath, "/%s/%s", cwd, image); | "/%s/%s.etherbus", getcwd(cwd, sizeof(cwd)), image); | ||||
snprintf(ethername_ro, sizeof ethername_ro, "%s_ro", ethername); | |||||
snprintf(imagepath, sizeof imagepath, "/%s/%s", cwd, image); | |||||
nfsdargv[0] = nfsdpath; | nfsdargv[0] = nfsdpath; | ||||
nfsdargv[1] = ethername; | nfsdargv[1] = ethername; | ||||
nfsdargv[2] = ethername_ro; | nfsdargv[2] = ethername_ro; | ||||
nfsdargv[3] = __UNCONST(SERVERADDR); | nfsdargv[3] = __UNCONST(SERVERADDR); | ||||
nfsdargv[4] = __UNCONST(SERVERROADDR); | nfsdargv[4] = __UNCONST(SERVERROADDR); | ||||
nfsdargv[5] = __UNCONST(NETNETMASK); | nfsdargv[5] = __UNCONST(NETNETMASK); | ||||
nfsdargv[6] = __UNCONST(EXPORTPATH); | nfsdargv[6] = __UNCONST(EXPORTPATH); | ||||
nfsdargv[7] = imagepath; | nfsdargv[7] = imagepath; | ||||
nfsdargv[8] = NULL; | nfsdargv[8] = NULL; | ||||
signal(SIGCHLD, childfail); | signal(SIGCHLD, childfail); | ||||
if (pipe(pipes) == -1) | if (pipe(pipes) == -1) | ||||
return errno; | return errno; | ||||
switch ((childpid = fork())) { | switch ((childpid = fork())) { | ||||
case 0: | case 0: | ||||
if (chdir(dirname(nfsdpath)) == -1) | if (chdir(dirname(nfsdpath)) == -1) | ||||
err(1, "chdir"); | err(1, "chdir"); | ||||
close(pipes[0]); | close(pipes[0]); | ||||
if (dup2(pipes[1], 3) == -1) | if (dup2(pipes[1], 3) == -1) | ||||
err(1, "dup2"); | err(1, "dup2"); | ||||
if (execvp(nfsdargv[0], nfsdargv) == -1) | execvp(nfsdargv[0], nfsdargv); | ||||
err(1, "execvp"); | err(1, "execvp"); | ||||
case -1: | case -1: | ||||
return errno; | return errno; | ||||
default: | default: | ||||
close(pipes[1]); | close(pipes[1]); | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 201 Lines • Show Last 20 Lines |