3 This contains a couple of examples for using the portal filing system.
5 The portal file system provides a way of obtaining a file descriptor
6 to a filesystem object (i.e. something that is accessed by open(2),
7 pipe(2), socket(2) or socketpair(2)) via the filesystem namespace.
8 At present the only file descriptor supported are TCP sockets and
11 NOTE!!!! The portal file system is experimental in nature and should
12 not be considered secure, use with caution.
14 First off mount the filesystem using something like:
16 # mount_portalfs /usr/share/examples/portal/portal.conf /p
18 Then you should be able to do things like
19 # cat /p/tcp/localhost/daytime
20 Sun Nov 22 17:50:09 1998
21 (assuming inetd is running the daytime service, by default it is off)
28 # cp /bin/sh /bin/cat bin
29 # mount_portalfs /usr/share/examples/portal/portal.conf /tmp/root/p
36 cat: /etc/motd: No such file or directory
38 FreeBSD 2.2.6-RELEASE (COMPUTER) #0: Sat Aug 22 17:11:37 BST 1998
42 Finally, a very simple example of the listening server is available,
43 fire up two xterms. In the first
45 xterm-1$ cat /p/tcplisten/ANY/6666
46 (the ANY is a wildcard just like using INADDR_ANY, any resolvable host
50 xterm-2$ echo "hello there" >/p/tcp/localhost/6666
52 You should see the "hello there" string appear on the first terminal.
54 Unprivilged users can't create servers on privalged ports.
55 xterm-1$ cat /p/tcplisten/ANY/666
56 cat: /p/tcplisten/ANY/666: Operation not permitted
59 xterm-1# cat /p/tcplisten/ANY/666
62 xterm-2$ echo "hello there" >/p/tcp/localhost/666
63 should produce the expected response.
65 You can also swap the client/server read and write commands etc.