coda_linux.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 "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 dentry_operations coda_dentry_operations;
  27. extern const struct address_space_operations coda_file_aops;
  28. extern const struct address_space_operations coda_symlink_aops;
  29. extern const struct file_operations coda_dir_operations;
  30. extern const struct file_operations coda_file_operations;
  31. extern const 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_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_getattr(struct vfsmount *, struct dentry *, struct kstat *);
  38. int coda_setattr(struct dentry *, struct iattr *);
  39. /* this file: heloers */
  40. char *coda_f2s(struct CodaFid *f);
  41. int coda_isroot(struct inode *i);
  42. int coda_iscontrol(const char *name, size_t length);
  43. void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
  44. void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
  45. unsigned short coda_flags_to_cflags(unsigned short);
  46. /* sysctl.h */
  47. void coda_sysctl_init(void);
  48. void coda_sysctl_clean(void);
  49. #define CODA_ALLOC(ptr, cast, size) do { \
  50. if (size < PAGE_SIZE) \
  51. ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
  52. else \
  53. ptr = (cast)vzalloc((unsigned long) size); \
  54. if (!ptr) \
  55. printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
  56. } while (0)
  57. #define CODA_FREE(ptr,size) \
  58. do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0)
  59. /* inode to cnode access functions */
  60. static inline struct coda_inode_info *ITOC(struct inode *inode)
  61. {
  62. return list_entry(inode, struct coda_inode_info, vfs_inode);
  63. }
  64. static __inline__ struct CodaFid *coda_i2f(struct inode *inode)
  65. {
  66. return &(ITOC(inode)->c_fid);
  67. }
  68. static __inline__ char *coda_i2s(struct inode *inode)
  69. {
  70. return coda_f2s(&(ITOC(inode)->c_fid));
  71. }
  72. /* this will not zap the inode away */
  73. static __inline__ void coda_flag_inode(struct inode *inode, int flag)
  74. {
  75. struct coda_inode_info *cii = ITOC(inode);
  76. spin_lock(&cii->c_lock);
  77. cii->c_flags |= flag;
  78. spin_unlock(&cii->c_lock);
  79. }
  80. #endif