1.\"     $NetBSD: p2k.3,v 1.13 2024/10/13 14:56:30 rillig Exp $
2.\"
3.\" Copyright (c) 2008 Antti Kantee.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.Dd October 13, 2024
27.Dt P2K 3
28.Os
29.Sh NAME
30.Nm p2k
31.Nd puffs to kernel vfs translation library
32.Sh LIBRARY
33p2k Library (libp2k, \-lp2k)
34.Sh SYNOPSIS
35.In rump/p2k.h
36.Ft struct p2k_mount *
37.Fn p2k_init "uint32_t puffs_flags"
38.Ft void
39.Fn p2k_cancel "struct p2k_mount *p2m" "int error"
40.Ft int
41.Fo p2k_setup_fs
42.Fa "struct p2k_mount *p2m" "const char *vfsname" "const char *devpath"
43.Fa "const char *mountpath" "int mntflags" "void *arg" "size_t alen"
44.Fc
45.Ft int
46.Fo p2k_setup_diskfs
47.Fa "struct p2k_mount *p2m" "const char *vfsname" "const char *devpath"
48.Fa "struct ukfs_part *part" "const char *mountpath" "int mntflags"
49.Fa "void *arg" "size_t alen"
50.Fc
51.Ft int
52.Fn p2k_mainloop "struct p2k_mount *p2m"
53.Ft int
54.Fo p2k_run_fs
55.Fa "const char *vfsname" "const char *devpath" "const char *mountpath"
56.Fa "int mntflags" "void *arg" "size_t alen" "uint32_t puffs_flags"
57.Fc
58.Ft int
59.Fo p2k_run_diskfs
60.Fa "const char *vfsname" "const char *devpath" "struct ukfs_part *part"
61.Fa "const char *mountpath" "int mntflags" "void *arg" "size_t alen"
62.Fa "uint32_t puffs_flags"
63.Fc
64.Sh DESCRIPTION
65The
66.Nm
67library translates the puffs protocol to the kernel
68.Xr vfs 9
69protocol and back again.
70It can therefore be used to mount and run kernel file system code as
71a userspace daemon.
72.Pp
73Calling the library interface function mounts the file system and,
74if successful, starts handling requests.
75The parameters are handled by
76.Fn ukfs_mount
77(see
78.Xr ukfs 3 ) ,
79with the exception that
80.Fa mountpath
81and
82.Fa puffs_flags
83are handled by
84.Xr puffs 3 .
85The "run_fs" variants of the interfaces are provided as a convenience
86for the common case.
87They execute all of init, setup and mainloop in one call.
88.Sh ENVIRONMENT
89The following environment variables affect the behaviour of
90.Nm .
91They are useful mostly for debugging purposes.
92The flags are environment variables because typically the command line
93arguments to
94.Nm
95utilities are parsed using versions not aware of
96.Nm
97options; for example, the
98.Xr rump_cd9660 8
99arguments are really parsed by
100.Xr mount_cd9660 8 .
101.Bl -tag -width "XP2K_NOCACHE_PAGE" -offset 2n
102.It Dv P2K_DEBUG
103Do not detach from tty and print information about each puffs operation.
104In case the daemon receives
105.Dv SIGINFO
106(typically from ctrl-T), it dumps out the status of the mount point.
107Sending
108.Dv SIGUSR1
109causes a dump of all the vnodes (verbose).
110.It Dv P2K_NODETACH
111Do not detach from tty.
112.It Dv P2K_NOCACHE_PAGE
113Do not use the puffs page cache.
114.It Dv P2K_NOCACHE_NAME
115Do not use the puffs name cache.
116.It Dv P2K_NOCACHE
117Do not use the puffs page or name cache.
118.It Dv P2K_WIZARDUID
119If set, use the value of the variable to determine the UID of the
120caller of each operation instead of the actual caller supplied by
121.Xr puffs 3 .
122This can be used for example to simplify modifying an OS installation's
123root image as a non-root user.
124.El
125.Sh SEE ALSO
126.Xr puffs 3 ,
127.Xr rump 3 ,
128.Xr ukfs 3 ,
129.Xr rump_cd9660 8 ,
130.Xr rump_efs 8 ,
131.Xr rump_ext2fs 8 ,
132.Xr rump_ffs 8 ,
133.Xr rump_hfs 8 ,
134.Xr rump_lfs 8 ,
135.Xr rump_msdos 8 ,
136.Xr rump_nfs 8 ,
137.Xr rump_ntfs 8 ,
138.Xr rump_syspuffs 8 ,
139.Xr rump_sysvbfs 8 ,
140.Xr rump_tmpfs 8 ,
141.Xr rump_udf 8
142