AFS.ukernel(3) | AFS Library Reference | AFS.ukernel(3) |
AFS::ukernel - Usermode cache manager for AFS
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);
AFS::ukernel contains the Perl bindings for libuafs. It allows Perl scripts to access files in AFS just like a normal AFS client would (including cache management and all), without the need of a kernel module.
This documentation does not cover all subroutines in AFS::ukernel. It just serves to provide documentation on semantics or functionality that is specific to the AFS::ukernel, or differs from the semantics or functionality of libuafs proper in some way. See the libuafs API or documentation for the rest of the subroutines, as they will behave the same here as in libuafs.
Any subroutine that returns an error should set errno. This is easily accessible in Perl for error messages via the $! variable, which expands to the human-readable error string corresponding to the current value of errno.
The $args string is broken into individual arguments by libcmd, according to the normal shell-like quoting and whitespace rules.
uafs_ParseArgs() returns 0 on success, and nonzero otherwise.
$mode is the mode the specified $path will be created with if you are creating a new file. If it is unspecified, it defaults to 0. If it is specified and the call does not create a new file, it is ignored.
Returns a nonnegative file descriptor on success, and -1 on error.
uafs_pread reads starting from the offset $offset.
Here is a small program to read the first 4096 bytes of /afs/localcell/user/adeason/file, and print them out:
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 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.
2022-12-22 | OpenAFS |