From b66396df80cda9f16db3ffe18bfd57d4f54de278 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Fri, 12 May 2023 13:57:55 +0200 Subject: [PATCH] zdev: add helper to convert from zdev config to dasd_mod.dasd Converts zdev configuration into the syntax of the kernel module parameter dasd_mod.dasd. Only DASD options with non-default values are emitted. The result string occurs on stdout. It represents one device-specification for the given DASD device bus-ID. Example: /lib/s390-tools/zdev-to-dasd_mod.dasd persistent 0.0.da5d 0.0.da5d(erplog) User: https://github.com/storaged-project/blivet/pull/1162 to generate dracut cmdline entries such as rd.dasd=0.0.da5d(erplog) Signed-off-by: Steffen Maier --- zdev/src/Makefile | 3 ++- zdev/src/zdev-to-dasd_mod.dasd | 37 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 zdev/src/zdev-to-dasd_mod.dasd diff --git a/zdev/src/Makefile b/zdev/src/Makefile index 281201e6..c43b6547 100644 --- a/zdev/src/Makefile +++ b/zdev/src/Makefile @@ -106,11 +106,12 @@ libs = $(rootdir)/libap/libap.a \ chzdev: $(chzdev_objects) $(libs) lszdev: $(lszdev_objects) $(libs) -install: chzdev zdev_id +install: chzdev zdev_id zdev-to-dasd_mod.dasd $(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR) $(INSTALL) -c chzdev $(DESTDIR)$(BINDIR) $(INSTALL) -c lszdev $(DESTDIR)$(BINDIR) $(INSTALL) -c zdev_id $(DESTDIR)$(TOOLS_LIBDIR) + $(INSTALL) -c zdev-to-dasd_mod.dasd $(DESTDIR)$(TOOLS_LIBDIR) ifeq ($(HAVE_DRACUT),1) $(INSTALL) -m 755 zdev-root-update.dracut \ $(DESTDIR)$(TOOLS_LIBDIR)/zdev-root-update diff --git a/zdev/src/zdev-to-dasd_mod.dasd b/zdev/src/zdev-to-dasd_mod.dasd new file mode 100755 index 00000000..f9f11026 --- /dev/null +++ b/zdev/src/zdev-to-dasd_mod.dasd @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copyright IBM Corp. 2023 +# +# s390-tools is free software; you can redistribute it and/or modify +# it under the terms of the MIT license. See LICENSE for details. +# +# zdev-to-dasd_mod.dasd +# Converts zdev configuration into the syntax of the kernel module parameter +# dasd_mod.dasd. Only DASD options with non-default values are emitted. The +# result string occurs on stdout. It represents one device-specification for +# the given DASD device bus-ID. +# + +function usage() { + echo "usage: ${0##*/} active|persistent " 1>&2 + exit 1 +} + +[[ $# -eq 2 ]] || usage + +[[ "$1" == active ]] || [[ "$1" == persistent ]] || usage + +_selection="--${1}" +_busid="$2" + +while read -r _line; do + case "$_line" in + "readonly=1") _attrs="${_attrs:+${_attrs}:}ro" ;; + "use_diag=1") _attrs="${_attrs:+${_attrs}:}diag" ;; + "raw_track_access=1") _attrs="${_attrs:+${_attrs}:}raw" ;; + "erplog=1") _attrs="${_attrs:+${_attrs}:}erplog" ;; + "failfast=1") _attrs="${_attrs:+${_attrs}:}failfast" ;; + esac +done < <(chzdev dasd "$_busid" "$_selection" --export - --quiet) +[[ -n "$_attrs" ]] && _attrs="($_attrs)" +printf "%s%s\n" "$_busid" "$_attrs"