Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 117459
b: refs/heads/master
c: 3a8cff4
h: refs/heads/master
i:
  117457: 3919ceb
  117455: 261d012
v: v3
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Oct 23, 2008
1 parent 8e35784 commit 4298e1e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a518ab9329041411526ab8e05edfda7e2715244f
refs/heads/master: 3a8cff4f026c0b98bee6291eb28d4df42feb76dc
58 changes: 40 additions & 18 deletions trunk/fs/read_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,61 @@ const struct file_operations generic_ro_fops = {

EXPORT_SYMBOL(generic_ro_fops);

/**
* generic_file_llseek_unlocked - lockless generic llseek implementation
* @file: file structure to seek on
* @offset: file offset to seek to
* @origin: type of seek
*
* Updates the file offset to the value specified by @offset and @origin.
* Locking must be provided by the caller.
*/
loff_t
generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
{
loff_t retval;
struct inode *inode = file->f_mapping->host;

switch (origin) {
case SEEK_END:
offset += inode->i_size;
break;
case SEEK_CUR:
offset += file->f_pos;
case SEEK_END:
offset += inode->i_size;
break;
case SEEK_CUR:
offset += file->f_pos;
break;
}
retval = -EINVAL;
if (offset>=0 && offset<=inode->i_sb->s_maxbytes) {
/* Special lock needed here? */
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = 0;
}
retval = offset;

if (offset < 0 || offset > inode->i_sb->s_maxbytes)
return -EINVAL;

/* Special lock needed here? */
if (offset != file->f_pos) {
file->f_pos = offset;
file->f_version = 0;
}
return retval;

return offset;
}
EXPORT_SYMBOL(generic_file_llseek_unlocked);

/**
* generic_file_llseek - generic llseek implementation for regular files
* @file: file structure to seek on
* @offset: file offset to seek to
* @origin: type of seek
*
* This is a generic implemenation of ->llseek useable for all normal local
* filesystems. It just updates the file offset to the value specified by
* @offset and @origin under i_mutex.
*/
loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
{
loff_t n;
loff_t rval;

mutex_lock(&file->f_dentry->d_inode->i_mutex);
n = generic_file_llseek_unlocked(file, offset, origin);
rval = generic_file_llseek_unlocked(file, offset, origin);
mutex_unlock(&file->f_dentry->d_inode->i_mutex);
return n;

return rval;
}
EXPORT_SYMBOL(generic_file_llseek);

Expand Down

0 comments on commit 4298e1e

Please sign in to comment.