5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22
23 /*
24 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
25 */
26
27 /*
28 * The routines defined in this file are supporting routines for FIFOFS
29 * file system type.
30 */
31 #include <sys/types.h>
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/debug.h>
35 #include <sys/errno.h>
36 #include <sys/time.h>
37 #include <sys/kmem.h>
38 #include <sys/inline.h>
39 #include <sys/file.h>
40 #include <sys/proc.h>
41 #include <sys/stat.h>
42 #include <sys/sysmacros.h>
43 #include <sys/var.h>
44 #include <sys/vfs.h>
535 fnp1->fn_flag = fnp2->fn_flag = ISPIPE | FIFOFAST;
536 #endif /* FIFODEBUG */
537 now = gethrestime_sec();
538 fnp1->fn_atime = fnp2->fn_atime = now;
539 fnp1->fn_mtime = fnp2->fn_mtime = now;
540 fnp1->fn_ctime = fnp2->fn_ctime = now;
541
542 *vpp1 = nvp1 = FTOV(fnp1);
543 *vpp2 = nvp2 = FTOV(fnp2);
544
545 fifo_reinit_vp(nvp1); /* Reinitialize vnodes for reuse... */
546 fifo_reinit_vp(nvp2);
547 nvp1->v_vfsp = fifovfsp; /* Need to re-establish VFS & device */
548 nvp2->v_vfsp = fifovfsp; /* before we can reuse this vnode. */
549 nvp1->v_rdev = fifodev;
550 nvp2->v_rdev = fifodev;
551 }
552
553 /*
554 * Attempt to establish a unique pipe id. Only un-named pipes use this
555 * routine.
556 */
557 ino_t
558 fifogetid(void)
559 {
560 static ino_t fifo_ino = 0;
561 ino_t fino;
562
563 mutex_enter(&fino_lock);
564 fino = fifo_ino++;
565 mutex_exit(&fino_lock);
566 return (fino);
567 }
568
569
570 /*
571 * Stream a pipe/FIFO.
572 * The FIFOCONNLD flag is used when CONNLD has been pushed on the stream.
573 * If the flag is set, a new vnode is created by calling fifo_connld().
574 * Connld logic was moved to fifo_connld() to speed up the open
575 * operation, simplify the connld/fifo interaction, and remove inherent
576 * race conditions between the connld module and fifos.
577 * This routine is single threaded for two reasons.
578 * 1) connld requests are synchronous; that is, they must block
579 * until the server does an I_RECVFD (oh, well). Single threading is
580 * the simplest way to accomplish this.
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22
23 /*
24 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
25 *
26 * Copyright 2017 Ivan Richwalski <ivan@seppuku.net>
27 *
28 */
29
30 /*
31 * The routines defined in this file are supporting routines for FIFOFS
32 * file system type.
33 */
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/debug.h>
38 #include <sys/errno.h>
39 #include <sys/time.h>
40 #include <sys/kmem.h>
41 #include <sys/inline.h>
42 #include <sys/file.h>
43 #include <sys/proc.h>
44 #include <sys/stat.h>
45 #include <sys/sysmacros.h>
46 #include <sys/var.h>
47 #include <sys/vfs.h>
538 fnp1->fn_flag = fnp2->fn_flag = ISPIPE | FIFOFAST;
539 #endif /* FIFODEBUG */
540 now = gethrestime_sec();
541 fnp1->fn_atime = fnp2->fn_atime = now;
542 fnp1->fn_mtime = fnp2->fn_mtime = now;
543 fnp1->fn_ctime = fnp2->fn_ctime = now;
544
545 *vpp1 = nvp1 = FTOV(fnp1);
546 *vpp2 = nvp2 = FTOV(fnp2);
547
548 fifo_reinit_vp(nvp1); /* Reinitialize vnodes for reuse... */
549 fifo_reinit_vp(nvp2);
550 nvp1->v_vfsp = fifovfsp; /* Need to re-establish VFS & device */
551 nvp2->v_vfsp = fifovfsp; /* before we can reuse this vnode. */
552 nvp1->v_rdev = fifodev;
553 nvp2->v_rdev = fifodev;
554 }
555
556 /*
557 * Attempt to establish a unique pipe id. Only un-named pipes use this
558 * routine. Use a 32-bit ino_t so any 32-bit processes that aren't large
559 * file aware can still stat() a pipe fd and not fail with EOVERFLOW.
560 */
561 ino_t
562 fifogetid(void)
563 {
564 static ino32_t fifo_ino = 0;
565 ino_t fino;
566
567 mutex_enter(&fino_lock);
568 fino = fifo_ino++;
569 mutex_exit(&fino_lock);
570 return (fino);
571 }
572
573
574 /*
575 * Stream a pipe/FIFO.
576 * The FIFOCONNLD flag is used when CONNLD has been pushed on the stream.
577 * If the flag is set, a new vnode is created by calling fifo_connld().
578 * Connld logic was moved to fifo_connld() to speed up the open
579 * operation, simplify the connld/fifo interaction, and remove inherent
580 * race conditions between the connld module and fifos.
581 * This routine is single threaded for two reasons.
582 * 1) connld requests are synchronous; that is, they must block
583 * until the server does an I_RECVFD (oh, well). Single threading is
584 * the simplest way to accomplish this.
|