From owner-freebsd-firewire@FreeBSD.ORG Sat Jun 28 18:23:20 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 0F0E51065671; Sat, 28 Jun 2008 18:23:20 +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 D738D8FC1B; Sat, 28 Jun 2008 18:23:19 +0000 (UTC) (envelope-from sbruno@miralink.com) Received: from localhost (localhost.localdomain [127.0.0.1]) by plato.miralink.com (Postfix) with ESMTP id 67FD41A90F4; Sat, 28 Jun 2008 11:22:49 -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 trwE2QDEIoM0; Sat, 28 Jun 2008 11:22:49 -0700 (PDT) Received: from [10.47.1.30] (vpn.office.miralink.com [10.0.0.5]) by plato.miralink.com (Postfix) with ESMTP id D06421A90E4; Sat, 28 Jun 2008 11:22:48 -0700 (PDT) Message-ID: <48668196.6080602@miralink.com> Date: Sat, 28 Jun 2008 11:23:18 -0700 From: Sean Bruno User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: freebsd-firewire@freebsd.org, Hidetoshi Shimokawa References: <486680D5.9070106@miralink.com> In-Reply-To: <486680D5.9070106@miralink.com> Content-Type: multipart/mixed; boundary="------------020908030805080901070407" Cc: Subject: CLEANUP Re: [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:23:20 -0000 This is a multi-part message in MIME format. --------------020908030805080901070407 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sean Bruno wrote: > -- 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 > ------------------------------------------------------------------------ > > _______________________________________________ > freebsd-firewire@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-firewire > To unsubscribe, send any mail to "freebsd-firewire-unsubscribe@freebsd.org" Sorry, I didn't clean up my patch before I sent it. Sean --------------020908030805080901070407 Content-Type: text/x-patch; name="fwcontrol.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwcontrol.c.diff" 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) { --------------020908030805080901070407--