]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: resuse udev handler
authorKarel Zak <kzak@redhat.com>
Mon, 18 Feb 2013 12:37:00 +0000 (13:37 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Feb 2013 12:37:00 +0000 (13:37 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index 9628ba6d8de5959943c9c6e74e6e9b0422a94e80..1d7920376b9b8bba71ebf0a749e846c754e59b8a 100644 (file)
@@ -182,6 +182,10 @@ static size_t nincludes;
 static struct libmnt_table *mtab, *swaps;
 static struct libmnt_cache *mntcache;
 
+#ifdef HAVE_LIBUDEV
+struct udev *udev;
+#endif
+
 struct blkdev_cxt {
        struct blkdev_cxt *parent;
 
@@ -400,13 +404,13 @@ static int get_udev_properties(struct blkdev_cxt *cxt
 #else
 static int get_udev_properties(struct blkdev_cxt *cxt)
 {
-       struct udev *udev;
        struct udev_device *dev;
 
        if (cxt->probed)
                return 0;               /* already done */
 
-       udev = udev_new();
+       if (!udev)
+               udev = udev_new();
        if (!udev)
                return -1;
 
@@ -437,8 +441,6 @@ static int get_udev_properties(struct blkdev_cxt *cxt)
                cxt->probed = 1;
        }
 
-       udev_unref(udev);
-
        return cxt->probed == 1 ? 0 : -1;
 
 }
@@ -1564,5 +1566,8 @@ leave:
        mnt_free_table(mtab);
        mnt_free_table(swaps);
        mnt_free_cache(mntcache);
+#ifdef HAVE_LIBUDEV
+       udev_unref(udev);
+#endif
        return status;
 }