blob: 6ca02c02a89cf7575c112a84324fe4129fa0749e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
<head>
<title>get9root(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>GET9ROOT(3)</b><td align=right><b>GET9ROOT(3)</b>
<tr><td width=20><td colspan=2>
<br>
<p><font size=+1><b>NAME </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
get9root, unsharp – get path to root of Plan 9 tree<br>
</table>
<p><font size=+1><b>SYNOPSIS </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>#include <u.h><br>
#include <libc.h>
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>char* get9root(void)
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
</font></tt>
<tt><font size=+1>char* unsharp(char *path)<br>
</font></tt>
</table>
<p><font size=+1><b>DESCRIPTION </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
This tree of Plan 9 software is conventionally installed in <tt><font size=+1>/usr/local/plan9</font></tt>
but may be installed in other places (for example, users without
the ability to write to <tt><font size=+1>/usr/local</font></tt> may with to install it in their
own home directories). The environment variable <tt><font size=+1>$PLAN9</font></tt> should
contain the path to the root. <i>Get9root
</i>returns a static pointer to the pathname of root, first checking
<tt><font size=+1>$PLAN9</font></tt> and defaulting to <tt><font size=+1>/usr/local/plan9</font></tt>.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
The lack of a fixed location for the Plan 9 tree makes it difficult
to hard-code paths to files. <i>Unsharp</i> replaces a leading <tt><font size=+1>#9</font></tt> in
<i>path</i> with the root of the tree. <i>Unsharp</i> also replaces a leading
<tt><font size=+1>#d</font></tt> with the path to the underlying system’s file descriptor dup
device, typically <tt><font size=+1>/dev/fd</font></tt>. The string returned from <i>unsharp</i>, if
different from <i>path</i>, should be freed with <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>)
when no longer needed.
<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
As a convention, programs should never <i>unsharp</i> paths obtained
from user input.<br>
</table>
<p><font size=+1><b>EXAMPLE </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
The <a href="../man4/plumber.html"><i>plumber</i>(4)</a> uses this code to find unrooted file names included
by plumb rules.<br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>snprint(buf, sizeof buf, "#9/plumb/%s", name);<br>
fd = open(unsharp(buf), OREAD);<br>
</font></tt>
</table>
</table>
<p><font size=+1><b>SOURCE </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<tt><font size=+1>/usr/local/plan9/src/lib9/getns.c<br>
</font></tt>
</table>
<p><font size=+1><b>SEE ALSO </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<a href="../man4/intro.html"><i>intro</i>(4)</a><br>
</table>
<p><font size=+1><b>BUGS </b></font><br>
<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>
<i>Get9root</i> could be smarter about finding the tree when <tt><font size=+1>$PLAN9</font></tt> is
not set.<br>
</table>
<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>
|