Documents
Uniform File Access Library
-
Architecture
The Architecture of UFAL is depicted in the following figure.

-
Pre-requisites
Supported Platform: GNU/Linux is supported as a development and production platform.
-
Installation
Download UFAL rpm package from here. After install the rpm, you can use UFAL tools and library. -
How to use
(1) Configuration
Please modify the enviornment variable "UFAL_NETFS" and "UFAL_DEBUG" in /etc/profile.d/ufal.sh or ufal.csh "UFAL_NETFS" defines which directory should be considered as network file system. UFAL_DEBUG defines the debug options, and 0 shows no debugging infomation is printed into terminal. For example,
export UFAL_DEBUG=0
export UFAL_NETFS="/besfs /afs"
Of course, you can override the setting through the configuration file in your own home directory, eg, .bash_profile.
(1) Command Line
One uniform file copy tool (ufcp) is embeded in UFAL, the syntax is:
ufcp [-vVh] src_file dest_file
-v: verbose mode, will shows the instant speed of copying
-V: shows the version
h: show the help.
For example,
ufcp -v root://cdev02.ihep.ac.cn//besfs/chyd/f1 /tmp/f1
(2) Programming with UFAL library
A program reading one file and print it to output:
/*
* Copyright (C) 2008-2010 by IHEP/CC
* All rights reserved
* unicp.c v0.1 2009-04-06 16:06:22
* Written by Yaodong Cheng, Computing Center, IHEP
* Contact: Yaodong.cheng@ihep.ac.cn
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <errno.h>
#include <sys/time.h>
#include <pthread.h>
#include <pwd.h>
#include "ufal_api.h"
int main(int argc, char *argv[])
{
int fd;
int c;
char *fn;
char buf[RECSIZE+1];
if (argc < 2){
printf("usage: %s filename\n", argv[0]);
return(-1);
}
#ifdef _USEXRD
xrd_init(OP_META);
#endif
fn = argv[1];
fd = uf_open64(fn, O_RDONLY, 0644);
if (fd < 0){
//printf("%s\n", strerror(errno));
perror("uf_open");
return (-1);
}
bzero(buf, sizeof(buf));
while ((c = uf_read(fd, buf, sizeof(buf))) > 0){
fprintf(stdout, "%s", buf);
bzero(buf, sizeof(buf));
}
if (uf_close(fd) < 0){
perror("uf_close");
exit (-1);
}
exit (0);
}
Then link it with UFAL library:
gcc -o ufcat ufcat.c -I/opt/ufal/include -lufal -L/opt/ufal/lib -I/usr/include/shift -D_LARGEFILE64_SOURCE


