Files
s390-tools/zdump/dt_s390sv_ext.c
T
Mikhail Zaslonko 6f82c5792a zdump: Drop support of non-extended single volume DASD dumpers
Since DASD standalone dumper does not support non-extended s390 dump
format for years, drop zgetdump support of non-extended s390 single volume
DASD dump-tool:
- Merge dt_390sv_ext.c and dt_s390sv.c counterparts.
- Update DT vector of supported dump tools removing dt_s390sv entry and
  keeping dt_s390sv_ext entry for s390 single volume extended dump tool.
- Remove dt_s390sv.c source and update the Makefile accordingly.
- Remove magic constants relevant to non-extended s390 single volume DASD
  dumper.
- Drop s390 single volume DASD dumper version 5 in df_s390_dumper_read().

Note: We still need support of non-extended s390 dump format since such
output dump files can be produced by 'zgetdump -f s390' via dfo_s390. Thus,
both dfi_s390 and dfi_s390_ext DFI vector entries remain in order to
process s390 dumps files as well as s390_ext dumps on the DASD partition.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-04-07 17:42:18 +02:00

112 lines
2.6 KiB
C

/*
* zgetdump - Tool for copying and converting System z dumps
*
* S390 single-volume DASD dump tool (extended)
*
* Copyright IBM Corp. 2001, 2025
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <linux/fs.h>
#include "zgetdump.h"
#include "zg.h"
#include "dt.h"
#include "df_s390.h"
/*
* File local static data
*/
static struct {
struct df_s390_dumper dumper;
enum dfi_arch dumper_arch;
} l;
/*
* Read dump tool from ECKD DASD device
*/
static int dumper_read_eckd(int blk_size)
{
if (df_s390_dumper_read(g.fh, blk_size, &l.dumper))
return -ENODEV;
if (strncmp(l.dumper.magic, DF_S390_DUMPER_MAGIC_EXT,
DF_S390_DUMPER_MAGIC_SIZE) != 0)
return -ENODEV;
return 0;
}
/*
* Read dump tool on FBA disk and check its magic number
*/
static int dumper_read_fba(void)
{
struct df_s390_dumper *dumper = &l.dumper;
int bytes_to_read;
/*
* On FBA device the dumper is written at the end of the volume because
* there is not enough space to place it at the beginning due to the
* linux disk layout.
* First read 2 fields at the start of the dumper. The magic number
* and the version.
*/
zg_seek_end(g.fh, -STAGE2_DUMPER_SIZE_SV, ZG_CHECK);
bytes_to_read = offsetof(struct df_s390_dumper, size);
zg_read(g.fh, dumper, bytes_to_read, ZG_CHECK);
if (strncmp(dumper->magic, DF_S390_DUMPER_MAGIC_FBA_EXT,
DF_S390_DUMPER_MAGIC_SIZE) != 0)
return -ENODEV;
dumper->size = STAGE2_DUMPER_SIZE_SV;
/* Read force and mem fields in the end of the dumper */
bytes_to_read = sizeof(dumper->force) + sizeof(dumper->mem);
zg_seek_end(g.fh, -bytes_to_read, ZG_CHECK);
zg_read(g.fh, &dumper->force, bytes_to_read, ZG_CHECK);
return 0;
}
/*
* Read single volume dumper from disk
*/
static int sv_dumper_read(void)
{
int blk_size;
if (zg_type(g.fh) == ZG_TYPE_DASD_PART)
return -ENODEV;
zg_ioctl(g.fh, BLKSSZGET, &blk_size, "BLKSSZGET", ZG_CHECK);
if (dumper_read_eckd(blk_size) == 0) {
dt_attr_dasd_type_set("ECKD");
return 0;
}
if (dumper_read_fba() == 0) {
dt_attr_dasd_type_set("FBA");
return 0;
}
return -ENODEV;
}
/*
* Initialize s390 single-volume extended dump tool (for -d option)
*/
static int dt_s390sv_ext_init(void)
{
if (sv_dumper_read() != 0)
return -ENODEV;
l.dumper_arch = DFI_ARCH_64;
dt_arch_set(l.dumper_arch);
dt_version_set(l.dumper.version);
dt_attr_mem_limit_set(l.dumper.mem);
return 0;
}
/*
* s390 single-volume DT (extended) operations
*/
struct dt dt_s390sv_ext = {
.desc = "Single-volume DASD dump tool (extended)",
.init = dt_s390sv_ext_init,
};