git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix setattr error handling in sysfs, configfs
[safe/jmp/linux-2.6]
/
fs
/
fifo.c
diff --git
a/fs/fifo.c
b/fs/fifo.c
index
2c27f56
..
5d6606f
100644
(file)
--- a/
fs/fifo.c
+++ b/
fs/fifo.c
@@
-10,9
+10,8
@@
*/
#include <linux/mm.h>
*/
#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/smp_lock.h>
#include <linux/fs.h>
#include <linux/fs.h>
+#include <linux/sched.h>
#include <linux/pipe_fs_i.h>
static void wait_for_partner(struct inode* inode, unsigned int *cnt)
#include <linux/pipe_fs_i.h>
static void wait_for_partner(struct inode* inode, unsigned int *cnt)
@@
-33,14
+32,17
@@
static void wake_up_partner(struct inode* inode)
static int fifo_open(struct inode *inode, struct file *filp)
{
static int fifo_open(struct inode *inode, struct file *filp)
{
+ struct pipe_inode_info *pipe;
int ret;
mutex_lock(&inode->i_mutex);
int ret;
mutex_lock(&inode->i_mutex);
- if (!inode->i_pipe) {
+ pipe = inode->i_pipe;
+ if (!pipe) {
ret = -ENOMEM;
ret = -ENOMEM;
-
inode->i_
pipe = alloc_pipe_info(inode);
- if (!
inode->i_
pipe)
+ pipe = alloc_pipe_info(inode);
+ if (!pipe)
goto err_nocleanup;
goto err_nocleanup;
+ inode->i_pipe = pipe;
}
filp->f_version = 0;
}
filp->f_version = 0;
@@
-48,67
+50,67
@@
static int fifo_open(struct inode *inode, struct file *filp)
filp->f_mode &= (FMODE_READ | FMODE_WRITE);
switch (filp->f_mode) {
filp->f_mode &= (FMODE_READ | FMODE_WRITE);
switch (filp->f_mode) {
- case
1
:
+ case
FMODE_READ
:
/*
* O_RDONLY
* POSIX.1 says that O_NONBLOCK means return with the FIFO
* opened, even when there is no process writing the FIFO.
*/
/*
* O_RDONLY
* POSIX.1 says that O_NONBLOCK means return with the FIFO
* opened, even when there is no process writing the FIFO.
*/
- filp->f_op = &read_fifo_fops;
-
inode->i_
pipe->r_counter++;
- if (
inode->i_
pipe->readers++ == 0)
+ filp->f_op = &read_
pipe
fifo_fops;
+ pipe->r_counter++;
+ if (pipe->readers++ == 0)
wake_up_partner(inode);
wake_up_partner(inode);
- if (!
inode->i_
pipe->writers) {
+ if (!pipe->writers) {
if ((filp->f_flags & O_NONBLOCK)) {
/* suppress POLLHUP until we have
* seen a writer */
if ((filp->f_flags & O_NONBLOCK)) {
/* suppress POLLHUP until we have
* seen a writer */
- filp->f_version =
inode->i_
pipe->w_counter;
+ filp->f_version = pipe->w_counter;
} else
{
} else
{
- wait_for_partner(inode, &
inode->i_
pipe->w_counter);
+ wait_for_partner(inode, &pipe->w_counter);
if(signal_pending(current))
goto err_rd;
}
}
break;
if(signal_pending(current))
goto err_rd;
}
}
break;
- case
2
:
+ case
FMODE_WRITE
:
/*
* O_WRONLY
* POSIX.1 says that O_NONBLOCK means return -1 with
* errno=ENXIO when there is no process reading the FIFO.
*/
ret = -ENXIO;
/*
* O_WRONLY
* POSIX.1 says that O_NONBLOCK means return -1 with
* errno=ENXIO when there is no process reading the FIFO.
*/
ret = -ENXIO;
- if ((filp->f_flags & O_NONBLOCK) && !
inode->i_
pipe->readers)
+ if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
goto err;
goto err;
- filp->f_op = &write_fifo_fops;
-
inode->i_
pipe->w_counter++;
- if (!
inode->i_
pipe->writers++)
+ filp->f_op = &write_
pipe
fifo_fops;
+ pipe->w_counter++;
+ if (!pipe->writers++)
wake_up_partner(inode);
wake_up_partner(inode);
- if (!
inode->i_
pipe->readers) {
- wait_for_partner(inode, &
inode->i_
pipe->r_counter);
+ if (!pipe->readers) {
+ wait_for_partner(inode, &pipe->r_counter);
if (signal_pending(current))
goto err_wr;
}
break;
if (signal_pending(current))
goto err_wr;
}
break;
- case
3
:
+ case
FMODE_READ | FMODE_WRITE
:
/*
* O_RDWR
* POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
* This implementation will NEVER block on a O_RDWR open, since
* the process can at least talk to itself.
*/
/*
* O_RDWR
* POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
* This implementation will NEVER block on a O_RDWR open, since
* the process can at least talk to itself.
*/
- filp->f_op = &rdwr_fifo_fops;
+ filp->f_op = &rdwr_
pipe
fifo_fops;
-
inode->i_
pipe->readers++;
-
inode->i_
pipe->writers++;
-
inode->i_
pipe->r_counter++;
-
inode->i_
pipe->w_counter++;
- if (
inode->i_pipe->readers == 1 || inode->i_
pipe->writers == 1)
+ pipe->readers++;
+ pipe->writers++;
+ pipe->r_counter++;
+ pipe->w_counter++;
+ if (
pipe->readers == 1 ||
pipe->writers == 1)
wake_up_partner(inode);
break;
wake_up_partner(inode);
break;
@@
-122,19
+124,19
@@
static int fifo_open(struct inode *inode, struct file *filp)
return 0;
err_rd:
return 0;
err_rd:
- if (!--
inode->i_
pipe->readers)
- wake_up_interruptible(&
inode->i_
pipe->wait);
+ if (!--pipe->readers)
+ wake_up_interruptible(&pipe->wait);
ret = -ERESTARTSYS;
goto err;
err_wr:
ret = -ERESTARTSYS;
goto err;
err_wr:
- if (!--
inode->i_
pipe->writers)
- wake_up_interruptible(&
inode->i_
pipe->wait);
+ if (!--pipe->writers)
+ wake_up_interruptible(&pipe->wait);
ret = -ERESTARTSYS;
goto err;
err:
ret = -ERESTARTSYS;
goto err;
err:
- if (!
inode->i_pipe->readers && !inode->i_
pipe->writers)
+ if (!
pipe->readers && !
pipe->writers)
free_pipe_info(inode);
err_nocleanup:
free_pipe_info(inode);
err_nocleanup:
@@
-148,5
+150,5
@@
err_nocleanup:
* depending on the access mode of the file...
*/
const struct file_operations def_fifo_fops = {
* depending on the access mode of the file...
*/
const struct file_operations def_fifo_fops = {
- .open = fifo_open, /* will set read
or write pipe
_fops */
+ .open = fifo_open, /* will set read
_ or write_pipefifo
_fops */
};
};