1 /* $NetBSD: rump_syspuffs.c,v 1.9 2009/04/15 08:36:21 pooka Exp $ */
4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
6 * Development of this software was supported by the
7 * Research Foundation of Helsinki University of Technology
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/types.h>
32 #include <sys/mount.h>
33 #include <sys/socket.h>
34 #include <sys/syslimits.h>
44 #include <rump/rump.h>
46 #include "rump_syspuffs.h"
52 main(int argc
, char *argv
[])
54 char canon_dev
[MAXPATHLEN
], canon_dir
[MAXPATHLEN
];
55 struct syspuffs_args args
;
59 extern int rumpns_puffsdebug
;
60 extern int rumpns_putterdebug
;
62 rumpns_puffsdebug
= rumpns_putterdebug
= 1;
67 mount_syspuffs_parseargs(argc
, argv
, &args
, &mntflags
,
68 canon_dev
, canon_dir
);
70 rv
= p2k_run_fs(MOUNT_PUFFS
, canon_dev
, canon_dir
, mntflags
,
71 &args
.us_kargs
, sizeof(args
.us_kargs
), args
.us_pflags
);
77 #endif /* MOUNT_NOMAIN */
83 errx(1, "%s: server server_parameters", getprogname());
87 mount_syspuffs_parseargs(int argc
, char *argv
[],
88 struct syspuffs_args
*args
, int *mntflags
,
89 char *canon_dev
, char *canon_dir
)
91 struct puffs_kargs
*kargs
= &args
->us_kargs
;
92 int *pflags
= &args
->us_pflags
;
101 /* Create sucketpair for communication with the real file server */
102 if (socketpair(PF_LOCAL
, SOCK_STREAM
, 0, sv
) == -1)
103 err(1, "socketpair");
105 if ((rv
= rump_init()) == -1)
111 snprintf(comfd
, sizeof(sv
[0]), "%d", sv
[0]);
112 if (setenv("PUFFS_COMFD", comfd
, 1) == -1)
116 if (execvp(argv
[0], argv
) == -1)
128 if (read(sv
[1], &len
, sizeof(len
)) != sizeof(len
))
130 if (len
> MAXPATHLEN
)
131 err(1, "mntpath > MAXPATHLEN");
132 if ((size_t)read(sv
[1], canon_dir
, len
) != len
)
134 if (read(sv
[1], &len
, sizeof(len
)) != sizeof(len
))
136 if (len
> MAXPATHLEN
)
137 err(1, "devpath > MAXPATHLEN");
138 if ((size_t)read(sv
[1], canon_dev
, len
) != len
)
140 if (read(sv
[1], mntflags
, sizeof(*mntflags
)) != sizeof(*mntflags
))
142 if (read(sv
[1], kargs
, sizeof(*kargs
)) != sizeof(*kargs
))
143 err(1, "puffs_args");
144 if (read(sv
[1], pflags
, sizeof(*pflags
)) != sizeof(*pflags
))
147 /* XXX: some adjustments */
148 *pflags
|= PUFFS_KFLAG_NOCACHE
;
149 *pflags
&= ~PUFFS_FLAG_BUILDPATH
;
151 rv
= rump_pub_syspuffs_glueinit(sv
[1], &kargs
->pa_fd
);