dasdfmt: Use libdasd provided ioctl functions

Closes: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
This commit is contained in:
Rafael Fonseca
2017-11-28 15:23:20 +01:00
committed by Stefan Haberland
parent 09aa7f2010
commit 8826028bdc
2 changed files with 142 additions and 314 deletions

View File

@@ -2,6 +2,7 @@
* dasdfmt - Format DASD ECKD devices for use by Linux
*
* Copyright IBM Corp. 1999, 2017
* Copyright Red Hat Inc. 2017
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -12,6 +13,7 @@
#include <sys/time.h>
#include <sys/utsname.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/util_opt.h"
#include "lib/util_prg.h"
@@ -26,6 +28,7 @@
#define SEC_PER_HOUR (60 * 60)
static int filedes;
static char dev_filename[PATH_MAX];
static int disk_disabled;
static format_data_t format_params;
static format_mode_t mode;
@@ -264,24 +267,6 @@ static void draw_progress(dasdfmt_info_t *info, int cyl, unsigned int cylinders,
}
}
static int reread_partition_table(void)
{
int i = 0;
int rc = -1;
/* If the BLKRRPART ioctl fails, it is most likely due to
* the device just being in use by udev. So it is worthwhile
* to retry the ioctl after a second as it is likely to succeed.
*/
while (rc && (i < 5)) {
++i;
rc = ioctl(filedes, BLKRRPART, NULL);
if (rc)
sleep(1);
}
return rc;
}
/*
* Helper function for recs_per_track.
*/
@@ -415,6 +400,30 @@ static void evaluate_format_error(dasdfmt_info_t *info, format_check_t *cdata,
}
}
static void disk_enable(void)
{
int err;
err = dasd_disk_enable(filedes);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDENABLE failed (%s)\n", prog_name,
strerror(err));
disk_disabled = 0;
}
static void disk_disable(const char *device)
{
int err;
err = dasd_disk_disable(device, &filedes);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDDISABLE failed. (%s)\n", prog_name,
strerror(err));
disk_disabled = 1;
}
/*
* signal handler:
* enables the disk again in case of SIGTERM, SIGINT and SIGQUIT
@@ -429,27 +438,18 @@ static void program_interrupt_signal(int sig)
if (disk_disabled) {
printf("Re-accessing the device...\n");
rc = ioctl(filedes, BIODASDENABLE, &format_params);
if (rc)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (signal handler) IOCTL "
"BIODASDENABLE failed (%s)\n", prog_name,
strerror(errno));
disk_enable();
}
printf("Rereading the partition table...\n");
rc = reread_partition_table();
rc = dasd_reread_partition_table(dev_filename, 5);
if (rc) {
ERRMSG("%s: (signal handler) Re-reading partition table "
"failed. (%s)\n", prog_name, strerror(errno));
"failed. (%s)\n", prog_name, strerror(rc));
} else {
printf("Exiting...\n");
}
rc = close(filedes);
if (rc)
ERRMSG("%s: (signal handler) Unable to close device (%s)\n",
prog_name, strerror(errno));
signal(sig, SIG_DFL);
raise(sig);
}
@@ -498,30 +498,15 @@ static void get_device_name(char *devname,
}
}
/*
* Retrieve DASD information
*/
static void get_device_info(dasdfmt_info_t *info)
static void get_blocksize(const char *device, unsigned int *blksize)
{
dasd_information2_t dasd_info;
int err;
if (ioctl(filedes, BIODASDINFO2, &dasd_info))
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl call to retrieve "
"device information failed (%s).\n",
prog_name, strerror(errno));
info->dasd_info = dasd_info;
}
/*
* Retrieve blocksize of device
*/
static void get_blocksize(unsigned int *blksize)
{
if (ioctl(filedes, BLKSSZGET, blksize) != 0)
err = dasd_get_blocksize(device, blksize);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to get the blocksize "
"of the device failed (%s).\n", prog_name,
strerror(errno));
strerror(err));
}
/*
@@ -535,7 +520,7 @@ static void check_blocksize(dasdfmt_info_t *info, unsigned int blksize)
info->dasd_info.format == DASD_FORMAT_NONE)
return;
get_blocksize(&dev_blksize);
get_blocksize(dev_filename, &dev_blksize);
if (dev_blksize != blksize) {
ERRMSG_EXIT(EXIT_FAILURE, "WARNING: Device is formatted with a "
"different blocksize (%d).\nUse --mode=full to "
@@ -577,16 +562,15 @@ static void check_layout(dasdfmt_info_t *info, unsigned int intensity)
*/
static void check_disk(dasdfmt_info_t *info, char *devname)
{
int ro, errno_save;
int err;
bool ro;
if (ioctl(filedes, BLKROGET, &ro) != 0) {
errno_save = errno;
close(filedes);
err = dasd_is_ro(devname, &ro);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE,
"%s: the ioctl call to retrieve read/write "
"status information failed (%s)\n",
prog_name, strerror(errno_save));
}
prog_name, strerror(err));
if (ro)
ERRMSG_EXIT(EXIT_FAILURE, "Disk is read only!\n");
@@ -776,9 +760,11 @@ static format_check_t check_track_format(dasdfmt_info_t *info, format_data_t *p)
.stop_unit = p->stop_unit
}, 0
};
int err;
if (ioctl(filedes, BIODASDCHECKFMT, &cdata)) {
if (errno == ENOTTY) {
err = dasd_check_format(dev_filename, &cdata);
if (err != 0) {
if (err == ENOTTY) {
ERRMSG("%s: Missing kernel support for format checking",
prog_name);
if (mode == EXPAND) {
@@ -789,7 +775,7 @@ static format_check_t check_track_format(dasdfmt_info_t *info, format_data_t *p)
ERRMSG_EXIT(EXIT_FAILURE, ".\n");
}
ERRMSG_EXIT(EXIT_FAILURE, "%s: Could no check format: %s\n",
prog_name, strerror(errno));
prog_name, strerror(err));
}
return cdata;
@@ -805,7 +791,7 @@ static int process_tracks(dasdfmt_info_t *info, unsigned int cylinders,
format_data_t step = *format_params;
unsigned long step_value;
unsigned long cur_trk;
int cyl = 0;
int cyl = 0, err;
check_hashmarks(info);
@@ -828,10 +814,11 @@ static int process_tracks(dasdfmt_info_t *info, unsigned int cylinders,
break;
}
} else {
if (ioctl(filedes, BIODASDFMT, &step) != 0)
err = dasd_format_disk(filedes, &step);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl call "
"to format tracks failed. (%s)\n",
prog_name, strerror(errno));
prog_name, strerror(err));
}
cyl = cur_trk / heads + 1;
@@ -966,7 +953,7 @@ static int dasdfmt_get_volser(char *devname, dasd_information2_t *dasd_info,
unsigned int blksize;
volume_label_t vlabel;
get_blocksize(&blksize);
get_blocksize(devname, &blksize);
if ((strncmp(dasd_info->type, "ECKD", 4) == 0) &&
!dasd_info->FBA_layout) {
@@ -993,24 +980,25 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
format5_label_t f5;
format7_label_t f7;
unsigned int blksize;
int rc;
int rc, fd;
void *ipl1_record, *ipl2_record;
int ipl1_record_len, ipl2_record_len;
if (info->verbosity > 0)
printf("Retrieving dasd information... ");
get_blocksize(&blksize);
get_blocksize(dev_filename, &blksize);
/*
* Don't rely on the cylinders returned by HDIO_GETGEO, they might be
* to small. geo is only used to get the number of sectors, which may
* vary depending on the format.
*/
if (ioctl(filedes, HDIO_GETGEO, &geo) != 0)
rc = dasd_get_geo(dev_filename, &geo);
if (rc != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (write labels) IOCTL "
"HDIO_GETGEO failed (%s).\n",
prog_name, strerror(errno));
prog_name, strerror(rc));
if (info->verbosity > 0)
printf("ok\n");
@@ -1036,26 +1024,40 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
ipl2_record_len = sizeof(ipl2.data);
}
if (lseek(filedes, 0, SEEK_SET) != 0)
fd = open(dev_filename, O_RDWR);
if (fd < 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device "
"'%s' (%s)\n", prog_name, dev_filename,
strerror(errno));
if (lseek(fd, 0, SEEK_SET) != 0) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command 0 failed "
"(%s)\n", prog_name, strerror(errno));
}
rc = write(filedes, ipl1_record, ipl1_record_len);
if (rc != ipl1_record_len)
rc = write(fd, ipl1_record, ipl1_record_len);
if (rc != ipl1_record_len) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Writing the bootstrap IPL1 "
"failed, only wrote %d bytes.\n", prog_name, rc);
}
label_position = blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
rc = write(filedes, ipl2_record, ipl2_record_len);
if (rc != ipl2_record_len)
rc = write(fd, ipl2_record, ipl2_record_len);
if (rc != ipl2_record_len) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Writing the bootstrap IPL2 "
"failed, only wrote %d bytes.\n", prog_name, rc);
}
/* write VTOC */
vtoc_init_format4_label(&f4, geo.cylinders, cylinders, heads,
@@ -1071,32 +1073,36 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
if (info->verbosity > 0)
printf("Writing label...\n");
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
/*
* Note: cdl volume labels do not contain the 'formatted_blocks' part
* and ldl labels do not contain the key field
*/
if (info->cdl_format) {
rc = write(filedes, vlabel, (sizeof(*vlabel) -
sizeof(vlabel->formatted_blocks)));
rc = write(fd, vlabel, (sizeof(*vlabel) -
sizeof(vlabel->formatted_blocks)));
} else {
vlabel->ldl_version = 0xf2; /* EBCDIC '2' */
vlabel->formatted_blocks = cylinders * heads * geo.sectors;
rc = write(filedes, &vlabel->vollbl, (sizeof(*vlabel)
- sizeof(vlabel->volkey)));
rc = write(fd, &vlabel->vollbl, (sizeof(*vlabel)
- sizeof(vlabel->volkey)));
}
if (((rc != sizeof(*vlabel) - sizeof(vlabel->formatted_blocks)) &&
info->cdl_format) ||
((rc != (sizeof(*vlabel) - sizeof(vlabel->volkey))) &&
!info->cdl_format))
!info->cdl_format)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing volume label "
"(%d).\n", prog_name, rc);
}
if (info->verbosity > 0)
printf("Writing VTOC... ");
@@ -1104,48 +1110,62 @@ static void dasdfmt_write_labels(dasdfmt_info_t *info, volume_label_t *vlabel,
label_position = (VTOC_START_CC * heads + VTOC_START_HH) *
geo.sectors * blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek command to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
/* write VTOC FMT4 DSCB */
rc = write(filedes, &f4, sizeof(format4_label_t));
if (rc != sizeof(format4_label_t))
rc = write(fd, &f4, sizeof(format4_label_t));
if (rc != sizeof(format4_label_t)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing FMT4 label "
"(%d).\n", prog_name, rc);
}
label_position += blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek to %i failed (%s).\n",
prog_name, label_position, strerror(errno));
}
/* write VTOC FMT5 DSCB */
rc = write(filedes, &f5, sizeof(format5_label_t));
if (rc != sizeof(format5_label_t))
rc = write(fd, &f5, sizeof(format5_label_t));
if (rc != sizeof(format5_label_t)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing FMT5 label "
"(%d).\n", prog_name, rc);
}
if ((cylinders * heads) > BIG_DISK_SIZE) {
label_position += blksize;
rc = lseek(filedes, label_position, SEEK_SET);
if (rc != label_position)
rc = lseek(fd, label_position, SEEK_SET);
if (rc != label_position) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: lseek to %i failed "
"(%s).\n", prog_name, label_position,
strerror(errno));
}
/* write VTOC FMT 7 DSCB (only on big disks) */
rc = write(filedes, &f7, sizeof(format7_label_t));
if (rc != sizeof(format7_label_t))
rc = write(fd, &f7, sizeof(format7_label_t));
if (rc != sizeof(format7_label_t)) {
close(fd);
ERRMSG_EXIT(EXIT_FAILURE, "%s: Error writing FMT7 "
"label (rc=%d).\n", prog_name, rc);
}
}
fsync(filedes);
fsync(fd);
close(fd);
if (info->verbosity > 0)
printf("ok\n");
@@ -1225,6 +1245,7 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
.intensity = ((p->intensity & ~DASD_FMT_INT_FMT_NOR0)
| DASD_FMT_INT_INVAL)
};
int err;
if (!(info->withoutprompt && (info->verbosity < 1)))
printf("Formatting the device. This may take a while "
@@ -1233,19 +1254,16 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
if (info->verbosity > 0)
printf("Detaching the device...\n");
if (ioctl(filedes, BIODASDDISABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDDISABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 1;
disk_disable(dev_filename);
if (info->verbosity > 0)
printf("Invalidate first track...\n");
if (ioctl(filedes, BIODASDFMT, &temp) != 0)
err = dasd_format_disk(filedes, &temp);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (invalidate first track) IOCTL "
"BIODASDFMT failed. (%s)\n", prog_name,
strerror(errno));
strerror(err));
/* except track 0 from standard formatting procss */
p->start_unit = 1;
@@ -1260,19 +1278,16 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
if (info->verbosity > 0)
printf("Revalidate first track...\n");
if (ioctl(filedes, BIODASDFMT, &temp) != 0)
err = dasd_format_disk(filedes, &temp);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (re-validate first track) IOCTL"
" BIODASDFMT failed (%s)\n", prog_name,
strerror(errno));
strerror(err));
if (info->verbosity > 0)
printf("Re-accessing the device...\n");
if (ioctl(filedes, BIODASDENABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDENABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 0;
disk_enable();
}
/*
@@ -1288,11 +1303,7 @@ static void dasdfmt_expand_format(dasdfmt_info_t *info, unsigned int cylinders,
if (info->verbosity > 0)
printf("Detaching the device...\n");
if (ioctl(filedes, BIODASDDISABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDDISABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 1;
disk_disable(dev_filename);
dasdfmt_format(info, cylinders, heads, p);
@@ -1302,11 +1313,7 @@ static void dasdfmt_expand_format(dasdfmt_info_t *info, unsigned int cylinders,
if (info->verbosity > 0)
printf("Re-accessing the device...\n");
if (ioctl(filedes, BIODASDENABLE, p) != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: (prepare device) IOCTL "
"BIODASDENABLE failed. (%s)\n", prog_name,
strerror(errno));
disk_disabled = 0;
disk_enable();
}
/*
@@ -1318,6 +1325,7 @@ static void dasdfmt_quick_format(dasdfmt_info_t *info, unsigned int cylinders,
{
format_check_t cdata = { .expect = {0}, 0 };
format_data_t tmp = *p;
int err;
if (info->force) {
printf("Skipping format check due to --force.\n");
@@ -1348,21 +1356,16 @@ static void dasdfmt_quick_format(dasdfmt_info_t *info, unsigned int cylinders,
printf("Formatting the first two tracks of the device.\n");
/* Disable the device before we do anything */
if (ioctl(filedes, BIODASDDISABLE, p))
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to disable the device "
"failed. (%s)\n", prog_name, strerror(errno));
disk_disabled = 1;
disk_disable(dev_filename);
/* Now do the actual formatting of our first two tracks */
if (ioctl(filedes, BIODASDFMT, p))
err = dasd_format_disk(filedes, p);
if (err != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to format the device "
"failed. (%s)\n", prog_name, strerror(errno));
"failed. (%s)\n", prog_name, strerror(err));
/* Re-Enable the device so that we can continue working with it */
if (ioctl(filedes, BIODASDENABLE, p))
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl to enable the device "
"failed. (%s)\n", prog_name, strerror(errno));
disk_disabled = 0;
disk_enable();
}
static void do_format_dasd(dasdfmt_info_t *info, char *devname,
@@ -1371,7 +1374,7 @@ static void do_format_dasd(dasdfmt_info_t *info, char *devname,
unsigned int heads)
{
char inp_buffer[5];
int count;
int count, err;
p->start_unit = 0;
@@ -1448,9 +1451,10 @@ static void do_format_dasd(dasdfmt_info_t *info, char *devname,
dasdfmt_write_labels(info, vlabel, cylinders, heads);
printf("Rereading the partition table... ");
if (reread_partition_table()) {
err = dasd_reread_partition_table(dev_filename, 5);
if (err != 0) {
ERRMSG("%s: error during rereading the partition "
"table: %s.\n", prog_name, strerror(errno));
"table: %s.\n", prog_name, strerror(err));
} else {
printf("ok\n");
}
@@ -1465,7 +1469,6 @@ int main(int argc, char *argv[])
volume_label_t vlabel;
char old_volser[7];
char dev_filename[PATH_MAX];
char str[ERR_LENGTH];
char buf[7];
@@ -1636,18 +1639,17 @@ int main(int argc, char *argv[])
get_device_name(dev_filename, optind, argc, argv);
filedes = open(dev_filename, O_RDWR);
if (filedes == -1)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device %s: %s\n",
prog_name, dev_filename, strerror(errno));
get_device_info(&info);
rc = dasd_get_info(dev_filename, &info.dasd_info);
if (rc != 0)
ERRMSG_EXIT(EXIT_FAILURE, "%s: the ioctl call to retrieve "
"device information failed (%s).\n",
prog_name, strerror(rc));
/* Either let the user specify the blksize or get it from the kernel */
if (!info.blksize_specified) {
if (!(mode == FULL ||
info.dasd_info.format == DASD_FORMAT_NONE) || info.check)
get_blocksize(&format_params.blksize);
get_blocksize(dev_filename, &format_params.blksize);
else
format_params = ask_user_for_blksize(format_params);
}
@@ -1686,9 +1688,5 @@ int main(int argc, char *argv[])
do_format_dasd(&info, dev_filename, &vlabel,
&format_params, cylinders, heads);
if (close(filedes) != 0)
ERRMSG("%s: error during close: %s\ncontinuing...\n",
prog_name, strerror(errno));
return 0;
}

View File

@@ -31,120 +31,6 @@
* SECTION: Definition needed for DASD-API (see dasd.h) *
****************************************************************************/
#define DASD_IOCTL_LETTER 'D'
/*
* struct dasd_information2_t
* represents any data about the device, which is visible to userspace.
* including format and features.
*/
typedef struct dasd_information2_t {
unsigned int devno; /* S/390 devno */
unsigned int real_devno; /* for aliases */
unsigned int schid; /* S/390 subchannel identifier */
unsigned int cu_type : 16; /* from SenseID */
unsigned int cu_model : 8; /* from SenseID */
unsigned int dev_type : 16; /* from SenseID */
unsigned int dev_model : 8; /* from SenseID */
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len; /* length of chanq */
char type[4]; /* from discipline.name, */
/* 'none' for unknown */
unsigned int status; /* current device level */
unsigned int label_block; /* where to find the VOLSER */
unsigned int FBA_layout; /* fixed block size (like AIXVOL) */
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64]; /* from read_device_characteristics */
char configuration_data[256]; /* from read_configuration_data */
unsigned int format; /* format info like formatted/cdl/ldl/... */
unsigned int features; /* dasd features like 'ro',... */
unsigned int reserved0; /* reserved for further use ,... */
unsigned int reserved1; /* reserved for further use ,... */
unsigned int reserved2; /* reserved for further use ,... */
unsigned int reserved3; /* reserved for further use ,... */
unsigned int reserved4; /* reserved for further use ,... */
unsigned int reserved5; /* reserved for further use ,... */
unsigned int reserved6; /* reserved for further use ,... */
unsigned int reserved7; /* reserved for further use ,... */
} dasd_information2_t;
struct dasd_eckd_characteristics {
unsigned short cu_type;
struct {
unsigned char support:2;
unsigned char async:1;
unsigned char reserved:1;
unsigned char cache_info:1;
unsigned char model:3;
} __attribute__ ((packed)) cu_model;
unsigned short dev_type;
unsigned char dev_model;
struct {
unsigned char mult_burst:1;
unsigned char RT_in_LR:1;
unsigned char reserved1:1;
unsigned char RD_IN_LR:1;
unsigned char reserved2:4;
unsigned char reserved3:8;
unsigned char defect_wr:1;
unsigned char XRC_supported:1;
unsigned char reserved4:1;
unsigned char striping:1;
unsigned char reserved5:4;
unsigned char cfw:1;
unsigned char reserved6:2;
unsigned char cache:1;
unsigned char dual_copy:1;
unsigned char dfw:1;
unsigned char reset_alleg:1;
unsigned char sense_down:1;
} __attribute__ ((packed)) facilities;
unsigned char dev_class;
unsigned char unit_type;
unsigned short no_cyl;
unsigned short trk_per_cyl;
unsigned char sec_per_trk;
unsigned char byte_per_track[3];
unsigned short home_bytes;
unsigned char formula;
union {
struct {
unsigned char f1;
unsigned short f2;
unsigned short f3;
} __attribute__ ((packed)) f_0x01;
struct {
unsigned char f1;
unsigned char f2;
unsigned char f3;
unsigned char f4;
unsigned char f5;
} __attribute__ ((packed)) f_0x02;
} __attribute__ ((packed)) factors;
unsigned short first_alt_trk;
unsigned short no_alt_trk;
unsigned short first_dia_trk;
unsigned short no_dia_trk;
unsigned short first_sup_trk;
unsigned short no_sup_trk;
unsigned char MDR_ID;
unsigned char OBR_ID;
unsigned char director;
unsigned char rd_trk_set;
unsigned short max_rec_zero;
unsigned char reserved1;
unsigned char RWANY_in_LR;
unsigned char factor6;
unsigned char factor7;
unsigned char factor8;
unsigned char reserved2[3];
unsigned char reserved3[6];
unsigned int long_no_cyl;
} __attribute__ ((packed));
/*
* Represents possible format modes that can be specified when formatting
* a DASD.
@@ -159,17 +45,6 @@ static const char mode_str[3][10] = {
"Full", "Quick", "Expand"
};
/*
* struct format_data_t
* represents all data necessary to format a dasd
*/
typedef struct format_data_t {
unsigned int start_unit; /* from track */
unsigned int stop_unit; /* to track */
unsigned int blksize; /* sectorsize */
unsigned int intensity;
} format_data_t;
/*
* values to be used for format_data_t.intensity
* 0/8: normal format
@@ -183,24 +58,6 @@ typedef struct format_data_t {
#define DASD_FMT_INT_COMPAT 8 /* use OS/390 compatible disk layout */
#define DASD_FMT_INT_FMT_NOR0 16 /* remove permission to write record zero */
/*
* struct format_check_t
* represents all data necessary to evaluate the format of
* different tracks of a dasd
*/
typedef struct format_check_t {
/* Input */
struct format_data_t expect;
/* Output */
unsigned int result; /* Error indication (DASD_FMT_ERR_*) */
unsigned int unit; /* Track that is in error */
unsigned int rec; /* Record that is in error */
unsigned int num_records; /* Records in the track in error */
unsigned int blksize; /* Block-size of first record in error */
unsigned int key_length; /* Key length of first record in error */
} format_check_t;
/*
* values to be used in format_check_t for indicating
* possible format errors
@@ -221,33 +78,6 @@ typedef struct format_check_t {
#define DASD_FORMAT_LDL 1
#define DASD_FORMAT_CDL 2
/* Disable the volume (for Linux) */
#define BIODASDDISABLE _IO(DASD_IOCTL_LETTER,0)
/* Enable the volume (for Linux) */
#define BIODASDENABLE _IO(DASD_IOCTL_LETTER,1)
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER, 3, dasd_information2_t)
/* #define BIODASDFORMAT _IOW(IOCTL_LETTER,0,format_data_t) , deprecated */
#define BIODASDFMT _IOW(DASD_IOCTL_LETTER,1,format_data_t)
/* Check device format according to format_data_t */
#define BIODASDCHECKFMT _IOWR(DASD_IOCTL_LETTER, 2, format_check_t)
/****************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h ) *
****************************************************************************/
/* re-read partition table */
#define BLKRRPART _IO(0x12,95)
/* get block device sector size */
#define BLKSSZGET _IO(0x12,104)
/* get read-only status (0 = read_write) */
#define BLKROGET _IO(0x12,94)
/* get device geometry */
#define HDIO_GETGEO 0x0301
/****************************************************************************
* SECTION: DASDFMT internal types *
****************************************************************************/