[Patch] fwcontrol.c: iterate over multiple firewire boards if available

Sean Bruno <[email protected]>
Newsgroups gmane.os.freebsd.devel.firewire
Message-ID <[email protected]>
-- 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

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-firewire
To unsubscribe, send any mail to "[email protected]"
fwcontrol.c.diff (text/x-patch, 1.5 KB)
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.