From owner-freebsd-stable Tue Oct 3 10:58:38 2000 Delivered-To: freebsd-stable@freebsd.org Received: from leeann.snedmail.com (lgoldste.dsl.speakeasy.net [64.81.34.20]) by hub.freebsd.org (Postfix) with ESMTP id A297937B502 for ; Tue, 3 Oct 2000 10:58:32 -0700 (PDT) Received: from leeann.snedmail.com (lgoldste@localhost) by leeann.snedmail.com (8.9.3/8.9.3) with ESMTP id KAA18121; Tue, 3 Oct 2000 10:58:31 -0700 (PDT) (envelope-from lgoldste@leeann.snedmail.com) Message-Id: <200010031758.KAA18121@leeann.snedmail.com> To: stable@FreeBSD.ORG Cc: Roman Shterenzon , lgoldste@leeann.snedmail.com Subject: Re: A new file for the base system? In-reply-to: Your message of Tue, 03 Oct 2000 18:01:50 +0300. Date: Tue, 03 Oct 2000 10:58:31 -0700 From: Lee Ann Goldstein Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Your message was: (from Roman Shterenzon) > > 1) Better use /var/run/dmesg.boot since message buffer may get filled with > other stuff. Unless something's changed in 4.1.1-S or 5.0-C, that's not really a problem. dmesg does not take its input from /var/log/messages. This is not necessarily true about dmesg in other *NIXes. > 2) Since perl is a part of a system now, perhaps it'll be prettier to use > perl for that task. *shrug* I speak awk better than I speak perl. Like any other even mildly interesting problem, there are at least half a dozen ways to solve this. I've been working with Stijn Hoop , who identified a locale problem with awk/gawk. This is reproduceable- with LANG set to en_US.ISO_8859-1, awk will not match the expression (<[[:print:]]+>), so a line like pci1: at 0.0 irq 9 does not get turned into pci1 irq 9 pci1.0.0 When LANG is not set, the expression matches as expected. I have no idea if this is a problem with gawk in general, or with the FreeBSD build of it. I note that I can successfully grep for both "<" and ">" regardless of how LANG is set, though this may be a red herring. I'm giving up on the regex problem, and will just unset LANG in my wrapper script. (bleh. nasty hack) I also found and fixed another regex problem, so here's my final form of both scripts. Lee Ann find_irq.sh ----------- #!/bin/sh LANG=;export LANG dmesg | \ ./find_irq.awk | \ sort -n +2 -3 -----end sh script----- find_irq.awk ------------ #!/usr/bin/awk -f ! /irq\>/ {next} /at device/ && /on pci/ {irqinfo = gensub(/(^[a-z0-9]+[: ]).*(irq [0-9]+).*\<([0-9]+\.[0-9]+)\> on (pci[0-9]+)/, "\\1 \\2 \\4.\\3", 1) sub(/:/, "", irqinfo) sub(/ [0-9] /, " &", irqinfo) print irqinfo next } /on pci/ {irqinfo = gensub(/(^[a-z0-9]+[: ]).*(irq [0-9]+).*(pci[0-9]+\.[0-9]+\.[0-9]+)/, "\\1 \\2 \\3", 1) sub(/:/, "", irqinfo) sub(/ [0-9] /, " &", irqinfo) print irqinfo next } /^pci[0-9]+/ {irqinfo = gensub(/(^[a-z0-9]+[: ]).*(<[[:print:]]+>).*\<([0-9]+\.[0-9]+)\> (irq [0-9]+)/,"\\1 \\4 \\1.\\3 \\2", 1) gsub(/:/, "", irqinfo) sub(/ [0-9] /, " &", irqinfo) print irqinfo next } {irqinfo = gensub(/(^[a-z0-9]+[: ]).*(irq [0-9]+).*/, "\\1 \\2", 1) sub(/:/, "", irqinfo) sub(/ [0-9]$/, " &", irqinfo) print irqinfo next } -----end awk script----- -- Lee Ann Goldstein Caffeine is *not* a substitute for sleep. lgoldste@leeann.snedmail.com lgoldste@lafn.org leeann@rand.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message