Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Fabian Frederick | f38cfb2 | 2014-06-06 14:36:19 -0700 | [diff] [blame] | 15 | #ifdef pr_fmt |
| 16 | #undef pr_fmt |
| 17 | #endif |
| 18 | |
| 19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/kernel.h> |
| 22 | #include <linux/param.h> |
| 23 | #include <linux/mm.h> |
| 24 | #include <linux/vmalloc.h> |
| 25 | #include <linux/slab.h> |
| 26 | #include <linux/wait.h> |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/fs.h> |
Al Viro | 31a203d | 2011-01-12 16:36:09 -0500 | [diff] [blame] | 29 | #include "coda_fs_i.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | /* operations */ |
Arjan van de Ven | c5ef1c4 | 2007-02-12 00:55:40 -0800 | [diff] [blame] | 32 | extern const struct inode_operations coda_dir_inode_operations; |
| 33 | extern const struct inode_operations coda_file_inode_operations; |
| 34 | extern const struct inode_operations coda_ioctl_inode_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Al Viro | 9501e4c | 2011-01-12 16:25:02 -0500 | [diff] [blame] | 36 | extern const struct dentry_operations coda_dentry_operations; |
| 37 | |
Christoph Hellwig | f5e54d6 | 2006-06-28 04:26:44 -0700 | [diff] [blame] | 38 | extern const struct address_space_operations coda_file_aops; |
| 39 | extern const struct address_space_operations coda_symlink_aops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 41 | extern const struct file_operations coda_dir_operations; |
| 42 | extern const struct file_operations coda_file_operations; |
| 43 | extern const struct file_operations coda_ioctl_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | /* operations shared over more than one file */ |
| 46 | int coda_open(struct inode *i, struct file *f); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | int coda_release(struct inode *i, struct file *f); |
Al Viro | 10556cb | 2011-06-20 19:28:19 -0400 | [diff] [blame] | 48 | int coda_permission(struct inode *inode, int mask); |
Al Viro | 11d100d | 2013-10-04 18:17:02 -0400 | [diff] [blame] | 49 | int coda_revalidate_inode(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *); |
| 51 | int coda_setattr(struct dentry *, struct iattr *); |
| 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | /* this file: heloers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | char *coda_f2s(struct CodaFid *f); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | int coda_iscontrol(const char *name, size_t length); |
| 56 | |
| 57 | void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); |
| 58 | void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); |
| 59 | unsigned short coda_flags_to_cflags(unsigned short); |
| 60 | |
| 61 | /* sysctl.h */ |
| 62 | void coda_sysctl_init(void); |
| 63 | void coda_sysctl_clean(void); |
| 64 | |
| 65 | #define CODA_ALLOC(ptr, cast, size) do { \ |
| 66 | if (size < PAGE_SIZE) \ |
Joe Perches | 558feb0 | 2011-05-28 10:36:33 -0700 | [diff] [blame] | 67 | ptr = kzalloc((unsigned long) size, GFP_KERNEL); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | else \ |
Joe Perches | 558feb0 | 2011-05-28 10:36:33 -0700 | [diff] [blame] | 69 | ptr = (cast)vzalloc((unsigned long) size); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | if (!ptr) \ |
Fabian Frederick | d9b4b31 | 2014-06-06 14:36:18 -0700 | [diff] [blame] | 71 | pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } while (0) |
| 73 | |
| 74 | |
| 75 | #define CODA_FREE(ptr,size) \ |
| 76 | do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0) |
| 77 | |
| 78 | /* inode to cnode access functions */ |
| 79 | |
| 80 | static inline struct coda_inode_info *ITOC(struct inode *inode) |
| 81 | { |
| 82 | return list_entry(inode, struct coda_inode_info, vfs_inode); |
| 83 | } |
| 84 | |
| 85 | static __inline__ struct CodaFid *coda_i2f(struct inode *inode) |
| 86 | { |
| 87 | return &(ITOC(inode)->c_fid); |
| 88 | } |
| 89 | |
| 90 | static __inline__ char *coda_i2s(struct inode *inode) |
| 91 | { |
| 92 | return coda_f2s(&(ITOC(inode)->c_fid)); |
| 93 | } |
| 94 | |
| 95 | /* this will not zap the inode away */ |
| 96 | static __inline__ void coda_flag_inode(struct inode *inode, int flag) |
| 97 | { |
Yoshihisa Abe | b5ce1d8 | 2010-10-25 02:03:44 -0400 | [diff] [blame] | 98 | struct coda_inode_info *cii = ITOC(inode); |
| 99 | |
| 100 | spin_lock(&cii->c_lock); |
| 101 | cii->c_flags |= flag; |
| 102 | spin_unlock(&cii->c_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | #endif |