Merge with 2.3.48.
[linux-2.6/linux-mips.git] / include / linux / coda_linux.h
blob21f5bad13a5fc51adce6731b18dc1b2217322dde
1 /*
2 * Coda File System, Linux Kernel module
3 *
4 * Original version, adapted from cfs_mach.c, (C) Carnegie Mellon University
5 * Linux modifications (C) 1996, Peter J. Braam
6 * Rewritten for Linux 2.1 (C) 1997 Carnegie Mellon University
8 * Carnegie Mellon University encourages users of this software to
9 * contribute improvements to the Coda project.
12 #ifndef _LINUX_CODA_FS
13 #define _LINUX_CODA_FS
15 #include <linux/kernel.h>
16 #include <linux/param.h>
17 #include <linux/sched.h>
18 #include <linux/mm.h>
19 #include <linux/vmalloc.h>
20 #include <linux/malloc.h>
21 #include <linux/wait.h>
22 #include <linux/types.h>
23 #include <linux/fs.h>
25 /* operations */
26 extern struct inode_operations coda_dir_inode_operations;
27 extern struct inode_operations coda_file_inode_operations;
28 extern struct inode_operations coda_ioctl_inode_operations;
30 extern struct address_space_operations coda_file_aops;
31 extern struct address_space_operations coda_symlink_aops;
33 extern struct file_operations coda_dir_operations;
34 extern struct file_operations coda_file_operations;
35 extern struct file_operations coda_ioctl_operations;
37 /* operations shared over more than one file */
38 int coda_open(struct inode *i, struct file *f);
39 int coda_release(struct inode *i, struct file *f);
40 int coda_permission(struct inode *inode, int mask);
41 int coda_revalidate_inode(struct dentry *);
42 int coda_notify_change(struct dentry *, struct iattr *);
44 /* global variables */
45 extern int coda_debug;
46 extern int coda_print_entry;
47 extern int coda_access_cache;
49 /* this file: heloers */
50 static __inline__ struct ViceFid *coda_i2f(struct inode *);
51 char *coda_f2s(ViceFid *f);
52 char *coda_f2s2(ViceFid *f);
53 int coda_isroot(struct inode *i);
54 int coda_fid_is_volroot(struct ViceFid *);
55 int coda_fid_is_weird(struct ViceFid *fid);
56 int coda_iscontrol(const char *name, size_t length);
58 void coda_load_creds(struct coda_cred *cred);
59 int coda_mycred(struct coda_cred *);
60 void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
61 void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
62 unsigned short coda_flags_to_cflags(unsigned short);
63 void print_vattr( struct coda_vattr *attr );
64 int coda_cred_ok(struct coda_cred *cred);
65 int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2);
67 /* defined in file.c */
68 void coda_prepare_openfile(struct inode *coda_inode, struct file *coda_file,
69 struct inode *open_inode, struct file *open_file,
70 struct dentry *open_dentry);
71 void coda_restore_codafile(struct inode *coda_inode, struct file *coda_file,
72 struct inode *open_inode, struct file *open_file);
73 int coda_inode_grab(dev_t dev, ino_t ino, struct inode **ind);
75 #define NB_SFS_SIZ 0x895440
77 /* cache.c */
78 void coda_purge_children(struct inode *, int);
79 void coda_purge_dentries(struct inode *);
81 /* sysctl.h */
82 void coda_sysctl_init(void);
83 void coda_sysctl_clean(void);
86 /* debugging masks */
87 #define D_SUPER 1 /* print results returned by Venus */
88 #define D_INODE 2 /* print entry and exit into procedure */
89 #define D_FILE 4
90 #define D_CACHE 8 /* cache debugging */
91 #define D_MALLOC 16 /* print malloc, de-alloc information */
92 #define D_CNODE 32
93 #define D_UPCALL 64 /* up and downcall debugging */
94 #define D_PSDEV 128
95 #define D_PIOCTL 256
96 #define D_SPECIAL 512
97 #define D_TIMING 1024
98 #define D_DOWNCALL 2048
100 #define CDEBUG(mask, format, a...) \
101 do { \
102 if (coda_debug & mask) { \
103 printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
104 printk(format, ## a); } \
105 } while (0) ;
107 #define ENTRY \
108 if(coda_print_entry) printk("Process %d entered %s\n",current->pid,__FUNCTION__)
110 #define EXIT \
111 if(coda_print_entry) printk("Process %d leaving %s\n",current->pid,__FUNCTION__)
113 #define CHECK_CNODE(c) do { } while (0);
115 #define CODA_ALLOC(ptr, cast, size) \
116 do { \
117 if (size < 3000) { \
118 ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
119 CDEBUG(D_MALLOC, "kmalloced: %lx at %p.\n", (long)size, ptr);\
120 } else { \
121 ptr = (cast)vmalloc((unsigned long) size); \
122 CDEBUG(D_MALLOC, "vmalloced: %lx at %p .\n", (long)size, ptr);}\
123 if (ptr == 0) { \
124 printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
126 memset( ptr, 0, size ); \
127 } while (0)
130 #define CODA_FREE(ptr,size) do {if (size < 3000) { kfree_s((ptr), (size)); CDEBUG(D_MALLOC, "kfreed: %lx at %p.\n", (long) size, ptr); } else { vfree((ptr)); CDEBUG(D_MALLOC, "vfreed: %lx at %p.\n", (long) size, ptr);} } while (0)
132 /* inode to cnode */
134 static __inline__ struct ViceFid *coda_i2f(struct inode *inode)
136 return &(inode->u.coda_i.c_fid);
139 #define ITOC(inode) (&((inode)->u.coda_i))
146 #endif