aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Battersby <tonyb@cybernetics.com>2010-08-10 18:01:29 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-11 08:59:02 -0700
commit58939473bacf08e7e7346673c6d70bc367bd091a (patch)
tree0ccf46d1b52f4ff7ec09017f174364b63fe64d70
parent5a19ae4bb003a428b9c8367daf05eed5029dc4cd (diff)
vfs: improve comment describing fget_light()
Improve the description of fget_light(), which is currently incorrect about needing a prior refcnt (judging by the way it is actually used). Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/file_table.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index b8a0bb63cbd..2fc3b3c0891 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -298,11 +298,20 @@ struct file *fget(unsigned int fd)
EXPORT_SYMBOL(fget);
/*
- * Lightweight file lookup - no refcnt increment if fd table isn't shared.
- * You can use this only if it is guranteed that the current task already
- * holds a refcnt to that file. That check has to be done at fget() only
- * and a flag is returned to be passed to the corresponding fput_light().
- * There must not be a cloning between an fget_light/fput_light pair.
+ * Lightweight file lookup - no refcnt increment if fd table isn't shared.
+ *
+ * You can use this instead of fget if you satisfy all of the following
+ * conditions:
+ * 1) You must call fput_light before exiting the syscall and returning control
+ * to userspace (i.e. you cannot remember the returned struct file * after
+ * returning to userspace).
+ * 2) You must not call filp_close on the returned struct file * in between
+ * calls to fget_light and fput_light.
+ * 3) You must not clone the current task in between the calls to fget_light
+ * and fput_light.
+ *
+ * The fput_needed flag returned by fget_light should be passed to the
+ * corresponding fput_light.
*/
struct file *fget_light(unsigned int fd, int *fput_needed)
{