mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl: add basic support of environment block by zipl(8)
When installing a boot record for "ipl" and "menu" job, always add an environment block as a boot component located in bootmap file at offset alinged on file system block size boundary. When adding, first try to import environment from a file at location specified by newly introduced "--environment" zipl option, or by default at "/etc/ziplenv". If nothing was imported, then add a blank environment block. Optionally print the content of the environment block. Store environment block size and address (as of boot component) in stage3_parms. Change interface of add_ipl_program(): add 2 additional arguments: a pointer to bootmap file name and a predicate indicating if we need to add environment block as a boot component. Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
bbeb0f8445
commit
1fb859729e
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* zipl - zSeries Initial Program Loader tool
|
||||
*
|
||||
* Functions to manipulate with bootmap header
|
||||
*
|
||||
* Copyright IBM Corp. 2021
|
||||
*
|
||||
* 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 <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bootmap.h"
|
||||
#include "error.h"
|
||||
#include "misc.h"
|
||||
|
||||
int bootmap_header_init(int fd)
|
||||
{
|
||||
struct bootmap_header bh = {
|
||||
.header_text =
|
||||
"zSeries bootmap file\n"
|
||||
"created by zIPL\n",
|
||||
.version = BOOTMAP_HEADER_VERSION
|
||||
};
|
||||
|
||||
return misc_write(fd, &bh, sizeof(bh));
|
||||
}
|
||||
|
||||
static int bootmap_header_access(int fd, struct bootmap_header *bh, int read)
|
||||
{
|
||||
off_t cur_off;
|
||||
int ret;
|
||||
|
||||
cur_off = lseek(fd, 0, SEEK_CUR);
|
||||
if (cur_off == -1) {
|
||||
error_reason(strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (lseek(fd, 0, SEEK_SET) == -1) {
|
||||
error_reason(strerror(errno));
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (read)
|
||||
ret = misc_read(fd, bh, sizeof(*bh));
|
||||
else
|
||||
ret = misc_write(fd, bh, sizeof(*bh));
|
||||
out:
|
||||
if (lseek(fd, cur_off, SEEK_SET) == -1)
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bootmap_header_read(int fd, struct bootmap_header *bh)
|
||||
{
|
||||
return bootmap_header_access(fd, bh, 1);
|
||||
}
|
||||
|
||||
int bootmap_header_write(int fd, struct bootmap_header *bh)
|
||||
{
|
||||
return bootmap_header_access(fd, bh, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user