Date: Tue, 6 Jan 2004 07:33:29 -0800 (PST) From: Issei Numata <issei@guru.gr.jp> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/60981: cannot obtain error(sense key, APC,..) while using ATAPICMD with /dev/ata Message-ID: <200401061533.i06FXT8m088148@www.freebsd.org> Resent-Message-ID: <200401061540.i06FeD1V094490@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 60981 >Category: kern >Synopsis: cannot obtain error(sense key, APC,..) while using ATAPICMD with /dev/ata >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jan 06 07:40:13 PST 2004 >Closed-Date: >Last-Modified: >Originator: Issei Numata >Release: 4.9-STABLE >Organization: Heart Solutions JP >Environment: FreeBSD puchiko.private 4.9-STABLE FreeBSD 4.9-STABLE #0: Tue Jan 6 15:18:32 JST 2004 issei@puchiko.private:/usr/src/sys/compile/GENERIC i386 >Description: I found Stable BSD cannot obtain error information while using ATAPICMD with /dev/ata >How-To-Repeat: Here is a simple program. please run it under the CD tray opened. This conditon cause error, but contents of sense_data is not a valid data. This is because bopy's first argument is incorrect(see patch) #include <stdio.h> #include <sys/types.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/ata.h> #include <camlib.h> #include <errno.h> int main() { struct ata_cmd cmd; int fd; int ret; int i; char buf[256] = {0}; fd = open("/dev/ata", O_RDWR); fprintf(stderr, "fd=%d\n", fd); memset(&cmd, 0, sizeof(cmd)); memset(buf, 0, sizeof(buf)); cmd.channel = 0; cmd.device = 1; cmd.cmd = ATAPICMD; cmd.u.atapi.ccb[0] = 0x25; cmd.u.atapi.flags = ATAPI_CMD_READ; cmd.u.atapi.data = buf; cmd.u.atapi.count = 256; cmd.u.atapi.timeout = 30; ret = ioctl(fd, IOCATA, &cmd); fprintf(stderr, "ioctl=%d\n", ret); fprintf(stderr, "errno=%d\n", errno); fprintf(stderr, "error=%d\n", cmd.u.atapi.error); for(i=0 ; i<32 ; ++i){ fprintf(stderr, "%02x ", buf[i] & 0xff); } fprintf(stderr, "\n\n"); for(i=0 ; i<17 ; ++i){ fprintf(stderr, "%02x ", cmd.u.atapi.sense_data[i] & 0xff); } fprintf(stderr, "\n"); sleep(1); close(fd); return 0; } >Fix: diff -c /sys/dev/ata/ata-all.c.orig /sys/dev/ata/ata-all.c *** /sys/dev/ata/ata-all.c.orig Tue Jan 6 15:33:49 2004 --- /sys/dev/ata/ata-all.c Tue Jan 6 15:33:54 2004 *************** *** 447,453 **** iocmd->u.atapi.timeout, NULL, NULL); if (error) { iocmd->u.atapi.error = error; ! bcopy(&atadev->result, iocmd->u.atapi.sense_data, sizeof(struct atapi_reqsense)); error = 0; } --- 447,453 ---- iocmd->u.atapi.timeout, NULL, NULL); if (error) { iocmd->u.atapi.error = error; ! bcopy(atadev->result, iocmd->u.atapi.sense_data, sizeof(struct atapi_reqsense)); error = 0; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401061533.i06FXT8m088148>