Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 159221 Details for
Bug 186008
Bad page state after issue SCSI Write via SCSI Generic (sg) driver
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
program to reproduce problem
wr.c (text/x-csrc), 5.01 KB, created by
Mike Christie
on 2007-07-13 17:41:13 UTC
(
hide
)
Description:
program to reproduce problem
Filename:
MIME Type:
Creator:
Mike Christie
Created:
2007-07-13 17:41:13 UTC
Size:
5.01 KB
patch
obsolete
>#include <stdlib.h> >#include <unistd.h> >#include <fcntl.h> >#include <stdio.h> >#include <string.h> >#include <errno.h> >#include <sys/stat.h> >#include <sys/ioctl.h> >#include <scsi/sg.h> /* take care: fetches glibc's /usr/include/scsi/sg.h */ > >// version 1.0 > > >#define WR_BUFF_LEN 0x8000 > >//**************************************************** >void mk_sg_dev_file(const char *sg_dev) >{ > char cmdline[1024]; > char junk[5] = ""; > int k; > > if ( strncmp(sg_dev, "/dev/sg", 7) == 0 ) { > strcpy(junk, sg_dev+7); > } > else if ( strncmp(sg_dev, "sg", 2) == 0 ) { > strcpy(junk, sg_dev+2); > k = atoi(junk); > } > else { > printf("mk_sg_dev_file: '%s' does not lead with either '/dev/sg' or 'sg'\n", sg_dev); > return; > } > > > // sprintf(cmdline,"/dev/sg%d", k); > > > if (mknod(sg_dev, S_IFCHR, makedev(21, (unsigned)k))) { > if (errno != EEXIST) > printf("mknod failed: %s (%d) %s\n", > strerror(errno), errno, sg_dev); > } > else { > sprintf(cmdline,"chmod 0660 %s; chown root:disk %s", > sg_dev, sg_dev); > > system(cmdline); > } > > return; >} > > >//**************************************************** >int main(int argc, char * argv[]) >{ > int sg_fd, res_buf_sz; > unsigned int k; > unsigned int nb = 8; > unsigned int block_size = 0x200; > long unsigned int lba = 0; > unsigned char wr_cdb[10] = > {0x2A, 0, 0, 0, 0, 0, 0, 0, 0, 0}; > > unsigned char wrBuff[WR_BUFF_LEN]; > unsigned char sense_buffer[32]; > sg_io_hdr_t io_hdr; > > if (argc < 2 || argc > 3) { > printf("Usage: 'tony <sg_device> <nb>'\n"); > return 1; > } > > if ((sg_fd = open(argv[1], O_RDWR)) < 0) { > if (ENOENT == errno) { > mk_sg_dev_file(argv[1]); > if ((sg_fd = open(argv[1], O_RDWR)) < 0) { > perror("error opening given file name"); > return 1; > } > } > else { > perror("error opening given file name"); > return 1; > } > } > > if (3 == argc) > nb = atoi(argv[2]); > > /* It is prudent to check we have a sg device by trying an ioctl */ > if ((ioctl(sg_fd, SG_GET_VERSION_NUM, &k) < 0) || (k < 30000)) { > printf("%s is not an sg device, or old sg driver\n", argv[1]); > return 1; > } > > if ((nb * block_size) > WR_BUFF_LEN) { > printf("nb=%u is too large for max buffer size of %u(%0Xh) bytes.\n", > nb, WR_BUFF_LEN, WR_BUFF_LEN); > > return 1; > } > > if (nb==0) { > printf("error nb=0\n"); > return 1; > } > > /* added lba and nb to cdb */ > wr_cdb[2] = (u_char)((lba >> 24) & 0xff); > wr_cdb[3] = (u_char)((lba >> 16) & 0xff); > wr_cdb[4] = (u_char)((lba >> 8) & 0xff); > wr_cdb[5] = (u_char)(lba & 0xff); > wr_cdb[7] = (u_char)((nb >> 8) & 0xff); > wr_cdb[8] = (u_char)(nb & 0xff); > > /* Print CDB */ > printf("CDB: "); > for (k = 0; k < sizeof(wr_cdb); ++k) > printf("%02x ", wr_cdb[k]); > printf("\n"); > > > if ( ioctl(sg_fd, SG_GET_RESERVED_SIZE, &res_buf_sz) < 0 ) { > perror("SG_GET_RESERVED_SIZE"); > return 1; > } > printf("SG_GET_RESERVED_SIZE=%d(%0Xh)\n", res_buf_sz, res_buf_sz); > > > /* Prepare command */ > memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); > io_hdr.interface_id = 'S'; > io_hdr.cmd_len = sizeof(wr_cdb); > /* io_hdr.iovec_count = 0; */ /* memset takes care of this */ > io_hdr.mx_sb_len = sizeof(sense_buffer); > io_hdr.dxfer_direction = SG_DXFER_TO_DEV; > io_hdr.dxfer_len = (nb * block_size); > io_hdr.dxferp = wrBuff; > io_hdr.cmdp = wr_cdb; > io_hdr.sbp = sense_buffer; > io_hdr.timeout = 20000; /* 20000 millisecs == 20 seconds */ > /* io_hdr.flags = 0; */ /* take defaults: indirect IO, etc */ > /* io_hdr.pack_id = 0; */ > /* io_hdr.usr_ptr = NULL; */ > > if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) { > perror("SG_IO ioctl error"); > return 1; > } > > /* now for the error processing */ > if ((io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK) { > if (io_hdr.sb_len_wr > 0) { > printf("Sense data: "); > for (k = 0; k < io_hdr.sb_len_wr; ++k) { > if ((k > 0) && (0 == (k % 10))) > printf("\n "); > printf("0x%02x ", sense_buffer[k]); > } > printf("\n"); > } > if (io_hdr.masked_status) > printf("SCSI status=0x%x\n", io_hdr.status); > if (io_hdr.host_status) > printf("host_status=0x%x\n", io_hdr.host_status); > if (io_hdr.driver_status) > printf("driver_status=0x%x\n", io_hdr.driver_status); > } > else > printf("Duration=%ums, dxfer_len=%d, iovec_count=%u, getpagesize=%u\n", > io_hdr.duration, io_hdr.dxfer_len, io_hdr.iovec_count, getpagesize()); > > close(sg_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
.
View Attachment As Raw
Actions:
View
Attachments on
bug 186008
:
126368
|
154358
|
159150
| 159221