File: /usr/src/linux/include/linux/coda_linux.h

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
7      *
8      * Carnegie Mellon University encourages users of this software to
9      * contribute improvements to the Coda project.
10      */
11     
12     #ifndef _LINUX_CODA_FS
13     #define _LINUX_CODA_FS
14     
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/slab.h>
21     #include <linux/wait.h>		
22     #include <linux/types.h>
23     #include <linux/fs.h>
24     
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;
29     
30     extern struct address_space_operations coda_file_aops;
31     extern struct address_space_operations coda_symlink_aops;
32     
33     extern struct file_operations coda_dir_operations;
34     extern struct file_operations coda_file_operations;
35     extern struct file_operations coda_ioctl_operations;
36     
37     /* operations shared over more than one file */
38     int coda_open(struct inode *i, struct file *f);
39     int coda_flush(struct file *f);
40     int coda_release(struct inode *i, struct file *f);
41     int coda_permission(struct inode *inode, int mask);
42     int coda_revalidate_inode(struct dentry *);
43     int coda_notify_change(struct dentry *, struct iattr *);
44     int coda_isnullfid(ViceFid *fid);
45     
46     /* global variables */
47     extern int coda_debug;
48     extern int coda_print_entry;
49     extern int coda_access_cache;
50     extern int coda_fake_statfs;
51     
52     /* this file:  heloers */
53     static __inline__ struct ViceFid *coda_i2f(struct inode *);
54     static __inline__ char *coda_i2s(struct inode *);
55     static __inline__ void coda_flag_inode(struct inode *, int flag);
56     char *coda_f2s(ViceFid *f);
57     char *coda_f2s2(ViceFid *f);
58     int coda_isroot(struct inode *i);
59     int coda_iscontrol(const char *name, size_t length);
60     
61     void coda_load_creds(struct coda_cred *cred);
62     void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
63     void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
64     unsigned short coda_flags_to_cflags(unsigned short);
65     void print_vattr( struct coda_vattr *attr );
66     int coda_cred_ok(struct coda_cred *cred);
67     int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2);
68     
69     /* sysctl.h */
70     void coda_sysctl_init(void);
71     void coda_sysctl_clean(void);
72     
73     
74     /* debugging masks */
75     #define D_SUPER     1   /* print results returned by Venus */ 
76     #define D_INODE     2   /* print entry and exit into procedure */
77     #define D_FILE      4   
78     #define D_CACHE     8   /* cache debugging */
79     #define D_MALLOC    16  /* print malloc, de-alloc information */
80     #define D_CNODE     32
81     #define D_UPCALL    64  /* up and downcall debugging */
82     #define D_PSDEV    128  
83     #define D_PIOCTL   256
84     #define D_SPECIAL  512
85     #define D_TIMING  1024
86     #define D_DOWNCALL 2048
87      
88     #define CDEBUG(mask, format, a...)                                \
89       do {                                                            \
90       if (coda_debug & mask) {                                        \
91         printk("(%s,l. %d): ",  __FUNCTION__, __LINE__);              \
92         printk(format, ## a); }                                       \
93     } while (0)
94     
95     #define ENTRY    \
96         if(coda_print_entry) printk("Process %d entered %s\n",current->pid,__FUNCTION__)
97     
98     #define EXIT    \
99         if(coda_print_entry) printk("Process %d leaving %s\n",current->pid,__FUNCTION__)
100     
101     #define CODA_ALLOC(ptr, cast, size)                                       \
102     do {                                                                      \
103         if (size < PAGE_SIZE) {                                               \
104             ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL);            \
105             CDEBUG(D_MALLOC, "kmalloced: %lx at %p.\n", (long)size, ptr);     \
106          }  else {                                                            \
107             ptr = (cast)vmalloc((unsigned long) size);                        \
108     	CDEBUG(D_MALLOC, "vmalloced: %lx at %p .\n", (long)size, ptr);}   \
109         if (ptr == 0) {                                                       \
110             printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
111         }                                                                     \
112         else memset( ptr, 0, size );                                          \
113     } while (0)
114     
115     
116     #define CODA_FREE(ptr,size) do {if (size < PAGE_SIZE) { kfree((ptr)); 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)
117     
118     /* inode to cnode access functions */
119     
120     #define ITOC(inode) (&((inode)->u.coda_i))
121     
122     static __inline__ struct ViceFid *coda_i2f(struct inode *inode)
123     {
124     	return &(ITOC(inode)->c_fid);
125     }
126     
127     static __inline__ char *coda_i2s(struct inode *inode)
128     {
129     	return coda_f2s(&(ITOC(inode)->c_fid));
130     }
131     
132     /* this will not zap the inode away */
133     static __inline__ void coda_flag_inode(struct inode *inode, int flag)
134     {
135     	ITOC(inode)->c_flags |= flag;
136     }		
137     
138     #endif
139