xfs_export.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_EXPORT_H__
  19. #define __XFS_EXPORT_H__
  20. /*
  21. * Common defines for code related to exporting XFS filesystems over NFS.
  22. *
  23. * The NFS fileid goes out on the wire as an array of
  24. * 32bit unsigned ints in host order. There are 5 possible
  25. * formats.
  26. *
  27. * (1) fileid_type=0x00
  28. * (no fileid data; handled by the generic code)
  29. *
  30. * (2) fileid_type=0x01
  31. * inode-num
  32. * generation
  33. *
  34. * (3) fileid_type=0x02
  35. * inode-num
  36. * generation
  37. * parent-inode-num
  38. * parent-generation
  39. *
  40. * (4) fileid_type=0x81
  41. * inode-num-lo32
  42. * inode-num-hi32
  43. * generation
  44. *
  45. * (5) fileid_type=0x82
  46. * inode-num-lo32
  47. * inode-num-hi32
  48. * generation
  49. * parent-inode-num-lo32
  50. * parent-inode-num-hi32
  51. * parent-generation
  52. *
  53. * Note, the NFS filehandle also includes an fsid portion which
  54. * may have an inode number in it. That number is hardcoded to
  55. * 32bits and there is no way for XFS to intercept it. In
  56. * practice this means when exporting an XFS filesystem with 64bit
  57. * inodes you should either export the mountpoint (rather than
  58. * a subdirectory) or use the "fsid" export option.
  59. */
  60. /* This flag goes on the wire. Don't play with it. */
  61. #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */
  62. /* Calculate the length in u32 units of the fileid data */
  63. static inline int
  64. xfs_fileid_length(int hasparent, int is64)
  65. {
  66. return hasparent ? (is64 ? 6 : 4) : (is64 ? 3 : 2);
  67. }
  68. /*
  69. * Decode encoded inode information (either for the inode itself
  70. * or the parent) into an xfs_fid2_t structure. Advances and
  71. * returns the new data pointer
  72. */
  73. static inline __u32 *
  74. xfs_fileid_decode_fid2(__u32 *p, xfs_fid2_t *fid, int is64)
  75. {
  76. fid->fid_len = sizeof(xfs_fid2_t) - sizeof(fid->fid_len);
  77. fid->fid_pad = 0;
  78. fid->fid_ino = *p++;
  79. #if XFS_BIG_INUMS
  80. if (is64)
  81. fid->fid_ino |= (((__u64)(*p++)) << 32);
  82. #endif
  83. fid->fid_gen = *p++;
  84. return p;
  85. }
  86. /*
  87. * Encode inode information (either for the inode itself or the
  88. * parent) into a fileid buffer. Advances and returns the new
  89. * data pointer.
  90. */
  91. static inline __u32 *
  92. xfs_fileid_encode_inode(__u32 *p, struct inode *inode, int is64)
  93. {
  94. *p++ = (__u32)inode->i_ino;
  95. #if XFS_BIG_INUMS
  96. if (is64)
  97. *p++ = (__u32)(inode->i_ino >> 32);
  98. #endif
  99. *p++ = inode->i_generation;
  100. return p;
  101. }
  102. #endif /* __XFS_EXPORT_H__ */