~ubuntu-branches/ubuntu/wily/grub2/wily

« back to all changes in this revision

Viewing changes to grub-core/fs/zfs/zfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-01-11 17:11:44 UTC
  • mto: (17.3.26 experimental)
  • mto: This revision was merged to the branch mainline in revision 60.
  • Revision ID: james.westby@ubuntu.com-20110111171144-o2h6luxzei5fivmf
Tags: upstream-1.99~20110111
ImportĀ upstreamĀ versionĀ 1.99~20110111

Show diffs side-by-side

added added

removed removed

Lines of Context:
603
603
  int idx, level;
604
604
  blkptr_t *bp_array = dn->dn.dn_blkptr;
605
605
  int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT;
606
 
  blkptr_t *bp, *tmpbuf = 0;
 
606
  blkptr_t *bp;
 
607
  void *tmpbuf = 0;
607
608
  grub_zfs_endian_t endian;
608
609
  grub_err_t err = GRUB_ERR_NONE;
609
610
 
646
647
          break;
647
648
        }
648
649
      grub_dprintf ("zfs", "endian = %d\n", endian);
649
 
      err = zio_read (bp, endian, (void **) &tmpbuf, 0, data);
 
650
      err = zio_read (bp, endian, &tmpbuf, 0, data);
650
651
      endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
651
652
      if (err)
652
653
        break;
880
881
fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap,
881
882
             char *name, grub_uint64_t * value, struct grub_zfs_data *data)
882
883
{
883
 
  zap_leaf_phys_t *l;
 
884
  void *l;
884
885
  grub_uint64_t hash, idx, blkid;
885
886
  int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, 
886
887
                                            zap_dnode->endian) << DNODE_SHIFT);
903
904
  /* Get the leaf block */
904
905
  if ((1U << blksft) < sizeof (zap_leaf_phys_t))
905
906
    return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small");
906
 
  err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data);
 
907
  err = dmu_read (zap_dnode, blkid, &l, &leafendian, data);
907
908
  if (err)
908
909
    return err;
909
910
 
920
921
             struct grub_zfs_data *data)
921
922
{
922
923
  zap_leaf_phys_t *l;
 
924
  void *l_in;
923
925
  grub_uint64_t idx, blkid;
924
926
  grub_uint16_t chunk;
925
927
  int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, 
947
949
    {
948
950
      blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))];
949
951
 
950
 
      err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data);
 
952
      err = dmu_read (zap_dnode, blkid, &l_in, &endian, data);
 
953
      l = l_in;
951
954
      if (err)
952
955
        {
953
956
          grub_errno = GRUB_ERR_NONE;
1108
1111
  grub_uint64_t blkid, blksz;   /* the block id this object dnode is in */
1109
1112
  int epbs;                     /* shift of number of dnodes in a block */
1110
1113
  int idx;                      /* index within a block */
1111
 
  dnode_phys_t *dnbuf;
 
1114
  void *dnbuf;
1112
1115
  grub_err_t err;
1113
1116
  grub_zfs_endian_t endian;
1114
1117
 
1131
1134
 
1132
1135
  grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian, 
1133
1136
                (unsigned long long) blkid);
1134
 
  err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data);
 
1137
  err = dmu_read (mdn, blkid, &dnbuf, &endian, data);
1135
1138
  if (err)
1136
1139
    return err;
1137
1140
  grub_dprintf ("zfs", "alive\n");
1153
1156
      data->dnode_endian = endian;
1154
1157
    }
1155
1158
 
1156
 
  grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE);
 
1159
  grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE);
1157
1160
  buf->endian = endian;
1158
1161
  if (type && buf->dn.dn_type != type) 
1159
1162
    return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type"); 
1465
1468
static grub_err_t
1466
1469
make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
1467
1470
{
1468
 
  objset_phys_t *osp;
 
1471
  void *osp;
1469
1472
  blkptr_t *bp;
1470
1473
  grub_size_t ospsize;
1471
1474
  grub_err_t err;
1473
1476
  grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
1474
1477
 
1475
1478
  bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp);
1476
 
  err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data);
 
1479
  err = zio_read (bp, mdn->endian, &osp, &ospsize, data);
1477
1480
  if (err)
1478
1481
    return err;
1479
1482
  if (ospsize < OBJSET_PHYS_SIZE_V14)
1483
1486
    }
1484
1487
 
1485
1488
  mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1;
1486
 
  grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE);
 
1489
  grub_memmove ((char *) &(mdn->dn),
 
1490
                (char *) &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE);
1487
1491
  grub_free (osp);
1488
1492
  return GRUB_ERR_NONE;
1489
1493
}
1960
1964
  int label = 0;
1961
1965
  uberblock_phys_t *ub_array, *ubbest = NULL;
1962
1966
  vdev_boot_header_t *bh;
1963
 
  objset_phys_t *osp = 0;
 
1967
  void *osp = 0;
1964
1968
  grub_size_t ospsize;
1965
1969
  grub_err_t err;
1966
1970
  int vdevnum;
2038
2042
                   ? LITTLE_ENDIAN : BIG_ENDIAN);
2039
2043
      err = zio_read (&ubbest->ubp_uberblock.ub_rootbp, 
2040
2044
                      ub_endian,
2041
 
                      (void **) &osp, &ospsize, data);
 
2045
                      &osp, &ospsize, data);
2042
2046
      if (err)
2043
2047
        {
2044
2048
          grub_dprintf ("zfs", "couldn't zio_read\n"); 
2067
2071
        continue;
2068
2072
#endif
2069
2073
      /* Got the MOS. Save it at the memory addr MOS. */
2070
 
      grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE);
 
2074
      grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode,
 
2075
                    DNODE_SIZE);
2071
2076
      data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1;
2072
2077
      grub_memmove (&(data->current_uberblock),
2073
2078
                    &ubbest->ubp_uberblock, sizeof (uberblock_t));
2201
2206
   */
2202
2207
  if (data->dnode.dn.dn_bonustype == DMU_OT_SA)
2203
2208
    {
2204
 
      sa_hdr_phys_t *sahdrp;
 
2209
      void *sahdrp;
2205
2210
      int hdrsize;
2206
2211
 
2207
2212
      if (data->dnode.dn.dn_bonuslen != 0)
2212
2217
        {
2213
2218
          blkptr_t *bp = &data->dnode.dn.dn_spill;
2214
2219
 
2215
 
          err = zio_read (bp, data->dnode.endian, (void **) &sahdrp, NULL, data);
 
2220
          err = zio_read (bp, data->dnode.endian, &sahdrp, NULL, data);
2216
2221
          if (err)
2217
2222
            return err;
2218
2223
        }
2221
2226
          return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
2222
2227
        }
2223
2228
 
2224
 
      hdrsize = SA_HDR_SIZE (sahdrp);
 
2229
      hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
2225
2230
      file->size = *(grub_uint64_t *) ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET);
2226
2231
    }
2227
2232
  else
2280
2285
  read = 0;
2281
2286
  while (length)
2282
2287
    {
 
2288
      void *t;
2283
2289
      /*
2284
2290
       * Find requested blkid and the offset within that block.
2285
2291
       */
2287
2293
      grub_free (data->file_buf);
2288
2294
      data->file_buf = 0;
2289
2295
 
2290
 
      err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf),
 
2296
      err = dmu_read (&(data->dnode), blkid, &t,
2291
2297
                      0, data);
 
2298
      data->file_buf = t;
2292
2299
      if (err)
2293
2300
        return -1;
2294
2301