~ubuntu-branches/debian/stretch/sg3-utils/stretch

« back to all changes in this revision

Viewing changes to src/sg_inq.c

  • Committer: Bazaar Package Importer
  • Author(s): Ritesh Raj Sarraf
  • Date: 2011-08-09 16:36:28 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110809163628-yh8okvhe20j5rekq
Tags: 1.32-1
* [06cef8d] Use kfreebsd-any as the build-dep.
  Thanks to Robert Millan (Closes: 634362)
* [850586d] separate build-arch and build-indep targets
* [a432747] Drop duplicate changelog
* [ec2bbd8] Update Standards Version to 3.9.2. No changes required

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* A utility program originally written for the Linux OS SCSI subsystem.
 
2
*  Copyright (C) 2000-2011 D. Gilbert
 
3
*  This program is free software; you can redistribute it and/or modify
 
4
*  it under the terms of the GNU General Public License as published by
 
5
*  the Free Software Foundation; either version 2, or (at your option)
 
6
*  any later version.
 
7
 
 
8
   This program outputs information provided by a SCSI INQUIRY command.
 
9
   It is mainly based on the SCSI SPC-4 document at http://www.t10.org .
 
10
 
 
11
   Acknowledgment:
 
12
      - Martin Schwenke <martin at meltin dot net> added the raw switch and
 
13
        other improvements [20020814]
 
14
      - Lars Marowsky-Bree <lmb at suse dot de> contributed Unit Path Report
 
15
        VPD page decoding for EMC CLARiiON devices [20041016]
 
16
*/
 
17
 
1
18
#include <unistd.h>
2
19
#include <fcntl.h>
3
20
#include <stdio.h>
22
39
#include "sg_lib.h"
23
40
#include "sg_cmds_basic.h"
24
41
 
25
 
/* A utility program originally written for the Linux OS SCSI subsystem.
26
 
*  Copyright (C) 2000-2011 D. Gilbert
27
 
*  This program is free software; you can redistribute it and/or modify
28
 
*  it under the terms of the GNU General Public License as published by
29
 
*  the Free Software Foundation; either version 2, or (at your option)
30
 
*  any later version.
31
 
 
32
 
   This program outputs information provided by a SCSI INQUIRY command.
33
 
   It is mainly based on the SCSI SPC-4 document at http://www.t10.org .
34
 
 
35
 
   Acknowledgment:
36
 
      - Martin Schwenke <martin at meltin dot net> added the raw switch and
37
 
        other improvements [20020814]
38
 
      - Lars Marowsky-Bree <lmb at suse dot de> contributed Unit Path Report
39
 
        VPD page decoding for EMC CLARiiON devices [20041016]
40
 
*/
41
 
 
42
42
/* INQUIRY notes:
43
43
 * It is recommended that the initial allocation length given to a
44
44
 * standard INQUIRY is 36 (bytes), especially if this is the first
66
66
 * information [MAINTENANCE IN, service action = 0xc]; see sg_opcodes.
67
67
 */
68
68
 
69
 
static char * version_str = "0.97 20110210";    /* SPC-4 rev 28 */
 
69
static char * version_str = "1.01 20110624";    /* SPC-4 rev 31 */
70
70
 
71
71
 
72
72
#define VPD_SUPPORTED_VPDS 0x0
79
79
#define VPD_SCSI_PORTS  0x88
80
80
#define VPD_ATA_INFO  0x89
81
81
#define VPD_POWER_CONDITION  0x8a
 
82
#define VPD_DEVICE_CONSTITUENTS 0x8b
 
83
#define VPD_CFA_PROFILE_INFO  0x8c
82
84
#define VPD_PROTO_LU 0x90
83
85
#define VPD_PROTO_PORT 0x91
84
86
#define VPD_BLOCK_LIMITS 0xb0
326
328
        usage_old();
327
329
}
328
330
 
 
331
/* Processes command line options according to new option format. Returns
 
332
 * 0 is ok, else SG_LIB_SYNTAX_ERROR is returned. */
329
333
static int
330
334
process_cl_new(struct opts_t * optsp, int argc, char * argv[])
331
335
{
431
435
    return 0;
432
436
}
433
437
 
 
438
/* Processes command line options according to old option format. Returns
 
439
 * 0 is ok, else SG_LIB_SYNTAX_ERROR is returned. */
