[DCCP] Give precedence to the biggest ELAPSED_TIME
[linux-2.6/s3c2410-cpufreq.git] / fs / pipe.c
blob2c7a23dde2d83f1ae18190e5723c0eb8d8ae0548
1 /*
2 * linux/fs/pipe.c
4 * Copyright (C) 1991, 1992, 1999 Linus Torvalds
5 */
7 #include <linux/mm.h>
8 #include <linux/file.h>
9 #include <linux/poll.h>
10 #include <linux/slab.h>
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/fs.h>
14 #include <linux/mount.h>
15 #include <linux/pipe_fs_i.h>
16 #include <linux/uio.h>
17 #include <linux/highmem.h>
19 #include <asm/uaccess.h>
20 #include <asm/ioctls.h>
23 * We use a start+len construction, which provides full use of the
24 * allocated memory.
25 * -- Florian Coosmann (FGC)
27 * Reads with count = 0 should always return 0.
28 * -- Julian Bradfield 1999-06-07.
30 * FIFOs and Pipes now generate SIGIO for both readers and writers.
31 * -- Jeremy Elson <jelson@circlemud.org> 2001-08-16
33 * pipe_read & write cleanup
34 * -- Manfred Spraul <manfred@colorfullife.com> 2002-05-09
37 /* Drop the inode semaphore and wait for a pipe event, atomically */
38 void pipe_wait(struct inode * inode)
40 DEFINE_WAIT(wait);
42 prepare_to_wait(PIPE_WAIT(*inode), &wait, TASK_INTERRUPTIBLE);
43 up(PIPE_SEM(*inode));
44 schedule();
45 finish_wait(PIPE_WAIT(*inode), &wait);
46 down(PIPE_SEM(*inode));
49 static inline int
50 pipe_iov_copy_from_user(void *to, struct iovec *iov, unsigned long len)
52 unsigned long copy;
54 while (len > 0) {
55 while (!iov->iov_len)
56 iov++;
57 copy = min_t(unsigned long, len, iov->iov_len);
59 if (copy_from_user(to, iov->iov_base, copy))
60 return -EFAULT;
61 to += copy;
62 len -= copy;
63 iov->iov_base += copy;
64 iov->iov_len -= copy;
66 return 0;
69 static inline int
70 pipe_iov_copy_to_user(struct iovec *iov, const void *from, unsigned long len)
72 unsigned long copy;
74 while (len > 0) {
75 while (!iov->iov_len)
76 iov++;
77 copy = min_t(unsigned long, len, iov->iov_len);
79 if (copy_to_user(iov->iov_base, from, copy))
80 return -EFAULT;
81 from += copy;
82 len -= copy;
83 iov->iov_base += copy;
84 iov->iov_len -= copy;
86 return 0;
89 static void anon_pipe_buf_release(struct pipe_inode_info *info, struct pipe_buffer *buf)
91 struct page *page = buf->page;
93 if (info->tmp_page) {
94 __free_page(page);
95 return;
97 info->tmp_page = page;
100 static void *anon_pipe_buf_map(struct file *file, struct pipe_inode_info *info, struct pipe_buffer *buf)
102 return kmap(buf->page);
105 static void anon_pipe_buf_unmap(struct pipe_inode_info *info, struct pipe_buffer *buf)
107 kunmap(buf->page);
110 static struct pipe_buf_operations anon_pipe_buf_ops = {
111 .can_merge = 1,
112 .map = anon_pipe_buf_map,
113 .unmap = anon_pipe_buf_unmap,
114 .release = anon_pipe_buf_release,
117 static ssize_t
118 pipe_readv(struct file *filp, const struct iovec *_iov,
119 unsigned long nr_segs, loff_t *ppos)
121 struct inode *inode = filp->f_dentry->d_inode;
122 struct pipe_inode_info *info;
123 int do_wakeup;
124 ssize_t ret;
125 struct iovec *iov = (struct iovec *)_iov;
126 size_t total_len;
128 total_len = iov_length(iov, nr_segs);
129 /* Null read succeeds. */
130 if (unlikely(total_len == 0))
131 return 0;
133 do_wakeup = 0;
134 ret = 0;
135 down(PIPE_SEM(*inode));
136 info = inode->i_pipe;
137 for (;;) {
138 int bufs = info->nrbufs;
139 if (bufs) {
140 int curbuf = info->curbuf;
141 struct pipe_buffer *buf = info->bufs + curbuf;
142 struct pipe_buf_operations *ops = buf->ops;
143 void *addr;
144 size_t chars = buf->len;
145 int error;
147 if (chars > total_len)
148 chars = total_len;
150 addr = ops->map(filp, info, buf);
151 error = pipe_iov_copy_to_user(iov, addr + buf->offset, chars);
152 ops->unmap(info, buf);
153 if (unlikely(error)) {
154 if (!ret) ret = -EFAULT;
155 break;
157 ret += chars;
158 buf->offset += chars;
159 buf->len -= chars;
160 if (!buf->len) {
161 buf->ops = NULL;
162 ops->release(info, buf);
163 curbuf = (curbuf + 1) & (PIPE_BUFFERS-1);
164 info->curbuf = curbuf;
165 info->nrbufs = --bufs;
166 do_wakeup = 1;
168 total_len -= chars;
169 if (!total_len)
170 break; /* common path: read succeeded */
172 if (bufs) /* More to do? */
173 continue;
174 if (!PIPE_WRITERS(*inode))
175 break;
176 if (!PIPE_WAITING_WRITERS(*inode)) {
177 /* syscall merging: Usually we must not sleep
178 * if O_NONBLOCK is set, or if we got some data.
179 * But if a writer sleeps in kernel space, then
180 * we can wait for that data without violating POSIX.
182 if (ret)
183 break;
184 if (filp->f_flags & O_NONBLOCK) {
185 ret = -EAGAIN;
186 break;
189 if (signal_pending(current)) {
190 if (!ret) ret = -ERESTARTSYS;
191 break;
193 if (do_wakeup) {
194 wake_up_interruptible_sync(PIPE_WAIT(*inode));
195 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
197 pipe_wait(inode);
199 up(PIPE_SEM(*inode));
200 /* Signal writers asynchronously that there is more room. */
201 if (do_wakeup) {
202 wake_up_interruptible(PIPE_WAIT(*inode));
203 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
205 if (ret > 0)
206 file_accessed(filp);
207 return ret;
210 static ssize_t
211 pipe_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
213 struct iovec iov = { .iov_base = buf, .iov_len = count };
214 return pipe_readv(filp, &iov, 1, ppos);
217 static ssize_t
218 pipe_writev(struct file *filp, const struct iovec *_iov,
219 unsigned long nr_segs, loff_t *ppos)
221 struct inode *inode = filp->f_dentry->d_inode;
222 struct pipe_inode_info *info;
223 ssize_t ret;
224 int do_wakeup;
225 struct iovec *iov = (struct iovec *)_iov;
226 size_t total_len;
227 ssize_t chars;
229 total_len = iov_length(iov, nr_segs);
230 /* Null write succeeds. */
231 if (unlikely(total_len == 0))
232 return 0;
234 do_wakeup = 0;
235 ret = 0;
236 down(PIPE_SEM(*inode));
237 info = inode->i_pipe;
239 if (!PIPE_READERS(*inode)) {
240 send_sig(SIGPIPE, current, 0);
241 ret = -EPIPE;
242 goto out;
245 /* We try to merge small writes */
246 chars = total_len & (PAGE_SIZE-1); /* size of the last buffer */
247 if (info->nrbufs && chars != 0) {
248 int lastbuf = (info->curbuf + info->nrbufs - 1) & (PIPE_BUFFERS-1);
249 struct pipe_buffer *buf = info->bufs + lastbuf;
250 struct pipe_buf_operations *ops = buf->ops;
251 int offset = buf->offset + buf->len;
252 if (ops->can_merge && offset + chars <= PAGE_SIZE) {
253 void *addr = ops->map(filp, info, buf);
254 int error = pipe_iov_copy_from_user(offset + addr, iov, chars);
255 ops->unmap(info, buf);
256 ret = error;
257 do_wakeup = 1;
258 if (error)
259 goto out;
260 buf->len += chars;
261 total_len -= chars;
262 ret = chars;
263 if (!total_len)
264 goto out;
268 for (;;) {
269 int bufs;
270 if (!PIPE_READERS(*inode)) {
271 send_sig(SIGPIPE, current, 0);
272 if (!ret) ret = -EPIPE;
273 break;
275 bufs = info->nrbufs;
276 if (bufs < PIPE_BUFFERS) {
277 int newbuf = (info->curbuf + bufs) & (PIPE_BUFFERS-1);
278 struct pipe_buffer *buf = info->bufs + newbuf;
279 struct page *page = info->tmp_page;
280 int error;
282 if (!page) {
283 page = alloc_page(GFP_HIGHUSER);
284 if (unlikely(!page)) {
285 ret = ret ? : -ENOMEM;
286 break;
288 info->tmp_page = page;
290 /* Always wakeup, even if the copy fails. Otherwise
291 * we lock up (O_NONBLOCK-)readers that sleep due to
292 * syscall merging.
293 * FIXME! Is this really true?
295 do_wakeup = 1;
296 chars = PAGE_SIZE;
297 if (chars > total_len)
298 chars = total_len;
300 error = pipe_iov_copy_from_user(kmap(page), iov, chars);
301 kunmap(page);
302 if (unlikely(error)) {
303 if (!ret) ret = -EFAULT;
304 break;
306 ret += chars;
308 /* Insert it into the buffer array */
309 buf->page = page;
310 buf->ops = &anon_pipe_buf_ops;
311 buf->offset = 0;
312 buf->len = chars;
313 info->nrbufs = ++bufs;
314 info->tmp_page = NULL;
316 total_len -= chars;
317 if (!total_len)
318 break;
320 if (bufs < PIPE_BUFFERS)
321 continue;
322 if (filp->f_flags & O_NONBLOCK) {
323 if (!ret) ret = -EAGAIN;
324 break;
326 if (signal_pending(current)) {
327 if (!ret) ret = -ERESTARTSYS;
328 break;
330 if (do_wakeup) {
331 wake_up_interruptible_sync(PIPE_WAIT(*inode));
332 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
333 do_wakeup = 0;
335 PIPE_WAITING_WRITERS(*inode)++;
336 pipe_wait(inode);
337 PIPE_WAITING_WRITERS(*inode)--;
339 out:
340 up(PIPE_SEM(*inode));
341 if (do_wakeup) {
342 wake_up_interruptible(PIPE_WAIT(*inode));
343 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
345 if (ret > 0)
346 inode_update_time(inode, 1); /* mtime and ctime */
347 return ret;
350 static ssize_t
351 pipe_write(struct file *filp, const char __user *buf,
352 size_t count, loff_t *ppos)
354 struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count };
355 return pipe_writev(filp, &iov, 1, ppos);
358 static ssize_t
359 bad_pipe_r(struct file *filp, char __user *buf, size_t count, loff_t *ppos)
361 return -EBADF;
364 static ssize_t
365 bad_pipe_w(struct file *filp, const char __user *buf, size_t count, loff_t *ppos)
367 return -EBADF;
370 static int
371 pipe_ioctl(struct inode *pino, struct file *filp,
372 unsigned int cmd, unsigned long arg)
374 struct inode *inode = filp->f_dentry->d_inode;
375 struct pipe_inode_info *info;
376 int count, buf, nrbufs;
378 switch (cmd) {
379 case FIONREAD:
380 down(PIPE_SEM(*inode));
381 info = inode->i_pipe;
382 count = 0;
383 buf = info->curbuf;
384 nrbufs = info->nrbufs;
385 while (--nrbufs >= 0) {
386 count += info->bufs[buf].len;
387 buf = (buf+1) & (PIPE_BUFFERS-1);
389 up(PIPE_SEM(*inode));
390 return put_user(count, (int __user *)arg);
391 default:
392 return -EINVAL;
396 /* No kernel lock held - fine */
397 static unsigned int
398 pipe_poll(struct file *filp, poll_table *wait)
400 unsigned int mask;
401 struct inode *inode = filp->f_dentry->d_inode;
402 struct pipe_inode_info *info = inode->i_pipe;
403 int nrbufs;
405 poll_wait(filp, PIPE_WAIT(*inode), wait);
407 /* Reading only -- no need for acquiring the semaphore. */
408 nrbufs = info->nrbufs;
409 mask = 0;
410 if (filp->f_mode & FMODE_READ) {
411 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
412 if (!PIPE_WRITERS(*inode) && filp->f_version != PIPE_WCOUNTER(*inode))
413 mask |= POLLHUP;
416 if (filp->f_mode & FMODE_WRITE) {
417 mask |= (nrbufs < PIPE_BUFFERS) ? POLLOUT | POLLWRNORM : 0;
419 * Most Unices do not set POLLERR for FIFOs but on Linux they
420 * behave exactly like pipes for poll().
422 if (!PIPE_READERS(*inode))
423 mask |= POLLERR;
426 return mask;
429 static int
430 pipe_release(struct inode *inode, int decr, int decw)
432 down(PIPE_SEM(*inode));
433 PIPE_READERS(*inode) -= decr;
434 PIPE_WRITERS(*inode) -= decw;
435 if (!PIPE_READERS(*inode) && !PIPE_WRITERS(*inode)) {
436 free_pipe_info(inode);
437 } else {
438 wake_up_interruptible(PIPE_WAIT(*inode));
439 kill_fasync(PIPE_FASYNC_READERS(*inode), SIGIO, POLL_IN);
440 kill_fasync(PIPE_FASYNC_WRITERS(*inode), SIGIO, POLL_OUT);
442 up(PIPE_SEM(*inode));
444 return 0;
447 static int
448 pipe_read_fasync(int fd, struct file *filp, int on)
450 struct inode *inode = filp->f_dentry->d_inode;
451 int retval;
453 down(PIPE_SEM(*inode));
454 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
455 up(PIPE_SEM(*inode));
457 if (retval < 0)
458 return retval;
460 return 0;
464 static int
465 pipe_write_fasync(int fd, struct file *filp, int on)
467 struct inode *inode = filp->f_dentry->d_inode;
468 int retval;
470 down(PIPE_SEM(*inode));
471 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
472 up(PIPE_SEM(*inode));
474 if (retval < 0)
475 return retval;
477 return 0;
481 static int
482 pipe_rdwr_fasync(int fd, struct file *filp, int on)
484 struct inode *inode = filp->f_dentry->d_inode;
485 int retval;
487 down(PIPE_SEM(*inode));
489 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_READERS(*inode));
491 if (retval >= 0)
492 retval = fasync_helper(fd, filp, on, PIPE_FASYNC_WRITERS(*inode));
494 up(PIPE_SEM(*inode));
496 if (retval < 0)
497 return retval;
499 return 0;
503 static int
504 pipe_read_release(struct inode *inode, struct file *filp)
506 pipe_read_fasync(-1, filp, 0);
507 return pipe_release(inode, 1, 0);
510 static int
511 pipe_write_release(struct inode *inode, struct file *filp)
513 pipe_write_fasync(-1, filp, 0);
514 return pipe_release(inode, 0, 1);
517 static int
518 pipe_rdwr_release(struct inode *inode, struct file *filp)
520 int decr, decw;
522 pipe_rdwr_fasync(-1, filp, 0);
523 decr = (filp->f_mode & FMODE_READ) != 0;
524 decw = (filp->f_mode & FMODE_WRITE) != 0;
525 return pipe_release(inode, decr, decw);
528 static int
529 pipe_read_open(struct inode *inode, struct file *filp)
531 /* We could have perhaps used atomic_t, but this and friends
532 below are the only places. So it doesn't seem worthwhile. */
533 down(PIPE_SEM(*inode));
534 PIPE_READERS(*inode)++;
535 up(PIPE_SEM(*inode));
537 return 0;
540 static int
541 pipe_write_open(struct inode *inode, struct file *filp)
543 down(PIPE_SEM(*inode));
544 PIPE_WRITERS(*inode)++;
545 up(PIPE_SEM(*inode));
547 return 0;
550 static int
551 pipe_rdwr_open(struct inode *inode, struct file *filp)
553 down(PIPE_SEM(*inode));
554 if (filp->f_mode & FMODE_READ)
555 PIPE_READERS(*inode)++;
556 if (filp->f_mode & FMODE_WRITE)
557 PIPE_WRITERS(*inode)++;
558 up(PIPE_SEM(*inode));
560 return 0;
564 * The file_operations structs are not static because they
565 * are also used in linux/fs/fifo.c to do operations on FIFOs.
567 struct file_operations read_fifo_fops = {
568 .llseek = no_llseek,
569 .read = pipe_read,
570 .readv = pipe_readv,
571 .write = bad_pipe_w,
572 .poll = pipe_poll,
573 .ioctl = pipe_ioctl,
574 .open = pipe_read_open,
575 .release = pipe_read_release,
576 .fasync = pipe_read_fasync,
579 struct file_operations write_fifo_fops = {
580 .llseek = no_llseek,
581 .read = bad_pipe_r,
582 .write = pipe_write,
583 .writev = pipe_writev,
584 .poll = pipe_poll,
585 .ioctl = pipe_ioctl,
586 .open = pipe_write_open,
587 .release = pipe_write_release,
588 .fasync = pipe_write_fasync,
591 struct file_operations rdwr_fifo_fops = {
592 .llseek = no_llseek,
593 .read = pipe_read,
594 .readv = pipe_readv,
595 .write = pipe_write,
596 .writev = pipe_writev,
597 .poll = pipe_poll,
598 .ioctl = pipe_ioctl,
599 .open = pipe_rdwr_open,
600 .release = pipe_rdwr_release,
601 .fasync = pipe_rdwr_fasync,
604 struct file_operations read_pipe_fops = {
605 .llseek = no_llseek,
606 .read = pipe_read,
607 .readv = pipe_readv,
608 .write = bad_pipe_w,
609 .poll = pipe_poll,
610 .ioctl = pipe_ioctl,
611 .open = pipe_read_open,
612 .release = pipe_read_release,
613 .fasync = pipe_read_fasync,
616 struct file_operations write_pipe_fops = {
617 .llseek = no_llseek,
618 .read = bad_pipe_r,
619 .write = pipe_write,
620 .writev = pipe_writev,
621 .poll = pipe_poll,
622 .ioctl = pipe_ioctl,
623 .open = pipe_write_open,
624 .release = pipe_write_release,
625 .fasync = pipe_write_fasync,
628 struct file_operations rdwr_pipe_fops = {
629 .llseek = no_llseek,
630 .read = pipe_read,
631 .readv = pipe_readv,
632 .write = pipe_write,
633 .writev = pipe_writev,
634 .poll = pipe_poll,
635 .ioctl = pipe_ioctl,
636 .open = pipe_rdwr_open,
637 .release = pipe_rdwr_release,
638 .fasync = pipe_rdwr_fasync,
641 void free_pipe_info(struct inode *inode)
643 int i;
644 struct pipe_inode_info *info = inode->i_pipe;
646 inode->i_pipe = NULL;
647 for (i = 0; i < PIPE_BUFFERS; i++) {
648 struct pipe_buffer *buf = info->bufs + i;
649 if (buf->ops)
650 buf->ops->release(info, buf);
652 if (info->tmp_page)
653 __free_page(info->tmp_page);
654 kfree(info);
657 struct inode* pipe_new(struct inode* inode)
659 struct pipe_inode_info *info;
661 info = kmalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
662 if (!info)
663 goto fail_page;
664 memset(info, 0, sizeof(*info));
665 inode->i_pipe = info;
667 init_waitqueue_head(PIPE_WAIT(*inode));
668 PIPE_RCOUNTER(*inode) = PIPE_WCOUNTER(*inode) = 1;
670 return inode;
671 fail_page:
672 return NULL;
675 static struct vfsmount *pipe_mnt;
676 static int pipefs_delete_dentry(struct dentry *dentry)
678 return 1;
680 static struct dentry_operations pipefs_dentry_operations = {
681 .d_delete = pipefs_delete_dentry,
684 static struct inode * get_pipe_inode(void)
686 struct inode *inode = new_inode(pipe_mnt->mnt_sb);
688 if (!inode)
689 goto fail_inode;
691 if(!pipe_new(inode))
692 goto fail_iput;
693 PIPE_READERS(*inode) = PIPE_WRITERS(*inode) = 1;
694 inode->i_fop = &rdwr_pipe_fops;
697 * Mark the inode dirty from the very beginning,
698 * that way it will never be moved to the dirty
699 * list because "mark_inode_dirty()" will think
700 * that it already _is_ on the dirty list.
702 inode->i_state = I_DIRTY;
703 inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR;
704 inode->i_uid = current->fsuid;
705 inode->i_gid = current->fsgid;
706 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
707 inode->i_blksize = PAGE_SIZE;
708 return inode;
710 fail_iput:
711 iput(inode);
712 fail_inode:
713 return NULL;
716 int do_pipe(int *fd)
718 struct qstr this;
719 char name[32];
720 struct dentry *dentry;
721 struct inode * inode;
722 struct file *f1, *f2;
723 int error;
724 int i,j;
726 error = -ENFILE;
727 f1 = get_empty_filp();
728 if (!f1)
729 goto no_files;
731 f2 = get_empty_filp();
732 if (!f2)
733 goto close_f1;
735 inode = get_pipe_inode();
736 if (!inode)
737 goto close_f12;
739 error = get_unused_fd();
740 if (error < 0)
741 goto close_f12_inode;
742 i = error;
744 error = get_unused_fd();
745 if (error < 0)
746 goto close_f12_inode_i;
747 j = error;
749 error = -ENOMEM;
750 sprintf(name, "[%lu]", inode->i_ino);
751 this.name = name;
752 this.len = strlen(name);
753 this.hash = inode->i_ino; /* will go */
754 dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this);
755 if (!dentry)
756 goto close_f12_inode_i_j;
757 dentry->d_op = &pipefs_dentry_operations;
758 d_add(dentry, inode);
759 f1->f_vfsmnt = f2->f_vfsmnt = mntget(mntget(pipe_mnt));
760 f1->f_dentry = f2->f_dentry = dget(dentry);
761 f1->f_mapping = f2->f_mapping = inode->i_mapping;
763 /* read file */
764 f1->f_pos = f2->f_pos = 0;
765 f1->f_flags = O_RDONLY;
766 f1->f_op = &read_pipe_fops;
767 f1->f_mode = FMODE_READ;
768 f1->f_version = 0;
770 /* write file */
771 f2->f_flags = O_WRONLY;
772 f2->f_op = &write_pipe_fops;
773 f2->f_mode = FMODE_WRITE;
774 f2->f_version = 0;
776 fd_install(i, f1);
777 fd_install(j, f2);
778 fd[0] = i;
779 fd[1] = j;
780 return 0;
782 close_f12_inode_i_j:
783 put_unused_fd(j);
784 close_f12_inode_i:
785 put_unused_fd(i);
786 close_f12_inode:
787 free_pipe_info(inode);
788 iput(inode);
789 close_f12:
790 put_filp(f2);
791 close_f1:
792 put_filp(f1);
793 no_files:
794 return error;
798 * pipefs should _never_ be mounted by userland - too much of security hassle,
799 * no real gain from having the whole whorehouse mounted. So we don't need
800 * any operations on the root directory. However, we need a non-trivial
801 * d_name - pipe: will go nicely and kill the special-casing in procfs.
804 static struct super_block *pipefs_get_sb(struct file_system_type *fs_type,
805 int flags, const char *dev_name, void *data)
807 return get_sb_pseudo(fs_type, "pipe:", NULL, PIPEFS_MAGIC);
810 static struct file_system_type pipe_fs_type = {
811 .name = "pipefs",
812 .get_sb = pipefs_get_sb,
813 .kill_sb = kill_anon_super,
816 static int __init init_pipe_fs(void)
818 int err = register_filesystem(&pipe_fs_type);
819 if (!err) {
820 pipe_mnt = kern_mount(&pipe_fs_type);
821 if (IS_ERR(pipe_mnt)) {
822 err = PTR_ERR(pipe_mnt);
823 unregister_filesystem(&pipe_fs_type);
826 return err;
829 static void __exit exit_pipe_fs(void)
831 unregister_filesystem(&pipe_fs_type);
832 mntput(pipe_mnt);
835 fs_initcall(init_pipe_fs);
836 module_exit(exit_pipe_fs);