summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-11-26 20:35:21 +0000
committerphk <phk@FreeBSD.org>2000-11-26 20:35:21 +0000
commit7101ba5caa38060b2d927dc5bd81c320b7055e6b (patch)
tree4294695f33143e401d4c51b3ef61ebb718ab91c4 /sys
parent7c4763bbdd4cb046f92027fbbfb033f3e9987580 (diff)
downloadFreeBSD-src-7101ba5caa38060b2d927dc5bd81c320b7055e6b.zip
FreeBSD-src-7101ba5caa38060b2d927dc5bd81c320b7055e6b.tar.gz
Simplify the tprintf() API.
Loose the special <sys/tprintf.h> #include file.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_prf.c52
-rw-r--r--sys/nfs/nfs_socket.c9
-rw-r--r--sys/nfsclient/nfs_socket.c9
-rw-r--r--sys/nfsserver/nfs_srvsock.c9
-rw-r--r--sys/sys/systm.h1
-rw-r--r--sys/sys/tprintf.h49
6 files changed, 22 insertions, 107 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 13a4ade..4fb776b 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -46,7 +46,6 @@
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/tty.h>
-#include <sys/tprintf.h>
#include <sys/syslog.h>
#include <sys/cons.h>
@@ -121,53 +120,39 @@ uprintf(const char *fmt, ...)
return retval;
}
-tpr_t
-tprintf_open(p)
- struct proc *p;
-{
-
- if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
- SESSHOLD(p->p_session);
- return ((tpr_t) p->p_session);
- }
- return ((tpr_t) NULL);
-}
-
-void
-tprintf_close(sess)
- tpr_t sess;
-{
-
- if (sess)
- SESSRELE((struct session *) sess);
-}
-
/*
* tprintf prints on the controlling terminal associated
- * with the given session.
+ * with the given session, possibly to the log as well.
*/
-int
-tprintf(tpr_t tpr, const char *fmt, ...)
+void
+tprintf(struct proc *p, int pri, const char *fmt, ...)
{
- struct session *sess = (struct session *)tpr;
struct tty *tp = NULL;
- int flags = TOLOG;
+ int flags = 0, shld = 0;
va_list ap;
struct putchar_arg pca;
int retval;
- logpri(LOG_INFO);
- if (sess && sess->s_ttyvp && ttycheckoutq(sess->s_ttyp, 0)) {
- flags |= TOTTY;
- tp = sess->s_ttyp;
+ if (pri != -1) {
+ logpri(pri);
+ flags |= TOLOG;
+ }
+ if (p->p_flag & P_CONTROLT && p->p_session->s_ttyvp) {
+ SESSHOLD(p->p_session);
+ shld++;
+ if (ttycheckoutq(p->p_session->s_ttyp, 0)) {
+ flags |= TOTTY;
+ tp = p->p_session->s_ttyp;
+ }
}
- va_start(ap, fmt);
pca.tty = tp;
pca.flags = flags;
+ va_start(ap, fmt);
retval = kvprintf(fmt, putchar, &pca, 10, ap);
va_end(ap);
+ if (shld)
+ SESSRELE(p->p_session);
logwakeup();
- return retval;
}
/*
@@ -222,7 +207,6 @@ log(int level, const char *fmt, ...)
va_end(ap);
}
logwakeup();
- return retval;
}
static void
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 7d8bec4..f1ace4e 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -53,7 +53,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
-#include <sys/tprintf.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
@@ -1969,14 +1968,8 @@ nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
{
- tpr_t tpr;
- if (p)
- tpr = tprintf_open(p);
- else
- tpr = NULL;
- tprintf(tpr, "nfs server %s: %s\n", server, msg);
- tprintf_close(tpr);
+ tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
return (0);
}
diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c
index 7d8bec4..f1ace4e 100644
--- a/sys/nfsclient/nfs_socket.c
+++ b/sys/nfsclient/nfs_socket.c
@@ -53,7 +53,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
-#include <sys/tprintf.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
@@ -1969,14 +1968,8 @@ nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
{
- tpr_t tpr;
- if (p)
- tpr = tprintf_open(p);
- else
- tpr = NULL;
- tprintf(tpr, "nfs server %s: %s\n", server, msg);
- tprintf_close(tpr);
+ tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
return (0);
}
diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c
index 7d8bec4..f1ace4e 100644
--- a/sys/nfsserver/nfs_srvsock.c
+++ b/sys/nfsserver/nfs_srvsock.c
@@ -53,7 +53,6 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syslog.h>
-#include <sys/tprintf.h>
#include <sys/sysctl.h>
#include <sys/signalvar.h>
@@ -1969,14 +1968,8 @@ nfs_msg(p, server, msg)
struct proc *p;
char *server, *msg;
{
- tpr_t tpr;
- if (p)
- tpr = tprintf_open(p);
- else
- tpr = NULL;
- tprintf(tpr, "nfs server %s: %s\n", server, msg);
- tprintf_close(tpr);
+ tprintf(p, LOG_INFO, "nfs server %s: %s\n", server, msg);
return (0);
}
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index de83697..fc8b9b1 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -122,6 +122,7 @@ long strtol __P((const char *, char **, int));
u_long strtoul __P((const char *, char **, int));
quad_t strtoq __P((const char *, char **, int));
u_quad_t strtouq __P((const char *, char **, int));
+void tprintf __P((struct proc *p, int pri, const char *, ...)) __printflike(3, 4);
void bcopy __P((const void *from, void *to, size_t len));
void ovbcopy __P((const void *from, void *to, size_t len));
diff --git a/sys/sys/tprintf.h b/sys/sys/tprintf.h
deleted file mode 100644
index ef56609..0000000
--- a/sys/sys/tprintf.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)tprintf.h 8.1 (Berkeley) 6/2/93
- * $FreeBSD$
- */
-
-#ifndef _SYS_TPRINTF_H_
-#define _SYS_TPRINTF_H_
-
-typedef struct session *tpr_t;
-
-struct proc;
-
-tpr_t tprintf_open __P((struct proc *));
-void tprintf_close __P((tpr_t));
-
-int tprintf __P((tpr_t, const char *fmt, ...)) __printflike(2, 3);
-
-#endif
OpenPOWER on IntegriCloud