Esempio n. 1
0
/* Use vfs-type to look for a filesystem of some sort on 'dev'.
 * Apart from some types which we ignore, add the result to the
 * 'ret' string list.
 */
static void
check_with_vfs_type (guestfs_h *g, const char *device,
                     char ***ret, size_t *ret_size)
{
  char *v;
  char *vfs_type;

  guestfs_push_error_handler (g, NULL, NULL);
  vfs_type = guestfs_vfs_type (g, device);
  guestfs_pop_error_handler (g);

  if (!vfs_type)
    v = safe_strdup (g, "unknown");
  else if (STREQ (vfs_type, "")) {
    v = safe_strdup (g, "unknown");
    free (vfs_type);
  }
  else if (STREQ (vfs_type, "btrfs")) {
    CLEANUP_FREE_BTRFSSUBVOLUME_LIST struct guestfs_btrfssubvolume_list *vols =
      guestfs_btrfs_subvolume_list (g, device);

    for (size_t i = 0; i < vols->len; i++) {
      struct guestfs_btrfssubvolume *this = &vols->val[i];
      char *mountable = safe_asprintf (g, "btrfsvol:%s/%s",
                                       device, this->btrfssubvolume_path);
      add_vfs (g, mountable, safe_strdup (g, "btrfs"), ret, ret_size);
    }

    v = vfs_type;
  }
Esempio n. 2
0
/* Use vfs-type to look for a filesystem of some sort on 'dev'.
 * Apart from some types which we ignore, add the result to the
 * 'ret' string list.
 */
static int
check_with_vfs_type (guestfs_h *g, const char *device, struct stringsbuf *sb)
{
  const char *v;
  CLEANUP_FREE char *vfs_type = NULL;

  guestfs_push_error_handler (g, NULL, NULL);
  vfs_type = guestfs_vfs_type (g, device);
  guestfs_pop_error_handler (g);

  if (!vfs_type)
    v = "unknown";
  else if (STREQ (vfs_type, ""))
    v = "unknown";
  else if (STREQ (vfs_type, "btrfs")) {
    CLEANUP_FREE_BTRFSSUBVOLUME_LIST struct guestfs_btrfssubvolume_list *vols =
      guestfs_btrfs_subvolume_list (g, device);

    if (vols == NULL)
      return -1;

    for (size_t i = 0; i < vols->len; i++) {
      struct guestfs_btrfssubvolume *this = &vols->val[i];
      guestfs_int_add_sprintf (g, sb,
			       "btrfsvol:%s/%s",
			       device, this->btrfssubvolume_path);
      guestfs_int_add_string (g, sb, "btrfs");
    }

    v = vfs_type;
  }
Esempio n. 3
0
/* Use vfs-type to look for a filesystem of some sort on 'dev'.
 * Apart from some types which we ignore, add the result to the
 * 'ret' string list.
 */
static int
check_with_vfs_type (guestfs_h *g, const char *device, struct stringsbuf *sb)
{
  const char *v;
  CLEANUP_FREE char *vfs_type = NULL;

  guestfs_push_error_handler (g, NULL, NULL);
  vfs_type = guestfs_vfs_type (g, device);
  guestfs_pop_error_handler (g);

  if (!vfs_type)
    v = "unknown";
  else if (STREQ (vfs_type, ""))
    v = "unknown";
  else if (STREQ (vfs_type, "btrfs")) {
    CLEANUP_FREE_BTRFSSUBVOLUME_LIST struct guestfs_btrfssubvolume_list *vols =
      guestfs_btrfs_subvolume_list (g, device);

    if (vols == NULL)
      return -1;

    int64_t default_volume = guestfs_btrfs_subvolume_get_default (g, device);

    for (size_t i = 0; i < vols->len; i++) {
      struct guestfs_btrfssubvolume *this = &vols->val[i];

      /* Ignore the default subvolume.  We get it by simply mounting
       * the whole device of this btrfs filesystem.
       */
      if (this->btrfssubvolume_id == (uint64_t) default_volume)
        continue;

      guestfs_int_add_sprintf (g, sb,
			       "btrfsvol:%s/%s",
			       device, this->btrfssubvolume_path);
      guestfs_int_add_string (g, sb, "btrfs");
    }

    v = vfs_type;
  }