From owner-freebsd-hackers Tue Jan 16 23:18:57 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from moby.geekhouse.net (moby.geekhouse.net [64.81.6.36]) by hub.freebsd.org (Postfix) with ESMTP id B68BA37B400 for ; Tue, 16 Jan 2001 23:18:36 -0800 (PST) Received: from laptop.baldwin.cx (john@dhcp150.geekhouse.net [192.168.1.150]) by moby.geekhouse.net (8.11.0/8.9.3) with ESMTP id f0H7MUs64531; Tue, 16 Jan 2001 23:22:30 -0800 (PST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20010116230007.A27043@meow.osd.bsdi.com> Date: Tue, 16 Jan 2001 23:18:40 -0800 (PST) From: John Baldwin To: Eric Melville Subject: RE: syslogd patch Cc: freebsd-hackers@FreeBSD.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 17-Jan-01 Eric Melville wrote: > Printing out the whole path to the kernel all the time in syslog messages is > a bit redundant and ugly, especially seeing that it isn't done for any other > binaries. > > Should I send-pr this thing too, or is just sending it to -hackers enough? > > --- usr/src/usr.sbin/syslogd/syslogd.c.old Sat Jan 13 21:20:28 2001 > +++ usr/src/usr.sbin/syslogd/syslogd.c Sat Jan 13 22:27:44 2001 > @@ -734,8 +734,8 @@ > int flags; > { > struct filed *f; > - int i, fac, msglen, omask, prilev; > - char *timestamp; > + int i, fac, msglen, omask, prilev, bflen; > + char *timestamp, *bfshort; > char prog[NAME_MAX+1]; > char buf[MAXLINE+1]; > > @@ -784,7 +784,16 @@ > > /* add kernel prefix for kernel messages */ > if (flags & ISKERNEL) { > - snprintf(buf, sizeof(buf), "%s: %s", bootfile, msg); > + /* ignore path to kernel */ > + bflen = strlen(bootfile); > + bfshort = bootfile; > + while(bflen--) > + if(*(bootfile+bflen) == '/') > + { > + bfshort = bootfile+bflen+1; > + break; > + } > + snprintf(buf, sizeof(buf), "%s: %s", bfshort, msg); You could use strrchr(3) here instead of rolling your own loop. However, this will print out 'kernel' for every kernel. If I 'boot kernel.foo' from the loader, then the bootfile will be /boot/kernel.foo/kernel, and this will trim the /boot/kenrel.foo/ part. The kernel.foo part is actually the important part, however, so I'd prefer it to not do this. -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message