1 /* $NetBSD: t_mountd.c,v 1.6 2017/01/13 21:30:40 christos Exp $ */
4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/types.h>
29 #include <sys/mount.h>
41 #include <rump/rump.h>
42 #include <rump/rump_syscalls.h>
45 #include "../common/h_fsmacros.h"
48 ATF_TC_HEAD(mountdhup, tc)
51 atf_tc_set_md_var(tc, "descr", "test for service interrupt while "
52 "mountd handles SIGHUP");
55 static volatile int quit;
58 wrkwrkwrk(void *unused)
64 rump_sys_chdir(FSTEST_MNTNAME);
66 fd = rump_sys_open("file", O_RDWR | O_CREAT);
68 if (errno == EACCES) {
74 if (rump_sys_unlink("file") == -1) {
75 if (errno == EACCES) {
84 return fail ? wrkwrkwrk : NULL;
87 ATF_TC_BODY(mountdhup, tc)
90 struct nfstestargs *nfsargs;
95 FSTEST_CONSTRUCTOR(tc, nfs, voidargs);
98 pthread_create(&pt, NULL, wrkwrkwrk, NULL);
99 for (attempts = 100; attempts && !quit; attempts--) {
101 kill(nfsargs->ta_childpid, SIGHUP);
104 pthread_join(pt, &fail);
106 FSTEST_DESTRUCTOR(tc, nfs, voidargs);
108 atf_tc_expect_fail("PR kern/5844");
110 atf_tc_fail("op failed with EACCES");
112 atf_tc_fail("race did not trigger this time");
118 ATF_TP_ADD_TC(tp, mountdhup);
120 return atf_no_error();