update pipe.c

This commit is contained in:
Meco Man 2021-01-01 17:21:48 +08:00
parent a940728162
commit a657c00e72
1 changed files with 29 additions and 29 deletions

View File

@ -41,16 +41,16 @@ static int pipe_fops_open(struct dfs_fd *fd)
switch (fd->flags & O_ACCMODE)
{
case O_RDONLY:
pipe->readers ++;
break;
case O_WRONLY:
pipe->writers ++;
break;
case O_RDWR:
pipe->readers ++;
pipe->writers ++;
break;
case O_RDONLY:
pipe->readers ++;
break;
case O_WRONLY:
pipe->writers ++;
break;
case O_RDWR:
pipe->readers ++;
pipe->writers ++;
break;
}
device->ref_count ++;
@ -73,16 +73,16 @@ static int pipe_fops_close(struct dfs_fd *fd)
switch (fd->flags & O_ACCMODE)
{
case O_RDONLY:
pipe->readers --;
break;
case O_WRONLY:
pipe->writers --;
break;
case O_RDWR:
pipe->readers --;
pipe->writers --;
break;
case O_RDONLY:
pipe->readers --;
break;
case O_WRONLY:
pipe->writers --;
break;
case O_RDWR:
pipe->readers --;
pipe->writers --;
break;
}
if (pipe->writers == 0)
@ -123,15 +123,15 @@ static int pipe_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
switch (cmd)
{
case FIONREAD:
*((int*)args) = rt_ringbuffer_data_len(pipe->fifo);
break;
case FIONWRITE:
*((int*)args) = rt_ringbuffer_space_len(pipe->fifo);
break;
default:
ret = -EINVAL;
break;
case FIONREAD:
*((int*)args) = rt_ringbuffer_data_len(pipe->fifo);
break;
case FIONWRITE:
*((int*)args) = rt_ringbuffer_space_len(pipe->fifo);
break;
default:
ret = -EINVAL;
break;
}
return ret;