f2c2d2c1cc7532e676ea71e57acfc5b3237f4471
[openafs.git] / src / sys / glue.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 any necessary C glue to allow programs to communicate
10  * with the AFS kernel module.  The necessary lower-level glue is defined in
11  * syscall.s.
12  */
13
14 #include <afsconfig.h>
15 #include <afs/param.h>
16
17
18 #include <afs/afs_args.h>
19 #include <sys/file.h>
20 #include <sys/ioctl.h>
21 #include <unistd.h>
22 #include <stdio.h>
23 #ifdef AFS_SUN5_ENV
24 #include <fcntl.h>
25 #endif
26 #include "afssyscalls.h"
27
28 #ifdef AFS_LINUX20_ENV
29 int proc_afs_syscall(long syscall, long param1, long param2, long param3, 
30                      long param4, int *rval) {
31   struct afsprocdata syscall_data;
32   int fd = open(PROC_SYSCALL_FNAME, O_RDWR);
33   if(fd < 0)
34       fd = open(PROC_SYSCALL_ARLA_FNAME, O_RDWR);
35   if(fd < 0)
36     return -1;
37
38   syscall_data.syscall = syscall;
39   syscall_data.param1 = param1;
40   syscall_data.param2 = param2;
41   syscall_data.param3 = param3;
42   syscall_data.param4 = param4;
43
44   *rval = ioctl(fd, VIOC_SYSCALL, &syscall_data);
45
46   close(fd);
47
48   return 0;
49 }
50 #endif
51
52 #if defined(AFS_DARWIN80_ENV)
53 int ioctl_afs_syscall(long syscall, long param1, long param2, long param3, 
54                      long param4, long param5, long param6, int *rval) {
55   struct afssysargs syscall_data;
56   int code;
57   int fd = open(SYSCALL_DEV_FNAME, O_RDWR);
58   if(fd < 0)
59     return -1;
60
61   syscall_data.syscall = syscall;
62   syscall_data.param1 = param1;
63   syscall_data.param2 = param2;
64   syscall_data.param3 = param3;
65   syscall_data.param4 = param4;
66   syscall_data.param5 = param5;
67   syscall_data.param6 = param6;
68
69   code = ioctl(fd, VIOC_SYSCALL, &syscall_data);
70
71   close(fd);
72   if (code)
73      return code;
74   *rval=syscall_data.retval;
75   return 0;
76 }
77 #endif