131a203dfSAl Viro /* 231a203dfSAl Viro * Coda File System, Linux Kernel module 331a203dfSAl Viro * 431a203dfSAl Viro * Original version, adapted from cfs_mach.c, (C) Carnegie Mellon University 531a203dfSAl Viro * Linux modifications (C) 1996, Peter J. Braam 631a203dfSAl Viro * Rewritten for Linux 2.1 (C) 1997 Carnegie Mellon University 731a203dfSAl Viro * 831a203dfSAl Viro * Carnegie Mellon University encourages users of this software to 931a203dfSAl Viro * contribute improvements to the Coda project. 1031a203dfSAl Viro */ 1131a203dfSAl Viro 1231a203dfSAl Viro #ifndef _LINUX_CODA_FS 1331a203dfSAl Viro #define _LINUX_CODA_FS 1431a203dfSAl Viro 1531a203dfSAl Viro #include <linux/kernel.h> 1631a203dfSAl Viro #include <linux/param.h> 1731a203dfSAl Viro #include <linux/mm.h> 1831a203dfSAl Viro #include <linux/vmalloc.h> 1931a203dfSAl Viro #include <linux/slab.h> 2031a203dfSAl Viro #include <linux/wait.h> 2131a203dfSAl Viro #include <linux/types.h> 2231a203dfSAl Viro #include <linux/fs.h> 2331a203dfSAl Viro #include "coda_fs_i.h" 2431a203dfSAl Viro 2531a203dfSAl Viro /* operations */ 2631a203dfSAl Viro extern const struct inode_operations coda_dir_inode_operations; 2731a203dfSAl Viro extern const struct inode_operations coda_file_inode_operations; 2831a203dfSAl Viro extern const struct inode_operations coda_ioctl_inode_operations; 2931a203dfSAl Viro 3031a203dfSAl Viro extern const struct dentry_operations coda_dentry_operations; 3131a203dfSAl Viro 3231a203dfSAl Viro extern const struct address_space_operations coda_file_aops; 3331a203dfSAl Viro extern const struct address_space_operations coda_symlink_aops; 3431a203dfSAl Viro 3531a203dfSAl Viro extern const struct file_operations coda_dir_operations; 3631a203dfSAl Viro extern const struct file_operations coda_file_operations; 3731a203dfSAl Viro extern const struct file_operations coda_ioctl_operations; 3831a203dfSAl Viro 3931a203dfSAl Viro /* operations shared over more than one file */ 4031a203dfSAl Viro int coda_open(struct inode *i, struct file *f); 4131a203dfSAl Viro int coda_release(struct inode *i, struct file *f); 4210556cb2SAl Viro int coda_permission(struct inode *inode, int mask); 4311d100d9SAl Viro int coda_revalidate_inode(struct inode *); 4431a203dfSAl Viro int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *); 4531a203dfSAl Viro int coda_setattr(struct dentry *, struct iattr *); 4631a203dfSAl Viro 4731a203dfSAl Viro /* this file: heloers */ 4831a203dfSAl Viro char *coda_f2s(struct CodaFid *f); 4931a203dfSAl Viro int coda_isroot(struct inode *i); 5031a203dfSAl Viro int coda_iscontrol(const char *name, size_t length); 5131a203dfSAl Viro 5231a203dfSAl Viro void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); 5331a203dfSAl Viro void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); 5431a203dfSAl Viro unsigned short coda_flags_to_cflags(unsigned short); 5531a203dfSAl Viro 5631a203dfSAl Viro /* sysctl.h */ 5731a203dfSAl Viro void coda_sysctl_init(void); 5831a203dfSAl Viro void coda_sysctl_clean(void); 5931a203dfSAl Viro 6031a203dfSAl Viro #define CODA_ALLOC(ptr, cast, size) do { \ 6131a203dfSAl Viro if (size < PAGE_SIZE) \ 62558feb08SJoe Perches ptr = kzalloc((unsigned long) size, GFP_KERNEL); \ 6331a203dfSAl Viro else \ 64558feb08SJoe Perches ptr = (cast)vzalloc((unsigned long) size); \ 6531a203dfSAl Viro if (!ptr) \ 66d9b4b319SFabian Frederick pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ 6731a203dfSAl Viro } while (0) 6831a203dfSAl Viro 6931a203dfSAl Viro 7031a203dfSAl Viro #define CODA_FREE(ptr,size) \ 7131a203dfSAl Viro do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0) 7231a203dfSAl Viro 7331a203dfSAl Viro /* inode to cnode access functions */ 7431a203dfSAl Viro 7531a203dfSAl Viro static inline struct coda_inode_info *ITOC(struct inode *inode) 7631a203dfSAl Viro { 7731a203dfSAl Viro return list_entry(inode, struct coda_inode_info, vfs_inode); 7831a203dfSAl Viro } 7931a203dfSAl Viro 8031a203dfSAl Viro static __inline__ struct CodaFid *coda_i2f(struct inode *inode) 8131a203dfSAl Viro { 8231a203dfSAl Viro return &(ITOC(inode)->c_fid); 8331a203dfSAl Viro } 8431a203dfSAl Viro 8531a203dfSAl Viro static __inline__ char *coda_i2s(struct inode *inode) 8631a203dfSAl Viro { 8731a203dfSAl Viro return coda_f2s(&(ITOC(inode)->c_fid)); 8831a203dfSAl Viro } 8931a203dfSAl Viro 9031a203dfSAl Viro /* this will not zap the inode away */ 9131a203dfSAl Viro static __inline__ void coda_flag_inode(struct inode *inode, int flag) 9231a203dfSAl Viro { 9331a203dfSAl Viro struct coda_inode_info *cii = ITOC(inode); 9431a203dfSAl Viro 9531a203dfSAl Viro spin_lock(&cii->c_lock); 9631a203dfSAl Viro cii->c_flags |= flag; 9731a203dfSAl Viro spin_unlock(&cii->c_lock); 9831a203dfSAl Viro } 9931a203dfSAl Viro 10031a203dfSAl Viro #endif 101