GET9ROOT(3)

πŸ“¦ version 0_git20260208, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

πŸ’– GET9ROOT(3) β€” Library Functions Manual πŸ’–

okay so bestie, welcome to the GET9ROOT(3) page from the Library Functions Manual. this one is literally about getting the path to the root of the Plan 9 tree, and it's giving niche-but-iconic. no cap. ✨

🌸 NAME 🌸

get9root, unsharp β€” get path to root of Plan 9 tree

✨ SYNOPSIS ✨

#include <u.h>
#include <libc.h>

char*     get9root(void)

char*     unsharp(char *path)

πŸ¦‹ DESCRIPTION πŸ¦‹

So this tree of Plan 9 software is conventionally installed in but may be installed in other places β€” yes, the source lowkey leaves that first spot open, and we are not inventing a path, bestie β€” for example, users without the ability to write to /usr/local may wish to install it in their own home directories. The environment variable $PLAN9 should contain the path to the root.

get9root returns a static pointer to the pathname of root, first checking $PLAN9 and defaulting to .. static pointer, slay πŸ’…

The lack of a fixed location for the Plan 9 tree makes it difficult to hard-code paths to files. unsharp replaces a leading #9 in path with the root of the tree. unsharp also replaces a leading #d with the path to the underlying system's file descriptor dup device, typically /dev/fd.

The string returned from unsharp, if different from path, should be freed with free (see malloc(3)) when no longer needed.

🚨 convention check: programs should never unsharp paths obtained from user input. periodt.

πŸŽ€ EXAMPLE πŸŽ€

The plumber(4) uses this code to find unrooted file names included by plumb rules.

snprint(buf, sizeof buf, "#9/plumb/%s", name);
fd = open(unsharp(buf), OREAD);

🌈 SOURCE 🌈

  • /src/lib9/get9root.c
  • /src/lib9/unsharp.c

πŸ’œ SEE ALSO πŸ’œ

πŸ’€ BUGS πŸ’€

Get9root could be smarter about finding the tree when $PLAN9 is not set.


k bye bestie β€” this was GET9ROOT(3) from the Library Functions Manual, source/version GET9ROOT(3), and the footer didn't give us a date, so that's the whole vibe. stay iconic 🫢✨