subr_prf.c (5580b0b1576de5c5b71774eb62b749e69d09c55a) subr_prf.c (329c75a73044af0f5a628267c024628cd4a609c3)
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

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

122uprintf(const char *fmt, ...)
123{
124 struct thread *td = curthread;
125 struct proc *p = td->td_proc;
126 va_list ap;
127 struct putchar_arg pca;
128 int retval;
129
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

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

122uprintf(const char *fmt, ...)
123{
124 struct thread *td = curthread;
125 struct proc *p = td->td_proc;
126 va_list ap;
127 struct putchar_arg pca;
128 int retval;
129
130 GIANT_REQUIRED;
131 if (td == NULL || td == PCPU_GET(idlethread))
132 return (0);
133
130 if (td == NULL || td == PCPU_GET(idlethread))
131 return (0);
132
133 mtx_lock(&Giant);
134 p = td->td_proc;
135 PROC_LOCK(p);
136 if ((p->p_flag & P_CONTROLT) == 0) {
137 PROC_UNLOCK(p);
134 p = td->td_proc;
135 PROC_LOCK(p);
136 if ((p->p_flag & P_CONTROLT) == 0) {
137 PROC_UNLOCK(p);
138 return (0);
138 retval = 0;
139 goto out;
139 }
140 SESS_LOCK(p->p_session);
141 pca.tty = p->p_session->s_ttyp;
142 SESS_UNLOCK(p->p_session);
143 PROC_UNLOCK(p);
140 }
141 SESS_LOCK(p->p_session);
142 pca.tty = p->p_session->s_ttyp;
143 SESS_UNLOCK(p->p_session);
144 PROC_UNLOCK(p);
144 if (pca.tty == NULL)
145 return (0);
145 if (pca.tty == NULL) {
146 retval = 0;
147 goto out;
148 }
146 pca.flags = TOTTY;
147 va_start(ap, fmt);
148 retval = kvprintf(fmt, putchar, &pca, 10, ap);
149 va_end(ap);
149 pca.flags = TOTTY;
150 va_start(ap, fmt);
151 retval = kvprintf(fmt, putchar, &pca, 10, ap);
152 va_end(ap);
150
153out:
154 mtx_unlock(&Giant);
151 return (retval);
152}
153
154/*
155 * tprintf prints on the controlling terminal associated with the given
156 * session, possibly to the log as well.
157 */
158void
159tprintf(struct proc *p, int pri, const char *fmt, ...)
160{
161 struct tty *tp = NULL;
162 int flags = 0;
163 va_list ap;
164 struct putchar_arg pca;
165 struct session *sess = NULL;
166
155 return (retval);
156}
157
158/*
159 * tprintf prints on the controlling terminal associated with the given
160 * session, possibly to the log as well.
161 */
162void
163tprintf(struct proc *p, int pri, const char *fmt, ...)
164{
165 struct tty *tp = NULL;
166 int flags = 0;
167 va_list ap;
168 struct putchar_arg pca;
169 struct session *sess = NULL;
170
167 GIANT_REQUIRED;
171 mtx_lock(&Giant);
168 if (pri != -1)
169 flags |= TOLOG;
170 if (p != NULL) {
171 PROC_LOCK(p);
172 if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
173 sess = p->p_session;
174 SESS_LOCK(sess);
175 PROC_UNLOCK(p);

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

187 pca.tty = tp;
188 pca.flags = flags;
189 va_start(ap, fmt);
190 kvprintf(fmt, putchar, &pca, 10, ap);
191 va_end(ap);
192 if (sess != NULL)
193 SESSRELE(sess);
194 msgbuftrigger = 1;
172 if (pri != -1)
173 flags |= TOLOG;
174 if (p != NULL) {
175 PROC_LOCK(p);
176 if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
177 sess = p->p_session;
178 SESS_LOCK(sess);
179 PROC_UNLOCK(p);

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

191 pca.tty = tp;
192 pca.flags = flags;
193 va_start(ap, fmt);
194 kvprintf(fmt, putchar, &pca, 10, ap);
195 va_end(ap);
196 if (sess != NULL)
197 SESSRELE(sess);
198 msgbuftrigger = 1;
199 mtx_unlock(&Giant);
195}
196
197/*
198 * Ttyprintf displays a message on a tty; it should be used only by
199 * the tty driver, or anything that knows the underlying tty will not
200 * be revoke(2)'d away. Other callers should use tprintf.
201 */
202int

--- 778 unchanged lines hidden ---
200}
201
202/*
203 * Ttyprintf displays a message on a tty; it should be used only by
204 * the tty driver, or anything that knows the underlying tty will not
205 * be revoke(2)'d away. Other callers should use tprintf.
206 */
207int

--- 778 unchanged lines hidden ---