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