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.
16 #include <netinet/in.h>
20 # include <sys/cred.h>
21 # ifdef HAVE_SYS_PAG_H
25 #include <sys/param.h>
26 #include <sys/types.h>
29 #include <afsconfig.h>
30 #include <afs/afssyscalls.h>
31 #include <afs/param.h>
34 static volatile sig_atomic_t syscall_okay = 1;
36 /* Signal handler to catch failed system calls and change the okay flag. */
42 signal(SIGSYS, sigsys_handler);
50 int okay, saved_errno;
51 RETSIGTYPE (*saved_func)(int);
56 saved_func = signal(SIGSYS, sigsys_handler);
63 lpioctl(NULL, VIOCSETTOK, &iob, 0);
66 signal(SIGSYS, saved_func);
70 if (!syscall_okay || errno != EINVAL)
83 k_pioctl(char *path, int cmd, struct ViceIoctl *cmarg, int follow)
85 return lpioctl(path, cmd, cmarg, follow);
97 return lpioctl(NULL, VIOCUNLOG, &iob, 0);
102 * If we don't have the VIOC_GETPAG pioctl, we try to determine whether we're
103 * in a PAG by using either a special OS call (AIX 5.2 and later) or by
104 * walking the group list, which works differently for current versions of
107 * These OS differences are encapsulated in the following OS-specific haspag
110 * This is largely copied from auth/ktc.c and should be merged with that
111 * version, but that version calls through the pioctl() interface right now
112 * and therefore pulls in Rx for NFS translator support. This avoids an Rx
113 * dependency in the standalone libkopenafs interface.
115 #if defined(AFS_AIX52_ENV)
119 return (getpagvalue("afs") < 0) ? 0 : 1;
121 #elif defined(AFS_AIX51_ENV)
134 afs_uint32 h, l, pag;
135 # ifdef AFS_LINUX26_ENV
139 ngroups = getgroups(0, NULL);
140 groups = malloc(sizeof(*groups) * ngroups);
143 ngroups = getgroups(ngroups, groups);
145 /* Check for AFS_LINUX26_ONEGROUP_ENV PAGs. */
146 # ifdef AFS_LINUX26_ENV
147 for (i = 0; i < ngroups; i++)
148 if (((groups[i] >> 24) & 0xff) == 'A') {
154 /* Check for the PAG group pair. */
159 g0 = groups[0] & 0xffff;
160 g1 = groups[1] & 0xffff;
164 if (g0 < 0xc000 && g1 < 0xc000) {
165 l = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff);
167 h = (g1 >> 14) + h + h + h;
168 pag = ((h << 28) | l);
169 if (((pag >> 24) & 0xff) == 'A')
176 #endif /* !AFS_AIX51_ENV */
182 struct ViceIoctl iob;
187 iob.out = (caddr_t) &pag;
188 iob.out_size = sizeof(afs_uint32);
189 code = lpioctl(NULL, VIOC_GETPAG, &iob, 0);
191 return pag != (afs_uint32) -1;