coda_linux.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:5k
源码类别:

嵌入式Linux

开发平台:

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