Example #1
0
static int sun_set_parttype(
		struct fdisk_context *cxt,
		size_t i,
		struct fdisk_parttype *t)
{
	struct sun_disklabel *sunlabel;
	struct sun_partition *part;
	struct sun_info *info;

	assert(cxt);
	assert(cxt->label);
	assert(fdisk_is_disklabel(cxt, SUN));

	sunlabel = self_disklabel(cxt);

	if (i >= cxt->label->nparts_max || !t || t->type > UINT16_MAX)
		return -EINVAL;

	if (i == 2 && t->type != SUN_TAG_WHOLEDISK)
		fdisk_info(cxt, _("Consider leaving partition 3 as Whole disk (5),\n"
		         "as SunOS/Solaris expects it and even Linux likes it.\n"));

	part = &sunlabel->partitions[i];
	info = &sunlabel->vtoc.infos[i];

	if (t->type == SUN_TAG_LINUX_SWAP && !part->start_cylinder) {
	    int yes, rc;
	    rc = fdisk_ask_yesno(cxt,
	      _("It is highly recommended that the partition at offset 0\n"
	      "is UFS, EXT2FS filesystem or SunOS swap. Putting Linux swap\n"
	      "there may destroy your partition table and bootblock.\n"
	      "Are you sure you want to tag the partition as Linux swap?"), &yes);
	    if (rc)
		    return rc;
	    if (!yes)
		    return 1;
	}

	switch (t->type) {
	case SUN_TAG_SWAP:
	case SUN_TAG_LINUX_SWAP:
		/* swaps are not mountable by default */
		info->flags |= cpu_to_be16(SUN_FLAG_UNMNT);
		break;
	default:
		/* assume other types are mountable;
		   user can change it anyway */
		info->flags &= ~cpu_to_be16(SUN_FLAG_UNMNT);
		break;
	}
	info->id = cpu_to_be16(t->type);
	return 0;
}
Example #2
0
static int sgi_set_partition(struct fdisk_context *cxt,
		size_t i,
		struct fdisk_partition *pa)
{
	struct sgi_disklabel *sgilabel;

	if (i >= cxt->label->nparts_max)
		return -EINVAL;

	sgilabel = self_disklabel(cxt);

	if (pa->type) {
		struct fdisk_parttype *t = pa->type;

		if (sgi_get_num_sectors(cxt, i) == 0)	/* caught already before, ... */ {
			fdisk_warnx(cxt, _("Sorry, only for non-empty partitions you can change the tag."));
			return -EINVAL;
		}

		if ((i == 10 && t->code != SGI_TYPE_ENTIRE_DISK)
		    || (i == 8 && t->code != 0))
			fdisk_info(cxt, _("Consider leaving partition 9 as volume header (0), "
					  "and partition 11 as entire volume (6), "
					  "as IRIX expects it."));

		if (cxt->script == NULL
		    && ((t->code != SGI_TYPE_ENTIRE_DISK) && (t->code != SGI_TYPE_VOLHDR))
		    && (sgi_get_start_sector(cxt, i) < 1)) {
			int yes = 0;
			fdisk_ask_yesno(cxt,
				_("It is highly recommended that the partition at offset 0 "
				  "is of type \"SGI volhdr\", the IRIX system will rely on it to "
				  "retrieve from its directory standalone tools like sash and fx. "
				  "Only the \"SGI volume\" entire disk section may violate this. "
				  "Are you sure about tagging this partition differently?"), &yes);
			if (!yes)
				return 1;
		}

		sgilabel->partitions[i].type = cpu_to_be32(t->code);
	}

	if (fdisk_partition_has_start(pa))
		sgilabel->partitions[i].first_block = cpu_to_be32(pa->start);
	if (fdisk_partition_has_size(pa))
		sgilabel->partitions[i].num_blocks = cpu_to_be32(pa->size);

	fdisk_label_set_changed(cxt->label, 1);
	return 0;
}
Example #3
0
/* Returns 0 on success, < 0 on error. */
static int bsd_create_disklabel(struct fdisk_context *cxt)
{
    int rc, yes = 0;
    struct bsd_disklabel *d = self_disklabel(cxt);

    fdisk_info(cxt, _("The device %s does not contain BSD disklabel."), cxt->dev_path);
    rc = fdisk_ask_yesno(cxt,
                         _("Do you want to create a BSD disklabel?"),
                         &yes);
    if (rc)
        return rc;
    if (!yes)
        return 1;
    if (cxt->parent) {
        rc = bsd_assign_dos_partition(cxt);
        if (rc == 1)
            /* not found DOS partition usable for BSD label */
            rc = -EINVAL;
    }
    if (rc)
        return rc;

    rc = bsd_initlabel(cxt);
    if (!rc) {
        int org = fdisk_context_display_details(cxt);

        cxt->label->nparts_cur = d->d_npartitions;
        cxt->label->nparts_max = BSD_MAXPARTITIONS;

        fdisk_context_enable_details(cxt, 1);
        bsd_list_disklabel(cxt);
        fdisk_context_enable_details(cxt, org);
    }

    return rc;
}