/src/util-linux/libblkid/src/topology/ioctl.c
Line | Count | Source |
1 | | /* |
2 | | * ioctl based topology -- gathers topology information |
3 | | * |
4 | | * Copyright (C) 2009 Karel Zak <kzak@redhat.com> |
5 | | * |
6 | | * This file may be redistributed under the terms of the |
7 | | * GNU Lesser General Public License. |
8 | | * |
9 | | */ |
10 | | #include <stdio.h> |
11 | | #include <string.h> |
12 | | #include <stdlib.h> |
13 | | #include <stdint.h> |
14 | | #include <sys/types.h> |
15 | | #include <sys/stat.h> |
16 | | #include <unistd.h> |
17 | | #include <errno.h> |
18 | | |
19 | | #include "topology.h" |
20 | | |
21 | | static int probe_ioctl_tp(blkid_probe pr, |
22 | | const struct blkid_idmag *mag __attribute__((__unused__))) |
23 | 0 | { |
24 | 0 | uint64_t u64; |
25 | 0 | int s32; |
26 | |
|
27 | 0 | if (ioctl(pr->fd, BLKALIGNOFF, &s32) == -1) |
28 | 0 | return 1; |
29 | 0 | if (blkid_topology_set_alignment_offset(pr, s32)) |
30 | 0 | return -1; |
31 | | |
32 | 0 | if (ioctl(pr->fd, BLKIOMIN, &s32) == -1) |
33 | 0 | return 1; |
34 | 0 | if (blkid_topology_set_minimum_io_size(pr, s32)) |
35 | 0 | return -1; |
36 | | |
37 | 0 | if (ioctl(pr->fd, BLKIOOPT, &s32) == -1) |
38 | 0 | return 1; |
39 | 0 | if (blkid_topology_set_optimal_io_size(pr, s32)) |
40 | 0 | return -1; |
41 | | |
42 | 0 | if (ioctl(pr->fd, BLKPBSZGET, &s32) == -1) |
43 | 0 | return 1; |
44 | 0 | if (blkid_topology_set_physical_sector_size(pr, s32)) |
45 | 0 | return -1; |
46 | | |
47 | 0 | if (ioctl(pr->fd, BLKGETDISKSEQ, &u64) == -1) |
48 | 0 | return 1; |
49 | 0 | if (blkid_topology_set_diskseq(pr, u64)) |
50 | 0 | return -1; |
51 | | |
52 | 0 | return 0; |
53 | 0 | } |
54 | | |
55 | | const struct blkid_idinfo ioctl_tp_idinfo = |
56 | | { |
57 | | .name = "ioctl", |
58 | | .probefunc = probe_ioctl_tp, |
59 | | .magics = BLKID_NONE_MAGIC |
60 | | }; |
61 | | |