Linux Device Mapper development
 help / color / mirror / Atom feed
From: Arsene Gschwind <arsene.gschwind@unibas.ch>
To: device-mapper development <dm-devel@redhat.com>
Subject: Re: multipath disk size
Date: Thu, 13 Apr 2006 11:34:45 +0200	[thread overview]
Message-ID: <443E1B35.2030204@unibas.ch> (raw)
In-Reply-To: <443D58CA.8080301@free.fr>

I'm having problems applying those patches. When I try to apply the 
first one it returns an error:

patch -p1 < ../patch1.diff
patching file libmultipath/discovery.c
patch: **** malformed patch at line 6: }

and when using git-apply:
git-apply --check ../patch1.diff
fatal: corrupt patch at line 6

As source I'm using the latest tarball "multipath-tools-0.4.7.tar.bz2"
I haven't been able to figure out what's wrong, I may have used the 
wrong patch tool or options ??
Thanks for any hint

Arsène

Christophe Varoqui wrote:

> Arsene Gschwind a écrit :
>
>> I've found something strange, 2 declaration of SERIAL_SIZE with 
>> different sizes
>> libmultipath/structs.h:#define SERIAL_SIZE              17
>> path_priority/pp_balance_units/pp_balance_units.c:#define SERIAL_SIZE 
>> 255
>>
>> In my case the first buffer size is to small because pp->serial has a 
>> size of 17 chars and when you look at my output it has 40 chars.
>> By setting libmultipath/structs.h:#define SERIAL_SIZE    to 255 it 
>> works for me and the returned volume size is correct.
>> I'm not sure if this is the right solution, it would be great if 
>> someone could verify that issue.
>>
>> Thanks a lot for your work
>> Arsène
>>
>>
> Very good catch.
> get_serial() was happily overflowing.
> Sorry for your being the first with a long-serial-hardware :)
>
>
> Please try the following 2 patchs, with testing between to 2, please.
>
> === 1===
> diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
> --- a/libmultipath/discovery.c
> +++ b/libmultipath/discovery.c
> @@ -339,24 +339,26 @@ do_inq(int sg_fd, int cmddt, int evpd, u
>         return -1;
> }
>
> -int
> -get_serial (char * str, int fd)
> +static int
> +get_serial (char * str, int maxlen, int fd)
> {
>         int len = 0;
>         char buff[MX_ALLOC_LEN + 1] = {0};
>
>        if (fd < 0)
> -                return 0;
> +                return 1;
>
>        if (0 == do_inq(fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0)) {
>                len = buff[3];
> +               if (len >= maxlen)
> +                       return 1;
>                if (len > 0) {
>                        memcpy(str, buff + 4, len);
>                        str[len] = '\0';
>                }
> -               return 1;
> +               return 0;
>        }
> -        return 0;
> +        return 1;
> }
>
> static int
> @@ -597,7 +599,7 @@ static int
> scsi_ioctl_pathinfo (struct path * pp, int mask)
> {
>        if (mask & DI_SERIAL) {
> -               get_serial(pp->serial, pp->fd);
> +               get_serial(pp->serial, SERIAL_SIZE, pp->fd);
>                condlog(3, "%s: serial = %s", pp->dev, pp->serial);
>        }
>
> diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
> --- a/libmultipath/discovery.h
> +++ b/libmultipath/discovery.h
> @@ -30,7 +30,6 @@ int sysfs_get_size (char * sysfs_path, c
> int path_discovery (vector pathvec, struct config * conf, int flag);
>
> void basename (char *, char *);
> -int get_serial (char * buff, int fd);
> int do_tur (char *);
> int devt2devname (char *, char *);
> int pathinfo (struct path *, vector hwtable, int mask);
> diff --git a/path_priority/pp_balance_units/pp_balance_units.c 
> b/path_priority/pp_balance_units/pp_balance_units.c
> --- a/path_priority/pp_balance_units/pp_balance_units.c
> +++ b/path_priority/pp_balance_units/pp_balance_units.c
> @@ -172,7 +172,7 @@ do_inq(int sg_fd, int cmddt, int evpd, u
> }
>
> static int
> -get_serial (char * str, char * devt)
> +get_serial (char * str, int maxlen, char * devt)
> {
>        int fd;
>         int len;
> @@ -181,20 +181,22 @@ get_serial (char * str, char * devt)
>        fd = opennode(devt, O_RDONLY);
>
>        if (fd < 0)
> -                return 0;
> +                return 1;
>
>        if (0 == do_inq(fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0)) {
>                len = buff[3];
> +               if (len >= maxlen)
> +                       return 1;
>                if (len > 0) {
>                        memcpy(str, buff + 4, len);
>                        buff[len] = '\0';
>                }
>                close(fd);
> -               return 1;
> +               return 0;
>        }
>
>        closenode(devt, fd);
> -        return 0;
> +        return 1;
> }
>
> static void *
> @@ -358,7 +360,7 @@ get_paths (vector pathvec)
>                        if (pos == BEFOREPG)
>                                pos = INPG;
>
> -                       get_serial(pp->serial, pp->dev_t);
> +                       get_serial(pp->serial, SERIAL_SIZE, pp->dev_t);
>                        vector_alloc_slot(pathvec);
>                        vector_set_slot(pathvec, pp);
>                        debug("store %s [%s]",
> @@ -449,7 +451,7 @@ main (int argc, char **argv)
>        if (optind<argc)
>                strncpy(ref_path->dev_t, argv[optind], WORD_SIZE);
>
> -       get_serial(ref_path->serial, ref_path->dev_t);
> +       get_serial(ref_path->serial, SERIAL_SIZE, ref_path->dev_t);
>
>        if (!ref_path->serial || !strlen(ref_path->serial))
>                exit_tool(0);
>
>
> ==== 2 ====
> diff --git a/libmultipath/structs.h b/libmultipath/structs.h
> --- a/libmultipath/structs.h
> +++ b/libmultipath/structs.h
> @@ -2,7 +2,7 @@
> #define _STRUCTS_H
>
> #define WWID_SIZE              64
> -#define SERIAL_SIZE            17
> +#define SERIAL_SIZE            64
> #define NODE_NAME_SIZE         19
> #define PATH_STR_SIZE                  16
> #define PARAMS_SIZE            1024
>
>
>
> -- 
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel


-- 
***********************************************************
Gschwind Arsene			
Universitaet Rechenzentrum (URZ)
Klingelbergstrasse 70
CH-4056 Basel
SWITZERLAND

Languages : F/E/D
WWW:  <http://www.urz.unibas.ch>
Mail: <Arsene DOT Gschwind AT unibas DOT ch>
************************************************************

  reply	other threads:[~2006-04-13  9:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-07  8:47 multipath disk size URZ- AG
2006-04-07 22:31 ` Christophe Varoqui
2006-04-11 19:54   ` URZ- AG
2006-04-12 12:19     ` Arsene Gschwind
2006-04-12 19:45       ` Christophe Varoqui
2006-04-13  9:34         ` Arsene Gschwind [this message]
2006-04-13 16:41         ` Arsene Gschwind
  -- strict thread matches above, loose matches on Subject: below --
2006-03-30 16:06 Arsene Gschwind

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=443E1B35.2030204@unibas.ch \
    --to=arsene.gschwind@unibas.ch \
    --cc=dm-devel@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox