lkml.org 
[lkml]   [2013]   [Oct]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 16/34] sysfs, kernfs: prepare llseek path for kernfs
Date
We're in the process of separating out core sysfs functionality into
kernfs which will deal with sysfs_dirents directly. This patch
introduces kernfs_file_llseek() which invokes either
generic_file_llseek() or seq_lseek() depending on the file type so
that both regular and bin files eventually can use the same
file_operations, which is necessary to separate out kernfs.

This patch doesn't introduce any behavior changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
fs/sysfs/file.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 2736ea9..4f99da5 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -356,6 +356,16 @@ out_free:
return len;
}

+static loff_t kernfs_file_llseek(struct file *file, loff_t off, int whence)
+{
+ struct sysfs_open_file *of = sysfs_of(file);
+
+ if (sysfs_is_bin(of->sd))
+ return generic_file_llseek(file, off, whence);
+ else
+ return seq_lseek(file, off, whence);
+}
+
static void sysfs_bin_vma_open(struct vm_area_struct *vma)
{
struct file *file = vma->vm_file;
@@ -854,7 +864,7 @@ EXPORT_SYMBOL_GPL(sysfs_notify);
const struct file_operations sysfs_file_operations = {
.read = kernfs_file_read,
.write = kernfs_file_write,
- .llseek = seq_lseek,
+ .llseek = kernfs_file_llseek,
.open = sysfs_open_file,
.release = sysfs_release,
.poll = sysfs_poll,
@@ -863,7 +873,7 @@ const struct file_operations sysfs_file_operations = {
const struct file_operations sysfs_bin_operations = {
.read = kernfs_file_read,
.write = kernfs_file_write,
- .llseek = generic_file_llseek,
+ .llseek = kernfs_file_llseek,
.mmap = sysfs_bin_mmap,
.open = sysfs_open_file,
.release = sysfs_release,
--
1.8.3.1


\
 
 \ /
  Last update: 2013-10-24 18:41    [W:0.198 / U:0.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site