summaryrefslogtreecommitdiffstats
path: root/include/linux/kernfs.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2016-12-27 14:49:03 -0500
committerTejun Heo <tj@kernel.org>2016-12-27 14:49:03 -0500
commit0e67db2f9fe91937e798e3d7d22c50a8438187e1 (patch)
treef89b0ef7b69fd5b48dcb76d6568e4963ebc19779 /include/linux/kernfs.h
parenta1d82aff5df760d933b6ea3a03805dbc2bd73eb8 (diff)
downloadlinux-stable-0e67db2f9fe91937e798e3d7d22c50a8438187e1.tar.gz
linux-stable-0e67db2f9fe91937e798e3d7d22c50a8438187e1.tar.bz2
linux-stable-0e67db2f9fe91937e798e3d7d22c50a8438187e1.zip
kernfs: add kernfs_ops->open/release() callbacks
Add ->open/release() methods to kernfs_ops. ->open() is called when the file is opened and ->release() when the file is either released or severed. These callbacks can be used, for example, to manage persistent caching objects over multiple seq_file iterations. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Acked-by: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'include/linux/kernfs.h')
-rw-r--r--include/linux/kernfs.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index afd4e5abc4fb..a9b11b8d06f2 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -46,6 +46,7 @@ enum kernfs_node_flag {
KERNFS_SUICIDAL = 0x0400,
KERNFS_SUICIDED = 0x0800,
KERNFS_EMPTY_DIR = 0x1000,
+ KERNFS_HAS_RELEASE = 0x2000,
};
/* @flags for kernfs_create_root() */
@@ -175,6 +176,7 @@ struct kernfs_open_file {
/* published fields */
struct kernfs_node *kn;
struct file *file;
+ struct seq_file *seq_file;
void *priv;
/* private fields, do not use outside kernfs proper */
@@ -186,11 +188,19 @@ struct kernfs_open_file {
size_t atomic_write_len;
bool mmapped:1;
+ bool released:1;
const struct vm_operations_struct *vm_ops;
};
struct kernfs_ops {
/*
+ * Optional open/release methods. Both are called with
+ * @of->seq_file populated.
+ */
+ int (*open)(struct kernfs_open_file *of);
+ void (*release)(struct kernfs_open_file *of);
+
+ /*
* Read is handled by either seq_file or raw_read().
*
* If seq_show() is present, seq_file path is active. Other seq