All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Add option to grub-probe to accept system devices as arguments
Date: Mon, 11 Feb 2008 15:39:03 +0100	[thread overview]
Message-ID: <20080211143903.GA21126@thorin> (raw)
In-Reply-To: <47B00CFB.4070304@leat.rub.de>

On Mon, Feb 11, 2008 at 09:53:15AM +0100, Fabian Greffrath wrote:
> The following patch adds to grub-probe the ability to accept system devices 
> as
> arguments and e.g. convert between system devices and GRUB drives.
> 
> This patch is improved over the one from my previous posting and has some 
> minor
> issues fixed. Please use this version instead. It is all my work.

Hi Fabian,

Some comments on this one.

> ???2008-02-11  Fabian Greffrath  <fabian.greffrath@web.de>
> 
> 	* util/grub-probe.c: Add new parameter '-d, --device'. If this is set,
> 	grub-probe expects the given argument to be a block device. All of the
> 	'--target' parameters work with this option as well. If the '--device'
> 	parameter is not set, grub-probe will work as before.

You need to list every function or variable separately.  E.g:

	* util/grub-probe.c (argument_is_device): New variable.
	(probe): Blah blah.
	(main): Etc.

If you use the -p option to diff it'll be easier to check it just by reading the
patch.

> +char *
> +grub_util_check_block_device (const char *blk_dev)
> +{
> +  struct stat st;
> +
> +  if (stat (blk_dev, &st) < 0)
> +    grub_util_error ("Cannot stat `%s'", blk_dev);
> +
> +  if (S_ISBLK (st.st_mode))
> +    return strdup (blk_dev);
> +  else
> +    return 0;
> +}

Is there really a need to strdup() it?

> diff -Naru grub2-1.96+20080203~/util/grub-probe.c grub2-1.96+20080203/util/grub-probe.c
> --- grub2-1.96+20080203~/util/grub-probe.c	2008-01-25 23:33:57.000000000 +0100
> +++ grub2-1.96+20080203/util/grub-probe.c	2008-02-08 12:50:13.000000000 +0100
> @@ -50,6 +50,7 @@
>  };
>  
>  int print = PRINT_FS;
> +static unsigned int argument_is_device = 0;
>  
>  void
>  grub_putchar (int c)
> @@ -84,9 +85,18 @@
>    int abstraction_type;
>    grub_device_t dev = NULL;
>    
> -  device_name = grub_guess_root_device (path);
> +  if (argument_is_device)
> +    device_name = grub_util_check_block_device (path);
> +  else
> +    device_name = grub_guess_root_device (path);

I find it confusing that you change the meaning of the `path' variable without
renaming it.  Also, the variable that describes what `path' is
(argument_is_device) is passed separately.

What would you think of a scheme where both are passed as strings and either
can be NULL?  E.g.

probe (char *path, char *device_name)
{
  if (path == NULL)
    {
      if (grub_util_check_block_device (device_name) == -1)
        return -1;
    }
  else
    device_name = grub_guess_root_device (path);
}

> -Usage: grub-probe [OPTION]... PATH\n\
> +Usage: grub-probe [OPTION]... [PATH|DEVICE]\n\
>  \n\
> -Probe device information for a given path.\n\
> +Probe device information for a given path or device.\n\

I suspect advertising it here might lead users to think they can pass a device
to it, without caring about ...

> +  -d, --device              given argument is a system device, not a path\n\

... this option.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



  reply	other threads:[~2008-02-11 14:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11  8:53 [PATCH] Add option to grub-probe to accept system devices as arguments Fabian Greffrath
2008-02-11 14:39 ` Robert Millan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-02-11 15:48 Fabian Greffrath
2008-02-11 16:12 ` Robert Millan
2008-02-12  9:49 Fabian Greffrath
2008-02-12 11:28 ` Robert Millan
2008-02-12 13:17 Fabian Greffrath
2008-02-13 13:03 ` Fabian Greffrath
2008-02-13 15:42 ` Robert Millan
2008-02-13 16:51   ` Fabian Greffrath
2008-02-13 19:35     ` Robert Millan
2008-02-14  8:33       ` Fabian Greffrath
2008-02-17 13:42         ` Robert Millan
2008-02-18 12:54           ` Fabian Greffrath
2008-02-20 14:14           ` Fabian Greffrath

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=20080211143903.GA21126@thorin \
    --to=rmh@aybabtu.com \
    --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.