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