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 k_pioctl(char *path
, int cmd
, struct ViceIoctl
*cmarg
, int follow
)
80 return lpioctl(path
, cmd
, cmarg
, follow
);
92 return lpioctl(NULL
, VIOCUNLOG
, &iob
, 0);
97 * If we don't have the VIOC_GETPAG pioctl, we try to determine whether we're
98 * in a PAG by using either a special OS call (AIX 5.2 and later) or by
99 * walking the group list, which works differently for current versions of
102 * These OS differences are encapsulated in the following OS-specific haspag
105 * This is largely copied from auth/ktc.c and should be merged with that
106 * version, but that version calls through the pioctl() interface right now
107 * and therefore pulls in Rx for NFS translator support. This avoids an Rx
108 * dependency in the standalone libkopenafs interface.
110 #if defined(AFS_AIX52_ENV)
114 return (getpagvalue("afs") < 0) ? 0 : 1;
116 #elif defined(AFS_AIX51_ENV)
129 afs_uint32 h
, l
, pag
;
130 # ifdef AFS_PAG_ONEGROUP_ENV
134 ngroups
= getgroups(0, NULL
);
135 groups
= malloc(sizeof(*groups
) * ngroups
);
138 ngroups
= getgroups(ngroups
, groups
);
140 /* Check for one-group PAGs. */
141 # ifdef AFS_PAG_ONEGROUP_ENV
142 for (i
= 0; i
< ngroups
; i
++)
143 if (((groups
[i
] >> 24) & 0xff) == 'A') {
149 /* Check for the PAG group pair. */
154 g0
= groups
[0] & 0xffff;
155 g1
= groups
[1] & 0xffff;
159 if (g0
< 0xc000 && g1
< 0xc000) {
160 l
= ((g0
& 0x3fff) << 14) | (g1
& 0x3fff);
162 h
= (g1
>> 14) + h
+ h
+ h
;
163 pag
= ((h
<< 28) | l
);
164 if (((pag
>> 24) & 0xff) == 'A')
171 #endif /* !AFS_AIX51_ENV */
177 struct ViceIoctl iob
;
182 iob
.out
= (caddr_t
) &pag
;
183 iob
.out_size
= sizeof(afs_uint32
);
184 code
= lpioctl(NULL
, VIOC_GETPAG
, &iob
, 0);
186 return pag
!= (afs_uint32
) -1;