Date: Sat, 28 Jun 2008 11:23:18 -0700 From: Sean Bruno <sbruno@miralink.com> To: freebsd-firewire@freebsd.org, Hidetoshi Shimokawa <simokawa@FreeBSD.ORG> Subject: CLEANUP Re: [Patch] fwcontrol.c: iterate over multiple firewire boards if available Message-ID: <48668196.6080602@miralink.com> In-Reply-To: <486680D5.9070106@miralink.com> References: <486680D5.9070106@miralink.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48668196.6080602>