xfs_export.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_EXPORT_H__
  33. #define __XFS_EXPORT_H__
  34. /*
  35. * Common defines for code related to exporting XFS filesystems over NFS.
  36. *
  37. * The NFS fileid goes out on the wire as an array of
  38. * 32bit unsigned ints in host order. There are 5 possible
  39. * formats.
  40. *
  41. * (1) fileid_type=0x00
  42. * (no fileid data; handled by the generic code)
  43. *
  44. * (2) fileid_type=0x01
  45. * inode-num
  46. * generation
  47. *
  48. * (3) fileid_type=0x02
  49. * inode-num
  50. * generation
  51. * parent-inode-num
  52. * parent-generation
  53. *
  54. * (4) fileid_type=0x81
  55. * inode-num-lo32
  56. * inode-num-hi32
  57. * generation
  58. *
  59. * (5) fileid_type=0x82
  60. * inode-num-lo32
  61. * inode-num-hi32
  62. * generation
  63. * parent-inode-num-lo32
  64. * parent-inode-num-hi32
  65. * parent-generation
  66. *
  67. * Note, the NFS filehandle also includes an fsid portion which
  68. * may have an inode number in it. That number is hardcoded to
  69. * 32bits and there is no way for XFS to intercept it. In
  70. * practice this means when exporting an XFS filesytem with 64bit
  71. * inodes you should either export the mountpoint (rather than
  72. * a subdirectory) or use the "fsid" export option.
  73. */
  74. /* This flag goes on the wire. Don't play with it. */
  75. #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */
  76. /* Calculate the length in u32 units of the fileid data */
  77. static inline int
  78. xfs_fileid_length(int hasparent, int is64)
  79. {
  80. return hasparent ? (is64 ? 6 : 4) : (is64 ? 3 : 2);
  81. }
  82. /*
  83. * Decode encoded inode information (either for the inode itself
  84. * or the parent) into an xfs_fid2_t structure. Advances and
  85. * returns the new data pointer
  86. */
  87. static inline __u32 *
  88. xfs_fileid_decode_fid2(__u32 *p, xfs_fid2_t *fid, int is64)
  89. {
  90. fid->fid_len = sizeof(xfs_fid2_t) - sizeof(fid->fid_len);
  91. fid->fid_pad = 0;
  92. fid->fid_ino = *p++;
  93. #if XFS_BIG_INUMS
  94. if (is64)
  95. fid->fid_ino |= (((__u64)(*p++)) << 32);
  96. #endif
  97. fid->fid_gen = *p++;
  98. return p;
  99. }
  100. /*
  101. * Encode inode information (either for the inode itself or the
  102. * parent) into a fileid buffer. Advances and returns the new
  103. * data pointer.
  104. */
  105. static inline __u32 *
  106. xfs_fileid_encode_inode(__u32 *p, struct inode *inode, int is64)
  107. {
  108. *p++ = (__u32)inode->i_ino;
  109. #if XFS_BIG_INUMS
  110. if (is64)
  111. *p++ = (__u32)(inode->i_ino >> 32);
  112. #endif
  113. *p++ = inode->i_generation;
  114. return p;
  115. }
  116. #endif /* __XFS_EXPORT_H__ */