2 * Copyright (c) 2005 Silicon Graphics, Inc.
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.
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.
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
18 #ifndef __XFS_EXPORT_H__
19 #define __XFS_EXPORT_H__
22 * Common defines for code related to exporting XFS filesystems over NFS.
24 * The NFS fileid goes out on the wire as an array of
25 * 32bit unsigned ints in host order. There are 5 possible
28 * (1) fileid_type=0x00
29 * (no fileid data; handled by the generic code)
31 * (2) fileid_type=0x01
35 * (3) fileid_type=0x02
41 * (4) fileid_type=0x81
46 * (5) fileid_type=0x82
50 * parent-inode-num-lo32
51 * parent-inode-num-hi32
54 * Note, the NFS filehandle also includes an fsid portion which
55 * may have an inode number in it. That number is hardcoded to
56 * 32bits and there is no way for XFS to intercept it. In
57 * practice this means when exporting an XFS filesystem with 64bit
58 * inodes you should either export the mountpoint (rather than
59 * a subdirectory) or use the "fsid" export option.
62 /* This flag goes on the wire. Don't play with it. */
63 #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */
65 /* Calculate the length in u32 units of the fileid data */
67 xfs_fileid_length(int hasparent
, int is64
)
69 return hasparent
? (is64
? 6 : 4) : (is64
? 3 : 2);
73 * Decode encoded inode information (either for the inode itself
74 * or the parent) into an xfs_fid2_t structure. Advances and
75 * returns the new data pointer
78 xfs_fileid_decode_fid2(__u32
*p
, xfs_fid2_t
*fid
, int is64
)
80 fid
->fid_len
= sizeof(xfs_fid2_t
) - sizeof(fid
->fid_len
);
85 fid
->fid_ino
|= (((__u64
)(*p
++)) << 32);
92 * Encode inode information (either for the inode itself or the
93 * parent) into a fileid buffer. Advances and returns the new
97 xfs_fileid_encode_inode(__u32
*p
, struct inode
*inode
, int is64
)
99 *p
++ = (__u32
)inode
->i_ino
;
102 *p
++ = (__u32
)(inode
->i_ino
>> 32);
104 *p
++ = inode
->i_generation
;
108 #endif /* __XFS_EXPORT_H__ */