Lines Matching defs:??

1 /*	$NetBSD: fstest_puffs.c,v 1.11 2013/09/09 19:47:38 pooka Exp $	*/
6 * Redistribution and use in source and binary forms, with or without
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
59 xread(int fd, void *vp, size_t n)
64 do {
67 ssz = read(fd, vp, left);
68 if (ssz == -1) {
72 vp = (char *)vp + ssz;
78 xwrite(int fd, const void *vp, size_t n)
83 do {
86 ssz = write(fd, vp, left);
87 if (ssz == -1) {
91 vp = (const char *)vp + ssz;
98 * (cannot use polling since fd's are in different namespaces)
120 if (n <= 0) {
121 fprintf(stderr, "readshovel r1 %zd / %d\n", n, errno);
128 if (n <= 0) {
129 fprintf(stderr, "readshovel r2 %zd / %d\n", n, errno);
134 if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VFS) {
137 } else if (PUFFSOP_OPCLASS(preq->preq_opclass) == PUFFSOP_VN) {
143 if (xwrite(comfd, buf, n) != n) {
144 fprintf(stderr, "readshovel write %zd / %d\n", n, errno);
149 if (n != 0 && mayquit == false)
177 * Need to write everything to the "kernel" in one chunk,
178 * so make sure we have it here.
183 do {
185 if (n <= 0) {
186 fprintf(stderr, "writeshovel read %zd / %d\n",
191 if (off >= sizeof(struct putter_hdr))
197 if (__predict_false(
200 if (preq->preq_rv == 0)
205 if ((size_t)n != phdr->pth_framelen) {
206 fprintf(stderr, "writeshovel wr %zd / %d\n", n, errno);
212 if (n != 0)
220 pthread_t pt;
221 int rv;
223 if ((rv = rump_init()) == -1)
226 if (pthread_create(&pt, NULL, readshovel, args) == -1)
228 pthread_detach(pt);
230 if (pthread_create(&pt, NULL, writeshovel, args) == -1)
232 pthread_detach(pt);
244 /* XXX: we don't support size */
246 donewfs(const atf_tc_t *tc, void **argp,
252 char comfd[16];
253 int sv[2];
261 if (args == NULL)
268 if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) == -1)
275 close(sv[1]);
276 snprintf(comfd, sizeof(sv[0]), "%d", sv[0]);
277 if (setenv("PUFFS_COMFD", comfd, 1) == -1)
280 if (execvp(theargv[0], theargv) == -1)
285 close(sv[0]);
290 if ((n = xread(sv[1], &len, sizeof(len))) != sizeof(len))
291 err(1, "mp 1 %zd", n);
292 if (len > MAXPATHLEN)
294 if ((size_t)xread(sv[1], args->pta_dir, len) != len)
295 err(1, "mp 2");
296 if (xread(sv[1], &len, sizeof(len)) != sizeof(len))
297 err(1, "fn 1");
298 if (len > MAXPATHLEN)
300 if ((size_t)xread(sv[1], args->pta_dev, len) != len)
301 err(1, "fn 2");
302 if (xread(sv[1], &mntflags, sizeof(mntflags)) != sizeof(mntflags))
304 if (xread(sv[1], &args->pta_pargslen, sizeof(args->pta_pargslen))
308 if (args->pta_pargs == NULL)
310 if (xread(sv[1], args->pta_pargs, args->pta_pargslen)
313 if (xread(sv[1], pflags, sizeof(*pflags)) != sizeof(*pflags))
317 args->pta_servfd = sv[1];
326 puffs_fstest_newfs(const atf_tc_t *tc, void **argp,
335 atf_tc_get_config_var(tc, "srcdir"));
337 if (fspriv) {
351 return donewfs(tc, argp, image, size, fspriv, theargv);
355 p2k_ffs_fstest_newfs(const atf_tc_t *tc, void **argp,
359 int rv;
362 if ((rv = ffs_fstest_newfs(tc, argp, image, size, fspriv)) != 0)
363 return rv;
364 if (mkdir("p2kffsfake", 0777) == -1 && errno != EEXIST)
373 if ((rv = donewfs(tc, argp, image, size, fspriv, rumpffs_argv)) != 0)
374 ffs_fstest_delfs(tc, argp);
375 return rv;
379 puffs_fstest_mount(const atf_tc_t *tc, void *arg, const char *path, int flags)
382 int fd;
385 fd = rump_sys_open("/dev/puffs", O_RDWR);
386 if (fd == -1)
387 return fd;
389 if (rump_sys_mkdir(path, 0777) == -1)
392 if (rump_sys_mount(MOUNT_PUFFS, path, flags,
394 /* apply "to kill a child" to avoid atf hang (kludge) */
399 pargs->pta_rumpfd = fd;
407 puffs_fstest_delfs(const atf_tc_t *tc, void *arg)
415 p2k_ffs_fstest_delfs(const atf_tc_t *tc, void *arg)
418 return ffs_fstest_delfs(tc, arg);
422 puffs_fstest_unmount(const atf_tc_t *tc, const char *path, int flags)
426 int rv;
428 /* ok, child might exit here */
431 rv = rump_sys_unmount(path, flags);
432 if (rv)
433 return rv;
435 if ((rv = rump_sys_rmdir(path)) != 0)
436 return rv;
438 if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0)
441 usleep(10);
442 if (waitpid(pargs->pta_childpid, &status, WNOHANG) > 0)