2 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __XFS_EXPORT_H__
33 #define __XFS_EXPORT_H__
36 * Common defines for code related to exporting XFS filesystems over NFS.
38 * The NFS fileid goes out on the wire as an array of
39 * 32bit unsigned ints in host order. There are 5 possible
42 * (1) fileid_type=0x00
43 * (no fileid data; handled by the generic code)
45 * (2) fileid_type=0x01
49 * (3) fileid_type=0x02
55 * (4) fileid_type=0x81
60 * (5) fileid_type=0x82
64 * parent-inode-num-lo32
65 * parent-inode-num-hi32
68 * Note, the NFS filehandle also includes an fsid portion which
69 * may have an inode number in it. That number is hardcoded to
70 * 32bits and there is no way for XFS to intercept it. In
71 * practice this means when exporting an XFS filesytem with 64bit
72 * inodes you should either export the mountpoint (rather than
73 * a subdirectory) or use the "fsid" export option.
76 /* This flag goes on the wire. Don't play with it. */
77 #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */
79 /* Calculate the length in u32 units of the fileid data */
81 xfs_fileid_length(int hasparent, int is64)
83 return hasparent ? (is64 ? 6 : 4) : (is64 ? 3 : 2);
87 * Decode encoded inode information (either for the inode itself
88 * or the parent) into an xfs_fid2_t structure. Advances and
89 * returns the new data pointer
92 xfs_fileid_decode_fid2(__u32 *p, xfs_fid2_t *fid, int is64)
94 fid->fid_len = sizeof(xfs_fid2_t) - sizeof(fid->fid_len);
99 fid->fid_ino |= (((__u64)(*p++)) << 32);
106 * Encode inode information (either for the inode itself or the
107 * parent) into a fileid buffer. Advances and returns the new
110 static inline __u32 *
111 xfs_fileid_encode_inode(__u32 *p, struct inode *inode, int is64)
113 *p++ = (__u32)inode->i_ino;
116 *p++ = (__u32)(inode->i_ino >> 32);
118 *p++ = inode->i_generation;
122 #endif /* __XFS_EXPORT_H__ */