>1) Is there any reasonable way figure out whether
> a specific machine is running AFS or not?
> By that, i mean other than checking "/afs" existance or "afsd"
> daemons in the Kernel Process Table.
This is what we use here at NADA. It is also ok to link in the AFS
libraries as long as you make sure to not call the AFS routines on
a non AFS machine.
/*
* Look in <sys/syscall.h> for proper define (usally old stty).
*/
#if defined(sun) || defined(ultrix)
#define SYS_afs_syscall 31
#endif
#include <signal.h>
#include <setjmp.h>
#include <errno.h>
static jmp_buf jmpbuf;
static void
catch_sig_sys()
{
errno = 0;
longjmp(jmpbuf, 1);
}
/*
* XXX: Only works for single entry point AFS syscalls!
*/
int
has_afs_syscalls()
{
void (*func)();
static int has_afs = -1;
if (has_afs != -1)
return has_afs;
has_afs = 0;
func = signal(SIGSYS, catch_sig_sys);
if (setjmp(jmpbuf) == 0)
{
syscall(SYS_afs_syscall,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
errno = 0;
has_afs = 1;
}
(void) signal(SIGSYS, func);
return has_afs;
}
Cheers, Bj|rn