Ignore:
Timestamp:
07/01/13 13:43:16 (18 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
5a110d6
Parents:
4546cd2
Message:

Update the ZFS feature flag support patch in grub2 from here:

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support-r1.patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • build-files/ports-overlay/sysutils/grub2/files/patch-grub-2.00-zfs-feature-flag-support

    r2dfacf2 rff9dd98  
    11From 
    22 
    3         http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support.patch 
     3        http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-boot/grub/files/grub-2.00-zfs-feature-flag-support-r1.patch 
    44 
    55ZFS Feature Flag Support 
     
    1313https://github.com/maxximino/grub2/commit/f12806f43a969a654dee7bb89b2e8fd5c42f0e2e 
    1414 
    15 A minor change was made to account for d8a0feb6 from upstream. This change 
    16 prevents a compile time failure that is caused by a change in the callback 
    17 interface used by mzap_interate(). 
     15A change was made to account for d8a0feb6 from upstream. This change prevents a 
     16compile time failure that is caused by a change in the callback interface used 
     17by mzap_interate(). Modifications to nvlist_find_value() were reverted to 
     18resolve Gentoo bug #462740. This eliminated the need for the new nvpair_type() 
     19and nvpair_value() functions. They have been removed to silence a compiler 
     20warning and reduce the size of the patch. Further adjustments were made to 
     21silence the following warnings: 
     22 
     23/var/tmp/portage/sys-boot/grub-2.00-r2/work/grub-2.00/grub-core/fs/zfs/zfs_lz4.c:77:5: 
     24warning: "__STDC_VERSION__" is not defined [-Wundef] 
     25/var/tmp/portage/sys-boot/grub-2.00-r2/work/grub-2.00/grub-core/fs/zfs/zfs.c:4079:3: 
     26warning: passing argument 4 of 'mzap_iterate' from incompatible pointer type 
     27[enabled by default] 
    1828 
    1929The initial feature flag support patches were written by Delphix while the LZ4 
    2030support was written by Saso Kiselkov. The work porting this to GRUB2 was done 
    2131by Massimo Maggi, while the adaption to Gentoo's GRUB2 package was done by 
    22 Richard Yao.  
     32Richard Yao. 
    2333 
    2434diff --git a/Makefile.util.def b/Makefile.util.def 
     
    4757 }; 
    4858diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c 
    49 index ba0554a..de31e6c 100644 
     59index ba0554a..811e3df 100644 
    5060--- grub-core/fs/zfs/zfs.c 
    5161+++ grub-core/fs/zfs/zfs.c 
     
    8696+}; 
    8797+ 
    88 +static int 
     98+static int NESTED_FUNC_ATTR 
    8999+check_feature(const char *name, grub_uint64_t val); 
    90100+static int 
     
    120130  
    121131   if (endian == GRUB_ZFS_UNKNOWN_ENDIAN) 
    122 @@ -764,6 +777,155 @@ fill_vdev_info (struct grub_zfs_data *data, 
     132@@ -764,6 +777,99 @@ fill_vdev_info (struct grub_zfs_data *data, 
    123133 } 
    124134  
     
    215225+       return (0); 
    216226+} 
    217 +/* 
    218 + * This function retrieves the value of the nvpair in the form of enumerated 
    219 + * type data_type_t. 
    220 + */ 
    221 +static int 
    222 +nvpair_type(const char *nvp) 
    223 +{ 
    224 +       int name_len, type; 
    225 + 
    226 +       /* skip over encode/decode size */ 
    227 +       nvp += 4 * 2; 
    228 + 
    229 +       /* skip over name_len */ 
    230 +       name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); 
    231 +       nvp += 4; 
    232 + 
    233 +       /* skip over name */ 
    234 +       nvp = nvp + ((name_len + 3) & ~3); /* align */ 
    235 + 
    236 +       type = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); 
    237 + 
    238 +       return (type); 
    239 +} 
    240 +static int 
    241 +nvpair_value(const char *nvp,char **val, 
    242 +                  grub_size_t *size_out, grub_size_t *nelm_out) 
    243 +{ 
    244 +       int name_len,nelm,encode_size; 
    245 + 
    246 +       /* skip over encode/decode size */ 
    247 +       encode_size = grub_be_to_cpu32 (grub_get_unaligned32(nvp)); 
    248 +       nvp += 8; 
    249 + 
    250 +       /* skip over name_len */ 
    251 +       name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); 
    252 +       nvp += 4; 
    253 + 
    254 +       /* skip over name */ 
    255 +       nvp = nvp + ((name_len + 3) & ~3); /* align */ 
    256 +        
    257 +       /* skip over type */ 
    258 +       nvp += 4; 
    259 +       nelm = grub_be_to_cpu32 (grub_get_unaligned32 (nvp)); 
    260 +       nvp +=4; 
    261 +       if (nelm < 1) 
    262 +       { 
    263 +         grub_error (GRUB_ERR_BAD_FS, "empty nvpair"); 
    264 +         return 0; 
    265 +       } 
    266 +         *val = (char *) nvp; 
    267 +         *size_out = encode_size; 
    268 +         if (nelm_out) 
    269 +           *nelm_out = nelm; 
    270 +            
    271 +       return 1; 
    272 +} 
    273227+ 
    274228+/* 
     
    276230  * 
    277231  */ 
    278 @@ -773,7 +935,7 @@ check_pool_label (struct grub_zfs_data *data, 
     232@@ -773,7 +879,7 @@ check_pool_label (struct grub_zfs_data *data, 
    279233                  int *inserted) 
    280234 { 
     
    285239   char *nv; 
    286240 #endif 
    287 @@ -837,13 +999,13 @@ check_pool_label (struct grub_zfs_data *data, 
     241@@ -837,13 +943,13 @@ check_pool_label (struct grub_zfs_data *data, 
    288242     } 
    289243   grub_dprintf ("zfs", "check 8 passed\n"); 
     
    301255   grub_dprintf ("zfs", "check 9 passed\n"); 
    302256  
    303 @@ -893,7 +1055,30 @@ check_pool_label (struct grub_zfs_data *data, 
     257@@ -893,7 +999,30 @@ check_pool_label (struct grub_zfs_data *data, 
    304258     grub_free (nv); 
    305259   } 
     
    333287  
    334288   return GRUB_ERR_NONE; 
    335 @@ -3034,34 +3219,14 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, 
     289@@ -3034,27 +3163,6 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, 
    336290   return err; 
    337291 } 
     
    361315 nvlist_find_value (const char *nvlist_in, const char *name, 
    362316                   int valtype, char **val, 
    363                    grub_size_t *size_out, grub_size_t *nelm_out) 
    364  { 
    365 -  int name_len, type, encode_size; 
    366 -  const char *nvpair, *nvp_name, *nvlist = nvlist_in; 
    367 +  int name_len, type ; 
    368 +  const char *nvpair=NULL,*nvlist=nvlist_in; 
    369 +  char *nvp_name; 
    370   
    371    /* Verify if the 1st and 2nd byte in the nvlist are valid. */ 
    372    /* NOTE: independently of what endianness header announces all  
    373 @@ -3074,62 +3239,18 @@ nvlist_find_value (const char *nvlist_in, const char *name, 
    374        return 0; 
    375      } 
    376   
    377 -  /* skip the header, nvl_version, and nvl_nvflag */ 
    378 -  nvlist = nvlist + 4 * 3; 
    379    /* 
    380     * Loop thru the nvpair list 
    381     * The XDR representation of an integer is in big-endian byte order. 
    382     */ 
    383 -  while ((encode_size = grub_be_to_cpu32 (grub_get_unaligned32 (nvlist)))) 
    384 +  while ((nvpair=nvlist_next_nvpair(nvlist,nvpair))) 
    385      { 
    386 -      int nelm; 
    387 - 
    388 -      if (nvlist + 4 * 4 >= nvlist_in + VDEV_PHYS_SIZE) 
    389 -       { 
    390 -         grub_dprintf ("zfs", "nvlist overflow\n"); 
    391 -         grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); 
    392 -         return 0; 
    393 -       } 
    394 - 
    395 -      nvpair = nvlist + 4 * 2; /* skip the encode/decode size */ 
    396 - 
    397 -      name_len = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair)); 
    398 -      nvpair += 4; 
    399 - 
    400 -      nvp_name = nvpair; 
    401 -      nvpair = nvpair + ((name_len + 3) & ~3); /* align */ 
    402 - 
    403 -      if (nvpair + 8 >= nvlist_in + VDEV_PHYS_SIZE 
    404 -         || encode_size < 0 
    405 -         || nvpair + 8 + encode_size > nvlist_in + VDEV_PHYS_SIZE) 
    406 +      nvpair_name(nvpair,&nvp_name,&name_len); 
    407 +      type = nvpair_type(nvpair); 
    408 +      if ((grub_strncmp (nvp_name, name, grub_strlen(name)) == 0) && type == valtype) 
    409         { 
    410 -         grub_dprintf ("zfs", "nvlist overflow\n"); 
    411 -         grub_error (GRUB_ERR_BAD_FS, "incorrect nvlist"); 
    412 -         return 0; 
    413 +         return nvpair_value(nvpair,val,size_out,nelm_out); 
    414         } 
    415 - 
    416 -      type = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair)); 
    417 -      nvpair += 4; 
    418 - 
    419 -      nelm = grub_be_to_cpu32 (grub_get_unaligned32 (nvpair)); 
    420 -      if (nelm < 1) 
    421 -       { 
    422 -         grub_error (GRUB_ERR_BAD_FS, "empty nvpair"); 
    423 -         return 0; 
    424 -       } 
    425 - 
    426 -      nvpair += 4; 
    427 - 
    428 -      if ((grub_strncmp (nvp_name, name, name_len) == 0) && type == valtype) 
    429 -       { 
    430 -         *val = (char *) nvpair; 
    431 -         *size_out = encode_size; 
    432 -         if (nelm_out) 
    433 -           *nelm_out = nelm; 
    434 -         return 1; 
    435 -       } 
    436 - 
    437 -      nvlist += encode_size;   /* goto the next nvpair */ 
    438      } 
    439    return 0; 
    440  } 
    441 @@ -3386,6 +3507,10 @@ zfs_mount (grub_device_t dev) 
     317@@ -3386,6 +3494,10 @@ zfs_mount (grub_device_t dev) 
    442318       return NULL; 
    443319     } 
     
    450326   grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, 
    451327                DNODE_SIZE); 
    452 @@ -3910,6 +4035,64 @@ grub_zfs_dir (grub_device_t device, const char *path, 
     328@@ -3910,6 +4022,64 @@ grub_zfs_dir (grub_device_t device, const char *path, 
    453329   return grub_errno; 
    454330 } 
    455331  
    456 +static int 
     332+static int NESTED_FUNC_ATTR 
    457333+check_feature(const char *name, grub_uint64_t val) 
    458334+{ 
     
    517393diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c 
    518394new file mode 100644 
    519 index 0000000..f199434 
     395index 0000000..ff85a77 
    520396--- /dev/null 
    521397+++ grub-core/fs/zfs/zfs_lz4.c 
     
    597473+ */ 
    598474+ 
    599 +#if __STDC_VERSION__ >= 199901L        /* C99 */ 
     475+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L  /* C99 */ 
    600476+/* "restrict" is a known keyword */ 
    601477+#else 
Note: See TracChangeset for help on using the changeset viewer.