]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/ofed/include/linux/fs.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / ofed / include / linux / fs.h
1 /*-
2  * Copyright (c) 2010 Isilon Systems, Inc.
3  * Copyright (c) 2010 iX Systems, Inc.
4  * Copyright (c) 2010 Panasas, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice unmodified, this list of conditions, and the following
12  *    disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef _LINUX_FS_H_
29 #define _LINUX_FS_H_
30
31 #include <sys/systm.h>
32 #include <sys/conf.h>
33 #include <sys/vnode.h>
34 #include <sys/file.h>
35 #include <sys/filedesc.h>
36 #include <linux/types.h>
37 #include <linux/wait.h>
38 #include <linux/semaphore.h>
39
40 struct module;
41 struct kiocb;
42 struct iovec;
43 struct dentry;
44 struct page;
45 struct file_lock;
46 struct pipe_inode_info;
47 struct vm_area_struct;
48 struct poll_table_struct;
49 struct files_struct;
50
51 #define inode   vnode
52 #define i_cdev  v_rdev
53
54 #define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
55 #define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
56
57
58 typedef struct files_struct *fl_owner_t;
59
60 struct dentry {
61         struct inode    *d_inode;
62 };
63
64 struct file_operations;
65
66 struct linux_file {
67         struct file     *_file;
68         const struct file_operations    *f_op;
69         void            *private_data;
70         int             f_flags;
71         int             f_mode; /* Just starting mode. */
72         struct dentry   *f_dentry;
73         struct dentry   f_dentry_store;
74         struct selinfo  f_selinfo;
75         struct sigio    *f_sigio;
76         struct vnode    *f_vnode;
77 };
78
79 #define file            linux_file
80 #define fasync_struct   sigio *
81
82 #define fasync_helper(fd, filp, on, queue)                              \
83 ({                                                                      \
84         if ((on))                                                       \
85                 *(queue) = &(filp)->f_sigio;                            \
86         else                                                            \
87                 *(queue) = NULL;                                        \
88         0;                                                              \
89 })
90
91 #define kill_fasync(queue, sig, pollstat)                               \
92 do {                                                                    \
93         if (*(queue) != NULL)                                           \
94                 pgsigio(*(queue), (sig), 0);                            \
95 } while (0)
96
97 typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
98
99 struct file_operations {
100         struct module *owner;
101         ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
102         ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
103         unsigned int (*poll) (struct file *, struct poll_table_struct *);
104         long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long);
105         int (*mmap)(struct file *, struct vm_area_struct *);
106         int (*open)(struct inode *, struct file *);
107         int (*release)(struct inode *, struct file *);
108         int (*fasync)(int, struct file *, int);
109 #if 0
110         /* We do not support these methods.  Don't permit them to compile. */
111         loff_t (*llseek)(struct file *, loff_t, int);
112         ssize_t (*aio_read)(struct kiocb *, const struct iovec *,
113             unsigned long, loff_t);
114         ssize_t (*aio_write)(struct kiocb *, const struct iovec *,
115             unsigned long, loff_t);
116         int (*readdir)(struct file *, void *, filldir_t);
117         int (*ioctl)(struct inode *, struct file *, unsigned int,
118             unsigned long);
119         long (*compat_ioctl)(struct file *, unsigned int, unsigned long);
120         int (*flush)(struct file *, fl_owner_t id);
121         int (*fsync)(struct file *, struct dentry *, int datasync);
122         int (*aio_fsync)(struct kiocb *, int datasync);
123         int (*lock)(struct file *, int, struct file_lock *);
124         ssize_t (*sendpage)(struct file *, struct page *, int, size_t,
125             loff_t *, int);
126         unsigned long (*get_unmapped_area)(struct file *, unsigned long,
127             unsigned long, unsigned long, unsigned long);
128         int (*check_flags)(int);
129         int (*flock)(struct file *, int, struct file_lock *);
130         ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
131             loff_t *, size_t, unsigned int);
132         ssize_t (*splice_read)(struct file *, loff_t *,
133             struct pipe_inode_info *, size_t, unsigned int);
134         int (*setlease)(struct file *, long, struct file_lock **);
135 #endif
136 };
137 #define fops_get(fops)  (fops)
138
139 #define FMODE_READ      FREAD
140 #define FMODE_WRITE     FWRITE
141 #define FMODE_EXEC      FEXEC
142
143 static inline int
144 register_chrdev_region(dev_t dev, unsigned range, const char *name)
145 {
146
147         return 0;
148 }
149
150 static inline void
151 unregister_chrdev_region(dev_t dev, unsigned range)
152 {
153
154         return;
155 }
156
157 static inline dev_t
158 iminor(struct inode *inode)
159 {
160
161         return dev2unit(inode->v_rdev);
162 }
163
164 static inline struct inode *
165 igrab(struct inode *inode)
166 {
167         int error;
168
169         error = vget(inode, 0, curthread);
170         if (error)
171                 return (NULL);
172
173         return (inode);
174 }
175
176 static inline void
177 iput(struct inode *inode)
178 {
179
180         vrele(inode);
181 }
182
183 #endif  /* _LINUX_FS_H_ */