@@ -166,6 +166,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c,
const struct inode *dir,
* purpose of rebuilding the index.
*/
ui->creat_sqnum = ++c->max_sqnum;
+ ui->parent_ino = dir->i_ino;
spin_unlock(&c->cnt_lock);
return inode;
}
@@ -1080,6 +1081,7 @@ static int ubifs_rename(struct inode *old_dir,
struct dentry *old_dentry,
if (err)
goto out_cancel;
+ old_inode_ui->parent_ino = new_dir->i_ino;
unlock_3_inodes(old_dir, new_dir, new_inode);
ubifs_release_budget(c, &req);
b/linux-3.10-rc3/fs/ubifs/journal.c
@@ -66,7 +66,6 @@
*/
static inline void zero_ino_node_unused(struct ubifs_ino_node *ino)
{
- memset(ino->padding1, 0, 4);
memset(ino->padding2, 0, 26);
}
@@ -480,6 +479,7 @@ static void pack_inode(struct ubifs_info *c, struct
ubifs_ino_node *ino,
ino->xattr_cnt = cpu_to_le32(ui->xattr_cnt);
ino->xattr_size = cpu_to_le32(ui->xattr_size);
ino->xattr_names = cpu_to_le32(ui->xattr_names);
+ ino->parent_ino = cpu_to_le32(ui->parent_ino);
zero_ino_node_unused(ino);
/*
b/linux-3.10-rc3/fs/ubifs/super.c
@@ -150,6 +150,7 @@ struct inode *ubifs_iget(struct super_block *sb,
unsigned long inum)
ui->synced_i_size = ui->ui_size = inode->i_size;
ui->xattr = (ui->flags & UBIFS_XATTR_FL) ? 1 : 0;
+ ui->parent_ino = le32_to_cpu(ino->parent_ino);
err = validate_inode(c, inode);
if (err)
@@ -2002,6 +2003,55 @@ static struct ubifs_info *alloc_ubifs_info(struct
ubi_volume_desc *ubi)
return c;
}
+static struct inode *ubifs_nfs_get_inode(struct super_block *sb, uint64_t
ino,
+ uint32_t generation)
+{
+/*
+ * Note, since UBIFS does re-use inode numbers at the moment, we do not
check
+ * the generation number in this function.
+ */
+ struct inode *inode;
+ inode = ubifs_iget(sb, ino);
+ if (IS_ERR(inode)) {
+ if (PTR_ERR(inode) == -ENOENT)
+ return ERR_PTR(-ESTALE);
+ return ERR_CAST(inode);
+ }
+ return inode;
+}
+
+static struct dentry *ubifs_fh_to_dentry(struct super_block *sb,
+ struct fid *fid, int fh_len, int fh_type)
+{
+ return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+ ubifs_nfs_get_inode);
+}
+
+static struct dentry *ubifs_fh_to_parent(struct super_block *sb,
+ struct fid *fid, int fh_len, int fh_type)
+{
+ return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+ ubifs_nfs_get_inode);
+}
+
+static struct dentry *ubifs_get_parent(struct dentry *child)
+{
+ struct ubifs_inode *ui;
+ unsigned long pino;
+
+ ui = ubifs_inode(child->d_inode);
+ pino = ui->parent_ino;
+ return d_obtain_alias(ubifs_iget(child->d_inode->i_sb, pino));
+}
+
+
+static struct export_operations ubifs_export_ops = {
+ .fh_to_dentry = ubifs_fh_to_dentry,
+ .fh_to_parent = ubifs_fh_to_parent,
+ .get_parent = ubifs_get_parent,
+};
+
+
static int ubifs_fill_super(struct super_block *sb, void *data, int
silent)
{
struct ubifs_info *c = sb->s_fs_info;
@@ -2047,6 +2097,7 @@ static int ubifs_fill_super(struct super_block *sb,
void *data, int silent)
if (c->max_inode_sz > MAX_LFS_FILESIZE)
sb->s_maxbytes = c->max_inode_sz = MAX_LFS_FILESIZE;
sb->s_op = &ubifs_super_operations;
+ sb->s_export_op = &ubifs_export_ops;
mutex_lock(&c->umount_mutex);
err = mount_ubifs(c);
b/linux-3.10-rc3/fs/ubifs/ubifs-media.h
@@ -472,7 +472,7 @@ union ubifs_dev_desc {
* @data_len: inode data length
* @xattr_cnt: count of extended attributes this inode has
* @xattr_size: summarized size of all extended attributes in bytes
- * @padding1: reserved for future, zeroes
+ * @parent_ino: the inode's parent inode number(for nfs exportfs)
* @xattr_names: sum of lengths of all extended attribute names belonging
to
* this inode
* @compr_type: compression type used for this inode
@@ -506,7 +506,7 @@ struct ubifs_ino_node {
__le32 data_len;
__le32 xattr_cnt;
__le32 xattr_size;
- __u8 padding1[4]; /* Watch 'zero_ino_node_unused()' if changing!
*/
+ __le32 parent_ino;
__le32 xattr_names;
__le16 compr_type;
__u8 padding2[26]; /* Watch 'zero_ino_node_unused()' if changing!
*/
b/linux-3.10-rc3/fs/ubifs/ubifs.h
@@ -339,6 +339,7 @@ struct ubifs_gced_idx_leb {
* @creat_sqnum: sequence number at time of creation
* @del_cmtno: commit number corresponding to the time the inode was
deleted,
* protected by @c->commit_sem;
+ * @parent_ino: the inode's parent inode number(for nfs exportfs)
* @xattr_size: summarized size of all extended attributes in bytes
* @xattr_cnt: count of extended attributes this inode has