| 1 |
/* |
| 2 |
* ioctl based topology -- gathers topology information |
| 3 |
* |
| 4 |
* Copyright (C) 2009 Karel Zak <[email protected]> |
| 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 |
{ |
| 24 |
uint64_t u64; |
| 25 |
int s32; |
| 26 |
|
| 27 |
if (ioctl(pr->fd, BLKALIGNOFF, &s32) == -1) |
| 28 |
return 1; |
| 29 |
if (blkid_topology_set_alignment_offset(pr, s32)) |
| 30 |
return -1; |
| 31 |
|
| 32 |
if (ioctl(pr->fd, BLKIOMIN, &s32) == -1) |
| 33 |
return 1; |
| 34 |
if (blkid_topology_set_minimum_io_size(pr, s32)) |
| 35 |
return -1; |
| 36 |
|
| 37 |
if (ioctl(pr->fd, BLKIOOPT, &s32) == -1) |
| 38 |
return 1; |
| 39 |
if (blkid_topology_set_optimal_io_size(pr, s32)) |
| 40 |
return -1; |
| 41 |
|
| 42 |
if (ioctl(pr->fd, BLKPBSZGET, &s32) == -1) |
| 43 |
return 1; |
| 44 |
if (blkid_topology_set_physical_sector_size(pr, s32)) |
| 45 |
return -1; |
| 46 |
|
| 47 |
if (ioctl(pr->fd, BLKGETDISKSEQ, &u64) == -1) |
| 48 |
return 1; |
| 49 |
if (blkid_topology_set_diskseq(pr, u64)) |
| 50 |
return -1; |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |
| 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 |
|