backport to buster
[hcoop/debian/openafs.git] / src / sys / setpag.c
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
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
8 *
9 * This file contains the lsetpag system call. (setpag is handled by the
10 * rmtsys layer and turned into either setpag or a remote call as is
11 * appropriate.) It is kept separate to allow for the creation of a simple
12 * shared library containing only setpag.
13 */
14
15 #include <afsconfig.h>
16 #include <afs/param.h>
17
18 #include <roken.h>
19
20 #if !defined(AFS_AIX_ENV) && !defined(AFS_NT40_ENV)
21 # include <sys/syscall.h>
22 #endif
23
24 #include <afs/afs_args.h>
25 #include <afs/sys_prototypes.h>
26
27 #include "afssyscalls.h"
28
29 #ifdef AFS_AIX32_ENV
30 /*
31 * in VRMIX, system calls look just like function calls, so we don't
32 * need to do anything!
33 */
34
35 #else
36 #if defined(AFS_SGI_ENV)
37
38 #pragma weak xlsetpag = lsetpag
39
40 int
41 lsetpag(void)
42 {
43 return (syscall(AFS_SETPAG));
44 }
45
46 #else /* AFS_SGI_ENV */
47
48 int
49 lsetpag(void)
50 {
51 int errcode;
52
53 #ifdef AFS_LINUX20_ENV
54 int rval;
55
56 rval = proc_afs_syscall(AFSCALL_SETPAG,0,0,0,0,&errcode);
57
58 if(rval) {
59 # ifdef AFS_SYSCALL
60 errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
61 # else
62 errcode = -1;
63 # endif
64 }
65
66 #elif defined(AFS_DARWIN80_ENV)
67 int rval;
68
69 rval = ioctl_afs_syscall(AFSCALL_SETPAG,0,0,0,0,0,0,&errcode);
70 if (rval) {
71 errcode = rval;
72 }
73 #elif defined(AFS_SUN511_ENV)
74 int rval;
75
76 rval = ioctl_sun_afs_syscall(AFSCALL_SETPAG,0,0,0,0,0,0,&errcode);
77 if (rval) {
78 errcode = rval;
79 }
80 #else
81 errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
82 #endif
83
84 return (errcode);
85 }
86
87 #endif /* !AFS_SGI_ENV */
88 #endif /* !AFS_AIX32_ENV */