[systemd-devel] [PATCH v2] Bootchart: allow parse LABEL, UUID, PARTUUID for svg info

Timofey Titovets nefelim4ag at gmail.com
Mon Oct 27 21:56:32 PDT 2014


Good time of day, list.
I try to fix "Fixme" in svg.c:
/* FIXME: this works only in the simple case */

By default function try to get only root=/dev/*

I also attach patch. Thanks.

v2:
	Rewrited with use fstab_node_to_udev_node() and 
canonicalize_file_name() functions.

 From 4d14e78977df92e010ea488f97acd6a5e8e30e97 Mon Sep 17 00:00:00 2001
From: Timofey Titovets <nefelim4ag at gmail.com>
Date: Tue, 28 Oct 2014 07:42:26 +0300
Subject: [PATCH] Bootchart: allow parse LABEL, UUID, PARTUUID for svg info

---
  src/bootchart/svg.c | 24 ++++++++++++++++++++----
  1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index faf377e..81d3da9 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -151,6 +151,24 @@ static void svg_header(void) {
          svg("    ]]>\n   </style>\n</defs>\n\n");
  }

+static void get_root_disk(const char *cmdline, char *rootbdev) {
+        char *ptr = strstr(cmdline, "root=");
+
+        if (!ptr)
+                return;
+
+        ptr = &ptr[5];
+        ptr = strtok(ptr," ");
+
+        if (ptr[0] != '/') {
+                ptr = fstab_node_to_udev_node(ptr);
+                ptr = canonicalize_file_name(ptr);
+        }
+
+        strncpy(rootbdev, &ptr[5], 3);
+        rootbdev[3] = '\0';
+}
+
  static void svg_title(const char *build) {
          char cmdline[256] = "";
          char filename[PATH_MAX];
@@ -175,11 +193,9 @@ static void svg_title(const char *build) {
          }

          /* extract root fs so we can find disk model name in sysfs */
-        /* FIXME: this works only in the simple case */
-        c = strstr(cmdline, "root=/dev/");
+        c = strstr(cmdline, "root=");
          if (c) {
-                strncpy(rootbdev, &c[10], 3);
-                rootbdev[3] = '\0';
+                get_root_disk(cmdline, rootbdev);
                  sprintf(filename, "block/%s/device/model", rootbdev);
                  fd = openat(sysfd, filename, O_RDONLY);
                  f = fdopen(fd, "r");
-- 
2.1.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Bootchart-allow-parse-LABEL-UUID-PARTUUID-for-svg-in.patch
Type: text/x-patch
Size: 1753 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20141028/7dc65bd1/attachment.bin>


More information about the systemd-devel mailing list