efs.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (c) 1999 Al Smith
  3. *
  4. * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
  5. * Portions derived from IRIX header files (c) 1988 Silicon Graphics
  6. */
  7. #ifndef _EFS_EFS_H_
  8. #define _EFS_EFS_H_
  9. #ifdef pr_fmt
  10. #undef pr_fmt
  11. #endif
  12. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  13. #include <linux/fs.h>
  14. #include <asm/uaccess.h>
  15. #define EFS_VERSION "1.0a"
  16. static const char cprt[] = "EFS: "EFS_VERSION" - (c) 1999 Al Smith <Al.Smith@aeschi.ch.eu.org>";
  17. /* 1 block is 512 bytes */
  18. #define EFS_BLOCKSIZE_BITS 9
  19. #define EFS_BLOCKSIZE (1 << EFS_BLOCKSIZE_BITS)
  20. typedef int32_t efs_block_t;
  21. typedef uint32_t efs_ino_t;
  22. #define EFS_DIRECTEXTENTS 12
  23. /*
  24. * layout of an extent, in memory and on disk. 8 bytes exactly.
  25. */
  26. typedef union extent_u {
  27. unsigned char raw[8];
  28. struct extent_s {
  29. unsigned int ex_magic:8; /* magic # (zero) */
  30. unsigned int ex_bn:24; /* basic block */
  31. unsigned int ex_length:8; /* numblocks in this extent */
  32. unsigned int ex_offset:24; /* logical offset into file */
  33. } cooked;
  34. } efs_extent;
  35. typedef struct edevs {
  36. __be16 odev;
  37. __be32 ndev;
  38. } efs_devs;
  39. /*
  40. * extent based filesystem inode as it appears on disk. The efs inode
  41. * is exactly 128 bytes long.
  42. */
  43. struct efs_dinode {
  44. __be16 di_mode; /* mode and type of file */
  45. __be16 di_nlink; /* number of links to file */
  46. __be16 di_uid; /* owner's user id */
  47. __be16 di_gid; /* owner's group id */
  48. __be32 di_size; /* number of bytes in file */
  49. __be32 di_atime; /* time last accessed */
  50. __be32 di_mtime; /* time last modified */
  51. __be32 di_ctime; /* time created */
  52. __be32 di_gen; /* generation number */
  53. __be16 di_numextents; /* # of extents */
  54. u_char di_version; /* version of inode */
  55. u_char di_spare; /* spare - used by AFS */
  56. union di_addr {
  57. efs_extent di_extents[EFS_DIRECTEXTENTS];
  58. efs_devs di_dev; /* device for IFCHR/IFBLK */
  59. } di_u;
  60. };
  61. /* efs inode storage in memory */
  62. struct efs_inode_info {
  63. int numextents;
  64. int lastextent;
  65. efs_extent extents[EFS_DIRECTEXTENTS];
  66. struct inode vfs_inode;
  67. };
  68. #include <linux/efs_fs_sb.h>
  69. #define EFS_DIRBSIZE_BITS EFS_BLOCKSIZE_BITS
  70. #define EFS_DIRBSIZE (1 << EFS_DIRBSIZE_BITS)
  71. struct efs_dentry {
  72. __be32 inode;
  73. unsigned char namelen;
  74. char name[3];
  75. };
  76. #define EFS_DENTSIZE (sizeof(struct efs_dentry) - 3 + 1)
  77. #define EFS_MAXNAMELEN ((1 << (sizeof(char) * 8)) - 1)
  78. #define EFS_DIRBLK_HEADERSIZE 4
  79. #define EFS_DIRBLK_MAGIC 0xbeef /* moo */
  80. struct efs_dir {
  81. __be16 magic;
  82. unsigned char firstused;
  83. unsigned char slots;
  84. unsigned char space[EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE];
  85. };
  86. #define EFS_MAXENTS \
  87. ((EFS_DIRBSIZE - EFS_DIRBLK_HEADERSIZE) / \
  88. (EFS_DENTSIZE + sizeof(char)))
  89. #define EFS_SLOTAT(dir, slot) EFS_REALOFF((dir)->space[slot])
  90. #define EFS_REALOFF(offset) ((offset << 1))
  91. static inline struct efs_inode_info *INODE_INFO(struct inode *inode)
  92. {
  93. return container_of(inode, struct efs_inode_info, vfs_inode);
  94. }
  95. static inline struct efs_sb_info *SUPER_INFO(struct super_block *sb)
  96. {
  97. return sb->s_fs_info;
  98. }
  99. struct statfs;
  100. struct fid;
  101. extern const struct inode_operations efs_dir_inode_operations;
  102. extern const struct file_operations efs_dir_operations;
  103. extern const struct address_space_operations efs_symlink_aops;
  104. extern struct inode *efs_iget(struct super_block *, unsigned long);
  105. extern efs_block_t efs_map_block(struct inode *, efs_block_t);
  106. extern int efs_get_block(struct inode *, sector_t, struct buffer_head *, int);
  107. extern struct dentry *efs_lookup(struct inode *, struct dentry *, unsigned int);
  108. extern struct dentry *efs_fh_to_dentry(struct super_block *sb, struct fid *fid,
  109. int fh_len, int fh_type);
  110. extern struct dentry *efs_fh_to_parent(struct super_block *sb, struct fid *fid,
  111. int fh_len, int fh_type);
  112. extern struct dentry *efs_get_parent(struct dentry *);
  113. extern int efs_bmap(struct inode *, int);
  114. #endif /* _EFS_EFS_H_ */