2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * Glue code for the kopenafs API. Mostly just wrappers around the functions
12 * included in the libsys code.
14 #include <afsconfig.h>
15 #include <afs/param.h>
20 # include <sys/cred.h>
21 # ifdef HAVE_SYS_PAG_H
26 #include <afs/afssyscalls.h>
29 static volatile sig_atomic_t syscall_okay = 1;
31 /* Signal handler to catch failed system calls and change the okay flag. */
37 signal(SIGSYS, sigsys_handler);
45 int okay, saved_errno;
46 void (*saved_func)(int);
51 saved_func = signal(SIGSYS, sigsys_handler);
58 lpioctl(NULL, VIOCSETTOK, &iob, 0);
61 signal(SIGSYS, saved_func);
65 if (!syscall_okay || errno != EINVAL)
78 } while (code && errno == EINTR);
84 k_pioctl(char *path, int cmd, struct ViceIoctl *cmarg, int follow)
86 return lpioctl(path, cmd, cmarg, follow);
98 return lpioctl(NULL, VIOCUNLOG, &iob, 0);
103 * If we don't have the VIOC_GETPAG pioctl, we try to determine whether we're
104 * in a PAG by using either a special OS call (AIX 5.2 and later) or by
105 * walking the group list, which works differently for current versions of
108 * These OS differences are encapsulated in the following OS-specific haspag
111 * This is largely copied from auth/ktc.c and should be merged with that
112 * version, but that version calls through the pioctl() interface right now
113 * and therefore pulls in Rx for NFS translator support. This avoids an Rx
114 * dependency in the standalone libkopenafs interface.
116 #if defined(AFS_AIX52_ENV)
120 return (getpagvalue("afs") < 0) ? 0 : 1;
122 #elif defined(AFS_AIX51_ENV)
135 afs_uint32 h, l, pag;
136 # ifdef AFS_PAG_ONEGROUP_ENV
140 ngroups = getgroups(0, NULL);
141 groups = malloc(sizeof(*groups) * ngroups);
144 ngroups = getgroups(ngroups, groups);
146 /* Check for one-group PAGs. */
147 # ifdef AFS_PAG_ONEGROUP_ENV
148 for (i = 0; i < ngroups; i++)
149 if (((groups[i] >> 24) & 0xff) == 'A') {
155 /* Check for the PAG group pair. */
160 g0 = groups[0] & 0xffff;
161 g1 = groups[1] & 0xffff;
165 if (g0 < 0xc000 && g1 < 0xc000) {
166 l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff);
168 h = (g1 >> 14) + h + h + h;
169 pag = ((h << 28) | l);
170 if (((pag >> 24) & 0xff) == 'A')
177 #endif /* !AFS_AIX51_ENV */
183 struct ViceIoctl iob;
188 iob.out = (caddr_t) &pag;
189 iob.out_size = sizeof(afs_uint32);
190 code = lpioctl(NULL, VIOC_GETPAG, &iob, 0);
192 return pag != (afs_uint32) -1;