Skip to content

Commit

Permalink
fs, exportfs: add exportfs_encode_inode_fh() helper
Browse files Browse the repository at this point in the history
We will need this helper in the next patch to provide a file handle for
inotify marks in /proc/pid/fdinfo output.

The patch is rather providing the way to use inodes directly when dentry
is not available (like in case of inotify system).

Signed-off-by: Cyrill Gorcunov <[email protected]>
Acked-by: Pavel Emelyanov <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Andrey Vagin <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: "Aneesh Kumar K.V" <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Cc: Matthew Helsley <[email protected]>
Cc: "J. Bruce Fields" <[email protected]>
Cc: "Aneesh Kumar K.V" <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Cyrill Gorcunov authored and torvalds committed Dec 18, 2012
1 parent ab49bde commit 711c7bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 14 additions & 5 deletions fs/exportfs/expfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,21 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
return type;
}

int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
int *max_len, struct inode *parent)
{
const struct export_operations *nop = inode->i_sb->s_export_op;

if (nop && nop->encode_fh)
return nop->encode_fh(inode, fid->raw, max_len, parent);

return export_encode_fh(inode, fid, max_len, parent);
}
EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);

int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
int connectable)
{
const struct export_operations *nop = dentry->d_sb->s_export_op;
int error;
struct dentry *p = NULL;
struct inode *inode = dentry->d_inode, *parent = NULL;
Expand All @@ -357,10 +368,8 @@ int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
*/
parent = p->d_inode;
}
if (nop && nop->encode_fh)
error = nop->encode_fh(inode, fid->raw, max_len, parent);
else
error = export_encode_fh(inode, fid, max_len, parent);

error = exportfs_encode_inode_fh(inode, fid, max_len, parent);
dput(p);

return error;
Expand Down
2 changes: 2 additions & 0 deletions include/linux/exportfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ struct export_operations {
int (*commit_metadata)(struct inode *inode);
};

extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
int *max_len, struct inode *parent);
extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
int *max_len, int connectable);
extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
Expand Down

0 comments on commit 711c7bf

Please sign in to comment.