efs.h 3.8 KB

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