]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: add sysfs_blkdev_get_parent()
authorKarel Zak <kzak@redhat.com>
Wed, 16 May 2018 11:20:01 +0000 (13:20 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 21 Jun 2018 11:07:46 +0000 (13:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/sysfs.h
lib/sysfs.c

index ea87d6a125cde2dd3b099a2c689b0bb441a1c3fb..a7e66f74b8406fee40938a193f545a656f8cfd22 100644 (file)
@@ -68,7 +68,9 @@ void ul_sysfs_init_debug(void);
 
 struct path_cxt *ul_new_sysfs_path(dev_t devno, struct path_cxt *parent, const char *prefix);
 int sysfs_blkdev_init_path(struct path_cxt *pc, dev_t devno, struct path_cxt *parent);
+
 int sysfs_blkdev_set_parent(struct path_cxt *pc, struct path_cxt *parent);
+struct path_cxt *sysfs_blkdev_get_parent(struct path_cxt *pc);
 
 char *sysfs_blkdev_get_name(struct path_cxt *pc, char *buf, size_t bufsiz);
 int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *parent_name);
index 5b4031e00b043f0bbe0138fcf7faf79207c64644..953627715d982f6a79c22057f671d8aad8404713 100644 (file)
@@ -148,6 +148,12 @@ int sysfs_blkdev_set_parent(struct path_cxt *pc, struct path_cxt *parent)
        return 0;
 }
 
+struct path_cxt *sysfs_blkdev_get_parent(struct path_cxt *pc)
+{
+       struct sysfs_blkdev *blk = ul_path_get_dialect(pc);
+       return blk ? blk->parent : NULL;
+}
+
 /*
  * Redirects ENOENT errors to the parent, if the path is to the queue/
  * sysfs directory. For example