vioc-header-split-20060802
[openafs.git] / src / util / vice.h
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
10 #ifndef AFS_VICE_H
11 #define AFS_VICE_H 1
12
13 #include <sys/types.h>
14 #include <sys/ioctl.h>
15
16 /*
17  * Structures used to pass data into AFS ioctls.  The buffer pointers may be
18  * null, or the counts may be 0 if there are no input or output parameters.
19  */
20
21 #if defined(KERNEL)
22 /* A fixed size, whether the kernel uses the ILP32 or LP64 data models. */
23 struct ViceIoctl32 {
24     unsigned int in, out;       /* Data to be transferred in, or out */
25     short in_size;              /* Size of input buffer <= 2K */
26     short out_size;             /* Maximum size of output buffer, <= 2K */
27 };
28 #endif
29
30 /* Windows uses a different structure layout, defined in sys/pioctl_nt.h. */
31 #ifndef _WIN32_WINNT
32 struct ViceIoctl {
33     caddr_t in, out;            /* Data to be transferred in, or out */
34     short in_size;              /* Size of input buffer <= 2K */
35     short out_size;             /* Maximum size of output buffer, <= 2K */
36 };
37 #endif
38
39 /*
40  * The structure argument to _IOW() is used to add a structure size component
41  * to the _IOW() value, to help the kernel code identify how big a structure
42  * the calling process is passing into a system call.
43  *
44  * In user space, struct ViceIoctl32 and struct ViceIoctl are the same except
45  * on Digital Unix, where user space code is compiled in 64-bit mode.
46  *
47  * So, in kernel space, regardless whether it is compiled in 32-bit mode or
48  * 64-bit mode, the kernel code can use the struct ViceIoctl32 version of
49  * _IOW() to check the size of user space arguments -- except on Digital Unix
50  * (or Linux on Alpha, since it's compatible with Digital Unix).  We don't
51  * care about other 64-bit Linux versions since they don't check this length.
52  */
53 #if defined(KERNEL) && !defined(__alpha__)
54 #define _VICEIOCTL(id) ((unsigned int) _IOW('V', id, struct ViceIoctl32))
55 #define _VICEIOCTL2(dev, id) ((unsigned int) _IOW(dev, id, struct ViceIoctl32))
56 #else
57 #define _VICEIOCTL(id) ((unsigned int) _IOW('V', id, struct ViceIoctl))
58 #define _VICEIOCTL2(dev, id) ((unsigned int) _IOW(dev, id, struct ViceIoctl))
59 #endif
60 #define _CVICEIOCTL(id) _VICEIOCTL2('C', id)
61 #define _OVICEIOCTL(id) _VICEIOCTL2('O', id)
62
63 /*
64  * Use these macros to define up to 256 vice ioctls in each space.  These
65  * ioctls all potentially have in/out parameters, depending on the values in
66  * the ViceIoctl structure.  This structure is passed into the kernel by the
67  * normal ioctl parameter passing mechanism.
68  *
69  * See <http://grand.central.org/numbers/pioctls.html> for the definition of
70  * the namespaces.
71  */
72
73 #endif /* AFS_VICE_H */