NAME
AFS::ukernel - Usermode cache manager for AFS
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 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.
SUBROUTINES
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.
- $code = AFS::ukernel::uafs_ParseArgs($args)
-
Call this after uafs_Setup() but before uafs_Run().
$argsis a single string of whitespace-separated arguments. The arguments accepted are the same as those accepted by the afsd(8) program, and have the same meaning.The
$argsstring 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.
- $fd = AFS::ukernel::uafs_open($path, $flags[, $mode])
-
Opens
$pathusing open flags$flags. The passed$flagsare interpreted just like open(2)'s flags; symbolic constants can be found in the POSIX module, for example"POSIX::O_RDONLY".$modeis the mode the specified$pathwill 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.
- ($code, $data) = AFS::ukernel::uafs_read($fd, $len)
- ($code, $data) = AFS::ukernel::uafs_pread($fd, $len, $offset)
-
Reads at most
$lenbytes from the file correcponding to the file descriptor$fd. On success, returns$dataas the string of data read, and$codeas the number of bytes read. On error, returns$dataas an empty string, and$codeas -1.uafs_pread reads 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, or fstat(2)s a file. On success,
$codeis 0, and@statsis a 13-element list that contains the stat information for the file. The order and meaning of the elements in@statsis the same as those returned by the builtin Perl stat function. On error,$codeis nonzero.
- ($code, $link) = AFS::ukernel::uafs_readlink($path, $len)
-
Reads the contents of the link in the symlink
$path. On success,$codeis 0, and the link data is returned 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, the returned$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 all other returned values are 0.
EXAMPLES
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
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.