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