Bugzilla – Attachment 65305 Details for
Bug 145147
hald cdrom polling causes scsi errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
SG_IO variant of the test program
getevent.c (text/x-csrc), 1.05 KB, created by
Jens Axboe
on 2006-01-26 19:41:20 UTC
(
hide
)
Description:
SG_IO variant of the test program
Filename:
MIME Type:
Creator:
Jens Axboe
Created:
2006-01-26 19:41:20 UTC
Size:
1.05 KB
patch
obsolete
>#include <stdio.h> >#include <unistd.h> >#include <fcntl.h> >#include <string.h> >#include <sys/ioctl.h> >#include <scsi/sg.h> > >void hexdump(unsigned char *b, int len) >{ > int i; > for (i = 0; i < len; i++) > printf("%02x", b[i]); > > printf("\n"); >} > >int do_getev(int fd) >{ > unsigned char cdb[10] = { 0x4a, 1, 0, 0, 16, 0, 0, 0, 8, }; > unsigned char buffer[8]; > struct sg_io_hdr h; > int ret; > > memset(buffer, 0, sizeof(buffer)); > memset(&h, 0, sizeof(h)); > > h.interface_id = 'S'; > h.cmd_len = sizeof(cdb); > h.dxfer_direction = SG_DXFER_FROM_DEV; > h.dxfer_len = sizeof(buffer); > h.dxferp = buffer; > h.cmdp = cdb; > h.timeout = 5000; > > ret = ioctl(fd, SG_IO, &h); > if (ret) { > printf("SG_IO failed\n"); > return -1; > } > > printf("status %d\n", h.status); > if (!h.status) > hexdump(buffer, sizeof(buffer)); > return h.status; >} > >int main(int argc, char *argv[]) >{ > int fd; > > if (argc < 2) { > fprintf(stderr, "%s: device\n", argv[0]); > return 1; > } > > fd = open(argv[1], O_RDONLY | O_NONBLOCK); > if (fd == -1) { > perror("open"); > return 1; > } > > do_getev(fd); > > close(fd); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 145147
: 65305