109 lines
4.2 KiB
HTML
109 lines
4.2 KiB
HTML
<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>
|