AFS.ukernel(3)
β¨ AFS.ukernel β the usermode cache manager for AFS, but make it a Perl era β¨
okay so this is AFS.ukernel(3) from the AFS Library Reference, and bestie, it's genuinely iconic. this is the page about the usermode cache manager for AFS. let's get into it π
π SYNOPSIS π
use AFS::ukernel;
use POSIX;
AFS::ukernel::uafs_Setup("/afs");
AFS::ukernel::uafs_ParseArgs($args);
AFS::ukernel::uafs_Run();
$fd = AFS::ukernel::uafs_open($path, POSIX::O_RDONLY);
πΈ DESCRIPTION πΈ
AFS::ukernel is where the Perl bindings for libuafs live. the whole point? your Perl scripts can get at files in AFS exactly like a normal AFS client would β cache management and all of it β and you do not need a kernel module. no kernel module!! we love a userspace moment π
real talk though: this doc does not cover every single subroutine inAFS::ukernel. it's only here to explain the semantics and functionality that are specific toAFS::ukernel, or that differ in some way fromlibuafsproper. for literally everything else, go read thelibuafsAPI or docs, because the rest of the subroutines behave the same here as they do inlibuafs. no cap.
π¦ SUBROUTINES π¦
any subroutine that hits an error should set errno. in Perl that's super easy to peek at for error messages via the $! variable β it expands into the human-readable error string matching whatever the current value of errno is. π«Ά
$code = AFS::ukernel::uafs_ParseArgs($args)β call this afteruafs_Setup()but beforeuafs_Run().$argsis one single string of whitespace-separated arguments. the arguments it accepts are the same onesafsd(8)accepts, and they mean the same thing. the$argsstring gets broken up into individual arguments bylibcmd, following the normal shell-like quoting and whitespace rules. returns0on success, nonzero otherwise.$fd = AFS::ukernel::uafs_open($path, $flags[, $mode])β opens$pathusing the open flags$flags. the$flagsyou pass in get interpreted exactly likeopen(2)'s flags, and you can grab the symbolic constants from thePOSIXmodule, e.g.POSIX::O_RDONLY.$modeis the mode that$pathgets created with if you're creating a new file. if you don't specify it, it defaults to0. if you do specify it and the call does not create a new file, it's just ignored, no biggie. returns a nonnegative file descriptor on success, and-1on error.($code, $data) = AFS::ukernel::uafs_read($fd, $len)($code, $data) = AFS::ukernel::uafs_pread($fd, $len, $offset)β reads at most$lenbytes from the file corresponding to the file descriptor$fd. on success,$datacomes back as the string of data that was read, and$codeis the number of bytes read. on error,$datais an empty string and$codeis-1.uafs_preaddoes its reading starting from the offset$offset.($code, @stats) = AFS::ukernel::uafs_stat($path)($code, @stats) = AFS::ukernel::uafs_lstat($path)($code, @stats) = AFS::ukernel::uafs_fstat($fd)βstat(2)s,lstat(2)s, orfstat(2)s a file. on success,$codeis0and@statsis a 13-element list holding the stat info for the file. the order and meaning of the elements in@statsis the same as what the builtin Perlstatfunction gives you. on error,$codeis nonzero.($code, $link) = AFS::ukernel::uafs_readlink($path, $len)β reads the contents of the link in the symlink$path. on success,$codeis0and the link data comes back in the string$link, which will be at most$lenbytes long. on error,$codeis nonzero and$linkis the empty string.($name, $ino, $off, $reclen) = AFS::ukernel::uafs_readdir($dir)β reads a directory entry from the directory represented by the directory pointer$dir. on success,$nameis the name of the file entry,$inois the inode number,$offis the offset of the entry, and$reclenis the length of the entry name. on error,$nameis the empty string and every other returned value is0.
β EXAMPLES β
here's a lil program that reads the first 4096 bytes of /afs/localcell/user/adeason/file and prints them out. she's cute, she's functional, she ate:
use strict;
use AFS::ukernel;
use POSIX;
my $path = "/afs/localcell/user/adeason/afile";
my $str;
my $code;
my $fd;
$code = AFS::ukernel::uafs_Setup("/afs");
$code == 0 or die("uafs_Setup: $!\n");
$code = AFS::ukernel::uafs_ParseArgs("-afsdb -cachedir /tmp/mycache");
$code == 0 or die("uafs_ParseArgs: $!\n");
$code = AFS::ukernel::uafs_Run();
$code == 0 or due("uafs_Run: $!\n");
$fd = AFS::ukernel::uafs_open($path, POSIX::O_RDONLY);
$fd >=0 or die("uafs_open: $fname: $!\n");
($code, $str) = AFS::ukernel::uafs_read($fd, 4096);
$code >= 0 or die("uafs_read: $!\n");
$code = AFS::ukernel::uafs_close($fd);
$code == 0 or die("uafs_close: $!\n");
print "The first 4096 bytes of $path are:\n$str\n";
AFS::ukernel::uafs_Shutdown();
π COPYRIGHT π
Copyright 2010 Sine Nomine Associates <http://www.sinenomine.net/>
This documentation is covered by the BSD License as written in the doc/LICENSE file. This man page was written by Andrew Deason for OpenAFS.
okay and that's the whole page, bestie π§ the source is OpenAFS and this version is dated 2026-07-27 β go forth and mount things in userspace, you absolute legend ππ
π¦ where this page comes from
- ubuntu stonking: openafs-fuse 1.8.16.1-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms