Deleted Added
full compact
pty.c (223575) pty.c (293825)
1/*-
2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Portions of this software were developed under sponsorship from Snow
6 * B.V., the Netherlands.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Portions of this software were developed under sponsorship from Snow
6 * B.V., the Netherlands.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/pty/pty.c 223575 2011-06-26 18:26:20Z ed $");
31__FBSDID("$FreeBSD: head/sys/dev/pty/pty.c 293825 2016-01-13 12:01:28Z kib $");
32
33#include <sys/param.h>
34#include <sys/conf.h>
35#include <sys/eventhandler.h>
36#include <sys/fcntl.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <sys/proc.h>

--- 52 unchanged lines hidden (view full) ---

92 .d_fdopen = ptydev_fdopen,
93 .d_name = "ptydev",
94};
95
96static void
97pty_clone(void *arg, struct ucred *cr, char *name, int namelen,
98 struct cdev **dev)
99{
32
33#include <sys/param.h>
34#include <sys/conf.h>
35#include <sys/eventhandler.h>
36#include <sys/fcntl.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <sys/proc.h>

--- 52 unchanged lines hidden (view full) ---

92 .d_fdopen = ptydev_fdopen,
93 .d_name = "ptydev",
94};
95
96static void
97pty_clone(void *arg, struct ucred *cr, char *name, int namelen,
98 struct cdev **dev)
99{
100 struct make_dev_args mda;
101 int error;
100
101 /* Cloning is already satisfied. */
102 if (*dev != NULL)
103 return;
104
105 /* Only catch /dev/ptyXX. */
106 if (namelen != 5 || bcmp(name, "pty", 3) != 0)
107 return;

--- 4 unchanged lines hidden (view full) ---

112 return;
113
114 /* Only catch /dev/pty[l-sL-S][0-9a-v]. */
115 if (!(name[4] >= '0' && name[4] <= '9') &&
116 !(name[4] >= 'a' && name[4] <= 'v'))
117 return;
118
119 /* Create the controller device node. */
102
103 /* Cloning is already satisfied. */
104 if (*dev != NULL)
105 return;
106
107 /* Only catch /dev/ptyXX. */
108 if (namelen != 5 || bcmp(name, "pty", 3) != 0)
109 return;

--- 4 unchanged lines hidden (view full) ---

114 return;
115
116 /* Only catch /dev/pty[l-sL-S][0-9a-v]. */
117 if (!(name[4] >= '0' && name[4] <= '9') &&
118 !(name[4] >= 'a' && name[4] <= 'v'))
119 return;
120
121 /* Create the controller device node. */
120 *dev = make_dev_credf(MAKEDEV_REF, &ptydev_cdevsw, 0,
121 NULL, UID_ROOT, GID_WHEEL, 0666, "%s", name);
122 make_dev_args_init(&mda);
123 mda.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_REF;
124 mda.mda_devsw = &ptydev_cdevsw;
125 mda.mda_uid = UID_ROOT;
126 mda.mda_gid = GID_WHEEL;
127 mda.mda_mode = 0666;
128 error = make_dev_s(&mda, dev, "%s", name);
129 if (error != 0) {
130 printf("pty_clone: failed to create %s: %d\n", name, error);
131 *dev = NULL;
132 }
122}
123
124static int
125ptmx_fdopen(struct cdev *dev __unused, int fflags, struct thread *td,
126 struct file *fp)
127{
128
129 return (pts_alloc(fflags & (FREAD|FWRITE), td, fp));

--- 31 unchanged lines hidden ---
133}
134
135static int
136ptmx_fdopen(struct cdev *dev __unused, int fflags, struct thread *td,
137 struct file *fp)
138{
139
140 return (pts_alloc(fflags & (FREAD|FWRITE), td, fp));

--- 31 unchanged lines hidden ---