]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/lsblk.h
lsblk: add --noempty
[thirdparty/util-linux.git] / misc-utils / lsblk.h
index a043e7fd76ecce2dae8914c2f3dc56cfb78aa8c1..0ffe380088810bf02dcc706b87a640f128ca11a2 100644 (file)
@@ -12,6 +12,7 @@
 #include <sys/statvfs.h>
 
 #include <libsmartcols.h>
+#include <libmount.h>
 
 #include "c.h"
 #include "list.h"
@@ -33,12 +34,14 @@ UL_DEBUG_DECLARE_MASK(lsblk);
 
 struct lsblk {
        struct libscols_table *table;   /* output table */
-
        struct libscols_column *sort_col;/* sort output by this column */
-       int sort_id;
+
+       int sort_id;                    /* id of the sort column */
+       int tree_id;                    /* od of column used for tree */
 
        int dedup_id;
 
+
        const char *sysroot;
        int flags;                      /* LSBLK_* */
 
@@ -52,12 +55,15 @@ struct lsblk {
        unsigned int sort_hidden:1;     /* sort column not between output columns */
        unsigned int dedup_hidden :1;   /* deduplication column not between output columns */
        unsigned int force_tree_order:1;/* sort lines by parent->tree relation */
+       unsigned int noempty:1;         /* hide empty devices */
 };
 
 extern struct lsblk *lsblk;     /* global handler */
 
 struct lsblk_devprop {
+       /* udev / blkid based */
        char *fstype;           /* detected fs, NULL or "?" if cannot detect */
+       char *fsversion;        /* filesystem version */
        char *uuid;             /* filesystem UUID (or stack uuid) */
        char *ptuuid;           /* partition table UUID */
        char *pttype;           /* partition table type */
@@ -69,6 +75,11 @@ struct lsblk_devprop {
        char *wwn;              /* storage WWN */
        char *serial;           /* disk serial number */
        char *model;            /* disk model */
+
+       /* lsblk specific (for --sysroot only)  */
+       char *owner;            /* user name */
+       char *group;            /* group name */
+       char *mode;             /* access mode in ls(1)-like notation */
 };
 
 /* Device dependence
@@ -107,7 +118,9 @@ struct lsblk_device {
 
        struct path_cxt *sysfs;
 
-       char *mountpoint;       /* device mountpoint */
+       struct libmnt_fs **fss; /* filesystems attached to the device */
+       size_t nfss;            /* number of items in fss[] */
+
        struct statvfs fsstat;  /* statvfs() result */
 
        int npartitions;        /* # of partitions this device has */
@@ -125,13 +138,26 @@ struct lsblk_device {
                        is_swap : 1,
                        is_printed : 1,
                        udev_requested : 1,
-                       blkid_requested : 1;
+                       blkid_requested : 1,
+                       file_requested : 1;
 };
 
 #define device_is_partition(_x)                ((_x)->wholedisk != NULL)
 
+/* Unfortunately, pktcdvd dependence on block device is not defined by
+ * slave/holder symlinks. The struct lsblk_devnomap represents one line in
+ * /sys/class/pktcdvd/device_map
+ */
+struct lsblk_devnomap {
+       dev_t slave;            /* packet device devno */
+       dev_t holder;           /* block device devno */
+
+       struct list_head ls_devnomap;
+};
+
+
 /*
- * Note that lsblk tree uses botton devices (devices without slaves) as root
+ * Note that lsblk tree uses bottom devices (devices without slaves) as root
  * of the tree, and partitions are interpreted as a dependence too; it means:
  *    sda -> sda1 -> md0
  *
@@ -143,8 +169,10 @@ struct lsblk_devtree {
 
        struct list_head        roots;          /* tree root devices */
        struct list_head        devices;        /* all devices */
+       struct list_head        pktcdvd_map;    /* devnomap->ls_devnomap */
 
-       unsigned int    is_inverse : 1;         /* inverse tree */
+       unsigned int    is_inverse : 1,         /* inverse tree */
+                       pktcdvd_read : 1;
 };
 
 
@@ -182,13 +210,17 @@ struct lsblk_iter {
 extern void lsblk_mnt_init(void);
 extern void lsblk_mnt_deinit(void);
 
-extern char *lsblk_device_get_mountpoint(struct lsblk_device *dev);
+extern void lsblk_device_free_filesystems(struct lsblk_device *dev);
+extern const char *lsblk_device_get_mountpoint(struct lsblk_device *dev);
+extern struct libmnt_fs **lsblk_device_get_filesystems(struct lsblk_device *dev, size_t *n);
 
 /* lsblk-properties.c */
 extern void lsblk_device_free_properties(struct lsblk_devprop *p);
 extern struct lsblk_devprop *lsblk_device_get_properties(struct lsblk_device *dev);
 extern void lsblk_properties_deinit(void);
 
+extern const char *lsblk_parttype_code_to_string(const char *code, const char *pttype);
+
 /* lsblk-devtree.c */
 void lsblk_reset_iter(struct lsblk_iter *itr, int direction);
 struct lsblk_device *lsblk_new_device(void);
@@ -200,6 +232,8 @@ int lsblk_device_next_child(struct lsblk_device *dev,
                           struct lsblk_iter *itr,
                           struct lsblk_device **child);
 
+dev_t lsblk_devtree_pktcdvd_get_mate(struct lsblk_devtree *tr, dev_t devno, int is_slave);
+
 int lsblk_device_is_last_parent(struct lsblk_device *dev, struct lsblk_device *parent);
 int lsblk_device_next_parent(
                         struct lsblk_device *dev,
@@ -210,6 +244,7 @@ struct lsblk_devtree *lsblk_new_devtree(void);
 void lsblk_ref_devtree(struct lsblk_devtree *tr);
 void lsblk_unref_devtree(struct lsblk_devtree *tr);
 int lsblk_devtree_add_root(struct lsblk_devtree *tr, struct lsblk_device *dev);
+int lsblk_devtree_remove_root(struct lsblk_devtree *tr, struct lsblk_device *dev);
 int lsblk_devtree_next_root(struct lsblk_devtree *tr,
                             struct lsblk_iter *itr,
                             struct lsblk_device **dev);