Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Jun 2008 11:20:05 -0700
From:      Sean Bruno <sbruno@miralink.com>
To:        freebsd-firewire@freebsd.org, Hidetoshi Shimokawa <simokawa@FreeBSD.ORG>
Subject:   [Patch] fwcontrol.c: iterate over multiple firewire boards if available
Message-ID:  <486680D5.9070106@miralink.com>

next in thread | raw e-mail | index | archive | help
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?486680D5.9070106>