mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Initial s390-tools-2.0.0 import
This commit is based on the s390-tools-1.39.0 version. Changes on top of s390-tools-1.39.0: - Add MIT license to all source files - Add LICENSE file - Transform REAMDE to README.md (markdown) - Add AUTHORS.md file - Add CONTRIBUTING.md file - Move changelog from README to CHANGELOG.md file Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
include ../common.mak
|
||||
|
||||
libs = $(rootdir)/libvtoc/libvtoc.a \
|
||||
$(rootdir)/libzds/libzds.a \
|
||||
$(rootdir)/libdasd/libdasd.a \
|
||||
$(rootdir)/libu2s/libu2s.a \
|
||||
$(rootdir)/libutil/libutil.a
|
||||
|
||||
all: fdasd
|
||||
|
||||
fdasd: fdasd.o $(libs)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man8
|
||||
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 fdasd $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 fdasd.8 \
|
||||
$(DESTDIR)$(MANDIR)/man8
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ fdasd core
|
||||
|
||||
.PHONY: all install clean
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
.\" Copyright 2017 IBM Corp.
|
||||
.\" s390-tools is free software; you can redistribute it and/or modify
|
||||
.\" it under the terms of the MIT license. See LICENSE for details.
|
||||
.\"
|
||||
.TH FDASD 8 "Apr 2006" "s390-tools"
|
||||
.SH NAME
|
||||
fdasd \- partitioning tool.
|
||||
.SH SYNOPSIS
|
||||
interactive mode:
|
||||
.br
|
||||
\fBfdasd\fR [-s] [-r] [-C] \fIdevice\fR
|
||||
.br
|
||||
command line mode:
|
||||
.br
|
||||
\fBfdasd\fR [-s] [-r] [-C] {-a[-k|-l \fIvolser\fR]|-i|-p|-c \fIconf_file\fR}
|
||||
[-f \fI[type,blocksize]\fR] \fIdevice\fR
|
||||
.br
|
||||
help:
|
||||
.br
|
||||
\fBfdasd\fR {-h|-v}
|
||||
.SH DESCRIPTION
|
||||
\fBfdasd\fR writes a partition table to a cdl (compatible disk layout)
|
||||
formatted DASD, in the form of
|
||||
a VTOC (volume table of contents) for usage with Linux for S/390
|
||||
or zSeries. If fdasd detects a valid \fBVOL1\fR volume label, it
|
||||
will use it, otherwise it asks to write a new one.
|
||||
.br
|
||||
|
||||
\fBAttention\fR: Careless use of
|
||||
\fBfdasd\fR can result in loss of data.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB-h\fR or \fB--help\fR
|
||||
Print usage information, then exit.
|
||||
|
||||
.TP
|
||||
\fB-v\fR or \fB--version\fR
|
||||
Print version information, then exit.
|
||||
|
||||
.TP
|
||||
\fB-s\fR or \fB--silent\fR
|
||||
Suppress messages in non-interactive mode.
|
||||
|
||||
.TP
|
||||
\fB-r\fR or \fB--verbose\fR
|
||||
Provide more verbose output.
|
||||
|
||||
.TP
|
||||
\fB-a\fR or \fB--auto\fR
|
||||
Automatically create a partition using the entire disk in non-interactive
|
||||
mode.
|
||||
|
||||
.TP
|
||||
\fB-k\fR or \fB--keep_volser\fR
|
||||
Keeps the volume serial when writing the volume label.
|
||||
.br
|
||||
This is useful, if the volume serial has been written before and should not
|
||||
be overwritten. This option is only applicable in non-interactive mode.
|
||||
|
||||
.TP
|
||||
\fB-l\fR \fIvolser\fR or \fB--label\fR \fIvolser\fR
|
||||
Specify the volume serial.
|
||||
.br
|
||||
\fIvolser\fR is interpreted as ASCII string and is automatically converted to
|
||||
uppercase, padded with blanks and finally converted to EBCDIC to be written
|
||||
to disk. This option is only applicable in non-interactive mode.
|
||||
.br
|
||||
|
||||
Do not use the following reserved volume serial: SCRTCH, PRIVAT, MIGRAT,
|
||||
or Lnnnnn (L with five digit number); These are used as keywords by
|
||||
other operating systems (OS/390).
|
||||
.br
|
||||
|
||||
A volume serial is 1 through 6 alphanumeric characters or one of the
|
||||
following special characters: $, #, @, %. All other characters are simply
|
||||
ignored.
|
||||
.br
|
||||
Try to avoid using special characters in the volume serial.
|
||||
This may cause problems accessing a disk by volser.
|
||||
In case you really have to use special characters, make sure you are using
|
||||
quotes. In addition there is a special handling for the '$' sign.
|
||||
Please specify it using '\\$' if necessary.
|
||||
.br
|
||||
|
||||
e.g. -l 'a@b\\$c#' to get A@B$C#
|
||||
.br
|
||||
|
||||
Omitting this parameter causes fdasd to ask for it in case it is needed.
|
||||
.br
|
||||
|
||||
.TP
|
||||
\fB-c\fR \fIconf_file\fR or \fB--config\fR \fIconf_file\fR
|
||||
Use this option to create multiple partitions according to
|
||||
specifications in a configuration file, \fIconf_file\fR.
|
||||
.br
|
||||
The configuration file contains one line for each partition. The lines
|
||||
have this format:
|
||||
.sp
|
||||
[<first>,<last>,<type>]
|
||||
.br
|
||||
|
||||
where:
|
||||
|
||||
.br
|
||||
<first> and <last> are numbers that specify the first and the last
|
||||
track of the partition. Instead of a numerical value, you can
|
||||
specify 'first' for the first possible track on the disk and 'last'
|
||||
for the last possible track on disk.
|
||||
.br
|
||||
|
||||
<type> is optional and specifies the partition type. <type> can be one
|
||||
of: native, swap, raid, lvm, or gpfs.
|
||||
If omitted, 'native' is used.
|
||||
.br
|
||||
|
||||
The configuration file of the following example specifies three
|
||||
partitions that use the entire disk:
|
||||
.sp
|
||||
[first,1000]
|
||||
.br
|
||||
[1001,2000,swap]
|
||||
.br
|
||||
[2001,last,lvm]
|
||||
.br
|
||||
|
||||
.TP
|
||||
\fB-i\fR or \fB--volser\fR
|
||||
Print the volume serial, then exit.
|
||||
|
||||
.TP
|
||||
\fB-p\fR or \fB--table\fR
|
||||
Print partition table, then exit.
|
||||
.br
|
||||
In combination with the -s option fdasd will display a short version of the
|
||||
partition table.
|
||||
|
||||
.TP
|
||||
\fB-C\fR or \fB--check_host_count\fR
|
||||
Force fdasd to check the host access open count to ensure the device
|
||||
is not online on another operating system instance
|
||||
|
||||
.TP
|
||||
\fB-f\fR \fI[type,blocksize]\fR or \fB--force\fR \fI[type,blocksize]\fR
|
||||
Force fdasd to work on non DASD devices.
|
||||
.br
|
||||
If fdasd is to be used on a block device that is neither a native DASD
|
||||
nor exposes the proper disk geometry of a DASD of type 3390,
|
||||
then the --force option can be used to assume the geometry of a
|
||||
given device type. The default device type is 3390 and the default
|
||||
block size is 4096. An optional argument of <device type>,<blocksize>
|
||||
can be used to specify type and blocksize explicitly. For example:
|
||||
|
||||
-f
|
||||
|
||||
has the same effect as
|
||||
|
||||
-f3390,4096 or --force=3390,4096
|
||||
|
||||
Valid device types are: 3390, 3380, 9345
|
||||
.br
|
||||
Valid block sizes are: 4096, 2048, 1024, 512
|
||||
|
||||
You can use the verbose option to get information about the disk
|
||||
geometry that fdasd has computed from device type and block size.
|
||||
|
||||
.TP
|
||||
\fIdevice\fR
|
||||
This parameter specifies the device to be partitioned:
|
||||
.sp
|
||||
\fB/dev/dasd/\fR\fIxxxx\fR\fB/device\fR
|
||||
.br
|
||||
|
||||
where \fIxxxx\fR is the four-letter devno (device number).
|
||||
.br
|
||||
|
||||
In case your are not using the device file system, please specify:
|
||||
.sp
|
||||
\fB/dev/dasd\fR\fIx\fR
|
||||
.br
|
||||
|
||||
where \fIx\fR is one or more lowercase letter(s) or any other device
|
||||
node specification configured by udev for kernel 2.6 or higher.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR dasdfmt (8)
|
||||
+3074
File diff suppressed because it is too large
Load Diff
+260
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* fdasd - Create or modify partitions on ECKD DASDs
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 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.
|
||||
*/
|
||||
|
||||
#ifndef FDASD_H
|
||||
#define FDASD_H
|
||||
|
||||
/*****************************************************************************
|
||||
* SECTION: Definitions needed for DASD-API (see dasd.h) *
|
||||
*****************************************************************************/
|
||||
|
||||
#define DASD_IOCTL_LETTER 'D'
|
||||
|
||||
#define DASD_PARTN_BITS 2
|
||||
|
||||
/*
|
||||
* struct dasd_information_t
|
||||
* represents any data about the device, which is visible to userspace.
|
||||
* including foramt and featueres.
|
||||
*/
|
||||
typedef struct dasd_information_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 */
|
||||
} dasd_information_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));
|
||||
|
||||
/* Get information on a dasd device (enhanced) */
|
||||
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
|
||||
|
||||
/*****************************************************************************
|
||||
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h) *
|
||||
*****************************************************************************/
|
||||
#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
|
||||
#define BLKRRPART _IO(0x12,95) /* re-read partition table */
|
||||
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
|
||||
#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* device size in bytes (u64 *arg)*/
|
||||
|
||||
/* get device geometry */
|
||||
#define HDIO_GETGEO 0x0301
|
||||
|
||||
/*****************************************************************************
|
||||
* SECTION: FDASD internal types *
|
||||
*****************************************************************************/
|
||||
#define PARTN_MASK ((1 << DASD_PARTN_BITS) - 1)
|
||||
#define USABLE_PARTITIONS ((1 << DASD_PARTN_BITS) - 1)
|
||||
|
||||
#define DEFAULT_FDASD_CONF "/etc/fdasd.conf" /* default config file */
|
||||
#define CONFIG_FILE_SIZE (USABLE_PARTITIONS * LINE_LENGTH)
|
||||
#define CONFIG_MAX 3 /* maximum number of parameters per config file entry */
|
||||
|
||||
#define FDASD_ERROR "fdasd error: "
|
||||
#define DEVICE "device"
|
||||
#define DISC "disc"
|
||||
#define PART "part"
|
||||
|
||||
#define ALTERNATE_CYLINDERS_USED 0x10
|
||||
|
||||
/* partition types */
|
||||
#define PARTITION_NEW 0
|
||||
#define PARTITION_NATIVE 1
|
||||
#define PARTITION_SWAP 2
|
||||
#define PARTITION_RAID 3
|
||||
#define PARTITION_LVM 4
|
||||
#define PARTITION_GPFS 5
|
||||
|
||||
/*
|
||||
* PARTITION_NEW is the first item in our partition_types array and technically
|
||||
* maps to PARTITION_NATIVE. As PARTITION_NEW isn't a valid partition_type, it
|
||||
* can be ignored. Use this offset when iterate over the array.
|
||||
*/
|
||||
#define VALID_PARTITION_OFFSET 1
|
||||
|
||||
typedef struct partition_type {
|
||||
char *name; /* User-friendly Name */
|
||||
char *dsname; /* Data Set Name */
|
||||
int type; /* Numerical Representation */
|
||||
} partition_type_t;
|
||||
|
||||
struct fdasd_options {
|
||||
char *device;
|
||||
char *volser;
|
||||
char *conffile;
|
||||
};
|
||||
|
||||
static struct fdasd_options options = {
|
||||
NULL, /* device */
|
||||
NULL, /* volser */
|
||||
NULL, /* conffile */
|
||||
};
|
||||
|
||||
typedef struct partition_info {
|
||||
u_int8_t used;
|
||||
unsigned long start_trk;
|
||||
unsigned long end_trk;
|
||||
unsigned long len_trk;
|
||||
unsigned long fspace_trk;
|
||||
format1_label_t *f1;
|
||||
int type;
|
||||
struct partition_info *next;
|
||||
struct partition_info *prev;
|
||||
} partition_info_t;
|
||||
|
||||
typedef struct config_data {
|
||||
unsigned long start;
|
||||
unsigned long stop;
|
||||
int type;
|
||||
} config_data_t;
|
||||
|
||||
typedef struct fdasd_anchor {
|
||||
int vlabel_changed;
|
||||
int vtoc_changed;
|
||||
int auto_partition;
|
||||
int print_table;
|
||||
int print_volser;
|
||||
int keep_volser;
|
||||
int force_virtual;
|
||||
int force_host;
|
||||
int big_disk;
|
||||
int silent;
|
||||
int verbose;
|
||||
int devno;
|
||||
int option_reuse;
|
||||
int option_recreate;
|
||||
int partno[USABLE_PARTITIONS];
|
||||
u_int16_t dev_type;
|
||||
unsigned int used_partitions;
|
||||
unsigned long label_pos;
|
||||
unsigned int blksize;
|
||||
unsigned long fspace_trk;
|
||||
format4_label_t *f4;
|
||||
format5_label_t *f5;
|
||||
format7_label_t *f7;
|
||||
format9_label_t *f9; /* template for all f9 labels */
|
||||
partition_info_t *first;
|
||||
partition_info_t *last;
|
||||
volume_label_t *vlabel;
|
||||
config_data_t confdata[USABLE_PARTITIONS];
|
||||
u_int32_t hw_cylinders;
|
||||
u_int32_t formatted_cylinders;
|
||||
} fdasd_anchor_t;
|
||||
|
||||
enum offset {lower, upper};
|
||||
|
||||
enum fdasd_failure {
|
||||
parser_failed,
|
||||
unable_to_open_disk,
|
||||
unable_to_seek_disk,
|
||||
unable_to_read_disk,
|
||||
read_only_disk,
|
||||
unable_to_ioctl,
|
||||
wrong_disk_type,
|
||||
wrong_disk_format,
|
||||
disk_in_use,
|
||||
config_syntax_error,
|
||||
vlabel_corrupted,
|
||||
dsname_corrupted,
|
||||
malloc_failed,
|
||||
device_verification_failed,
|
||||
volser_not_found
|
||||
};
|
||||
|
||||
#define ERROR_STRING_SIZE 1024
|
||||
#define INPUT_BUF_SIZE 1024
|
||||
|
||||
#endif /* FDASD_H */
|
||||
Reference in New Issue
Block a user