Whamcloud - gitweb
b=17604
[fs/lustre-release.git] / libsysio / include / dev.h
1 /*
2  *    This Cplant(TM) source code is the property of Sandia National
3  *    Laboratories.
4  *
5  *    This Cplant(TM) source code is copyrighted by Sandia National
6  *    Laboratories.
7  *
8  *    The redistribution of this Cplant(TM) source code is subject to the
9  *    terms of the GNU Lesser General Public License
10  *    (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
11  *
12  *    Cplant(TM) Copyright 1998-2003 Sandia Corporation. 
13  *    Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
14  *    license for use of this work by or on behalf of the US Government.
15  *    Export of this program may require a license from the United States
16  *    Government.
17  */
18
19 /*
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  * 
25  * This library is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  * 
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33  *
34  * Questions or comments about this library should be sent to:
35  *
36  * Lee Ward
37  * Sandia National Laboratories, New Mexico
38  * P.O. Box 5800
39  * Albuquerque, NM 87185-1110
40  *
41  * lee@sandia.gov
42  */
43
44 /*
45  * Device support.
46  */
47
48 /*
49  * Make a device number, composed of major and minor parts. We *assume* that
50  * the system version of a dev_t is 16 bits or more.
51  */
52 #define SYSIO_MKDEV(major, minor) \
53         ((((major) & 0xff) << 8) | ((minor) & 0xff))
54
55 /*
56  * Return major unit given dev number.
57  */
58 #define SYSIO_MAJOR_DEV(dev) \
59         (((dev) >> 8) & 0xff)
60
61 /*
62  * Return minor unit given dev number.
63  */
64 #define SYSIO_MINOR_DEV(dev) \
65         ((dev) & 0xff)
66
67 extern const struct inode_ops _sysio_nodev_ops;
68
69 #define _sysio_nodev_inop_lookup \
70         (int (*)(struct pnode *, \
71                  struct inode **, \
72                  struct intent *, \
73                  const char *))_sysio_do_illop
74 #define _sysio_nodev_inop_getattr \
75         (int (*)(struct pnode *, \
76                  struct inode *, \
77                  struct intnl_stat *))_sysio_do_ebadf
78 #define _sysio_nodev_inop_setattr \
79         (int (*)(struct pnode *, \
80                  struct inode *, \
81                  unsigned , \
82                  struct intnl_stat *))_sysio_do_ebadf
83 #define _sysio_nodev_filldirentries \
84         (ssize_t (*)(struct inode *, \
85                      _SYSIO_OFF_T *, \
86                      char *, \
87                      size_t))_sysio_do_illop
88 #define _sysio_nodev_inop_mkdir \
89         (int (*)(struct pnode *, \
90                  mode_t))_sysio_do_illop
91 #define _sysio_nodev_inop_rmdir \
92         (int (*)(struct pnode *))_sysio_do_illop
93 #define _sysio_nodev_inop_symlink \
94         (int (*)(struct pnode *, \
95                  const char *))_sysio_do_illop
96 #define _sysio_nodev_inop_readlink \
97         (int (*)(struct pnode *, \
98                  char *, \
99                  size_t))_sysio_do_illop
100 #define _sysio_nodev_inop_open \
101         (int (*)(struct pnode *, \
102                  int, \
103                  mode_t))_sysio_do_enodev
104 #define _sysio_nodev_inop_close \
105         (int (*)(struct inode *))_sysio_do_ebadf
106 #define _sysio_nodev_inop_link \
107         (int (*)(struct pnode *, struct pnode *))_sysio_do_illop
108 #define _sysio_nodev_inop_unlink \
109         (int (*)(struct pnode *))_sysio_do_illop
110 #define _sysio_nodev_inop_rename \
111         (int (*)(struct pnode *, struct pnode *))_sysio_do_illop
112 #define _sysio_nodev_inop_read \
113         (int (*)(struct inode *, \
114                  struct ioctx *))_sysio_do_ebadf
115 #define _sysio_nodev_inop_write \
116         (int (*)(struct inode *, \
117                  struct ioctx *))_sysio_do_ebadf
118 #define _sysio_nodev_inop_pos \
119         (_SYSIO_OFF_T (*)(struct inode *, _SYSIO_OFF_T))_sysio_do_ebadf
120 #define _sysio_nodev_inop_iodone \
121         (int (*)(struct ioctx *))_sysio_do_einval
122 #define _sysio_nodev_inop_fcntl \
123         (int (*)(struct inode *, \
124                  int, \
125                  va_list, \
126                  int *))_sysio_do_ebadf
127 #define _sysio_nodev_inop_sync \
128         (int (*)(struct inode *))_sysio_do_ebadf
129 #define _sysio_nodev_inop_datasync \
130         (int (*)(struct inode *))_sysio_do_ebadf
131 #define _sysio_nodev_inop_ioctl \
132         (int (*)(struct inode *, \
133                  unsigned long int, \
134                  va_list))_sysio_do_ebadf
135 #define _sysio_nodev_inop_mknod \
136         (int (*)(struct pnode *, \
137                  mode_t, \
138                  dev_t))_sysio_do_illop
139 #ifdef _HAVE_STATVFS
140 #define _sysio_nodev_inop_statvfs \
141         (int (*)(struct pnode *, \
142                  struct inode *, \
143                  struct intnl_statvfs *))_sysio_do_illop
144 #endif
145 #define _sysio_nodev_inop_gone \
146         (void (*)(struct inode *ino))_sysio_do_noop
147
148 extern int _sysio_dev_init(void);
149 extern dev_t _sysio_dev_alloc(void);
150 extern struct inode_ops *_sysio_dev_lookup(mode_t mode, dev_t dev);
151 extern int _sysio_char_dev_register(int major,
152                                     const char *name,
153                                     struct inode_ops *ops);