Beispiel #1
0
/*
 * initializes a format1 label
 */
void
vtoc_init_format1_label (char *volid, unsigned int blksize,
                         extent_t *part_extent, format1_label_t *f1)
{
	PDEBUG
	struct tm * creatime;
	time_t t;
	char str[80];

	/* get actual date */
	t = time(NULL);
	creatime = gmtime(&t);

	bzero(f1->DS1DSNAM, sizeof(f1->DS1DSNAM));
	sprintf(str, "PART    .NEW                                ");
	vtoc_ebcdic_enc(str, str, 44);
	strncpy(f1->DS1DSNAM, str, 44);
	f1->DS1FMTID = 0xf1;
	strncpy(f1->DS1DSSN, "      ", 6);
	f1->DS1VOLSQ = 0x0001;

	vtoc_set_date(&f1->DS1CREDT, (u_int8_t) creatime->tm_year,
				  (u_int16_t) creatime->tm_yday);
	/* expires never - 99 365 */
	vtoc_set_date(&f1->DS1EXPDT, 0x63, 0x016D);
	f1->DS1NOEPV = 0x01;
	f1->DS1NOBDB = 0x00;
	f1->DS1FLAG1 = 0x00;
	vtoc_ebcdic_enc("IBM LINUX    ", str, 13);
	strncpy(f1->DS1SYSCD, str, 13);
	vtoc_set_date(&f1->DS1REFD, (u_int8_t) creatime->tm_year,
				  (u_int16_t) creatime->tm_yday);
	f1->DS1SMSFG = 0x00;
	f1->DS1SCXTF = 0x00;
	f1->DS1SCXTV = 0x0000;
	f1->DS1DSRG1 = 0x00;
	f1->DS1DSRG2 = 0x00;
	f1->DS1RECFM = 0x88;
	f1->DS1OPTCD = 0x00;
	f1->DS1BLKL  = blksize;
	f1->DS1LRECL = blksize;
	f1->DS1KEYL  = 0x00;
	f1->DS1RKP   = 0x0000;
	f1->DS1DSIND = 0x80; /* last volume for this dataset */
	f1->DS1SCAL1 = 0x80;
	bzero(&f1->DS1SCAL3, sizeof(f1->DS1SCAL3));
	vtoc_set_ttr(&f1->DS1LSTAR, 0x0000, 0x00);
	f1->DS1TRBAL = 0x00;
	bzero(&f1->res1, sizeof(f1->res1));
	memcpy(&f1->DS1EXT1, part_extent, sizeof(extent_t));
	bzero(&f1->DS1EXT2, sizeof(extent_t));
	bzero(&f1->DS1EXT3, sizeof(extent_t));
	vtoc_set_cchhb(&f1->DS1PTRDS, 0x0000, 0x0000, 0x00);
}
Beispiel #2
0
/*
 * initializes a format4 label
 */
