~ubuntu-branches/ubuntu/hardy/sg3-utils/hardy

« back to all changes in this revision

Viewing changes to sg_emc_trespass.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-09-19 21:00:55 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060919210055-j9deachd976os9my
Tags: 1.21-1ubuntu1
* Sync with Debian
* debian/control:
  + Let the -dev package depend on the runtime package
* llseek.c:
  + Fix syntax errors. Patch taken from Gentoo:
    http://mir2.ovh.net/gentoo-portage/sys-apps/sg3_utils/files/sg3_utils-llseek.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 *  any later version.
26
26
 */
27
27
 
28
 
static char * version_str = "0.12 20051220";
 
28
static char * version_str = "0.13 20060623";
29
29
 
30
30
static int debug = 0;
31
31
 
32
32
#define TRESPASS_PAGE           0x22
33
33
 
34
 
static void do_trespass(int fd, int hr, int short_cmd)
 
34
static int do_trespass(int fd, int hr, int short_cmd)
35
35
{
36
36
        unsigned char long_trespass_pg[] =
37
37
                { 0, 0, 0, 0, 0, 0, 0, 0x00, 
75
75
                        "'-s' option\n", short_cmd ? "short" : "long",
76
76
                        short_cmd ? "without" : "with");
77
77
                break;
 
78
        case SG_LIB_CAT_NOT_READY:
 
79
                fprintf(stderr, "device not ready\n");
 
80
                break;
 
81
        case SG_LIB_CAT_UNIT_ATTENTION:
 
82
                fprintf(stderr, "unit attention\n");
 
83
                break;
78
84
        default:
79
85
                if (debug)
80
86
                        fprintf(stderr, "%s trespass failed\n",
81
87
                                        short_cmd ? "short" : "long");
82
88
                break;
83
89
        }
 
90
        return res;
84
91
}
85
92
 
86
93
void usage ()
106
113
        int k, fd;
107
114
        int hr = 0;
108
115
        int short_cmd = 0;
 
116
        int ret = 0;
109
117
        
110
118
        if (argc < 2) 
111
119
                usage ();
137
145
        }
138
146
        if (0 == file_name) {
139
147
                usage();
140
 
                return 1;
 
148
                return SG_LIB_SYNTAX_ERROR;
141
149
        }
142
150
                
143
151
        fd = open(file_name, O_RDWR | O_NONBLOCK);
145
153
                fprintf(stderr, "Error trying to open %s\n", file_name);
146
154
                perror("");
147
155
                usage();
148
 
                return 2;
 
156
                return SG_LIB_FILE_ERROR;
149
157
        }
150
158
       
151
 
        do_trespass(fd, hr, short_cmd);
 
159
        ret = do_trespass(fd, hr, short_cmd);
152
160
        
153
161
        close (fd);
154
 
        return 0;
 
162
        return (ret >= 0) ? ret : SG_LIB_CAT_OTHER;
155
163
}