Ejemplo n.º 1
0
int
do_set_label (const mountable_t *mountable, const char *label)
{
  int r;

  /* How we set the label depends on the filesystem type. */
  CLEANUP_FREE char *vfs_type = do_vfs_type (mountable);
  if (vfs_type == NULL)
    return -1;

  if (STREQ (vfs_type, "btrfs"))
    r = btrfslabel (mountable->device, label);

  else if (STREQ (vfs_type, "msdos") ||
           STREQ (vfs_type, "fat") ||
           STREQ (vfs_type, "vfat"))
    r = dosfslabel (mountable->device, label);

  else if (fstype_is_extfs (vfs_type))
    r = e2label (mountable->device, label);

  else if (STREQ (vfs_type, "ntfs"))
    r = ntfslabel (mountable->device, label);

  else if (STREQ (vfs_type, "xfs"))
    r = xfslabel (mountable->device, label);

  else {
    reply_with_error ("don't know how to set the label for '%s' filesystems",
                      vfs_type);
    r = -1;
  }

  return r;
}
Ejemplo n.º 2
0
char *
do_vfs_label (const mountable_t *mountable)
{
  CLEANUP_FREE char *type = do_vfs_type (mountable);

  if (type) {
    if (STREQ (type, "btrfs") && optgroup_btrfs_available ())
      return btrfs_get_label (mountable->device);
    if (STREQ (type, "ntfs") && optgroup_ntfsprogs_available ())
      return ntfs_get_label (mountable->device);
  }

  return get_blkid_tag (mountable->device, "LABEL");
}