remove redundant semicolon
[arla.git] / nnpfs / linux / nnpfs / nnpfs_locl.h
blob0b3a053d5f22c87dfd5603047fb80f4335a8b434
1 /*
2 * Copyright (c) 1995 - 2004 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following 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.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * Alternatively, this software may be distributed under the terms of the
22 * GNU General Public License ("GPL").
24 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
37 /* $Id$ */
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
43 #include <asm/current.h>
44 #include <linux/version.h>
45 #include <linux/module.h>
46 #include <linux/errno.h>
47 #include <linux/fs.h>
48 #include <linux/slab.h>
49 #include <linux/time.h>
50 #include <linux/sched.h>
51 #include <linux/stat.h>
52 #include <linux/string.h>
53 #include <linux/namei.h>
54 #include <linux/smp_lock.h>
55 #include <linux/wait.h>
58 * Linux 2.3.39 and above has a new setgroups() system call for
59 * 32-bit UIDs, on arm, i386, m68k, sh, and sparc32. The old system call
60 * also has to be handled properly, with a different type for gid_t.
61 * See nnpfs_syscalls.c for more information.
64 #include <asm/unistd.h>
66 #ifdef __NR_setgroups32
67 #define ARLA_NR_setgroups __NR_setgroups32
70 * For the time being Linux 2.3/2.4 will call the old 16-bit uid
71 * setgroups() __NR_setgroups; at some point in the future it may go away,
72 * so we put this ifdef here
74 #ifdef __NR_setgroups
75 #define ARLA_NR_setgroups16 __NR_setgroups
76 #endif
78 #else
79 #define ARLA_NR_setgroups __NR_setgroups
80 #endif
82 #include <asm/uaccess.h>
84 /*
85 * The people at FSF seems to think that user program
86 * should include /usr/include/{,sys} and the kernel
87 * should have their own include files.
89 * That seems ok to me, but then we don't get the int23_t & friends
90 * from userland. And in kernelspace it seems that we should use
91 * __{s,u}32, and that seems silly, so we typedef them ourself.
92 * It's the same thing with MAXPATHLEN that is named PATH_MAX in
93 * the kernel.
95 * Thank you to N.N for pointing this out.
98 #ifdef HAVE_GLIBC
100 #ifndef HAVE_LINUX_KERNEL_INT8_T
101 typedef __s8 int8_t;
102 #endif
103 #ifndef HAVE_LINUX_KERNEL_UINT8_T
104 typedef __u8 uint8_t;
105 #endif
106 #ifndef HAVE_LINUX_KERNEL_INT16_T
107 typedef __s16 int16_t;
108 #endif
109 #ifndef HAVE_LINUX_KERNEL_UINT16_T
110 typedef __u16 uint16_t;
111 #endif
112 #ifndef HAVE_LINUX_KERNEL_INT32_T
113 typedef __s32 int32_t;
114 #endif
115 #ifndef HAVE_LINUX_KERNEL_UINT32_T
116 typedef __u32 uint32_t;
117 #endif
119 #ifndef MAXPATHLEN
120 #define MAXPATHLEN PATH_MAX
121 #endif
123 #endif
125 #include <nnpfs/nnpfs_message.h>
126 #include <nnpfs/nnpfs_fs.h>
127 #include <nnpfs/nnpfs_node.h>
128 #include <nnpfs/nnpfs_deb.h>
131 /* A panic() suitable for testing scenarios */
132 #if 0
133 #define nnpfs_debug_oops() BUG()
134 #else
135 #define nnpfs_debug_oops() do { ; } while (0)
136 #endif
139 nnpfs_fetch_root(struct inode *i);
141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
143 nnpfs_get_sb(struct file_system_type *fs_type,
144 int flags, const char *dev_name,
145 void *data, struct vfsmount *mnt);
146 #else
147 struct super_block *
148 nnpfs_get_sb (struct file_system_type *fs_type,
149 int flags, const char *dev_name, void *data);
150 #endif
152 extern struct dentry_operations nnpfs_dentry_operations;
155 * i_blocks should apparently always be returned in 512-bytes units
158 #define I_BLOCKS_UNIT 512
160 #define I_BLOCKS_BITS 9
163 * Help function to read the inode->i_count a portable way
166 static inline int
167 nnpfs_icount (struct inode *inode)
169 return atomic_read(&inode->i_count);
173 * Help functions to manipulate inode->i_count
176 static inline void
177 nnpfs_iref (struct inode *inode)
179 atomic_inc(&inode->i_count);
182 static inline void
183 nnpfs_irele (struct inode *inode)
185 atomic_dec(&inode->i_count);
190 * Help function to read the inode->i_writecount a portable way
193 static inline int
194 nnpfs_iwritecount (struct inode *inode)
196 return atomic_read(&inode->i_writecount);
200 * Help function to read the dentry->d_count a portable way
203 static inline int
204 nnpfs_dcount (const struct dentry *dentry)
206 return atomic_read(&dentry->d_count);
209 extern
210 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
211 const
212 #endif
213 struct address_space_operations nnpfs_aops;
215 #ifndef list_for_each
216 #define list_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next)
217 #endif /* list_for_each */
220 #ifndef list_for_each_safe
221 #define list_for_each_safe(pos, n, head) \
222 for (pos = (head)->next, n = pos->next; pos != (head); \
223 pos = n, n = pos->next)
224 #endif
226 #if !defined(HAVE_INIT_MUTEX) && !defined(init_MUTEX)
227 #define init_MUTEX(m) *(m) = MUTEX
228 #endif
230 typedef asmlinkage long (*nnpfs_sys_call_function)(void);
233 nnpfs_fixup_syscall_lossage(void);
235 #ifndef I_DIRTY_DATASYNC
236 #define I_DIRTY_DATASYNC 0
237 #endif
239 #define nnpfs_dev_t dev_t
240 #define nnpfs_d_entry_unhashed(d) hlist_unhashed(d)
242 #define NNPFS_NOOP while(0){}
244 #define NNPFS_SET_TIME(timeunit, sec) \
245 ((timeunit).tv_sec = (sec), (timeunit).tv_nsec = 0)
246 #define NNPFS_GET_TIME_SEC(timeunit) ((timeunit).tv_sec)
248 #define NNPFS_MSG_WAKEUP_ERROR(m) \
249 (((struct nnpfs_message_wakeup *)(void *)m)->error)
251 #ifndef O_LARGEFILE
252 #define O_LARGEFILE 0
253 #endif