4 * Copyright (C) 1991, 1992, 1999 Linus Torvalds
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>
14 #include <linux/mount.h>
15 #include <linux/pipe_fs_i.h>
16 #include <linux/uio.h>
17 #include <linux/highmem.h>
18 #include <linux/pagemap.h>
20 #include <asm/uaccess.h>
21 #include <asm/ioctls.h>
24 * We use a start+len construction, which provides full use of the
26 * -- Florian Coosmann (FGC)
28 * Reads with count = 0 should always return 0.
29 * -- Julian Bradfield 1999-06-07.
31 * FIFOs and Pipes now generate SIGIO for both readers and writers.
32 * -- Jeremy Elson <jelson@circlemud.org> 2001-08-16
34 * pipe_read & write cleanup
35 * -- Manfred Spraul <manfred@colorfullife.com> 2002-05-09
38 /* Drop the inode semaphore and wait for a pipe event, atomically */
39 void pipe_wait(struct pipe_inode_info
*pipe
)
44 * Pipes are system-local resources, so sleeping on them
45 * is considered a noninteractive wait:
47 prepare_to_wait(&pipe
->wait
, &wait
,
48 TASK_INTERRUPTIBLE
| TASK_NONINTERACTIVE
);
50 mutex_unlock(&pipe
->inode
->i_mutex
);
52 finish_wait(&pipe
->wait
, &wait
);
54 mutex_lock(&pipe
->inode
->i_mutex
);
58 pipe_iov_copy_from_user(void *to
, struct iovec
*iov
, unsigned long len
,
66 copy
= min_t(unsigned long, len
, iov
->iov_len
);
69 if (__copy_from_user_inatomic(to
, iov
->iov_base
, copy
))
72 if (copy_from_user(to
, iov
->iov_base
, copy
))
77 iov
->iov_base
+= copy
;
84 pipe_iov_copy_to_user(struct iovec
*iov
, const void *from
, unsigned long len
,
92 copy
= min_t(unsigned long, len
, iov
->iov_len
);
95 if (__copy_to_user_inatomic(iov
->iov_base
, from
, copy
))
98 if (copy_to_user(iov
->iov_base
, from
, copy
))
103 iov
->iov_base
+= copy
;
104 iov
->iov_len
-= copy
;
110 * Attempt to pre-fault in the user memory, so we can use atomic copies.
111 * Returns the number of bytes not faulted in.
113 static int iov_fault_in_pages_write(struct iovec
*iov
, unsigned long len
)
115 while (!iov
->iov_len
)
119 unsigned long this_len
;
121 this_len
= min_t(unsigned long, len
, iov
->iov_len
);
122 if (fault_in_pages_writeable(iov
->iov_base
, this_len
))
133 * Pre-fault in the user memory, so we can use atomic copies.
135 static void iov_fault_in_pages_read(struct iovec
*iov
, unsigned long len
)
137 while (!iov
->iov_len
)
141 unsigned long this_len
;
143 this_len
= min_t(unsigned long, len
, iov
->iov_len
);
144 fault_in_pages_readable(iov
->iov_base
, this_len
);
150 static void anon_pipe_buf_release(struct pipe_inode_info
*pipe
,
151 struct pipe_buffer
*buf
)
153 struct page
*page
= buf
->page
;
156 * If nobody else uses this page, and we don't already have a
157 * temporary page, let's keep track of it as a one-deep
158 * allocation cache. (Otherwise just release our reference to it)
160 if (page_count(page
) == 1 && !pipe
->tmp_page
)
161 pipe
->tmp_page
= page
;
163 page_cache_release(page
);
166 void *generic_pipe_buf_map(struct pipe_inode_info
*pipe
,
167 struct pipe_buffer
*buf
, int atomic
)
170 buf
->flags
|= PIPE_BUF_FLAG_ATOMIC
;
171 return kmap_atomic(buf
->page
, KM_USER0
);
174 return kmap(buf
->page
);
177 void generic_pipe_buf_unmap(struct pipe_inode_info
*pipe
,
178 struct pipe_buffer
*buf
, void *map_data
)
180 if (buf
->flags
& PIPE_BUF_FLAG_ATOMIC
) {
181 buf
->flags
&= ~PIPE_BUF_FLAG_ATOMIC
;
182 kunmap_atomic(map_data
, KM_USER0
);
187 int generic_pipe_buf_steal(struct pipe_inode_info
*pipe
,
188 struct pipe_buffer
*buf
)
190 struct page
*page
= buf
->page
;
192 if (page_count(page
) == 1) {
200 void generic_pipe_buf_get(struct pipe_inode_info
*info
, struct pipe_buffer
*buf
)
202 page_cache_get(buf
->page
);
205 int generic_pipe_buf_pin(struct pipe_inode_info
*info
, struct pipe_buffer
*buf
)
210 static struct pipe_buf_operations anon_pipe_buf_ops
= {
212 .map
= generic_pipe_buf_map
,
213 .unmap
= generic_pipe_buf_unmap
,
214 .pin
= generic_pipe_buf_pin
,
215 .release
= anon_pipe_buf_release
,
216 .steal
= generic_pipe_buf_steal
,
217 .get
= generic_pipe_buf_get
,
221 pipe_read(struct kiocb
*iocb
, const struct iovec
*_iov
,
222 unsigned long nr_segs
, loff_t pos
)
224 struct file
*filp
= iocb
->ki_filp
;
225 struct inode
*inode
= filp
->f_dentry
->d_inode
;
226 struct pipe_inode_info
*pipe
;
229 struct iovec
*iov
= (struct iovec
*)_iov
;
232 total_len
= iov_length(iov
, nr_segs
);
233 /* Null read succeeds. */
234 if (unlikely(total_len
== 0))
239 mutex_lock(&inode
->i_mutex
);
240 #if 0 // mask by Victor Yu. 02-12-2007
241 pipe
= inode
->i_pipe
;
243 pipe
= inode
->u
.i_pipe
;
246 int bufs
= pipe
->nrbufs
;
248 int curbuf
= pipe
->curbuf
;
249 struct pipe_buffer
*buf
= pipe
->bufs
+ curbuf
;
250 struct pipe_buf_operations
*ops
= buf
->ops
;
252 size_t chars
= buf
->len
;
255 if (chars
> total_len
)
258 error
= ops
->pin(pipe
, buf
);
265 atomic
= !iov_fault_in_pages_write(iov
, chars
);
267 addr
= ops
->map(pipe
, buf
, atomic
);
268 error
= pipe_iov_copy_to_user(iov
, addr
+ buf
->offset
, chars
, atomic
);
269 ops
->unmap(pipe
, buf
, addr
);
270 if (unlikely(error
)) {
272 * Just retry with the slow path if we failed.
283 buf
->offset
+= chars
;
287 ops
->release(pipe
, buf
);
288 curbuf
= (curbuf
+ 1) & (PIPE_BUFFERS
-1);
289 pipe
->curbuf
= curbuf
;
290 pipe
->nrbufs
= --bufs
;
295 break; /* common path: read succeeded */
297 if (bufs
) /* More to do? */
301 if (!pipe
->waiting_writers
) {
302 /* syscall merging: Usually we must not sleep
303 * if O_NONBLOCK is set, or if we got some data.
304 * But if a writer sleeps in kernel space, then
305 * we can wait for that data without violating POSIX.
309 if (filp
->f_flags
& O_NONBLOCK
) {
314 if (signal_pending(current
)) {
320 wake_up_interruptible_sync(&pipe
->wait
);
321 kill_fasync(&pipe
->fasync_writers
, SIGIO
, POLL_OUT
);
325 mutex_unlock(&inode
->i_mutex
);
327 /* Signal writers asynchronously that there is more room. */
329 wake_up_interruptible(&pipe
->wait
);
330 kill_fasync(&pipe
->fasync_writers
, SIGIO
, POLL_OUT
);
338 pipe_write(struct kiocb
*iocb
, const struct iovec
*_iov
,
339 unsigned long nr_segs
, loff_t ppos
)
341 struct file
*filp
= iocb
->ki_filp
;
342 struct inode
*inode
= filp
->f_dentry
->d_inode
;
343 struct pipe_inode_info
*pipe
;
346 struct iovec
*iov
= (struct iovec
*)_iov
;
350 total_len
= iov_length(iov
, nr_segs
);
351 /* Null write succeeds. */
352 if (unlikely(total_len
== 0))
357 mutex_lock(&inode
->i_mutex
);
358 #if 0 // mask by Victor Yu. 02-12-2007
359 pipe
= inode
->i_pipe
;
361 pipe
= inode
->u
.i_pipe
;
364 if (!pipe
->readers
) {
365 send_sig(SIGPIPE
, current
, 0);
370 /* We try to merge small writes */
371 chars
= total_len
& (PAGE_SIZE
-1); /* size of the last buffer */
372 if (pipe
->nrbufs
&& chars
!= 0) {
373 int lastbuf
= (pipe
->curbuf
+ pipe
->nrbufs
- 1) &
375 struct pipe_buffer
*buf
= pipe
->bufs
+ lastbuf
;
376 struct pipe_buf_operations
*ops
= buf
->ops
;
377 int offset
= buf
->offset
+ buf
->len
;
379 if (ops
->can_merge
&& offset
+ chars
<= PAGE_SIZE
) {
380 int error
, atomic
= 1;
383 error
= ops
->pin(pipe
, buf
);
387 iov_fault_in_pages_read(iov
, chars
);
389 addr
= ops
->map(pipe
, buf
, atomic
);
390 error
= pipe_iov_copy_from_user(offset
+ addr
, iov
,
392 ops
->unmap(pipe
, buf
, addr
);
413 if (!pipe
->readers
) {
414 send_sig(SIGPIPE
, current
, 0);
420 if (bufs
< PIPE_BUFFERS
) {
421 int newbuf
= (pipe
->curbuf
+ bufs
) & (PIPE_BUFFERS
-1);
422 struct pipe_buffer
*buf
= pipe
->bufs
+ newbuf
;
423 struct page
*page
= pipe
->tmp_page
;
425 int error
, atomic
= 1;
428 page
= alloc_page(GFP_HIGHUSER
);
429 if (unlikely(!page
)) {
430 ret
= ret
? : -ENOMEM
;
433 pipe
->tmp_page
= page
;
435 /* Always wake up, even if the copy fails. Otherwise
436 * we lock up (O_NONBLOCK-)readers that sleep due to
438 * FIXME! Is this really true?
442 if (chars
> total_len
)
445 iov_fault_in_pages_read(iov
, chars
);
448 src
= kmap_atomic(page
, KM_USER0
);
452 error
= pipe_iov_copy_from_user(src
, iov
, chars
,
455 kunmap_atomic(src
, KM_USER0
);
459 if (unlikely(error
)) {
470 /* Insert it into the buffer array */
472 buf
->ops
= &anon_pipe_buf_ops
;
475 pipe
->nrbufs
= ++bufs
;
476 pipe
->tmp_page
= NULL
;
482 if (bufs
< PIPE_BUFFERS
)
484 if (filp
->f_flags
& O_NONBLOCK
) {
489 if (signal_pending(current
)) {
495 wake_up_interruptible_sync(&pipe
->wait
);
496 kill_fasync(&pipe
->fasync_readers
, SIGIO
, POLL_IN
);
499 pipe
->waiting_writers
++;
501 pipe
->waiting_writers
--;
504 mutex_unlock(&inode
->i_mutex
);
506 wake_up_interruptible(&pipe
->wait
);
507 kill_fasync(&pipe
->fasync_readers
, SIGIO
, POLL_IN
);
510 file_update_time(filp
);
515 bad_pipe_r(struct file
*filp
, char __user
*buf
, size_t count
, loff_t
*ppos
)
521 bad_pipe_w(struct file
*filp
, const char __user
*buf
, size_t count
,
528 pipe_ioctl(struct inode
*pino
, struct file
*filp
,
529 unsigned int cmd
, unsigned long arg
)
531 struct inode
*inode
= filp
->f_dentry
->d_inode
;
532 struct pipe_inode_info
*pipe
;
533 int count
, buf
, nrbufs
;
537 mutex_lock(&inode
->i_mutex
);
538 #if 0 // mask by Victor Yu. 02-12-2007
539 pipe
= inode
->i_pipe
;
541 pipe
= inode
->u
.i_pipe
;
545 nrbufs
= pipe
->nrbufs
;
546 while (--nrbufs
>= 0) {
547 count
+= pipe
->bufs
[buf
].len
;
548 buf
= (buf
+1) & (PIPE_BUFFERS
-1);
550 mutex_unlock(&inode
->i_mutex
);
552 return put_user(count
, (int __user
*)arg
);
558 /* No kernel lock held - fine */
560 pipe_poll(struct file
*filp
, poll_table
*wait
)
563 struct inode
*inode
= filp
->f_dentry
->d_inode
;
564 #if 0 // mask by Victor Yu. 02-12-2007
565 struct pipe_inode_info
*pipe
= inode
->i_pipe
;
567 struct pipe_inode_info
*pipe
= inode
->u
.i_pipe
;
571 poll_wait(filp
, &pipe
->wait
, wait
);
573 /* Reading only -- no need for acquiring the semaphore. */
574 nrbufs
= pipe
->nrbufs
;
576 if (filp
->f_mode
& FMODE_READ
) {
577 mask
= (nrbufs
> 0) ? POLLIN
| POLLRDNORM
: 0;
578 if (!pipe
->writers
&& filp
->f_version
!= pipe
->w_counter
)
582 if (filp
->f_mode
& FMODE_WRITE
) {
583 mask
|= (nrbufs
< PIPE_BUFFERS
) ? POLLOUT
| POLLWRNORM
: 0;
585 * Most Unices do not set POLLERR for FIFOs but on Linux they
586 * behave exactly like pipes for poll().
596 pipe_release(struct inode
*inode
, int decr
, int decw
)
598 struct pipe_inode_info
*pipe
;
600 mutex_lock(&inode
->i_mutex
);
601 #if 0 // mask by Victor Yu. 02-12-2007
602 pipe
= inode
->i_pipe
;
604 pipe
= inode
->u
.i_pipe
;
606 pipe
->readers
-= decr
;
607 pipe
->writers
-= decw
;
609 if (!pipe
->readers
&& !pipe
->writers
) {
610 free_pipe_info(inode
);
612 wake_up_interruptible(&pipe
->wait
);
613 kill_fasync(&pipe
->fasync_readers
, SIGIO
, POLL_IN
);
614 kill_fasync(&pipe
->fasync_writers
, SIGIO
, POLL_OUT
);
616 mutex_unlock(&inode
->i_mutex
);
622 pipe_read_fasync(int fd
, struct file
*filp
, int on
)
624 struct inode
*inode
= filp
->f_dentry
->d_inode
;
627 mutex_lock(&inode
->i_mutex
);
628 #if 0 // mask by Victor Yu. 02-12-2007
629 retval
= fasync_helper(fd
, filp
, on
, &inode
->i_pipe
->fasync_readers
);
631 retval
= fasync_helper(fd
, filp
, on
, &inode
->u
.i_pipe
->fasync_readers
);
633 mutex_unlock(&inode
->i_mutex
);
643 pipe_write_fasync(int fd
, struct file
*filp
, int on
)
645 struct inode
*inode
= filp
->f_dentry
->d_inode
;
648 mutex_lock(&inode
->i_mutex
);
649 #if 0 // mask by Victor Yu. 02-12-2007
650 retval
= fasync_helper(fd
, filp
, on
, &inode
->i_pipe
->fasync_writers
);
652 retval
= fasync_helper(fd
, filp
, on
, &inode
->u
.i_pipe
->fasync_writers
);
654 mutex_unlock(&inode
->i_mutex
);
664 pipe_rdwr_fasync(int fd
, struct file
*filp
, int on
)
666 struct inode
*inode
= filp
->f_dentry
->d_inode
;
667 #if 0 // mask by Victor Yu. 02-12-2007
668 struct pipe_inode_info
*pipe
= inode
->i_pipe
;
670 struct pipe_inode_info
*pipe
= inode
->u
.i_pipe
;
674 mutex_lock(&inode
->i_mutex
);
676 retval
= fasync_helper(fd
, filp
, on
, &pipe
->fasync_readers
);
679 retval
= fasync_helper(fd
, filp
, on
, &pipe
->fasync_writers
);
681 mutex_unlock(&inode
->i_mutex
);
691 pipe_read_release(struct inode
*inode
, struct file
*filp
)
693 pipe_read_fasync(-1, filp
, 0);
694 return pipe_release(inode
, 1, 0);
698 pipe_write_release(struct inode
*inode
, struct file
*filp
)
700 pipe_write_fasync(-1, filp
, 0);
701 return pipe_release(inode
, 0, 1);
705 pipe_rdwr_release(struct inode
*inode
, struct file
*filp
)
709 pipe_rdwr_fasync(-1, filp
, 0);
710 decr
= (filp
->f_mode
& FMODE_READ
) != 0;
711 decw
= (filp
->f_mode
& FMODE_WRITE
) != 0;
712 return pipe_release(inode
, decr
, decw
);
716 pipe_read_open(struct inode
*inode
, struct file
*filp
)
718 /* We could have perhaps used atomic_t, but this and friends
719 below are the only places. So it doesn't seem worthwhile. */
720 mutex_lock(&inode
->i_mutex
);
721 #if 0 // mask by Victor Yu. 02-12-2007
722 inode
->i_pipe
->readers
++;
724 inode
->u
.i_pipe
->readers
++;
726 mutex_unlock(&inode
->i_mutex
);
732 pipe_write_open(struct inode
*inode
, struct file
*filp
)
734 mutex_lock(&inode
->i_mutex
);
735 #if 0 // mask by Victor Yu. 02-12-2007
736 inode
->i_pipe
->writers
++;
738 inode
->u
.i_pipe
->writers
++;
740 mutex_unlock(&inode
->i_mutex
);
746 pipe_rdwr_open(struct inode
*inode
, struct file
*filp
)
748 mutex_lock(&inode
->i_mutex
);
749 if (filp
->f_mode
& FMODE_READ
)
750 #if 0 // mask by Victor Yu. 02-12-2007
751 inode
->i_pipe
->readers
++;
753 inode
->u
.i_pipe
->readers
++;
755 if (filp
->f_mode
& FMODE_WRITE
)
756 #if 0 // mask by Victor Yu. 02-12-2007
757 inode
->i_pipe
->writers
++;
759 inode
->u
.i_pipe
->writers
++;
761 mutex_unlock(&inode
->i_mutex
);
767 * The file_operations structs are not static because they
768 * are also used in linux/fs/fifo.c to do operations on FIFOs.
770 const struct file_operations read_fifo_fops
= {
772 .read
= do_sync_read
,
773 .aio_read
= pipe_read
,
777 .open
= pipe_read_open
,
778 .release
= pipe_read_release
,
779 .fasync
= pipe_read_fasync
,
782 const struct file_operations write_fifo_fops
= {
785 .write
= do_sync_write
,
786 .aio_write
= pipe_write
,
789 .open
= pipe_write_open
,
790 .release
= pipe_write_release
,
791 .fasync
= pipe_write_fasync
,
794 const struct file_operations rdwr_fifo_fops
= {
796 .read
= do_sync_read
,
797 .aio_read
= pipe_read
,
798 .write
= do_sync_write
,
799 .aio_write
= pipe_write
,
802 .open
= pipe_rdwr_open
,
803 .release
= pipe_rdwr_release
,
804 .fasync
= pipe_rdwr_fasync
,
807 static struct file_operations read_pipe_fops
= {
809 .read
= do_sync_read
,
810 .aio_read
= pipe_read
,
814 .open
= pipe_read_open
,
815 .release
= pipe_read_release
,
816 .fasync
= pipe_read_fasync
,
819 static struct file_operations write_pipe_fops
= {
822 .write
= do_sync_write
,
823 .aio_write
= pipe_write
,
826 .open
= pipe_write_open
,
827 .release
= pipe_write_release
,
828 .fasync
= pipe_write_fasync
,
831 static struct file_operations rdwr_pipe_fops
= {
833 .read
= do_sync_read
,
834 .aio_read
= pipe_read
,
835 .write
= do_sync_write
,
836 .aio_write
= pipe_write
,
839 .open
= pipe_rdwr_open
,
840 .release
= pipe_rdwr_release
,
841 .fasync
= pipe_rdwr_fasync
,
844 struct pipe_inode_info
* alloc_pipe_info(struct inode
*inode
)
846 struct pipe_inode_info
*pipe
;
848 pipe
= kzalloc(sizeof(struct pipe_inode_info
), GFP_KERNEL
);
850 init_waitqueue_head(&pipe
->wait
);
851 pipe
->r_counter
= pipe
->w_counter
= 1;
858 void __free_pipe_info(struct pipe_inode_info
*pipe
)
862 for (i
= 0; i
< PIPE_BUFFERS
; i
++) {
863 struct pipe_buffer
*buf
= pipe
->bufs
+ i
;
865 buf
->ops
->release(pipe
, buf
);
868 __free_page(pipe
->tmp_page
);
872 void free_pipe_info(struct inode
*inode
)
874 #if 0 // mask by Victor Yu. 02-12-2007
875 __free_pipe_info(inode
->i_pipe
);
876 inode
->i_pipe
= NULL
;
878 __free_pipe_info(inode
->u
.i_pipe
);
879 inode
->u
.i_pipe
= NULL
;
883 static struct vfsmount
*pipe_mnt __read_mostly
;
884 static int pipefs_delete_dentry(struct dentry
*dentry
)
889 static struct dentry_operations pipefs_dentry_operations
= {
890 .d_delete
= pipefs_delete_dentry
,
893 static struct inode
* get_pipe_inode(void)
895 struct inode
*inode
= new_inode(pipe_mnt
->mnt_sb
);
896 struct pipe_inode_info
*pipe
;
901 pipe
= alloc_pipe_info(inode
);
904 #if 0 // mask by Victor Yu. 02-12-2007
905 inode
->i_pipe
= pipe
;
907 inode
->u
.i_pipe
= pipe
;
910 pipe
->readers
= pipe
->writers
= 1;
911 inode
->i_fop
= &rdwr_pipe_fops
;
914 * Mark the inode dirty from the very beginning,
915 * that way it will never be moved to the dirty
916 * list because "mark_inode_dirty()" will think
917 * that it already _is_ on the dirty list.
919 inode
->i_state
= I_DIRTY
;
920 inode
->i_mode
= S_IFIFO
| S_IRUSR
| S_IWUSR
;
921 inode
->i_uid
= current
->fsuid
;
922 inode
->i_gid
= current
->fsgid
;
923 inode
->i_atime
= inode
->i_mtime
= inode
->i_ctime
= CURRENT_TIME
;
934 struct file
*create_write_pipe(void)
939 struct dentry
*dentry
;
943 f
= get_empty_filp();
945 return ERR_PTR(-ENFILE
);
947 inode
= get_pipe_inode();
951 sprintf(name
, "[%lu]", inode
->i_ino
);
953 this.len
= strlen(name
);
954 this.hash
= inode
->i_ino
; /* will go */
956 dentry
= d_alloc(pipe_mnt
->mnt_sb
->s_root
, &this);
960 dentry
->d_op
= &pipefs_dentry_operations
;
961 d_add(dentry
, inode
);
962 f
->f_vfsmnt
= mntget(pipe_mnt
);
963 f
->f_dentry
= dentry
;
964 f
->f_mapping
= inode
->i_mapping
;
966 f
->f_flags
= O_WRONLY
;
967 f
->f_op
= &write_pipe_fops
;
968 f
->f_mode
= FMODE_WRITE
;
974 free_pipe_info(inode
);
981 void free_write_pipe(struct file
*f
)
988 struct file
*create_read_pipe(struct file
*wrf
)
990 struct file
*f
= get_empty_filp();
992 return ERR_PTR(-ENFILE
);
994 /* Grab pipe from the writer */
995 f
->f_vfsmnt
= mntget(wrf
->f_vfsmnt
);
996 f
->f_dentry
= dget(wrf
->f_dentry
);
997 f
->f_mapping
= wrf
->f_dentry
->d_inode
->i_mapping
;
1000 f
->f_flags
= O_RDONLY
;
1001 f
->f_op
= &read_pipe_fops
;
1002 f
->f_mode
= FMODE_READ
;
1008 int do_pipe(int *fd
)
1010 struct file
*fw
, *fr
;
1014 fw
= create_write_pipe();
1017 fr
= create_read_pipe(fw
);
1018 error
= PTR_ERR(fr
);
1020 goto err_write_pipe
;
1022 error
= get_unused_fd();
1027 error
= get_unused_fd();
1032 fd_install(fdr
, fr
);
1033 fd_install(fdw
, fw
);
1044 free_write_pipe(fw
);
1049 * pipefs should _never_ be mounted by userland - too much of security hassle,
1050 * no real gain from having the whole whorehouse mounted. So we don't need
1051 * any operations on the root directory. However, we need a non-trivial
1052 * d_name - pipe: will go nicely and kill the special-casing in procfs.
1054 static int pipefs_get_sb(struct file_system_type
*fs_type
,
1055 int flags
, const char *dev_name
, void *data
,
1056 struct vfsmount
*mnt
)
1058 return get_sb_pseudo(fs_type
, "pipe:", NULL
, PIPEFS_MAGIC
, mnt
);
1061 static struct file_system_type pipe_fs_type
= {
1063 .get_sb
= pipefs_get_sb
,
1064 .kill_sb
= kill_anon_super
,
1067 static int __init
init_pipe_fs(void)
1069 int err
= register_filesystem(&pipe_fs_type
);
1072 pipe_mnt
= kern_mount(&pipe_fs_type
);
1073 if (IS_ERR(pipe_mnt
)) {
1074 err
= PTR_ERR(pipe_mnt
);
1075 unregister_filesystem(&pipe_fs_type
);
1081 static void __exit
exit_pipe_fs(void)
1083 unregister_filesystem(&pipe_fs_type
);
1087 fs_initcall(init_pipe_fs
);
1088 module_exit(exit_pipe_fs
);