aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/read_write.c37
-rw-r--r--include/linux/fs.h2
2 files changed, 30 insertions, 9 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index 672b187def62..dfd125798791 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -51,23 +51,23 @@ static loff_t lseek_execute(struct file *file, struct inode *inode,
51} 51}
52 52
53/** 53/**
54 * generic_file_llseek - generic llseek implementation for regular files 54 * generic_file_llseek_size - generic llseek implementation for regular files
55 * @file: file structure to seek on 55 * @file: file structure to seek on
56 * @offset: file offset to seek to 56 * @offset: file offset to seek to
57 * @origin: type of seek 57 * @origin: type of seek
58 * @size: max size of file system
58 * 59 *
59 * This is a generic implemenation of ->llseek usable for all normal local 60 * This is a variant of generic_file_llseek that allows passing in a custom
60 * filesystems. It just updates the file offset to the value specified by 61 * file size.
61 * @offset and @origin under i_mutex.
62 * 62 *
63 * Synchronization: 63 * Synchronization:
64 * SEEK_SET is unsynchronized (but atomic on 64bit platforms) 64 * SEEK_SET and SEEK_END are unsynchronized (but atomic on 64bit platforms)
65 * SEEK_CUR is synchronized against other SEEK_CURs, but not read/writes. 65 * SEEK_CUR is synchronized against other SEEK_CURs, but not read/writes.
66 * read/writes behave like SEEK_SET against seeks. 66 * read/writes behave like SEEK_SET against seeks.
67 * SEEK_END
68 */ 67 */
69loff_t 68loff_t
70generic_file_llseek(struct file *file, loff_t offset, int origin) 69generic_file_llseek_size(struct file *file, loff_t offset, int origin,
70 loff_t maxsize)
71{ 71{
72 struct inode *inode = file->f_mapping->host; 72 struct inode *inode = file->f_mapping->host;
73 73
@@ -91,7 +91,7 @@ generic_file_llseek(struct file *file, loff_t offset, int origin)
91 */ 91 */
92 spin_lock(&file->f_lock); 92 spin_lock(&file->f_lock);
93 offset = lseek_execute(file, inode, file->f_pos + offset, 93 offset = lseek_execute(file, inode, file->f_pos + offset,
94 inode->i_sb->s_maxbytes); 94 maxsize);
95 spin_unlock(&file->f_lock); 95 spin_unlock(&file->f_lock);
96 return offset; 96 return offset;
97 case SEEK_DATA: 97 case SEEK_DATA:
@@ -113,7 +113,26 @@ generic_file_llseek(struct file *file, loff_t offset, int origin)
113 break; 113 break;
114 } 114 }
115 115
116 return lseek_execute(file, inode, offset, inode->i_sb->s_maxbytes); 116 return lseek_execute(file, inode, offset, maxsize);
117}
118EXPORT_SYMBOL(generic_file_llseek_size);
119
120/**
121 * generic_file_llseek - generic llseek implementation for regular files
122 * @file: file structure to seek on
123 * @offset: file offset to seek to
124 * @origin: type of seek
125 *
126 * This is a generic implemenation of ->llseek useable for all normal local
127 * filesystems. It just updates the file offset to the value specified by
128 * @offset and @origin under i_mutex.
129 */
130loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
131{
132 struct inode *inode = file->f_mapping->host;
133
134 return generic_file_llseek_size(file, offset, origin,
135 inode->i_sb->s_maxbytes);
117} 136}
118EXPORT_SYMBOL(generic_file_llseek); 137EXPORT_SYMBOL(generic_file_llseek);
119 138
diff --git a/include/linux/fs.h b/include/linux/fs.h
index db85196f6308..d055cc7d7240 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2403,6 +2403,8 @@ file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
2403extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); 2403extern loff_t noop_llseek(struct file *file, loff_t offset, int origin);
2404extern loff_t no_llseek(struct file *file, loff_t offset, int origin); 2404extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
2405extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); 2405extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
2406extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
2407 int origin, loff_t maxsize);
2406extern int generic_file_open(struct inode * inode, struct file * filp); 2408extern int generic_file_open(struct inode * inode, struct file * filp);
2407extern int nonseekable_open(struct inode * inode, struct file * filp); 2409extern int nonseekable_open(struct inode * inode, struct file * filp);
2408 2410