コード例 #1
0
ファイル: dev_manager.c プロジェクト: ystk/debian-lvm2
static const struct dm_info *_cached_info(struct dm_pool *mem,
					  const struct logical_volume *lv,
					  struct dm_tree *dtree)
{
	const char *dlid;
	struct dm_tree_node *dnode;
	const struct dm_info *dinfo;

	if (!(dlid = build_dm_uuid(mem, lv->lvid.s, NULL))) {
		log_error("dlid build failed for %s", lv->name);
		return NULL;
	}

	/* An activating merging origin won't have a node in the tree yet */
	if (!(dnode = dm_tree_find_node_by_uuid(dtree, dlid)))
		return NULL;

	if (!(dinfo = dm_tree_node_get_info(dnode))) {
		log_error("failed to get info from tree node for %s", lv->name);
		return NULL;
	}

	if (!dinfo->exists)
		return NULL;

	return dinfo;
}
コード例 #2
0
ファイル: getroot.c プロジェクト: 376473984/TrustedGRUB2
void
grub_util_pull_devmapper (const char *os_dev)
{
  struct dm_tree *tree;
  struct dm_tree_node *node;
  struct dm_tree_node *child;
  void *handle = NULL;
  char *lastsubdev = NULL;
  char *uuid;

  uuid = get_dm_uuid (os_dev);

  if (!grub_util_open_dm (os_dev, &tree, &node))
    {
      grub_free (uuid);
      return;
    }

  while ((child = dm_tree_next_child (&handle, node, 0)))
    {
      const struct dm_info *dm = dm_tree_node_get_info (child);
      char *subdev;
      if (!dm)
	continue;
      subdev = grub_find_device ("/dev", makedev (dm->major, dm->minor));
      if (subdev)
	{
	  lastsubdev = subdev;
	  grub_util_pull_device (subdev);
	}
    }
  if (uuid && strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0
      && lastsubdev)
    {
      char *grdev = grub_util_get_grub_dev (lastsubdev);
      dm_tree_free (tree);
      if (grdev)
	{
	  grub_err_t err;
	  err = grub_cryptodisk_cheat_mount (grdev, os_dev);
	  if (err)
	    grub_util_error (_("can't mount encrypted volume `%s': %s"),
			     lastsubdev, grub_errmsg);
	}
      grub_free (grdev);
    }
  else
    dm_tree_free (tree);
  grub_free (uuid);
}