1*8382dc4bSFrançois Revol /*
2*8382dc4bSFrançois Revol * Copyright 2002, François Revol, revol@free.fr.
3*8382dc4bSFrançois Revol * Distributed under the terms of the MIT License.
4*8382dc4bSFrançois Revol */
5*8382dc4bSFrançois Revol
617049c45SAxel Dörfler #include <fcntl.h>
7*8382dc4bSFrançois Revol #include <stdio.h>
8*8382dc4bSFrançois Revol #include <string.h>
917049c45SAxel Dörfler #include <unistd.h>
1017049c45SAxel Dörfler
11*8382dc4bSFrançois Revol // 2002, François Revol
1217049c45SAxel Dörfler // technical reference:
1317049c45SAxel Dörfler // http://bedriven.be-in.org/document/280-serial_port_driver.html
1417049c45SAxel Dörfler // 2004: bedriven is down now, mirror at:
1517049c45SAxel Dörfler // http://web.archive.org/web/20040220055400/http://bedriven.be-in.org/document/280-serial_port_driver.html
1617049c45SAxel Dörfler
main(int argc,char ** argv)1717049c45SAxel Dörfler int main(int argc, char **argv)
1817049c45SAxel Dörfler {
1917049c45SAxel Dörfler char *default_scan[] = { "scsi_dsk", "scsi_cd", "ata", "atapi" }; // not really sure here...
2017049c45SAxel Dörfler char *default_scan_names[] = { "scsi disks", "scsi cdroms", "ide ata", "ide atapi" };
2117049c45SAxel Dörfler char **scan = default_scan;
2217049c45SAxel Dörfler char **scan_names = default_scan_names;
2317049c45SAxel Dörfler int scan_count = 4;
2417049c45SAxel Dörfler int scan_index = 0;
2517049c45SAxel Dörfler int fd_dev;
2617049c45SAxel Dörfler
2717049c45SAxel Dörfler if (argc == 2 && !strcmp(argv[1], "--help")) {
2817049c45SAxel Dörfler printf("usage: rescan [driver]\n");
2917049c45SAxel Dörfler return 0;
3017049c45SAxel Dörfler }
3117049c45SAxel Dörfler if (argc > 1) {
3217049c45SAxel Dörfler scan = scan_names = argv;
3317049c45SAxel Dörfler scan_count = argc;
3417049c45SAxel Dörfler scan_index++; // not argv[0]
3517049c45SAxel Dörfler }
3617049c45SAxel Dörfler for (; scan_index < scan_count; scan_index++) {
3717049c45SAxel Dörfler printf("scanning %s...\n", scan_names[scan_index]);
3817049c45SAxel Dörfler fd_dev = open("/dev", O_WRONLY);
3917049c45SAxel Dörfler write(fd_dev, scan[scan_index], strlen(scan[scan_index]));
4017049c45SAxel Dörfler close(fd_dev);
4117049c45SAxel Dörfler }
4217049c45SAxel Dörfler return 0;
4317049c45SAxel Dörfler }
4417049c45SAxel Dörfler
45