From: Johan Rydberg <jrydberg@night.trouble.net>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH 3/3] grub EFI disk device enumberating
Date: Tue, 24 Oct 2006 16:05:56 +0200 [thread overview]
Message-ID: <877iyp3j23.fsf@night.trouble.net> (raw)
In-Reply-To: <87fydd3ll4.fsf@night.trouble.net> (Johan Rydberg's message of "Tue, 24 Oct 2006 15:11:19 +0200")
[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]
Johan Rydberg <jrydberg@night.trouble.net> writes:
> This code can be shorter; you only have to compare the lengths. If
> they match, you can do a memcmp on the whole device path.
It could look something like this;
/* Returns zero if device path SUBPATH is a subpath of device path
PATH. */
static int
compare_subpath (const grub_efi_device_path_t *subpath,
const grub_efi_device_path_t *path)
{
if (! subpath || ! path)
return 1;
while (1)
{
int len, ret;
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (subpath))
return 0;
else if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (path))
return 1;
if (GRUB_EFI_DEVICE_PATH_LENGTH (subpath)
!= GRUB_EFI_DEVICE_PATH_LENGTH (path))
return ((int) GRUB_EFI_DEVICE_PATH_LENGTH (subpath)
- (int) GRUB_EFI_DEVICE_PATH_LENGTH (path));
len = GRUB_EFI_DEVICE_PATH_LENGTH (path);
ret = grub_memcmp (subpath, path, len);
if (ret)
return ret;
path = (grub_efi_device_path_t *) ((char *) path + len);
subpath = (grub_efi_device_path_t *) ((char *) subpath + len);
}
}
I guess that should work at least, it is not tested.
In gnufi I have a device_path_iterate function that could be used for
these kind of things. Maybe we should bring it in to GRUB2.
/* Iterate nodes of the device path. *PATHP should be set to point to
the path that is to be iterated. NULL will be returned when the
end of the path has been reached. */
efi_device_path_t *
efi_device_path_iterate (efi_device_path_t **pathp)
{
efi_device_path_t *p = *pathp;
if (EFI_END_ENTIRE_DEVICE_PATH (p))
return NULL;
else
{
efi_uint_t len = EFI_DEVICE_PATH_LENGTH (p);
*pathp = (efi_device_path_t *) (((char *) p) + len);
return p;
}
}
~j
[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2006-10-24 13:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-24 7:19 [PATCH 3/3] grub EFI disk device enumberating bibo,mao
2006-10-24 13:11 ` Johan Rydberg
2006-10-24 14:05 ` Johan Rydberg [this message]
2006-10-25 5:43 ` bibo,mao
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=877iyp3j23.fsf@night.trouble.net \
--to=jrydberg@night.trouble.net \
--cc=grub-devel@gnu.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.