X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=fs%2Fpipe.c;h=3a89592bdf577930b4c1698c4811261aa467cbf2;hb=864022344caf43dab7fa5219152280d056c6e051;hp=f8b6bdcb879aa8f4ba9ccfa7340edb087d7e2d57;hpb=a57bf8a4f23cca2b5be5446649bbe22d1440af5d;p=linux-2.6-omap-h63xx.git diff --git a/fs/pipe.c b/fs/pipe.c index f8b6bdcb879..3a89592bdf5 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -207,7 +208,7 @@ int generic_pipe_buf_pin(struct pipe_inode_info *info, struct pipe_buffer *buf) return 0; } -static struct pipe_buf_operations anon_pipe_buf_ops = { +static const struct pipe_buf_operations anon_pipe_buf_ops = { .can_merge = 1, .map = generic_pipe_buf_map, .unmap = generic_pipe_buf_unmap, @@ -243,7 +244,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov, if (bufs) { int curbuf = pipe->curbuf; struct pipe_buffer *buf = pipe->bufs + curbuf; - struct pipe_buf_operations *ops = buf->ops; + const struct pipe_buf_operations *ops = buf->ops; void *addr; size_t chars = buf->len; int error, atomic; @@ -365,7 +366,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov, int lastbuf = (pipe->curbuf + pipe->nrbufs - 1) & (PIPE_BUFFERS-1); struct pipe_buffer *buf = pipe->bufs + lastbuf; - struct pipe_buf_operations *ops = buf->ops; + const struct pipe_buf_operations *ops = buf->ops; int offset = buf->offset + buf->len; if (ops->can_merge && offset + chars <= PAGE_SIZE) { @@ -756,7 +757,7 @@ const struct file_operations rdwr_fifo_fops = { .fasync = pipe_rdwr_fasync, }; -static struct file_operations read_pipe_fops = { +static const struct file_operations read_pipe_fops = { .llseek = no_llseek, .read = do_sync_read, .aio_read = pipe_read, @@ -768,7 +769,7 @@ static struct file_operations read_pipe_fops = { .fasync = pipe_read_fasync, }; -static struct file_operations write_pipe_fops = { +static const struct file_operations write_pipe_fops = { .llseek = no_llseek, .read = bad_pipe_r, .write = do_sync_write, @@ -780,7 +781,7 @@ static struct file_operations write_pipe_fops = { .fasync = pipe_write_fasync, }; -static struct file_operations rdwr_pipe_fops = { +static const struct file_operations rdwr_pipe_fops = { .llseek = no_llseek, .read = do_sync_read, .aio_read = pipe_read, @@ -840,8 +841,18 @@ static int pipefs_delete_dentry(struct dentry *dentry) return 0; } +/* + * pipefs_dname() is called from d_path(). + */ +static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen) +{ + return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]", + dentry->d_inode->i_ino); +} + static struct dentry_operations pipefs_dentry_operations = { .d_delete = pipefs_delete_dentry, + .d_dname = pipefs_dname, }; static struct inode * get_pipe_inode(void) @@ -887,8 +898,7 @@ struct file *create_write_pipe(void) struct inode *inode; struct file *f; struct dentry *dentry; - char name[32]; - struct qstr this; + struct qstr name = { .name = "" }; f = get_empty_filp(); if (!f) @@ -898,11 +908,8 @@ struct file *create_write_pipe(void) if (!inode) goto err_file; - this.len = sprintf(name, "[%lu]", inode->i_ino); - this.name = name; - this.hash = 0; err = -ENOMEM; - dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); + dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); if (!dentry) goto err_inode; @@ -935,8 +942,9 @@ struct file *create_write_pipe(void) void free_write_pipe(struct file *f) { - mntput(f->f_path.mnt); + free_pipe_info(f->f_dentry->d_inode); dput(f->f_path.dentry); + mntput(f->f_path.mnt); put_filp(f); } @@ -984,6 +992,10 @@ int do_pipe(int *fd) goto err_fdr; fdw = error; + error = audit_fd_pair(fdr, fdw); + if (error < 0) + goto err_fdw; + fd_install(fdr, fr); fd_install(fdw, fw); fd[0] = fdr; @@ -991,9 +1003,13 @@ int do_pipe(int *fd) return 0; + err_fdw: + put_unused_fd(fdw); err_fdr: put_unused_fd(fdr); err_read_pipe: + dput(fr->f_dentry); + mntput(fr->f_vfsmnt); put_filp(fr); err_write_pipe: free_write_pipe(fw);