All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kiper <dkiper@net-space.pl>
To: samuel.thibault@ens-lyon.org
Cc: grub-devel@gnu.org, bug-hurd@gnu.org
Subject: Re: [PATCHv2] hurd: Support device entries with @/dev/disk: qualifier
Date: Wed, 27 Apr 2022 17:04:11 +0200	[thread overview]
Message-ID: <20220427150411.o2tabth2j7ze5y7b@tomti.i.net-space.pl> (raw)
In-Reply-To: <20220223233413.wkk66pxp5p2q2wrf@begin>

Sorry for late reply but I am busy...

On Thu, Feb 24, 2022 at 12:34:13AM +0100, Samuel Thibault wrote:
> Those are used with non-bootstrap disk drivers, for which libstore has to
> open /dev/disk before calling device_open on it instead of on the device
> master port.  Normally in that case all /dev/ entries also have the @/dev/disk:
> qualifier, so we can just drop it.
>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>
> ---
> Difference with v1: better drop the @/dev/disk: qualifier right from
> grub_util_hurd_get_disk_info so it benefits alls the callees and not
> only grub_util_part_to_disk.
>
> Index: grub2-2.06/grub-core/osdep/hurd/getroot.c
> ===================================================================
> --- grub2-2.06.orig/grub-core/osdep/hurd/getroot.c
> +++ grub2-2.06/grub-core/osdep/hurd/getroot.c
> @@ -112,11 +112,23 @@ grub_util_find_hurd_root_device (const c
>    if (strncmp (name, "device:", sizeof ("device:") - 1) == 0)
>      {
>        char *dev_name = name + sizeof ("device:") - 1;
> -      size_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
> -      char *next;
> -      ret = malloc (size);
> -      next = stpncpy (ret, "/dev/", size);
> -      stpncpy (next, dev_name, size - (next - ret));
> +
> +      if (dev_name[0] == '@')
> +        {
> +          /* non-bootstrap disk driver, the /dev/ entry is normally set up with
> +             the same @.  */

Please format comments according to this [1].

> +          char *next_name = strchr (dev_name, ':');

Could you put empty line here?

> +          if (next_name)
> +            dev_name = next_name + 1;
> +        }
> +
> +      {
> +        size_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
> +        char *next;

I would prefer if you leave variable definitions above and put code
without {} here.

> +        ret = malloc (size);

I think this should be xmalloc() call instead of malloc() one. Or you
should check ret != NULL before use.

> +        next = stpncpy (ret, "/dev/", size);
> +        stpncpy (next, dev_name, size - (next - ret));
> +      }
>      }
>    else if (!strncmp (name, "file:", sizeof ("file:") - 1))
>      ret = strdup (name + sizeof ("file:") - 1);
> Index: grub2-2.06/grub-core/osdep/hurd/hostdisk.c
> ===================================================================
> --- grub2-2.06.orig/grub-core/osdep/hurd/hostdisk.c
> +++ grub2-2.06/grub-core/osdep/hurd/hostdisk.c
> @@ -87,6 +87,19 @@ grub_util_hurd_get_disk_info (const char
>  	  *parent = xmalloc (len+1);
>  	  memcpy (*parent, data, len);
>  	  (*parent)[len] = '\0';
> +
> +	  if ((*parent)[0] == '@')
> +	    {
> +	      /* non-bootstrap disk driver, the /dev/ entry is normally set up with
> +		 the same @.  */

Please fix this comment too.

> +	      char *next_path = strchr (*parent, ':');

Please add empty line here.

> +	      if (next_path)
> +		{
> +		  char *n = strdup (next_path + 1);

Ditto.

> +		  free (*parent);
> +		  *parent = n;
> +		}
> +	    }
>  	}
>      }
>    if (offset)

[1] https://www.gnu.org/software/grub/manual/grub-dev/grub-dev.html#Comments

Daniel


  reply	other threads:[~2022-04-27 15:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 23:27 [PATCH] hurd: Support device entries with @/dev/disk: qualifier Samuel Thibault
2022-02-23 23:34 ` [PATCHv2] " Samuel Thibault
2022-04-27 15:04   ` Daniel Kiper [this message]
2022-04-27 21:00     ` [PATCHv3] " Samuel Thibault
2022-05-17 14:22       ` Daniel Kiper
2022-05-17 14:42         ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220427150411.o2tabth2j7ze5y7b@tomti.i.net-space.pl \
    --to=dkiper@net-space.pl \
    --cc=bug-hurd@gnu.org \
    --cc=grub-devel@gnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.