Thread (66 messages) 66 messages, 8 authors, 2012-08-23

Re: [patch 4/8] fs, exportfs: Add export_encode_inode_fh helper

From: Aneesh Kumar K.V <hidden>
Date: 2012-08-20 14:19:23
Also in: lkml

Cyrill Gorcunov [off-list ref] writes:
To provide fsnotify object inodes being watched without
binding to alphabetical path we need to encode them with
exportfs help. This patch adds a helper which operates
with plain inodes directly.
doesn't name_to_handle_at()  work for you ? It also allows to get a file
handle using file descriptor.
quoted hunk ↗ jump to hunk
Signed-off-by: Cyrill Gorcunov <redacted>
Acked-by: Pavel Emelyanov <redacted>
CC: Al Viro <viro@ZenIV.linux.org.uk>
CC: Alexey Dobriyan <redacted>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: James Bottomley <redacted>
---
 fs/exportfs/expfs.c      |   19 +++++++++++++++++++
 include/linux/exportfs.h |    2 ++
 2 files changed, 21 insertions(+)

Index: linux-2.6.git/fs/exportfs/expfs.c
===================================================================
--- linux-2.6.git.orig/fs/exportfs/expfs.c
+++ linux-2.6.git/fs/exportfs/expfs.c
@@ -302,6 +302,25 @@ out:
 	return error;
 }

+int export_encode_inode_fh(struct inode *inode, struct fid *fid, int *max_len)
+{
+	int len = *max_len;
+	int type = FILEID_INO32_GEN;
+
+	if (len < 2) {
+		*max_len = 2;
+		return 255;
+	}
+
+	len = 2;
+	fid->i32.ino = inode->i_ino;
+	fid->i32.gen = inode->i_generation;
+	*max_len = len;
+
+	return type;
+}
+EXPORT_SYMBOL_GPL(export_encode_inode_fh);
+

If you are looking at getting file handle, that may not be
sufficient. Some file system put more info in file handle (btrfs)
quoted hunk ↗ jump to hunk
 /**
  * export_encode_fh - default export_operations->encode_fh function
  * @inode:   the object to encode
Index: linux-2.6.git/include/linux/exportfs.h
===================================================================
--- linux-2.6.git.orig/include/linux/exportfs.h
+++ linux-2.6.git/include/linux/exportfs.h
@@ -177,6 +177,8 @@ struct export_operations {
 	int (*commit_metadata)(struct inode *inode);
 };

+extern int export_encode_inode_fh(struct inode *inode, struct fid *fid, int *max_len);
+
 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,
-aneesh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help