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

2014-10-29 Thread Timofey Titovets
Why then developers use cmdline before?
Maybe cmdline allow determine disk when bootchart working from or in initrd?

2014-10-28 15:37 GMT+03:00 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl:
 On Tue, Oct 28, 2014 at 07:56:32AM +0300, Timofey Titovets wrote:
 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.
 There's infrastracture to do this properly: see
 parse_proc_cmdline_item, e.g. in cryptsetup-generator.c.

 Nevertheless, I'm wondering if this couldn't be done better by checking
 what is mounted on /. Seems that it would work in more cases.

 Zbyszek



 From 4d14e78977df92e010ea488f97acd6a5e8e30e97 Mon Sep 17 00:00:00 2001
 From: Timofey Titovets nefelim...@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


 From 4d14e78977df92e010ea488f97acd6a5e8e30e97 Mon Sep 17 00:00:00 2001
 From: Timofey Titovets nefelim...@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


 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel




-- 
Have a nice day,
Timofey.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-10-29 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Oct 29, 2014 at 04:16:22PM +0300, Timofey Titovets wrote:
 Why then developers use cmdline before?
 Maybe cmdline allow determine disk when bootchart working from or in initrd?
bootchart was merged into systemd after being developed in separate and
often does not follow the same conventions.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-10-29 Thread Timofey Titovets
2014-10-29 16:20 GMT+03:00 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl:
 On Wed, Oct 29, 2014 at 04:16:22PM +0300, Timofey Titovets wrote:
 Why then developers use cmdline before?
 Maybe cmdline allow determine disk when bootchart working from or in initrd?
 bootchart was merged into systemd after being developed in separate and
 often does not follow the same conventions.

 Zbyszek

Hm.. okay.
I did short search in systemd and can't find function to extract
values from /proc/mounts
It's needed to rework patch for use /proc/mounts and implement
function to parse?
I miss something?

-- 
Have a nice day,
Timofey.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-10-28 Thread Zbigniew Jędrzejewski-Szmek
On Tue, Oct 28, 2014 at 07:56:32AM +0300, Timofey Titovets wrote:
 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.
There's infrastracture to do this properly: see
parse_proc_cmdline_item, e.g. in cryptsetup-generator.c.

Nevertheless, I'm wondering if this couldn't be done better by checking
what is mounted on /. Seems that it would work in more cases.

Zbyszek


 
 From 4d14e78977df92e010ea488f97acd6a5e8e30e97 Mon Sep 17 00:00:00 2001
 From: Timofey Titovets nefelim...@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
 

 From 4d14e78977df92e010ea488f97acd6a5e8e30e97 Mon Sep 17 00:00:00 2001
 From: Timofey Titovets nefelim...@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
 

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-10-27 Thread Timofey Titovets

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 nefelim...@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

From 4d14e78977df92e010ea488f97acd6a5e8e30e97 Mon Sep 17 00:00:00 2001
From: Timofey Titovets nefelim...@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

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel