2 * Copyright (c) 2010 Isilon Systems, Inc.
3 * Copyright (c) 2010 iX Systems, Inc.
4 * Copyright (c) 2010 Panasas, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
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.
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.
31 #include <sys/systm.h>
33 #include <sys/vnode.h>
35 #include <sys/filedesc.h>
36 #include <linux/types.h>
37 #include <linux/wait.h>
38 #include <linux/semaphore.h>
46 struct pipe_inode_info;
47 struct vm_area_struct;
48 struct poll_table_struct;
54 #define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
55 #define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
58 typedef struct files_struct *fl_owner_t;
61 struct inode *d_inode;
64 struct file_operations;
68 const struct file_operations *f_op;
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;
79 #define file linux_file
80 #define fasync_struct sigio *
82 #define fasync_helper(fd, filp, on, queue) \
85 *(queue) = &(filp)->f_sigio; \
91 #define kill_fasync(queue, sig, pollstat) \
93 if (*(queue) != NULL) \
94 pgsigio(*(queue), (sig), 0); \
97 typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
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);
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,
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,
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 **);
137 #define fops_get(fops) (fops)
139 #define FMODE_READ FREAD
140 #define FMODE_WRITE FWRITE
141 #define FMODE_EXEC FEXEC
144 register_chrdev_region(dev_t dev, unsigned range, const char *name)
151 unregister_chrdev_region(dev_t dev, unsigned range)
158 iminor(struct inode *inode)
161 return dev2unit(inode->v_rdev);
164 static inline struct inode *
165 igrab(struct inode *inode)
169 error = vget(inode, 0, curthread);
177 iput(struct inode *inode)
183 #endif /* _LINUX_FS_H_ */