git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
fs
/
seq_file.c
diff --git
a/fs/seq_file.c
b/fs/seq_file.c
index
38ef913
..
0ac22af
100644
(file)
--- a/
fs/seq_file.c
+++ b/
fs/seq_file.c
@@
-26,15
+26,19
@@
* ERR_PTR(error). In the end of sequence they return %NULL. ->show()
* returns 0 in case of success and negative number in case of error.
*/
* ERR_PTR(error). In the end of sequence they return %NULL. ->show()
* returns 0 in case of success and negative number in case of error.
*/
-int seq_open(struct file *file, struct seq_operations *op)
+int seq_open(struct file *file,
const
struct seq_operations *op)
{
{
- struct seq_file *p = kmalloc(sizeof(*p), GFP_KERNEL);
- if (!p)
- return -ENOMEM;
+ struct seq_file *p = file->private_data;
+
+ if (!p) {
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+ file->private_data = p;
+ }
memset(p, 0, sizeof(*p));
memset(p, 0, sizeof(*p));
-
sema_init(&p->sem, 1
);
+
mutex_init(&p->lock
);
p->op = op;
p->op = op;
- file->private_data = p;
/*
* Wrappers around seq_open(e.g. swaps_open) need to be
/*
* Wrappers around seq_open(e.g. swaps_open) need to be
@@
-67,7
+71,7
@@
ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
void *p;
int err = 0;
void *p;
int err = 0;
-
down(&m->sem
);
+
mutex_lock(&m->lock
);
/*
* seq_file->op->..m_start/m_stop/m_next may do special actions
* or optimisations based on the file->f_version, so we want to
/*
* seq_file->op->..m_start/m_stop/m_next may do special actions
* or optimisations based on the file->f_version, so we want to
@@
-160,7
+164,7
@@
Done:
else
*ppos += copied;
file->f_version = m->version;
else
*ppos += copied;
file->f_version = m->version;
-
up(&m->sem
);
+
mutex_unlock(&m->lock
);
return copied;
Enomem:
err = -ENOMEM;
return copied;
Enomem:
err = -ENOMEM;
@@
-233,7
+237,7
@@
loff_t seq_lseek(struct file *file, loff_t offset, int origin)
struct seq_file *m = (struct seq_file *)file->private_data;
long long retval = -EINVAL;
struct seq_file *m = (struct seq_file *)file->private_data;
long long retval = -EINVAL;
-
down(&m->sem
);
+
mutex_lock(&m->lock
);
m->version = file->f_version;
switch (origin) {
case 1:
m->version = file->f_version;
switch (origin) {
case 1:
@@
-256,7
+260,7
@@
loff_t seq_lseek(struct file *file, loff_t offset, int origin)
}
}
}
}
}
}
-
up(&m->sem
);
+
mutex_unlock(&m->lock
);
file->f_version = m->version;
return retval;
}
file->f_version = m->version;
return retval;
}
@@
-265,7
+269,7
@@
EXPORT_SYMBOL(seq_lseek);
/**
* seq_release - free the structures associated with sequential file.
* @file: file in question
/**
* seq_release - free the structures associated with sequential file.
* @file: file in question
- * @inode: file->f_dentry->d_inode
+ * @inode: file->f_
path.
dentry->d_inode
*
* Frees the structures associated with sequential file; can be used
* as ->f_op->release() if you don't have private data to destroy.
*
* Frees the structures associated with sequential file; can be used
* as ->f_op->release() if you don't have private data to destroy.
@@
-404,7
+408,7
@@
EXPORT_SYMBOL(single_open);
int single_release(struct inode *inode, struct file *file)
{
int single_release(struct inode *inode, struct file *file)
{
- struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
+
const
struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
int res = seq_release(inode, file);
kfree(op);
return res;
int res = seq_release(inode, file);
kfree(op);
return res;