Subject: Re: lseek(2) & read(2) on raw cd(4) device
To: None <smd@ebone.net, tech-kern@netbsd.org>
From: Sean Doran <smd@ebone.net>
List: tech-kern
Date: 08/24/2000 21:08:05
With the simple unified diff below, I get the following results on
the other drive. Note EINVAL instead of EIO. Drive quirk?
Sean.
sean# ./tstdvd -noread
lseek(3, 0, 0) -> 0
lseek(3, 2048, 0) -> 2048
lseek(3, 0, 2) -> 0
lseek(3, 2496425984, 0) -> 2496425984
lseek(3, 0, 1) -> 2496425984
lseek(3, 4096, 1) -> 2496430080
lseek(3, 0, 1) -> 2496430080
lseek(3, 697884672, 0) -> 697884672
lseek(3, 0, 1) -> 697884672
lseek(3, 0, 2) -> 0
lseek(3, 0, 1) -> 0
lseek(3, 8192, 0) -> 8192
lseek(3, 0, 1) -> 8192
sean# ./tstdvd
lseek(3, 0, 0) -> 0
block read OK
lseek(3, 2048, 0) -> 2048
block read OK
lseek(3, 0, 2) -> 0
block read OK
lseek(3, 2496425984, 0) -> 2496425984
block read OK
lseek(3, 0, 1) -> 2496428032
block read OK
lseek(3, 4096, 1) -> 2496434176
errno = 0 read failed: Invalid argument
errno = 22 doing lseek: Invalid argument
errno = 22 doing lseek: Invalid argument
errno = 22 doing lseek: Invalid argument
errno = 22 doing lseek: Invalid argument
errno = 22 doing lseek: Invalid argument
errno = 22 doing lseek: Invalid argument
errno = 22 doing lseek: Invalid argument
ahc0: target 2 synchronous at 10.0MHz, offset = 0xf
cd1(ahc0:2:0): Check Condition on CDB: 0x08 12 99 92 01 00
SENSE KEY: Illegal Request
INFO FIELD: 1218960
ASC/ASCQ: Logical Block Address Out of Range
sean# diff -u ../tstcd.c tstdvd.c
--- ../tstcd.c Thu Aug 24 21:02:58 2000
+++ tstdvd.c Thu Aug 24 21:05:07 2000
@@ -4,7 +4,7 @@
#include <fcntl.h>
#include <errno.h>
-char cd_device[] = "/dev/rcd0d";
+char cd_device[] = "/dev/rcd1d";
void test_lseek(int, off_t, int);
void read_a_block(int);
@@ -36,24 +36,24 @@
test_lseek(fd, (off_t) 0L, SEEK_END);
/* from the disklabel:
- total sectors: 296118
+ total sectors: 1218960
bytes/sector: 2048
*/
/* seek to end but one sector, print where we are */
- test_lseek(fd, (off_t) 2048L * 296116L, SEEK_SET);
- test_lseek(fd, (off_t) 0L, SEEK_CUR);
+ test_lseek(fd, (off_t) 2048L * 1218958L, SEEK_SET);
+ test_lseek(fd, (off_t) 0L, SEEK_CUR);
/* seek two forward, print where we are - shouldn't be able to do this */
test_lseek(fd, (off_t) 2L * 2048L, SEEK_CUR);
test_lseek(fd, (off_t) 0L, SEEK_CUR);
/* seek waaaaaay past the end, print where we are - shouldn't be able to do this */
- test_lseek(fd, (off_t) 2L * 2048L * 296116L, SEEK_SET);
- test_lseek(fd, (off_t) 0L, SEEK_CUR);
+ test_lseek(fd, (off_t) 2L * 2048L * 1218958L, SEEK_SET);
+ test_lseek(fd, (off_t) 0L, SEEK_CUR);
/* try again at end, print where we are */
test_lseek(fd, (off_t) 0L, SEEK_END);
- test_lseek(fd, (off_t) 0L, SEEK_CUR);
+ test_lseek(fd, (off_t) 0L, SEEK_CUR);
/* try again at block 4, print where we are */
test_lseek(fd, (off_t) 4L * 2048L, SEEK_SET);