2 get_serial (int fd, char * str)
4 char buff[MX_ALLOC_LEN + 1];
7 if (0 == do_inq(fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0)) {
10 memcpy(str, buff + 4, len);
21 unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
22 struct sg_io_hdr io_hdr;
23 unsigned char sense_buffer[32];
25 memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
26 io_hdr.interface_id = 'S';
27 io_hdr.cmd_len = sizeof (turCmdBlk);
28 io_hdr.mx_sb_len = sizeof (sense_buffer);
29 io_hdr.dxfer_direction = SG_DXFER_NONE;
30 io_hdr.cmdp = turCmdBlk;
31 io_hdr.sbp = sense_buffer;
32 io_hdr.timeout = 20000;
34 if (ioctl(fd, SG_IO, &io_hdr) < 0) {
38 if (io_hdr.info & SG_INFO_OK_MASK) {
48 if (!(dmt = dm_task_create(DM_DEVICE_REMOVE)))
50 if (!dm_task_set_name(dmt, str))
52 if (!dm_task_run(dmt))
55 printf("Deleted device map : %s\n", str);
62 get_table(const char * str)
67 uint64_t start, length;
68 char *target_type = NULL;
71 if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
74 if (!dm_task_set_name(dmt, str))
77 if (!dm_task_run(dmt))
81 next = dm_get_next_target(dmt, next, &start, &length,
82 &target_type, ¶ms);
84 printf("%" PRIu64 " %" PRIu64 " %s %s\n",
85 start, length, target_type, params);