void
vtoc_init_format4_label (format4_label_t *f4, unsigned int usable_partitions,
                         unsigned int cylinders, unsigned int tracks,
                         unsigned int blocks, unsigned int blksize,
                         u_int16_t dev_type)
{
	PDEBUG
	int i;

	cchh_t lower = {VTOC_START_CC, VTOC_START_HH};
	cchh_t upper = {VTOC_START_CC, VTOC_START_HH};

	for (i=0; i<44; i++) f4->DS4KEYCD[i] = 0x04;
        f4->DS4IDFMT = 0xf4;

	vtoc_set_cchhb(&f4->DS4HPCHR, 0x0000, 0x0000, 0x00);
	f4->DS4DSREC = blocks - 2;
	/* free space starts right behind VTOC
	   vtoc_set_cchh(&f4->DS4HCCHH, VTOC_START_CC, VTOC_START_HH + 1);*/
	vtoc_set_cchh(&f4->DS4HCCHH, 0x0000, 0x0000);
	f4->DS4NOATK = 0x0000;
	f4->DS4VTOCI = 0x00;
	f4->DS4NOEXT = 0x01;
	f4->DS4SMSFG = 0x00;
	f4->DS4DEVAC = 0x00;

	/* -- begin f4->DS4DEVCT -- */
	f4->DS4DEVCT.DS4DSCYL = cylinders;
	f4->DS4DEVCT.DS4DSTRK = tracks;

	switch (dev_type) {
		case DASD_3380_TYPE:
			f4->DS4DEVCT.DS4DEVTK = DASD_3380_VALUE;
			break;
		case DASD_3390_TYPE:
			f4->DS4DEVCT.DS4DEVTK = DASD_3390_VALUE;
			break;
		case DASD_9345_TYPE:
			f4->DS4DEVCT.DS4DEVTK = DASD_9345_VALUE;
			break;
		default:
			f4->DS4DEVCT.DS4DEVTK = blocks * blksize;;
	}

	f4->DS4DEVCT.DS4DEVI  = 0x00;
	f4->DS4DEVCT.DS4DEVL  = 0x00;
	f4->DS4DEVCT.DS4DEVK  = 0x00;
	f4->DS4DEVCT.DS4DEVFG = 0x30;
	f4->DS4DEVCT.DS4DEVTL = 0x0000;
	f4->DS4DEVCT.DS4DEVDT = blocks;
	f4->DS4DEVCT.DS4DEVDB = 0x00;
	/* -- end f4->DS4DEVCT -- */

	bzero(f4->DS4AMTIM, sizeof(f4->DS4AMTIM));
	bzero(f4->DS4AMCAT, sizeof(f4->DS4AMCAT));
	bzero(f4->DS4R2TIM, sizeof(f4->DS4R2TIM));
	bzero(f4->res1, sizeof(f4->res1));
	bzero(f4->DS4F6PTR, sizeof(f4->DS4F6PTR));

	/* -- begin f4lbl->DS4VTOCE -- */
	vtoc_set_extent(&f4->DS4VTOCE, 0x01, 0x00, &lower, &upper);
	/* -- end f4lbl->DS4VTOCE -- */

	bzero(f4->res2, sizeof(f4->res2));
	f4->DS4EFLVL = 0x00;
	bzero(&f4->DS4EFPTR, sizeof(f4->DS4EFPTR));
	bzero(f4->res3, sizeof(f4->res3));
}
Beispiel #3
0
static void do_format_dasd(dasdfmt_info_t *info, format_data_t *p,
                           volume_label_t *vlabel)
{
    char               inp_buffer[5];
    dasd_information_t  dasd_info;
    struct dasd_eckd_characteristics *characteristics;
    unsigned int cylinders, heads;

    if (info->verbosity > 0) printf("Retrieving disk geometry...\n");

    if (ioctl(filedes, BIODASDINFO, &dasd_info) != 0)
        ERRMSG_EXIT(EXIT_FAILURE, "%s: (retrieving disk information) "
                    "IOCTL BIODASDINFO failed (%s).\n",
                    prog_name, strerror(errno));

    characteristics =
        (struct dasd_eckd_characteristics *) &dasd_info.characteristics;
    if (characteristics->no_cyl == LV_COMPAT_CYL &&
            characteristics->long_no_cyl)
        cylinders = characteristics->long_no_cyl;
    else
        cylinders = characteristics->no_cyl;
    heads = characteristics->trk_per_cyl;

    p->start_unit = 0;
    p->stop_unit  = (cylinders * heads) - 1;

    if (info->writenolabel) {
        if (cylinders > LV_COMPAT_CYL && !info->withoutprompt) {
            printf("\n--->> ATTENTION! <<---\n");
            printf("You specified to write no labels to a"
                   " volume with more then %u cylinders.\n"
                   "Cylinders above this limit will not be"
                   " accessible as a linux partition!\n"
                   "Type \"yes\" to continue, no will leave"
                   " the disk untouched: ", LV_COMPAT_CYL);
            if (fgets(inp_buffer, sizeof(inp_buffer), stdin) == NULL)
                return;
            if (strcasecmp(inp_buffer, "yes") &&
                    strcasecmp(inp_buffer, "yes\n")) {
                printf("Omitting ioctl call (disk will "
                       "NOT be formatted).\n");
                return;
            }
        }
    } else {
        if (!info->labelspec && !info->keep_volser) {
            char buf[7];

            sprintf(buf, "0X%04x", info->devno);
            check_volser(buf, info->devno);
            vtoc_volume_label_set_volser(vlabel, buf);
        }

        if (p->intensity & DASD_FMT_INT_COMPAT) {
            info->cdl_format = 1;
            vtoc_volume_label_set_label(vlabel, "VOL1");
            vtoc_volume_label_set_key(vlabel, "VOL1");
            vtoc_set_cchhb(&vlabel->vtoc, 0x0000, 0x0001, 0x01);
        } else
            vtoc_volume_label_set_label(vlabel, "LNX1");
    }

    if ((info->verbosity > 0) || (!info->withoutprompt))
        dasdfmt_print_info(info, vlabel, cylinders, heads, p);

    if (!info->testmode) {
        if (!info->withoutprompt) {
            printf("\n--->> ATTENTION! <<---\n");
            printf("All data of that device will be lost.\nType "
                   "\"yes\" to continue, no will leave the disk "
                   "untouched: ");
            if (fgets(inp_buffer, sizeof(inp_buffer), stdin) == NULL)
                return;
            if (strcasecmp(inp_buffer,"yes") &&
                    strcasecmp(inp_buffer,"yes\n")) {
                printf("Omitting ioctl call (disk will "
                       "NOT be formatted).\n");
                return;
            }
        }

        if (!((info->withoutprompt)&&(info->verbosity<1)))
            printf("Formatting the device. This may take a "
                   "while (get yourself a coffee).\n");

        dasdfmt_prepare_and_format(info, cylinders, heads, p);

        printf("Finished formatting the device.\n");

        if (!info->writenolabel)
            dasdfmt_write_labels(info, vlabel, cylinders, heads);

        printf("Rereading the partition table... ");
        if (reread_partition_table()) {
            ERRMSG("%s: error during rereading the partition "
                   "table: %s.\n", prog_name, strerror(errno));
        } else
            printf("ok\n");
    }
}