bfs_fs.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * include/linux/bfs_fs.h - BFS data structures on disk.
  4. * Copyright (C) 1999 Tigran Aivazian <tigran@veritas.com>
  5. */
  6. #ifndef _LINUX_BFS_FS_H
  7. #define _LINUX_BFS_FS_H
  8. #include <linux/types.h>
  9. #define BFS_BSIZE_BITS 9
  10. #define BFS_BSIZE (1<<BFS_BSIZE_BITS)
  11. #define BFS_MAGIC 0x1BADFACE
  12. #define BFS_ROOT_INO 2
  13. #define BFS_INODES_PER_BLOCK 8
  14. /* SVR4 vnode type values (bfs_inode->i_vtype) */
  15. #define BFS_VDIR 2L
  16. #define BFS_VREG 1L
  17. /* BFS inode layout on disk */
  18. struct bfs_inode {
  19. __le16 i_ino;
  20. __u16 i_unused;
  21. __le32 i_sblock;
  22. __le32 i_eblock;
  23. __le32 i_eoffset;
  24. __le32 i_vtype;
  25. __le32 i_mode;
  26. __le32 i_uid;
  27. __le32 i_gid;
  28. __le32 i_nlink;
  29. __le32 i_atime;
  30. __le32 i_mtime;
  31. __le32 i_ctime;
  32. __u32 i_padding[4];
  33. };
  34. #define BFS_NAMELEN 14
  35. #define BFS_DIRENT_SIZE 16
  36. #define BFS_DIRS_PER_BLOCK 32
  37. struct bfs_dirent {
  38. __le16 ino;
  39. char name[BFS_NAMELEN];
  40. };
  41. /* BFS superblock layout on disk */
  42. struct bfs_super_block {
  43. __le32 s_magic;
  44. __le32 s_start;
  45. __le32 s_end;
  46. __le32 s_from;
  47. __le32 s_to;
  48. __s32 s_bfrom;
  49. __s32 s_bto;
  50. char s_fsname[6];
  51. char s_volume[6];
  52. __u32 s_padding[118];
  53. };
  54. #define BFS_OFF2INO(offset) \
  55. ((((offset) - BFS_BSIZE) / sizeof(struct bfs_inode)) + BFS_ROOT_INO)
  56. #define BFS_INO2OFF(ino) \
  57. ((__u32)(((ino) - BFS_ROOT_INO) * sizeof(struct bfs_inode)) + BFS_BSIZE)
  58. #define BFS_NZFILESIZE(ip) \
  59. ((le32_to_cpu((ip)->i_eoffset) + 1) - le32_to_cpu((ip)->i_sblock) * BFS_BSIZE)
  60. #define BFS_FILESIZE(ip) \
  61. ((ip)->i_sblock == 0 ? 0 : BFS_NZFILESIZE(ip))
  62. #define BFS_FILEBLOCKS(ip) \
  63. ((ip)->i_sblock == 0 ? 0 : (le32_to_cpu((ip)->i_eblock) + 1) - le32_to_cpu((ip)->i_sblock))
  64. #define BFS_UNCLEAN(bfs_sb, sb) \
  65. ((le32_to_cpu(bfs_sb->s_from) != -1) && (le32_to_cpu(bfs_sb->s_to) != -1) && !(sb->s_flags & SB_RDONLY))
  66. #endif /* _LINUX_BFS_FS_H */