]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/lsblk.h
8817314afd9da1378f90b0a2258809c3ed1b868e
[thirdparty/util-linux.git] / misc-utils / lsblk.h
1 /*
2 * Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
3 * Written by Milan Broz <mbroz@redhat.com>
4 * Karel Zak <kzak@redhat.com>
5 */
6 #ifndef UTIL_LINUX_LSBLK_H
7 #define UTIL_LINUX_LSBLK_H
8
9 #include <stdint.h>
10 #include <inttypes.h>
11 #include <sys/statvfs.h>
12
13 #include <libsmartcols.h>
14
15 #include "c.h"
16 #include "debug.h"
17
18 #define LSBLK_DEBUG_INIT (1 << 1)
19 #define LSBLK_DEBUG_FILTER (1 << 2)
20 #define LSBLK_DEBUG_DEV (1 << 3)
21 #define LSBLK_DEBUG_CXT (1 << 4)
22 #define LSBLK_DEBUG_ALL 0xFFFF
23
24 UL_DEBUG_DECLARE_MASK(lsblk);
25 #define DBG(m, x) __UL_DBG(lsblk, LSBLK_DEBUG_, m, x)
26 #define ON_DBG(m, x) __UL_DBG_CALL(lsblk, LSBLK_DEBUG_, m, x)
27
28 #define UL_DEBUG_CURRENT_MASK UL_DEBUG_MASK(lsblk)
29 #include "debugobj.h"
30
31 struct lsblk {
32 struct libscols_table *table; /* output table */
33 struct libscols_column *sort_col;/* sort output by this column */
34 int sort_id;
35
36 const char *sysroot;
37 int flags; /* LSBLK_* */
38
39 unsigned int all_devices:1; /* print all devices, including empty */
40 unsigned int bytes:1; /* print SIZE in bytes */
41 unsigned int inverse:1; /* print inverse dependencies */
42 unsigned int nodeps:1; /* don't print slaves/holders */
43 unsigned int scsi:1; /* print only device with HCTL (SCSI) */
44 unsigned int paths:1; /* print devnames with "/dev" prefix */
45 unsigned int sort_hidden:1; /* sort column not between output columns */
46 unsigned int force_tree_order:1;/* sort lines by parent->tree relation */
47 };
48
49 extern struct lsblk *lsblk; /* global handler */
50
51 struct blkdev_cxt {
52 struct blkdev_cxt *parent;
53
54 struct libscols_line *scols_line;
55 struct stat st;
56
57 char *name; /* kernel name in /sys/block */
58 char *dm_name; /* DM name (dm/block) */
59
60 char *filename; /* path to device node */
61
62 struct path_cxt *sysfs;
63
64 int partition; /* is partition? TRUE/FALSE */
65
66 int probed; /* already probed */
67 char *fstype; /* detected fs, NULL or "?" if cannot detect */
68 char *uuid; /* filesystem UUID (or stack uuid) */
69 char *ptuuid; /* partition table UUID */
70 char *pttype; /* partition table type */
71 char *label; /* filesystem label */
72 char *parttype; /* partition type UUID */
73 char *partuuid; /* partition UUID */
74 char *partlabel; /* partition label */
75 char *partflags; /* partition flags */
76 char *wwn; /* storage WWN */
77 char *serial; /* disk serial number */
78 char *model; /* disk model */
79
80 char *mountpoint; /* device mountpoint */
81 struct statvfs fsstat; /* statvfs() result */
82
83 int npartitions; /* # of partitions this device has */
84 int nholders; /* # of devices mapped directly to this device
85 * /sys/block/.../holders */
86 int nslaves; /* # of devices this device maps to */
87 int maj, min; /* devno */
88 int discard; /* supports discard */
89
90 uint64_t size; /* device size */
91
92 unsigned int is_mounted : 1;
93 };
94
95 /* lsblk-mnt.c */
96 extern void lsblk_mnt_init(void);
97 extern void lsblk_mnt_deinit(void);
98
99 extern char *lsblk_device_get_mountpoint(struct blkdev_cxt *cxt);
100
101 #endif /* UTIL_LINUX_LSBLK_H */