xref: /haiku/src/bin/rescan.c (revision 0562493379cd52eb7103531f895f10bb8e77c085)
1 #include <stdio.h>
2 // for O_WRONLY
3 #include <fcntl.h>
4 #include <unistd.h>
5 
6 // 2002, Fran�ois Revol
7 // technical reference:
8 // http://bedriven.be-in.org/document/280-serial_port_driver.html
9 // 2004: bedriven is down now, mirror at:
10 // http://web.archive.org/web/20040220055400/http://bedriven.be-in.org/document/280-serial_port_driver.html
11 
12 int main(int argc, char **argv)
13 {
14 	char *default_scan[] = { "scsi_dsk", "scsi_cd", "ata", "atapi" }; // not really sure here...
15 	char *default_scan_names[] = { "scsi disks", "scsi cdroms", "ide ata", "ide atapi" };
16 	char **scan = default_scan;
17 	char **scan_names = default_scan_names;
18 	int scan_count = 4;
19 	int scan_index = 0;
20 	int fd_dev;
21 
22 	if (argc == 2 && !strcmp(argv[1], "--help")) {
23 		printf("usage: rescan [driver]\n");
24 		return 0;
25 	}
26 	if (argc > 1) {
27 		scan = scan_names = argv;
28 		scan_count = argc;
29 		scan_index++; // not argv[0]
30 	}
31 	for (; scan_index < scan_count; scan_index++) {
32 		printf("scanning %s...\n", scan_names[scan_index]);
33 		fd_dev = open("/dev", O_WRONLY);
34 		write(fd_dev, scan[scan_index], strlen(scan[scan_index]));
35 		close(fd_dev);
36 	}
37 	return 0;
38 }
39 
40