[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCHv3] hurd: Support device entries with @/dev/disk: qualifier
From: |
Daniel Kiper |
Subject: |
Re: [PATCHv3] hurd: Support device entries with @/dev/disk: qualifier |
Date: |
Tue, 17 May 2022 16:22:10 +0200 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Wed, Apr 27, 2022 at 11:00:29PM +0200, 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>
>
> Message-Id: <20220223233413.wkk66pxp5p2q2wrf@begin>
>
> ---
> Difference with v2: formatting, using xmalloc instead of malloc.
>
> 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.
>
> diff --git a/grub-core/osdep/hurd/getroot.c b/grub-core/osdep/hurd/getroot.c
> index c66b206fa..5f0e366d1 100644
> --- a/grub-core/osdep/hurd/getroot.c
> +++ b/grub-core/osdep/hurd/getroot.c
> @@ -112,9 +112,21 @@ grub_util_find_hurd_root_device (const char *path)
> 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;
> + size_t size;
> char *next;
> - ret = malloc (size);
> +
> + if (dev_name[0] == '@')
> + {
> + /* non-bootstrap disk driver, the /dev/ entry is normally set up
> with
> + * the same @. */
> + char *next_name = strchr (dev_name, ':');
> +
> + if (next_name)
> + dev_name = next_name + 1;
> + }
> +
> + size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1;
> + ret = xmalloc (size);
> next = stpncpy (ret, "/dev/", size);
> stpncpy (next, dev_name, size - (next - ret));
> }
> diff --git a/grub-core/osdep/hurd/hostdisk.c b/grub-core/osdep/hurd/hostdisk.c
> index c47b5a5ea..73c442ae5 100644
> --- a/grub-core/osdep/hurd/hostdisk.c
> +++ b/grub-core/osdep/hurd/hostdisk.c
> @@ -87,6 +87,21 @@ grub_util_hurd_get_disk_info (const char *dev,
> grub_uint32_t *secsize, grub_disk
> *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 @. */
> + char *next_path = strchr (*parent, ':');
> +
> + if (next_path)
> + {
> + char *n = strdup (next_path + 1);
I think this should be xstrdup() instead of strdup(). I can fix this for
you before push.
Otherwise Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
> + free (*parent);
> + *parent = n;
> + }
> + }
> }
> }
> if (offset)
- Re: [PATCHv3] hurd: Support device entries with @/dev/disk: qualifier,
Daniel Kiper <=