chiark / gitweb /
scsi_id: cleanup
[elogind.git] / src / udev / scsi_id / scsi_id.h
1 /*
2  * Copyright (C) IBM Corp. 2003
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #define MAX_PATH_LEN 512
19
20 /*
21  * MAX_ATTR_LEN: maximum length of the result of reading a sysfs
22  * attribute.
23  */
24 #define MAX_ATTR_LEN 256
25
26 /*
27  * MAX_SERIAL_LEN: the maximum length of the serial number, including
28  * added prefixes such as vendor and product (model) strings.
29  */
30 #define MAX_SERIAL_LEN 256
31
32 /*
33  * MAX_BUFFER_LEN: maximum buffer size and line length used while reading
34  * the config file.
35  */
36 #define MAX_BUFFER_LEN 256
37
38 struct scsi_id_device {
39         char vendor[9];
40         char model[17];
41         char revision[5];
42         char type[33];
43         char kernel[64];
44         char serial[MAX_SERIAL_LEN];
45         char serial_short[MAX_SERIAL_LEN];
46         int use_sg;
47
48         /* Always from page 0x80 e.g. 'B3G1P8500RWT' - may not be unique */
49         char unit_serial_number[MAX_SERIAL_LEN];
50
51         /* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */
52         char wwn[17];
53
54         /* NULs if not set - otherwise hex encoding using lower-case e.g. '0xe00000d80000' */
55         char wwn_vendor_extension[17];
56
57         /* NULs if not set - otherwise decimal number */
58         char tgpt_group[8];
59 };
60
61 int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname);
62 int scsi_get_serial(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname,
63                     int page_code, int len);
64
65 /*
66  * Page code values.
67  */
68 enum page_code {
69         PAGE_83_PRE_SPC3 = -0x83,
70         PAGE_UNSPECIFIED = 0x00,
71         PAGE_80          = 0x80,
72         PAGE_83          = 0x83,
73 };