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