File volume_id-fix-logging.patch of Package udev

diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c
index 79ed099..9e8133b 100644
--- a/extras/volume_id/vol_id.c
+++ b/extras/volume_id/vol_id.c
@@ -38,6 +38,7 @@
 
 #define BLKGETSIZE64 _IOR(0x12,114,size_t)
 
+static struct udev *udev_ctx;
 static int debug;
 
 static void log_fn(struct udev *udev, int priority,
@@ -56,8 +57,10 @@ static void vid_log(int priority, const char *file, int line, const char *format
 {
 	va_list args;
 
+	if (priority > udev_get_log_priority(udev_ctx))
+		return;
 	va_start(args, format);
-	log_fn(NULL, priority, file, line, NULL, format, args);
+	log_fn(udev_ctx, priority, file, line, NULL, format, args);
 	va_end(args);
 	return;
 }
@@ -109,7 +112,6 @@ static int all_probers(volume_id_probe_fn_t probe_fn,
 
 int main(int argc, char *argv[])
 {
-	struct udev *udev;
 	static const struct option options[] = {
 		{ "label", 0, NULL, 'l' },
 		{ "label-raw", 0, NULL, 'L' },
@@ -146,11 +148,11 @@ int main(int argc, char *argv[])
 	int retval;
 	int rc = 0;
 
-	udev = udev_new();
-	if (udev == NULL)
+	udev_ctx = udev_new();
+	if (udev_ctx == NULL)
 		goto exit;
 	logging_init("vol_id");
-	udev_set_log_fn(udev, log_fn);
+	udev_set_log_fn(udev_ctx, log_fn);
 
 	/* hook in our debug into libvolume_id */
 	volume_id_log_fn = vid_log;
@@ -165,8 +167,8 @@ int main(int argc, char *argv[])
 		switch (option) {
 		case 'd':
 			debug = 1;
-			if (udev_get_log_priority(udev) < LOG_INFO)
-				udev_set_log_priority(udev, LOG_INFO);
+			if (udev_get_log_priority(udev_ctx) < LOG_INFO)
+				udev_set_log_priority(udev_ctx, LOG_INFO);
 			break;
 		case 'l':
 			print = PRINT_LABEL;
@@ -214,7 +216,7 @@ int main(int argc, char *argv[])
 
 	node = argv[optind];
 	if (!node) {
-		err(udev, "no device\n");
+		err(udev_ctx, "no device\n");
 		fprintf(stderr, "no device\n");
 		rc = 1;
 		goto exit;
@@ -235,7 +237,7 @@ int main(int argc, char *argv[])
 
 	if (ioctl(fd, BLKGETSIZE64, &size) != 0)
 		size = 0;
-	info(udev, "BLKGETSIZE64=%llu (%lluGB)\n", (unsigned long long)size, (unsigned long long)size >> 30);
+	info(udev_ctx, "BLKGETSIZE64=%llu (%lluGB)\n", (unsigned long long)size, (unsigned long long)size >> 30);
 
 	/* try to drop all privileges before reading disk content */
 	if (getuid() == 0) {
@@ -246,7 +248,7 @@ int main(int argc, char *argv[])
 			if (setgroups(0, NULL) != 0 ||
 			    setgid(pw->pw_gid) != 0 ||
 			    setuid(pw->pw_uid) != 0)
-				info(udev, "unable to drop privileges: %s\n\n", strerror(errno));
+				info(udev_ctx, "unable to drop privileges: %s\n\n", strerror(errno));
 		}
 	}
 
@@ -320,7 +322,7 @@ int main(int argc, char *argv[])
 exit:
 	if (vid != NULL)
 		volume_id_close(vid);
-	udev_unref(udev);
+	udev_unref(udev_ctx);
 	logging_close();
 	return rc;
 }
openSUSE Build Service is sponsored by