coda_linux.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/mm.h>
  16. #include <linux/vmalloc.h>
  17. #include <linux/slab.h>
  18. #include <linux/wait.h>
  19. #include <linux/types.h>
  20. #include <linux/fs.h>
  21. #include <linux/coda_fs_i.h>
  22. /* operations */
  23. extern const struct inode_operations coda_dir_inode_operations;
  24. extern const struct inode_operations coda_file_inode_operations;
  25. extern const struct inode_operations coda_ioctl_inode_operations;
  26. extern const struct address_space_operations coda_file_aops;
  27. extern const struct address_space_operations coda_symlink_aops;
  28. extern const struct file_operations coda_dir_operations;
  29. extern const struct file_operations coda_file_operations;
  30. extern const 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, fl_owner_t id);
  34. int coda_release(struct inode *i, struct file *f);
  35. int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
  36. int coda_revalidate_inode(struct dentry *);
  37. int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
  38. int coda_setattr(struct dentry *, struct iattr *);
  39. /* global variables */
  40. extern int coda_fake_statfs;
  41. /* this file: heloers */
  42. static __inline__ struct CodaFid *coda_i2f(struct inode *);
  43. static __inline__ char *coda_i2s(struct inode *);
  44. static __inline__ void coda_flag_inode(struct inode *, int flag);
  45. char *coda_f2s(struct CodaFid *f);
  46. int coda_isroot(struct inode *i);
  47. int coda_iscontrol(const char *name, size_t length);
  48. void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
  49. void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
  50. unsigned short coda_flags_to_cflags(unsigned short);
  51. /* sysctl.h */
  52. void coda_sysctl_init(void);
  53. void coda_sysctl_clean(void);
  54. #define CODA_ALLOC(ptr, cast, size) do { \
  55. if (size < PAGE_SIZE) \
  56. ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
  57. else \
  58. ptr = (cast)vmalloc((unsigned long) size); \
  59. if (!ptr) \
  60. printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
  61. else memset( ptr, 0, size ); \
  62. } while (0)
  63. #define CODA_FREE(ptr,size) \
  64. do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0)
  65. /* inode to cnode access functions */
  66. static inline struct coda_inode_info *ITOC(struct inode *inode)
  67. {
  68. return list_entry(inode, struct coda_inode_info, vfs_inode);
  69. }
  70. static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
  71. {
  72. return &(ITOC(inode)->c_fid);
  73. }
  74. static __inline__ char *coda_i2s(struct inode *inode)
  75. {
  76. return coda_f2s(&(ITOC(inode)->c_fid));
  77. }
  78. /* this will not zap the inode away */
  79. static __inline__ void coda_flag_inode(struct inode *inode, int flag)
  80. {
  81. ITOC(inode)->c_flags |= flag;
  82. }
  83. #endif