/* This default encode_fh function assumes that the 32 inode number is suitable for locating an inode, and that the generation number can be used to check that it is still valid. It places them in the filehandle fragment where export_decode_fh expects to find them.  */
static int export_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, int connectable)
/* This default encode_fh function assumes that the 32 inode number is suitable for locating an inode, and that the generation number can be used to check that it is still valid. It places them in the filehandle fragment where export_decode_fh expects to find them.  */
static int export_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, int connectable)
{
	struct inode * inode = dentry->d_inode;
	int len = *max_len;
	int type = FILEID_INO32_GEN;
	if (len < 2 || (connectable && len < 4))
		return 255;
	len = 2;
	fid->i32.ino = inode->i_ino;
	fid->i32.gen = inode->i_generation;
	if (connectable && !S_ISDIR(inode->i_mode)) {
		struct inode *parent;
		spin_lock(&dentry->d_lock);
		parent = dentry->d_parent->d_inode;
		fid->i32.parent_ino = parent->i_ino;
		fid->i32.parent_gen = parent->i_generation;
		spin_unlock(&dentry->d_lock);
		len = 4;
		type = FILEID_INO32_GEN_PARENT;
	}
	*max_len = len;
	return type;
}