~ubuntu-branches/ubuntu/wily/sg3-utils/wily

« back to all changes in this revision

Viewing changes to src/sg_modes.c

  • Committer: Package Import Robot
  • Author(s): Ritesh Raj Sarraf
  • Date: 2013-06-23 16:08:01 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20130623160801-7rt7zb2dwk0ba7ut
Tags: 1.36-1
* [69e9dac] Imported Upstream version 1.36
* [cb75936] Add debian compat, level 7
* [68fed25] update README.source
* [3c724fc] Add build-dep autotools-dev
* [e4b9fdd] add destdir to install path
* [7cfff11] Simplify build with debhelper
* [f9a7540] Update symbols for 1.36 release
* [7b0b48d] Enable hardening build

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2000-2013 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 MODE SENSE command.
 
9
 *  Does 10 byte MODE SENSE commands by default, Trent Piepho added a "-6"
 
10
 *  switch for force 6 byte mode sense commands.
 
11
 *  This utility cannot modify mode pages. See the sdparm utility for that.
 
12
 */
 
13
 
1
14
#include <unistd.h>
2
15
#include <fcntl.h>
3
16
#include <stdio.h>
12
25
#include "sg_lib.h"
13
26
#include "sg_cmds_basic.h"
14
27
 
15
 
/*
16
 
*  Copyright (C) 2000-2011 D. Gilbert
17
 
*  This program is free software; you can redistribute it and/or modify
18
 
*  it under the terms of the GNU General Public License as published by
19
 
*  the Free Software Foundation; either version 2, or (at your option)
20
 
*  any later version.
21
 
 
22
 
   This program outputs information provided by a SCSI MODE SENSE command.
23
 
   Does 10 byte MODE SENSE commands by default, Trent Piepho added a "-6"
24
 
   switch for force 6 byte mode sense commands.
25
 
   This utility cannot modify mode pages. See the sdparm utility for that.
26
 
 
27
 
*/
28
 
 
29
 
static char * version_str = "1.37 20111113";
 
28
static const char * version_str = "1.41 20130507";
30
29
 
31
30
#define DEF_ALLOC_LEN (1024 * 4)
32
31
#define DEF_6_ALLOC_LEN 252
119
118
           "sense (10) cdb)\n"
120
119
           "    --maxlen=LEN|-m LEN    max response length (allocation "
121
120
           "length in cdb)\n"
122
 
           "                           (def: 0 -> 4096 or 252 (for MODE SENSE 6) "
123
 
           "bytes)\n"
 
121
           "                           (def: 0 -> 4096 or 252 (for MODE "
 
122
           "SENSE 6) bytes)\n"
124
123
           "    --page=PG|-p PG    page code to fetch (def: 63)\n"
125
124
           "    --page=PG,SPG|-p PG,SPG\n"
126
125
           "                       page code and subpage code to fetch "
133
132
           "SENSE(10)\n"
134
133
           "    --verbose|-v    increase verbosity\n"
135
134
           "    --version|-V    output version string then exit\n\n"
136
 
           "Performs a SCSI MODE SENSE (10 or 6) command\n");
 
135
           "Performs a SCSI MODE SENSE (10 or 6) command. To access and "
 
136
           "possibly change\nmode page fields see the sdparm utility.\n");
137
137
}
138
138
 
139
139
static void
539
539
    {0xb, 0x0, "Medium types supported (obsolete)"},
540
540
    {0xc, 0x0, "Notch and partition (obsolete)"},
541
541
    {0xd, 0x0, "Power condition (obsolete, moved to 0x1a)"},
542
 
    {0x10, 0x0, "XOR control"},
 
542
    {0x10, 0x0, "XOR control"}, /* obsolete in sbc3r32 */
543
543
    {0x1a, 0xf1, "ATA Power condition"},
544
544
    {0x1c, 0x1, "Background control"},
545
545
    {0x1c, 0x2, "Logical block provisioning"},
867
867
    for (header = 0, k = 0; k < PG_CODE_MAX; ++k) {
868
868
        if (optsp->do_six) {
869
869
            res = sg_ll_mode_sense6(sg_fd, 0, 0, k, 0, rbuf, mresp_len,
870
 
                                    0, optsp->do_verbose);
 
870
                                    1, optsp->do_verbose);
871
871
            if (SG_LIB_CAT_INVALID_OP == res) {
872
872
                fprintf(stderr, ">>>>>> try again without the '-6' "
873
873
                        "switch for a 10 byte MODE SENSE command\n");
992
992
            return SG_LIB_SYNTAX_ERROR;
993
993
        }
994
994
        if (opts.maxlen > DEF_ALLOC_LEN) {
995
 
            malloc_rsp_buff = malloc(opts.maxlen);
 
995
            malloc_rsp_buff = (unsigned char *)malloc(opts.maxlen);
996
996
            if (NULL == malloc_rsp_buff) {
997
997
                fprintf(stderr, "Unable to malloc maxlen=%d bytes\n",
998
998
                        opts.maxlen);