coda_linux.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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