434
440
static int
435
441
process_cl_old(struct opts_t * optsp, int argc, char * argv[])
436
442
{
582
588
    return 0;
583
589
}
584
590
 
 
591
/* Process command line options. First check using new option format unless
 
592
 * the SG3_UTILS_OLD_OPTS environment variable is defined which causes the
 
593
 * old option format to be checked first. Both new and old format can be
 
594
 * countermanded by a '-O' and '-N' options respectively. As soon as either
 
595
 * of these options is detected (when processing the other format), processing
 
596
 * stops and is restarted using the other format. Clear? */
585
597
static int
586
598
process_cl(struct opts_t * optsp, int argc, char * argv[])
587
599
{
642
654
    char * name;
643
655
};
644
656
 
 
657
/* In numerical order */
645
658
static struct vpd_name vpd_name_arr[] = {
646
 
    {VPD_SUPPORTED_VPDS, 0, "Supported VPD pages"},
647
 
    {VPD_UNIT_SERIAL_NUM, 0, "Unit serial number"},
 
659
    {VPD_SUPPORTED_VPDS, 0, "Supported VPD pages"},             /* 0x0 */
 
660
    {VPD_UNIT_SERIAL_NUM, 0, "Unit serial number"},             /* 0x80 */
648
661
    {0x81, 0, "Implemented operating definitions (obsolete)"},
649
662
    {0x82, 0, "ASCII implemented operating definition (obsolete)"},
650
663
    {VPD_DEVICE_ID, 0, "Device identification"},
655
668
    {VPD_SCSI_PORTS, 0, "SCSI ports"},
656
669
    {VPD_ATA_INFO, 0, "ATA information"},
657
670
    {VPD_POWER_CONDITION, 0, "Power condition"},
658
 
    {VPD_BLOCK_LIMITS, 0, "Block limits (sbc2)"},
 
671
    {VPD_DEVICE_CONSTITUENTS, 0, "Device constituents"},
 
672
    {VPD_CFA_PROFILE_INFO, 0, "CFA profile information"},       /* 0x8c */
 
673
    /* 0xb0 to 0xbf are per peripheral device type */
 
674
    {VPD_BLOCK_LIMITS, 0, "Block limits (sbc2)"},               /* 0xb0 */
659
675
    {VPD_BLOCK_DEV_CHARS, 0, "Block device characteristics (sbc3)"},
660
676
    {VPD_LB_PROVISIONING, 0, "Logical block provisioning (sbc3)"},
661
677
    {VPD_REFERRALS, 0, "Referrals (sbc3)"},
663
679
    {0xb2, PDT_TAPE, "TapeAlert supported flags (ssc3)"},
664
680
    {0xb0, PDT_OSD, "OSD information (osd)"},
665
681
    {0xb1, PDT_OSD, "Security token (osd)"},
 
682
    /* 0xc0 to 0xff are vendor specific */
666
683
    {0xc0, 0, "vendor: Firmware numbers (seagate); Unit path report (EMC)"},
667
684
    {0xc1, 0, "vendor: Date code (seagate)"},
668
685
    {0xc2, 0, "vendor: Jumper settings (seagate); Software version (RDAC)"},
897
914
    "Reserved [0xc]", "Reserved [0xd]", "Reserved [0xe]", "Reserved [0xf]",
898
915
};
899
916
 
900
 
/* These are target port, device server (i.e. target) and lu identifiers */
 
917
/* These are target port, device server (i.e. target) and LU identifiers */
901
918
static void
902
919
decode_dev_ids(const char * leadin, unsigned char * buff, int len, int do_hex)
903
920
{
1812
1829
                printf("standard INQUIRY:\n");
1813
1830
            else if (1 == pqual)
1814
1831
                printf("standard INQUIRY: [qualifier indicates no connected "
1815
 
                       "lu]\n");
 
1832
                       "LU]\n");
1816
1833
            else if (3 == pqual)
1817
1834
                printf("standard INQUIRY: [qualifier indicates not capable "
1818
 
                       "of supporting lu]\n");
 
1835
                       "of supporting LU]\n");
1819
1836
            else
1820
1837
                printf("standard INQUIRY: [reserved or vendor specific "
1821
1838
                       "qualifier [%d]\n", pqual);