[systemd-devel] [PATCH] bootchart: if "root=/dev" is not matched, don't try to read /sys
Tom Gundersen
teg at jklm.no
Thu Feb 14 05:20:50 PST 2013
On Thu, Feb 14, 2013 at 11:26 AM, <harald at redhat.com> wrote:
> From: Harald Hoyer <harald at redhat.com>
>
> ---
> src/bootchart/svg.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
> index dc55cb3..7fdcd01 100644
> --- a/src/bootchart/svg.c
> +++ b/src/bootchart/svg.c
> @@ -166,18 +166,19 @@ static void svg_title(void)
> }
>
> /* extract root fs so we can find disk model name in sysfs */
> + /* FIXME: this works only in the simple case */
Couldn't we simply query the '-.mount' unit to find out 'What=' and
then use libudev to get the model name?
> c = strstr(cmdline, "root=/dev/");
> if (c) {
> strncpy(rootbdev, &c[10], 3);
> rootbdev[3] = '\0';
> - }
> - sprintf(filename, "block/%s/device/model", rootbdev);
> - fd = openat(sysfd, filename, O_RDONLY);
> - f = fdopen(fd, "r");
> - if (f) {
> - if (!fgets(model, 255, f))
> - fprintf(stderr, "Error reading disk model for %s\n", rootbdev);
> - fclose(f);
> + sprintf(filename, "block/%s/device/model", rootbdev);
> + fd = openat(sysfd, filename, O_RDONLY);
> + f = fdopen(fd, "r");
> + if (f) {
> + if (!fgets(model, 255, f))
> + fprintf(stderr, "Error reading disk model for %s\n", rootbdev);
> + fclose(f);
> + }
> }
>
> /* various utsname parameters */
> --
> 1.8.1
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list