From owner-freebsd-firewire@FreeBSD.ORG Sat Jun 28 18:20:07 2008 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4B951065671; Sat, 28 Jun 2008 18:20:07 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from plato.miralink.com (mail.miralink.com [70.103.185.20]) by mx1.freebsd.org (Postfix) with ESMTP id 93D0B8FC20; Sat, 28 Jun 2008 18:20:07 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 1B5081A90F4; Sat, 28 Jun 2008 11:19:37 -0700 (PDT) X-Virus-Scanned: amavisd-new at X-Spam-Flag: NO X-Spam-Score: -4.399 X-Spam-Level: X-Spam-Status: No, score=-4.399 tagged_above=-10 required=6.6 tests=[ALL_TRUSTED=-1.8, BAYES_00=-2.599] Received: from plato.miralink.com ([127.0.0.1]) by localhost (plato.miralink.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VC8Er7k4nk-B; Sat, 28 Jun 2008 11:19:36 -0700 (PDT) Received: from [10.47.1.30] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id 6ED9F1A90E4; Sat, 28 Jun 2008 11:19:36 -0700 (PDT) Message-ID: <486680D5.9070106@miralink.com> Date: Sat, 28 Jun 2008 11:20:05 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: freebsd-firewire@freebsd.org, Hidetoshi Shimokawa Content-Type: multipart/mixed; boundary="------------000401030404020107040309" Cc: Subject: [Patch] fwcontrol.c: iterate over multiple firewire boards if available X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jun 2008 18:20:07 -0000 This is a multi-part message in MIME format. --------------000401030404020107040309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit -- Iterate over mulitple f/w boards if there are no arguments passed. Provides the following output for multiple boards: [sean@home-test ~/RELENG_7/src/usr.sbin/fwcontrol]$ sudo ./fwcontrol 1 devices (info_len=1) node EUI64 status hostname 0 00-13-3b-01-00-01-01-82 0 1 devices (info_len=1) node EUI64 status hostname 0 00-11-06-00-00-00-4a-bb 0 Sean --------------000401030404020107040309 Content-Type: text/x-patch; name="fwcontrol.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.c.diff" Only in RELENG_7/src/usr.sbin/fwcontrol: .fwcontrol.c.swp Only in RELENG_7/src/usr.sbin/fwcontrol: fwcontrol Only in RELENG_7/src/usr.sbin/fwcontrol: fwcontrol.8.gz diff -u reference_RELENG_7/src/usr.sbin/fwcontrol/fwcontrol.c RELENG_7/src/usr.sbin/fwcontrol/fwcontrol.c --- reference_RELENG_7/src/usr.sbin/fwcontrol/fwcontrol.c 2008-05-01 23:15:58.000000000 -0700 +++ RELENG_7/src/usr.sbin/fwcontrol/fwcontrol.c 2008-06-28 05:17:21.000000000 -0700 @@ -666,9 +666,12 @@ int main(int argc, char **argv) { +#define MAX_BOARDS 10 u_int32_t crom_buf[1024/4]; - char devbase[1024] = "/dev/fw0"; + char devbase[64]; + const char *device_string = "/dev/fw"; int fd, ch, len=1024; + int dev_counter = 0; long tmp; struct fw_eui64 eui; struct eui64 target; @@ -677,9 +680,20 @@ fd = -1; if (argc < 2) { - open_dev(&fd, devbase); - list_dev(fd); - } + while (dev_counter < MAX_BOARDS) { + snprintf(devbase, sizeof(devbase), "%s%d", device_string, dev_counter); + fd = open(devbase, O_RDWR); + if (fd > 0) { + list_dev(fd); + close(fd); + dev_counter++; + } else { + fd = -1; + dev_counter = MAX_BOARDS; + } + } + } else + snprintf(devbase, sizeof(devbase), "%s%d", device_string, dev_counter); while ((ch = getopt(argc, argv, "M:f:g:m:o:s:b:prtc:d:l:u:R:S:")) != -1) switch(ch) { Only in RELENG_7/src/usr.sbin/fwcontrol: fwcontrol.o Only in RELENG_7/src/usr.sbin/fwcontrol: fwcrom.o Only in RELENG_7/src/usr.sbin/fwcontrol: fwdv.o Only in RELENG_7/src/usr.sbin/fwcontrol: fwmpegts.o --------------000401030404020107040309--