diff -ur CDspindown-1.0b/CDspindown.c CDspindown-1.1/CDspindown.c --- CDspindown-1.0b/CDspindown.c Thu May 23 01:46:50 1996 +++ CDspindown-1.1/CDspindown.c Thu Apr 29 02:06:21 1999 @@ -5,6 +5,9 @@ * v1.0 * 19 May 1996 * + * v1.1 1999-04-27 Dobrica Pavlinusic + * support for 2.2.x kernels, verbose errors + * * This code is distributed under the GNU General Public License * */ @@ -18,6 +21,12 @@ #include #include +/* This shouldn't go here, but I can't include a include from kernel! */ +#ifndef CDROMGETSPINDOWN + #define CDROMGETSPINDOWN 0x531d + #define CDROMSETSPINDOWN 0x531e +#endif + char *intervals[16] = { "vendor specific", "125 ms", @@ -43,6 +52,7 @@ char current, new; int arg, result, verbose=1; char *program_name = argv[0]; +extern errno; if ( (argc > 1) && (*argv[1] == '-') ) { @@ -73,17 +83,17 @@ return 0; } -fd = open(argv[1], O_RDONLY); -if (fd == -1) +fd = open(argv[1], O_RDONLY | O_NONBLOCK ); +if (fd < 0) { - fprintf(stderr, "Error opening device (code=%d).\n", errno); + fprintf(stderr, "Error opening device: %s\n", strerror(errno)); return -1; } result = ioctl(fd, CDROMGETSPINDOWN, ¤t); if (result == -1) { - fprintf(stderr, "CDROMGETSPINDOWN IOCTL error (code=%d).\n", errno); + fprintf(stderr, "CDROMGETSPINDOWN IOCTL error: %s\n", strerror(errno)); return -1; } if ( (current < 0) || (current > 15) ) @@ -110,7 +120,7 @@ result = ioctl(fd, CDROMSETSPINDOWN, &new); if (result == -1) { - fprintf(stderr, "CDROMSETSPINDOWN IOCTL error (code=%d).\n", errno); + fprintf(stderr, "CDROMSETSPINDOWN IOCTL error: %s\n", strerror(errno)); return -1; } if (verbose)