Compare commits

..

85 Commits

Author SHA1 Message Date
Stefan Haberland
f4eb7e4907 New release s390-tools-2.3.0
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 16:01:29 +01:00
Philipp Kern
c5a91199e3 zipl: Always build and link without PIE.
Compilers in Debian and Ubuntu default to enabling PIE for all binaries.
This is a poor fit for boot loader code that has strict requirements
for its layout. Hence always forcefully disable PIE.

As older compilers still need to be supported, no-pie usage is
conditional on CC's -dumpspecs output.

Fixes: #3

Signed-off-by: Philipp Kern <pkern@debian.org>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:38:41 +01:00
Hendrik Brueckner
144bddbf5b cpumf: correct z14 counter number
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:37:19 +01:00
Hendrik Brueckner
36ef451e6b CHANGELOG: Add z14 hardware counter support
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:36:48 +01:00
Hendrik Brueckner
1064e5b9cc cpumf/cpumf_helper: read split counter sets (part 2/2)
Update the cpumf helper program to read the split counter set
definition files.  Changes to higher-level program like lscpumf
are not necessary.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:36:23 +01:00
Hendrik Brueckner
d121ffa3f0 cpumf/z14: split counter sets according to CFVN/CSVN (part 1/2)
With z14, the counters in the problem-state are reduced resulting
in an increased first version number of the CPUM CF.  To adapt to
this change, split the counter sets according to their counter
first and second version number.  The second version number controls
the crypto-activity and extended counter set.  Treat the crypto-activity
counter set as generic, as the extended counter set is already handled
based on hardware models.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:35:39 +01:00
Martin Schwidefsky
57f18c5f59 cpumf: Add extended counter defintion files for IBM z14
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
[brueckner: Prefer plural for counter names]
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:35:18 +01:00
Peter Oberparleiter
3b2a8777b1 common.mak: Fix disappearing check errors
When 'make C=1' reports a fatal error for a source file, re-running
'make C=1' will no longer report this error because the target object
file was successfully created before the check was run.

Fix this by moving the check before the compilation step so that the
object file is not built in case of a fatal check error.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2018-01-30 15:33:38 +01:00
Michael Holzheu
89ead069f9 util_list: Use util_malloc() for util_list_new()
Since now util_list_new() internally fails for out-of-memory situations,
we can also remove some NULL pointer checks.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-29 18:15:03 +01:00
Dan Horák
05de40cdeb Replace delimiter char in sed expressions
Use a character, that can't be used in rpm Version and Release tag, as
the delimiter in sed expressions.

Fixes: #25

Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-22 13:50:36 +01:00
Mikhail Zaslonko
a74103dba7 zgetdump: Fix overflow/truncation in part_off calculation
When calculating partition start offset during multi-volume dump processing,
the result of multiplication is truncated to 32-bits thus resulting in
invalid behavior in case the real offset is beyond 4Gig boundary.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.vnet.ibm.com>
Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-22 13:50:07 +01:00
Sa Liu
b4868c21bf Add VM command to query processor
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2018-01-22 13:49:02 +01:00
Rafael Fonseca
8826028bdc 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>
2017-12-14 16:16:51 +01:00
Rafael Fonseca
09aa7f2010 dasdfmt: Apply project's code conventions
GitHub-ID: #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>
2017-12-14 16:16:13 +01:00
Rafael Fonseca
e7d3638c6b dasdview: Use libdasd provided functions
GitHub-ID: #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>
2017-12-14 16:15:50 +01:00
Rafael Fonseca
68b0b4c268 dasdview: Apply project's coding conventions
GitHub-ID: #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>
2017-12-14 16:15:15 +01:00
Rafael Fonseca
caeb4470cd zdsfs: Use libdasd provided ioctl functions
GitHub-ID: #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>
2017-12-14 16:14:09 +01:00
Rafael Fonseca
8b11ea73ac fdasd: Use libdasd for DASD ioctls
GitHub-ID: #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>
2017-12-14 16:05:02 +01:00
Rafael Fonseca
45e20a5044 fdasd: Apply project's coding conventions
GitHub-ID: #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>
2017-12-14 16:04:19 +01:00
Rafael Fonseca
105b30a805 dasdinfo: Use libdasd for DASD ioctls
GitHub-ID: #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>
2017-12-14 14:49:49 +01:00
Rafael Fonseca
70a7fc3e72 dasdinfo: Apply project's coding convention
GitHub-ID: #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>
2017-12-14 14:15:54 +01:00
Rafael Fonseca
2d3774932b vtoc: hd_geometry is already defined in libdasd
GitHub-ID: #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>
2017-12-14 14:13:09 +01:00
Rafael Fonseca
a5c1923d32 libdasd: Add common DASD ioctl's to the lib
This will avoid code duplication in dasd-related programs.

GitHub-ID: #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>
2017-12-14 14:11:14 +01:00
Peter Oberparleiter
0348a8443e zdev: Fix zdev dracut module aborting on unknown root device
Running dracut when the root device is not known to zdev (for example
because it is located on a virtio block device) will cause the zdev
dracut module to incorrectly return an error in the installkernel()
function. As a result dracut aborts with an error.

Fix this by ensuring that the non-zero exit code resulting from lszdev
not being able to determine the root device is not passed on to the
calling function. Also remove unnecessary error output in this case
by leaving the install() function early when the root device is not
known to zdev.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-07 17:38:34 +01:00
Michael Holzheu
dba9616a5b Prepare for next release
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-07 17:38:21 +01:00
Michael Holzheu
44598496c5 New release s390-tools-2.2.0
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-07 14:36:50 +01:00
Peter Oberparleiter
2a6a28023b zdev: Enable running chzdev from unknown root devices
When a persistent device configuration is changed, chzdev tries to
find out if it needs to perform additional steps to make this change
persistent. If this check fails, for example because the root device
is located on a RAM-disk, or on a device type not managed by chzdev,
the tool reports an error and exits with non-zero exit code:

  chzdev: Could not determine device that provides /

or

  chzdev: Could not determine device that provides loop0

This behavior unnecessarily restricts chzdev from being used in
scripted environments like an installation initial RAM-disk.

Fix this by removing the non-zero exit code and moving the message to
verbose output mode only.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 16:00:36 +01:00
Jan Höppner
e581fa3fea dasdinfo: Fix false line breaks
Commit 61b60baf57 ("dasdinfo: Fix GCC 7 overflow warning") erroneously
introduced line breaks to the UID (-u) output. To be consistent with the
extended uid ouput code, keep the newley indroduced line breaks and
remove the additional one from the string split above instead.

Fixes: 61b60baf57 ("dasdinfo: Fix GCC 7 overflow warning")
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 16:00:16 +01:00
Michael Holzheu
0382659f4f ipl_tools: Use quotes for local include files
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 16:00:08 +01:00
Michael Holzheu
e767a2b99d build process: Fix parallel build for libutil
When building libutil in parallel, it can happen that the archive
file is created twice:

 $ cd libutil
 $ make -j
  ...
  CC      libutil/util_rec_example.o
  AR      libutil/libutil.a
  AR      libutil/libutil.a
  LINK    libutil/util_base_example

This can lead to the following build error:

 $ make -j OPT_FLAGS="-pipe"
   ..//libutil/libutil.a(util_path.o): In function `sys_mount_point':
   util_path.c:56: undefined reference to `util_proc_mnt_get_entry'
   util_path.c:60: undefined reference to `util_proc_mnt_free_entry'
   collect2: error: ld returned 1 exit status
   ../common.mak:232: recipe for target 'util_path_example' failed

The problem is that the following rule from common.mak is triggered in
the libutil directory:

 $(rootdir)/libutil/libutil.a: $(rootdir)/libutil
      $(MAKE) -C $(rootdir)/libutil/ libutil.a
 .PHONY: $(rootdir)/libutil

To prevent this rule, use the local "libutil.a" as dependency for the
example binaries.

Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-12-06 15:59:58 +01:00
Michael Holzheu
869f629746 CONTRIBUTING: Outline steps to submit and rework code
For GitHub and git beginners explain in more detail how to submit s390-tools
contributions as pull requests, how to update already submitted code
and how to rebase a contribution branch.

Based on the initial proposal from: Jens Remus <jremus@linux.vnet.ibm.com>

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
2017-11-30 15:18:28 +01:00
Rafael Fonseca
7b8d09e62e ziomon: fix typo when checking for attribute existence
Fix possible c&p mistake when checking the presence of `queue_full` attribute
in old kernels. There should be no impact on how the tool works other than
exiting gracefully in case the attribute does not exist.

Fixes: #21

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-28 18:54:39 +01:00
Michael Holzheu
5a8eee163b osasnmpd: Use ALL_CFLAGS instead of directly CFLAGS
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-28 18:51:30 +01:00
Michael Holzheu
75a45158ad util_path_example: Improve output of is_xxx
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:25 +01:00
Michael Holzheu
16c4074e47 util_path_example: Add example for new util_path_exists() function
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:19 +01:00
Michael Holzheu
2b92bc4c08 util_path: Make true/false handling consistent with other functions
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:10 +01:00
Michael Holzheu
d0e2caf0ff util_path: Add description for util_path_exists()
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 17:00:05 +01:00
Rafael Fonseca
d542138868 zdev: use libutil provided path functions
Closes: #20

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:59:31 +01:00
Rafael Fonseca
df133846b5 util_path: add function to check if a path exists
GitHub-ID: #20

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:57 +01:00
Jens Remus
283e0bd5ea CONTRIBUTING: Clarifications to Signed-off-by requirement
Mention that the Signed-off-by line should be at the bottom of every commit
message and that the e-mail address must be valid.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:29 +01:00
Jens Remus
5ae3ec72b2 CODINGSTYLE: Add links to the Linux kernel coding style and checkpatch
Add link to the Linux kernel coding style on https://www.kernel.org/ and
convert link to the checkpatch tool into a proper Markdown link.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:18 +01:00
Jens Remus
d9e9f7185f CODINGSTYLE: Add link to libutil
Format reference to libutil in code style and add link to its subdirectory.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:58:03 +01:00
Jens Remus
532d87d281 CONTRIBUTING: Fix spelling of GitHub
Spell GitHub in camel case as it is done on https://github.com/.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:57:31 +01:00
Michael Holzheu
8600296030 osasnmpd: Add -fPIC to CFLAGS to fix build on Fedora 27
On Fedora 27 "net-snmp-config --agent-libs" returns
"--specs=/usr/lib/rpm/redhat/redhat-hardened-ld" which introduces "-pie":

 # cat /usr/lib/rpm/redhat/redhat-hardened-ld
 *self_spec:
 + %{!static:%{!shared:%{!r:-pie}}}
 *link:
 + -z now

This leads to the following link error:

 /usr/bin/ld: osasnmpd.o: `getopt_long@@GLIBC_2.2' non-PLT reloc for symbol
              defined in shared library and accessed from executable
              (rebuild file with -fPIC ?)
 /usr/bin/ld: final link failed: Bad value

Add -fPIC to CLFAGS as a workaround to enbable linking again.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:57:21 +01:00
Michael Holzheu
3908725d3b zfcpdump: Add HAVE_LIBC_STATIC check
For systems that do not have glibc-static installed, print the
following error message when building zfcpdump:

 s390-tools/zfcpdump # make
   REQCHK  zfcpdump (stdio.h)
 ****************************************************************
 * Missing build requirement for: zfcpdump                      *
 * Install package..............: glibc-static or libc-dev      *
 * You can skip build with......: make HAVE_LIBC_STATIC=0       *
 ****************************************************************

To allow the check add a new compiler/linker option to the "check_dep"
macro and do full compile/link instead of a simple compile.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-27 16:57:12 +01:00
Gerald Schaefer
780133f825 mon_tools: Improve systemctl start error handling
This fixes the same issue as in commit 82c8148983 ("cpuplugd: Improve
systemctl start error handling") for mon_tools (mon_procd and mon_fsstatd).

Currently "systemctl start mon_procd/fsstatd" does not report any errors
in case the startup fails.

Example (with mon_procd):

 (change interval in /etc/sysconfig/mon_procd to an invalid value "abc")
 # systemctl start mon_procd

The reason is that for type=simple systemd forks/execs mon_procd and if
that is successful immediately returns. There is no way to find out if the
initial startup fails.

Fix this by using type=fork and running the process in the background. In
this case systemd waits until the initial process returns.

In addition use PIDFile and ensure that the pid file is already available
when the initial process returns. To achieve this, use startup
synchronization via pipe. Without that systemd would print the following
warning:

systemd[1]: mon_procd.service: PID file /var/run/mon_procd.pid not readable
            (yet?) after start: No such file or directory

With this patch, an early startup error like in the example above, is now
reported correctly in "systemctl start":

 # systemctl start mon_procd
   Job for mon_procd.service failed because the control process exited...
   See "systemctl status mon_procd.service" and "journalctl -xe" for ...
 # journalctl -xe | grep mon_procd
   mon_procd[3184]: Error: Invalid interval (needs to be greater than 0)

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 20:33:17 +01:00
Michael Holzheu
82c8148983 cpuplugd: Improve systemctl start error handling
Currently "systemctl start cpuplugd" does not report any errors in
case the startup fails.

Example:

 # mv /etc/cpuplugd.conf /etc/cpuplugd.conf.xxx
 # systemctl start cpuplugd

The reason is that for type=simple systemd forks/execs cpuplugd and if
that is successful immediately returns. There is no way to find out
if the initial startup fails.

Fix this by using type=fork and running cpuplugd in the background. In
this case systemd waits until the initial process returns.

In addition use PIDFile and ensure that the pid file is already available
when the initial cpuplugd process returns. To achieve this, replace the
daemon() function by our own implementation that introduces startup
synchronization via pipe. Without that systemd would print the following
warning:

systemd[1]: cpuplugd.service: PID file /var/run/cpuplugd.pid not readable
                              (yet?) after start: No such file or directory

With this patch, an early startup error like in the example above, is now
reported correctly in "systemctl start":

 # systemctl start cpuplugd
   Job for cpuplugd.service failed because the control process exited...
   See "systemctl status cpuplugd.service" and "journalctl -xe" for ...
 # journalctl -ex | grep cpuplugd
   Nov 16 15:52:27 ... cpuplugd[5096]: Opening configuration file failed:
                                       No such file or directory

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Acked-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
2017-11-20 20:29:20 +01:00
Michael Holzheu
c12c4af760 Start CODINGSTYLE document and add table with abbreviations
To get consistent and readable code let's try to advertise some common
abbreviations.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 14:58:09 +01:00
Michael Holzheu
f595bce3c0 systemd: Use SYSCONFDIR instead of /etc for 'make install'
Suggested-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 14:57:58 +01:00
André Wild
0768fbbb20 chzdev.8: Fix chzdev examples
This patch fixes two examples which are shown in the man page of chzdev.

Signed-off-by: André Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-20 14:56:47 +01:00
Michael Holzheu
523d833eb3 ziomon: Re-add missing line in ziomon_fcpconf
During the GPL to MIT conversion process from v1.39.0 to v2.0.0 one line has
been lost by accident. Fix this and re-add that line again.

Fixes: #17

Reported-by: Mikhail Obirvalger
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-16 18:26:34 +01:00
Christian Ehrhardt
3fc01e7520 mk-pxelinux-ramfs: make infinite loop a timeout
So far it infinitely retried the bootscript, that doesn#t seem
reasonable. Per IRC discussion this is now changed to a 600 sec timeout
waiting for a config to appear to then run once on that config.

In case the pxe boot fails the it is now no more a retry loop, but
instead considered a crash as init exits.

Closes: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Christian Ehrhardt
9259370891 mk-pxelinux-ramfs: fix escaping kexec appends
Currently multiple entries in a single append is broken by how the
shell in busybox escapes them. No usual grouping with " or ' will
work but calling them directly but without the --append in the
variable will let busybox do the right thing.

GitHub-ID: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Christian Ehrhardt
7b84e30471 mk-pxelinux-ramfs: case insensitive arg parsing
Many documentations refer to kernel, initrd, ... arguments
in upper case so the grep/sed should support both.

GitHub-ID: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Christian Ehrhardt
9c2a0649f2 mk-pxelinux-ramfs: improve console output
Currently for a user the pxe boot seems unclear and it
is hard to follow what is going on.

- Report on when (re-)starting the bootscript.
- Report configs fetched (Without e.g. on a virsh console
  one only sees a loop of timeouts.)
- Report which config is missing on the PXE_CONF check
- Report kexec calls made

GitHub-ID: #16

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Gerald Schaefer
778292e771 lsmem/chmem: Remove tools
lsmem/chmem moved to util-linux >= 2.30, remove them from s390-tools.

For kernels >= 4.13, the default memory zone for hotplug memory was
changed from zone MOVABLE to zone NORMAL. In order to keep using zone
MOVABLE for memory hotplug, either use the lsmem/chmem tools from
s390-tools version 2.1.0, or an updated version of the util-linux
version of lsmem/chmem that contains the following util-linux git
commits (included in util-linux 2.32):

60a7e9e94e49 "lsmem/chmem: add memory zone awareness"
0a4320f5e785 "tests/lsmem: update lsmem test with ZONES column"
afee3f204247 "lsmem/chmem: add memory zone awareness to bash-completion"

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:46:09 +01:00
Sa Liu
c21e464856 dbginfo: Show thread with ps command.
Signed-off-by: Sa Liu <saliu@de.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-14 14:38:21 +01:00
Peter Oberparleiter
a060dc22db zdev: Use correct path to vmcp binary
The zdev tools use a hard-coded path to locate the vmcp binary. Since
this path may differ between distributions, the vmcp binary may not be
successfully located in all cases. Fix this by using the BINDIR macro
to determine the correct path. This macro is also used during
installation of the vmcp binary itself.

Reviewed-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-13 14:53:06 +01:00
Michael Holzheu
66f0090989 systemd: Install also the unit configuration files
If SYSTEMDSYSTEMUNITDIR is defined, the systemd units are automatically
installed. Therefore consequently also install the required config files
in that case.

Example:

 $ make install SYSTEMDSYSTEMUNITDIR=/usr/lib/systemd/system/

Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-11-13 14:52:58 +01:00
Rafael Fonseca
5d10b925c8 zipl: remove invalid dasdview command line option
dasdview command does not accept the '-f' option so because of that the
command will always fail.

Fixes: #10

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:49:04 +01:00
Michael Holzheu
7076d19c7f iucvterm: Add "all" to make install dependency
When doing parallel builds, we currently get the following error for
iucvterm:

 ~/s390-tools/iucvterm (bb/holzheu/install-configs)# make install  -j
   INSTALL iucvterm
   CC      iucvterm/src/iucvconn.o
   INSTALL iucvterm/src
   CC      iucvterm/src/getopt.o
 install: cannot stat 'iucvconn': No such file or directory
 install: cannot stat 'iucvtty': No such file or directory
 Makefile:19: recipe for target 'install' failed

Fix this and "all" as explicit dependency to the install target.

Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:39:13 +01:00
Fedor Loshakov
69199219bc ziomon: fix non-zero return code in ziomon_util
Use additional variable to store return code from
parse_params function for distinguishing return
codes from help and version from others in ziomon_util

Before patch applied:

 # /usr/sbin/ziomon_util --help
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 255

 # /usr/sbin/ziomon_util --version
 ziomon_util: ziomon utilization monitor, version ...
 # echo $?
 255

After patch applied:

 # /usr/sbin/ziomon_util --help
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 0

 # /usr/sbin/ziomon_util --version
 ziomon_util: ziomon utilization monitor, version ...
 # echo $?
 0

Signed-off-by: Fedor Loshakov <loshakov@linux.vnet.ibm.com>
Suggested-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:38:39 +01:00
Hendrik Brueckner
f0116ee79c cpi: add missing Install section to service unit
The cpi service unit requires an Install section to tell systemd
when to start the cpi service.  Add an install section and start
cpi for the multi-user target.

Reported-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:37:38 +01:00
Harald Freudenberger
4ad5e29f2f lszcrypt: fix date and wrong indentation
The man page date was AUG 2008. Changed to OCT 2017.
A previous commit had a wrong indentation on following
options text for lszcrypt. Fixed.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:37:28 +01:00
Michael Holzheu
a0d3e3a1a8 CHANGELOG: lszcrypt: CEX6S exploitation
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-11-07 16:35:41 +01:00
Jan Höppner
1261105fe2 dasdinfo: Fix truncation warning
Commit 3c80f7e025 ("dasdinfo: fix buffer overflow warning") changed a
sprintf call to snprintf to avoid a buffer overflow warning. However,
GCC 7 now warns about a potential truncation with snprintf:

dasdinfo.c: In function 'main':
dasdinfo.c:577:18: warning: '%s' directive output may be truncated
writing up to 255 bytes into a region of size 69 [-Wformat-truncation=]
      "/sys/block/%s/device/uid", dir_entry->d_name);
                  ^~
dasdinfo.c:576:4: note: 'snprintf' output between 23 and 278 bytes into
a destination of size 80
    snprintf(*uidfile, RD_BUFFER_SIZE,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "/sys/block/%s/device/uid", dir_entry->d_name);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We could get around this by increasing the buffer. Though, the current
buffer size is already plenty and we know better anyway.
Avoid the warning by simply checking the return value of snprintf and
display an error in case data was truncated nonetheless.

Fixes: 3c80f7e025 ("dasdinfo: fix buffer overflow warning")
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 16:58:49 +02:00
Harald Freudenberger
31866fbfa4 lszcrypt: CEX6S exploitation
With z14 there comes a new crypto card 'CEX6S'.

This patch introduces the s390-tools changes needed
to list the new card and show the capabilities correctly.

Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 14:53:06 +02:00
Hendrik Brueckner
e179b7a9ac iucvterm: include ctype for toupper()
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-18 14:49:57 +02:00
Hannes Reinecke
5e4577d76b Update gitignore to not exclude init.d and rules.d directories
Fixes: #9

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:22:43 +02:00
Hannes Reinecke
496c257bf2 dasdfmt: drop 'device_id' parameter
Drop device_id parameter from dasdfmt_info() and pass in 'optind'
directly.

Closes: #8

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:22:25 +02:00
Hannes Reinecke
0028f166aa dasdfmt: Fixup device name handling
get_device_name() contains a chunk of unreachable code, as the
'name' argument is never filled with any value.
So turn things around to have get_device_name() always fill the
'name' argument with the real device name, and remove the
devname entry from the dasdfmt_info_t structure.

GitHub-ID: #8

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:22:13 +02:00
Hannes Reinecke
97047896ab dasdfmt: Fixup dasdfmt_get_volser()
dasdfmt_get_volser() opens its own private filedescriptor
despite the global filedes already being opened.
And we should be passing in only the bits of the info structure
that we actually need.

GitHub-ID: #8

Signed-off-by: Hannes Reinecke <hare@suse.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-12 20:14:03 +02:00
Dan Horák
94fcd8dc18 use TOOLS_LIBDIR in definition of ZFCPDUMP_DIR
Fixes: #6

Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:13:27 +02:00
Jens Remus
afdecb4a57 lsluns: update s390-tools CHANGELOG and README for preceding commits
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:11:49 +02:00
Steffen Maier
e5f9279295 lsluns: complement alternative tools with lszdev
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:10:56 +02:00
Steffen Maier
55f0b001d1 lsluns: document restriction to zfcp-only systems
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:10:39 +02:00
Steffen Maier
5f768dd52d lsluns: point out IBM Storwize configuration requirements
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:10:15 +02:00
Steffen Maier
0daa7ba0b5 lsluns: clarify discovery use case, relation to NPIV and to zfcp auto LUN scan
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:09:48 +02:00
Jens Remus
e748fff347 lsluns: enhance usage statement and man page
The wording in the lsluns usage statement and man page was misleading
in several aspects:

* lsluns does not list all LUNs, just those discovered in the FC SAN
* lsluns -a should only be used to display the LUN encryption status

Fix filter option arguments. Clarify filter option usage. Refer to
lszfcp and lsscsi.

Reported-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:09:17 +02:00
Jens Remus
d81c423429 lsluns: fix flawed formatting of man page
The formatting in the SYNOPSIS, OPTIONS, and EXAMPLES sections was flawed
in the lsluns(8) man page:

* The comma between short and long options were erroneously formatted in
  bold, which would indicate to be typed exactly as shown. [see man(1)]

* The option parameters (e.g. adapter and port) were erroneously formatted
  in bold instead of italic text (usually displayed as underlined on the
  console), which would again indicate to be typed exactly as shown instead
  of to be replaced with the appropriate argument. [see man(1)]

* Ellipses were missing after the the options that may be specified multiple
  times (e.g. adapter and port). [see man(1)]

* Dashes in options in the SYNOPSIS and OPTIONS section needed to be
  escaped. [see man-pages(7)]

* User input in example shell sessions should have been formatted in bold.
  [see man-pages(7)]

Correct formatting based on man(7) and man-pages(7) man pages as reference.
Add proper spacing between options and their surrounding square brackets and
between the three periods of ellipses.

Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:08:57 +02:00
Jens Remus
c993ad89c5 lsluns: do not print confusing messages when a filter matches nothing
lsluns printed potentially confusing messages when a filter or combination
of filters matched nothing:

    No valid combination found for adapter '0.0.1906'. Removing from
    resource list.
    No valid combination found for port '0x50050763071845e3'. Removing from
    resource list.
...

To the user it is potentially unclear which 'combination' is actually being
referred to, as only one part of the combination is mentioned, and what the
ominous 'resource list' is. The later information is merely useful for a
developer to debug the script.

Such a message was written for every user supplied filter that did not
contribute anything to the resulting subset that is being listed, although
the filter actually might match something when used standalone.

Additionally those messages were printed to stdout instead of stderr. As
there is no debug or verbose switch and the information level of those
messages is low, we may simply discard them.

Reported-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:08:35 +02:00
Jens Remus
398f9ceac8 lsluns: do not scan (all) if filters match nothing
Fix the following undesired behavior of lsluns to scan all resources if the
user provided filters did not match anything:

    No valid combination found for adapter '5080'. Removing from resource
    list.
No valid parameters left, using all available resources in system.
Scanning for LUNs on adapter 0.0.5080
...

Scanning can be resource consumptive. So if a user already wants to filter,
possibly to reduce resource consumption, he does not want to happen to scan
everything and thus consume the worst case of resources.

Instead print a message to inform the user why nothing was scanned.

Reported-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.vnet.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:08:09 +02:00
Philipp Rudo
f0d8bc02a7 util_prg: Delete douplicate copyright header
Signed-off-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:07:48 +02:00
Michael Holzheu
aba46da2d0 Prepare for next release
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:07:31 +02:00
Philipp Rudo
ddfe2bf59b README: add glibc-static to dependencies
Signed-off-by: Philipp Rudo <prudo@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-10-05 17:07:14 +02:00
98 changed files with 2553 additions and 2440 deletions

2
.gitignore vendored
View File

@@ -3,7 +3,7 @@
#
*.o
*.a
*.d
*.o.d
#
# Ignore generated executables and other generated files

View File

@@ -2,24 +2,29 @@ List of all individuals having contributed content to s390-tools
----------------------------------------------------------------
- Alexey Ishchuk
- Andre Wild
- Andreas Herrmann
- Andre Wild
- Antoinette Kaschner
- Arnd Bergmann
- Axel Wirbser
- Benjamin Block
- Carsten Otte
- Christian Borntraeger
- Christian Ehrhardt
- Christof Schmitt
- Claudio Imbrenda
- Clemens von Mann
- cvs2git
- Dan Horak
- Despina Papadopoulou
- Eberhard Pasch
- Einar Lueck
- Erwin Vicari
- Eugene Crosser
- Eugene Dvurechenski
- Eugene (jno) Dvurechenski
- Farhan Ali
- Fedor Loshakov
- Felix Beck
- Frank Blaschka
- Frank Munzert
@@ -27,8 +32,9 @@ List of all individuals having contributed content to s390-tools
- Fritz Elfert
- Gerald Schaefer
- Gerhard Tonn
- Hans Wippel
- Hannes Reinecke
- Hans-Joachim Picht
- Hans Wippel
- Harald Freudenberger
- Heiko Carstens
- Hendrik Brueckner
@@ -56,6 +62,7 @@ List of all individuals having contributed content to s390-tools
- Martin Schwidefsky
- Maxim Shchetynin
- Melissa Howland
- Michael
- Michael Ernst
- Michael Holzheu
- Michael Mueller
@@ -64,13 +71,17 @@ List of all individuals having contributed content to s390-tools
- Peter Oberparleiter
- Peter Tiedemann
- Philipp Kern
- Philipp Rudo
- Rafael Fonseca
- Raimund Schroeder
- Ralph Wuerthner
- Rene Trumpp
- Rolf Schaefer
- root
- Sa Liu
- Sascha Silbe
- Sebastian Ott
- Seshagiri N Ippili
- Seshagiri N. Ippili
- Simon Sturm
- Stefan Bader

View File

@@ -1,8 +1,45 @@
Release history for s390-tools (MIT version)
--------------------------------------------
* __v2.3.0 (2018-01-30)__
For Linux kernel version: 4.15
Changes of existing tools:
- lscpumf: Add support for IBM z14 hardware counters
- libdasd: Introduce libdasd and use for dasd tools
- zipl: Always build and link without PIE
Bug Fixes:
- zgetdump: Fix handling of DASD multi-volume dump for partitions above 4 GB
- zdev: Fix zdev dracut module aborting on unknown root device
* __v2.2.0 (2017-12-07)__
For Linux kernel version: 4.14
Removed tools:
- lsmem/chmem: Moved to util-linux >= 2.30
Changes of existing tools:
- lszcrypt: Add CEX6S support
- cpuplugd/mon_tools: Improve systemctl start error handling
- systemd: Install also the unit configuration files
Bug Fixes:
- build process: Fix parallel build for libutil
- cpi: Add missing Install section to service unit
- lsluns: Do not scan (all) if filters match nothing
- lsluns: Enhance usage statement and man page
- zdev: Use correct path to vmcp binary
- ziomon: Re-add missing line in ziomon_fcpconf
- ziomon: Fix non-zero return code in ziomon_util
- zipl: Remove invalid dasdview command line option
* __v2.1.0 (2017-09-25)__
For Linux kernel version: 4.13
Added new tools:
- netboot: Scripts for building a PXE-style netboot image for KVM
- 90-cpi.rules/cpictl: New udev rule to update CPI when KVM is used

47
CODINGSTYLE.md Normal file
View File

@@ -0,0 +1,47 @@
Coding guidelines for s390-tools
================================
For s390-tools the preferred language is C. We provide libraries, e.g.
[`libutil`](libutil) that should be used by all tools if possible.
The coding style is based on the Linux [kernel guidelines]. Therefore, use
the [checkpatch] tool for verification before you submit a patch.
[kernel guidelines]: https://www.kernel.org/doc/html/latest/process/coding-style.html
[checkpatch]: https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
Below we describe some additional things that we want you to consider when
writing new code for s390-tools.
This package started in 2001 and has a long "tradition" - therefore, older tools
might not follow all recommendations. Note that when changing existing code,
consistency could have priority over applying rules.
Standard abbreviations
----------------------
The abbreviations below are recommended to be used in the source code.
| __Short Name__ | __Long Name__ |
|:----------------|:--------------------------------------------------|
| attr | Attribute |
| blk | Block |
| buf | Buffer |
| col | Column |
| count | Count |
| desc | Description |
| dir | Directory |
| fd | File descriptor (open) |
| fp | File pointer (fopen) |
| len | Length |
| lib | Library |
| mod | Module |
| nr | Number |
| parm | Parameter |
| path | File path |
| ptr | Pointer |
| rc | Return code |
| size | Size |
| src | Source |
| str | String |
| sym | Symbol |

View File

@@ -42,24 +42,222 @@ Developer's Certificate of Origin 1.1
this project or the open source license(s) involved.
```
If you can certify the above, just add a line saying:
If you can certify the above, just add a line stating the following at the
bottom of each of your commit messages:
```
Signed-off-by: Random Developer <random@developer.example.org>
```
Please use your real name (no pseudonyms or anonymous contributions).
Please use your real name and a valid e-mail address (no pseudonyms or anonymous
contributions).
Submitting code
---------------
The preferred way is to create a github pull request for your code.
The preferred way is to create GitHub pull requests for your code contributions.
Please create separate pull requests for each logical enhancement, new feature,
or fix.
Coding guidelines
-----------------
For s390-tools the preferred language is C. We provide libraries, e.g. libutil
that should be used by all tools if possible.
Before you submit your code please consider our recommendations in the
[CODINGSTYLE](CODINGSTYLE.md) document.
The coding style is based on the Linux kernel guidelines. Therefore, use
the checkpatch tool [1] for verification before you submit a patch.
GitHub workflow for contributions
---------------------------------
In the examples below we use this fictive identity:
[1] https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
- Name: Random Developer
- E-mail: random@developer.example.org
- GitHub ID: random-developer
### Setup GitHub and local git
1. Create a fork of this repository by clicking the `Fork` button on the top
right of the [s390-tools](https://github.com/ibm-s390-tools/s390-tools)
main page
2. Clone your forked repository to your local development system
```
$ git clone https://github.com/random-developer/s390-tools.git
```
3. Configure a remote called "upstream" pointing to the official
s390-tools repository on GitHub
```
$ cd s390-tools
~/s390-tools $ git remote add upstream https://github.com/ibm-s390-tools/s390-tools.git
```
4. Verify your remotes
```
~/s390-tools $ git remote -v
origin https://github.com/random-developer/s390-tools.git (fetch)
origin https://github.com/random-developer/s390-tools.git (push)
upstream https://github.com/ibm-s390-tools/s390-tools.git (fetch)
upstream https://github.com/ibm-s390-tools/s390-tools.git (push)
```
You now have two remotes: The "origin" remote points to your fork
and the "upstream" remote to the official s390-tools repository.
5. Configure your git user name and e-mail
```
~/s390-tools $ git config user.name "Random Developer"
~/s390-tools $ git config user.email "random@developer.example.com"
```
### Create a pull request
1. Create and checkout a new branch for your contribution
```
~/s390-tools $ git checkout -b contrib-doc-pr
```
2. Make your changes to the code
```
~/s390-tools $ vim CONTRIBUTING.md
```
3. Build and test your contribution
```
~/s390-tools $ make clean all
~/s390-tools $ # Whatever you have to do for testing
```
4. Commit your changes
```
~/s390-tools $ git add CONTRIBUTING.md
~/s390-tools $ git commit -s
```
Provide a meaningful commit message including your "Signed-off-by" line to
each commit:
```
CONTRIBUTING: Outline steps to submit code
Explain in more detail how to submit s390-tools contributions as GitHub
pull requests.
Signed-off-by: Random Developer <random@developer.example.com>
```
5. Use the [checkpatch] tool to validate your commits
```
~/s390-tools $ checkpatch.pl --no-tree --git master..HEAD
```
Interpret the checkpatch messages wisely - e.g. the 80 character rule can be
ignored for printf format strings.
[checkpatch]: https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
6. Push the changes to your fork of the repository
```
~/s390-tools $ git push origin contrib-doc-pr
```
7. Go to the GitHub website of your s390-tools fork and create a pull request
for your branch "contrib-doc-pr"
### Update a pull request during review
If there are changes requested during the review process, you have to update
your code in the pull request.
To retain the existing review comments, add commits on top of your pull request
branch. Depending on the size and number of changes, a rebase of the pull
request might be required. This will be communicated during the review.
1. Update your code with new commits
```
~/s390-tools $ vi CONTRIBUTING.md
~/s390-tools $ git add CONTRIBUTING.md
~/s390-tools $ git commit -s -m "CONTRIBUTING: Add update PR info"
```
2. Update your pull request by pushing changes
```
~/s390-tools $ git push origin contrib-doc-pr
```
### Finalize a pull request
After the review process is finished or if you are explicitly asked for it,
you have to create a clean commit series.
1. Save branch to "contrib-doc-pr.v1"
```
$ cd s390-tools
~/s390-tools $ git branch contrib-doc-pr.v1
```
2. Use interactive git rebase to merge commits, adjust commit messages,
and rebase onto your local master branch
```
~/s390-tools $ git rebase -i master
```
An editor is started and shows the following:
```
pick 2c73b9fc CONTRIBUTING: Outline steps to submit code
pick fcfb0412 CONTRIBUTING: Add update PR info
```
To merge the update into the original commit, replace "pick fcfb0412"
with "squash fcfb0412".
```
pick 2c73b9fc CONTRIBUTING: Outline steps to submit code
squash fcfb0412 CONTRIBUTING: Add update PR info
```
Save the document and exit the editor to finish the merge. Another editor
window is presented to modify the commit message.
You now could change the commit message as follows:
```
CONTRIBUTING: Outline steps to submit code
Explain in more detail how to submit s390-tools contributions as GitHub
pull requests and how to update already submitted pull requests.
Signed-off-by: Random Developer <random@developer.example.com>
```
With interactive rebasing you can also change the order of commits and
modify commit messages with "reword".
3. Use `git push` with the force option to replace the existing pull request
with your locally modified commits
```
~/s390-tools $ git push --force origin contrib-doc-pr
```
### Rebase a pull request
If changes are made to the master branch in the official s390-tools
repository you may be asked to rebase your branch with your contribution
onto it. This can be required to prevent any merge conflicts that might
arise when integrating your contribution.
1. Fetch all upstream changes from the official s390-tools repository,
rebase your local master branch and update the master branch
on your fork
```
~/s390-tools $ git fetch upstream
~/s390-tools $ git checkout master
~/s390-tools $ git rebase upstream/master
~/s390-tools $ git push origin master
```
2. Rebase your branch with your contribution onto the master branch of
the official s390-tools repository
```
~/s390-tools $ git checkout contrib-doc-pr
~/s390-tools $ git rebase master
```
3. Use `git push` with the force option to replace the existing pull
request with your locally modified commits
```
~/s390-tools $ git push --force origin contrib-doc-pr
```

View File

@@ -8,7 +8,7 @@ TOOL_DIRS = zipl zdump fdasd dasdfmt dasdview tunedasd \
tape390 osasnmpd qetharp ip_watcher qethconf scripts zconf \
vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools \
ziomon iucvterm hyptop cmsfs-fuse qethqoat zfcpdump zdsfs cpumf \
systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot
systemd hmcdrvfs cpacfstats zdev dump2tar zkey netboot etc
SUB_DIRS = $(LIB_DIRS) $(TOOL_DIRS)
all: $(TOOL_DIRS)

View File

@@ -11,6 +11,7 @@ The package also contains the following files:
* [LICENSE](LICENSE): The MIT license that applies to this package
* [CHANGELOG](CHANGELOG.md): The history of s390-tools versions
* [AUTHORS](AUTHORS.md): A list of all authors of the s390-tools package
* [CODINGSTYLE](CODINGSTYLE.md): Recommendations for writing s390-tools code
Package contents
----------------
@@ -124,14 +125,13 @@ Package contents
- lsscm: List information about available Storage Class Memory
Increments.
- chchp: Modify channel-path state.
- lsluns: List available SCSI LUNs depending on adapter or port.
- lsluns: List LUNs discovered in the FC SAN,
or show encryption state of attached LUNs.
- lszcrypt: Show Information about zcrypt devices and configuration.
- chzcrypt: Modify the zcrypt configuration.
- znetconf: List and configure network devices for s390 network adapters.
- cio_ignore: Query and modify the contents of the CIO device driver
blacklist.
- lsmem: Display the online status of the available memory.
- chmem: Set hotplug memory online or offline.
- dasdstat: Configure and format the debugfs based DASD statistics data.
* zkey:
@@ -256,13 +256,14 @@ HAVE_FUSE=0`".
The following table provides an overview of the used libraries and
build options:
| __LIBRARY__|__BUILD OPTION__| __TOOLS__ |
|------------|:--------------:|:-------------------------------------:|
| fuse | `HAVE_FUSE` | cmsfs-fuse, zdsfs, hmcdrvfs, zgetdump |
| zlib | `HAVE_ZLIB` | zgetdump, dump2tar |
| ncurses | `HAVE_NCURSES` | hyptop |
| pfm | `HAVE_PFM` | cpacfstats |
| net-snmp | `HAVE_SNMP` | osasnmpd |
| __LIBRARY__ | __BUILD OPTION__ | __TOOLS__ |
|----------------|:------------------:|:-------------------------------------:|
| fuse | `HAVE_FUSE` | cmsfs-fuse, zdsfs, hmcdrvfs, zgetdump |
| zlib | `HAVE_ZLIB` | zgetdump, dump2tar |
| ncurses | `HAVE_NCURSES` | hyptop |
| pfm | `HAVE_PFM` | cpacfstats |
| net-snmp | `HAVE_SNMP` | osasnmpd |
| glibc-static | `HAVE_LIBC_STATIC` | zfcpdump |
This table lists additional build or install options:
@@ -286,9 +287,9 @@ the different tools are provided:
http://net-snmp.sourceforge.net
* lsluns:
For executing the lsluns script the sg_luns command must be available.
The sg_luns executable is part of the SCSI generic device driver package
(sg3 utils/sg utils).
For executing the lsluns script the sg_luns and sg_inq commands must
be available. The sg_luns and sg_inq executables are part of the
SCSI generic device driver package (sg3 utils/sg utils).
* ziomon tools:
For running the ziomon tools the following tools/packages are required:

View File

@@ -5,7 +5,7 @@ COMMON_INCLUDED = true
# The variable "DISTRELEASE" should be overwritten in rpm spec files with:
# "make DISTRELEASE=%{release}" and "make install DISTRELEASE=%{release}"
VERSION = 2
RELEASE = 1
RELEASE = 3
PATCHLEVEL = 0
DISTRELEASE = build-$(shell date +%Y%m%d)
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
@@ -113,9 +113,10 @@ DEFAULT_LDFLAGS = -rdynamic
# $2: Name of include file to check
# $3: Name of required devel package
# $4: Option to skip build (e.g. HAVE_FUSE=0)
# $5: Additional compiler & linker options (optional)
#
check_dep=\
printf "\#include <%s>" $2 | ( $(CC) $(filter-out --coverage, $(ALL_CFLAGS)) $(ALL_CPPFLAGS) -c -o /dev/null -xc - ) > /dev/null 2>&1; \
printf "\#include <%s>\n int main(void) {return 0;}" $2 | ( $(CC) $(filter-out --coverage, $(ALL_CFLAGS)) $(ALL_CPPFLAGS) $5 -o /dev/null -xc - ) > /dev/null 2>&1; \
if [ $$? != 0 ]; \
then \
printf " REQCHK %s (%s)\n" $1 $2; \
@@ -167,13 +168,14 @@ MANDIR = $(INSTALLDIR)/usr/share/man
VARDIR = $(INSTALLDIR)/var
TOOLS_DATADIR = $(INSTALLDIR)/usr/share/s390-tools
TOOLS_LIBDIR = $(INSTALLDIR)/lib/s390-tools
ZFCPDUMP_DIR = $(INSTALLDIR)/lib/s390-tools/zfcpdump
ZFCPDUMP_DIR = $(TOOLS_LIBDIR)/zfcpdump
# Systemd support files are installed only if a directory is specified
# for SYSTEMDSYSTEMUNITDIR (e.g. /lib/systemd/system)
SYSTEMDSYSTEMUNITDIR =
INSTDIRS = $(USRSBINDIR) $(USRBINDIR) $(BINDIR) $(LIBDIR) $(MANDIR) \
$(SYSCONFDIR) $(TOOLS_LIBDIR) $(TOOLS_DATADIR) \
$(SYSCONFDIR) $(SYSCONFDIR)/sysconfig \
$(TOOLS_LIBDIR) $(TOOLS_DATADIR) \
$(ZFCPDUMP_DIR) $(SYSTEMDSYSTEMUNITDIR)
OWNER = $(shell id -un)
GROUP = $(shell id -gn)
@@ -193,12 +195,14 @@ ALL_CFLAGS = -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-DS390_TOOLS_LIBDIR=$(TOOLS_LIBDIR) \
-DS390_TOOLS_DATADIR=$(TOOLS_DATADIR) \
-DS390_TOOLS_SYSCONFDIR=$(SYSCONFDIR) \
-DS390_TOOLS_BINDIR=$(BINDIR) \
$(CFLAGS)
CXXFLAGS ?= $(DEFAULT_CFLAGS) $(OPT_FLAGS)
ALL_CXXFLAGS = -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-DS390_TOOLS_LIBDIR=$(TOOLS_LIBDIR) \
-DS390_TOOLS_DATADIR=$(TOOLS_DATADIR) \
-DS390_TOOLS_SYSCONFDIR=$(SYSCONFDIR) \
-DS390_TOOLS_BINDIR=$(BINDIR) \
$(CXXFLAGS)
ALL_CPPFLAGS = -I $(rootdir)include $(CPPFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
@@ -214,12 +218,22 @@ endif
export AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP INSTALL CFLAGS CXXFLAGS \
LDFLAGS CPPFLAGS ALL_CFLAGS ALL_CXXFLAGS ALL_LDFLAGS ALL_CPPFLAGS
ifneq ($(shell $(CC_SILENT) -dumpspecs 2>/dev/null | grep -e '[^f]no-pie'),)
NO_PIE_CFLAGS := -fno-pie
NO_PIE_LINKFLAGS := -no-pie
NO_PIE_LDFLAGS := -no-pie
else
NO_PIE_CFLAGS :=
NO_PIE_LINKFLAGS :=
NO_PIE_LDFLAGS :=
endif
# Overwrite implicite makefile rules for having nice compile output
%.o: %.c
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
ifeq ("${C}","1")
$(CHECKTOOL) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
endif
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
%.o: %.cpp
$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -c $< -o $@

View File

@@ -4,10 +4,12 @@ include ../common.mak
CPUMF_DATADIR = $(TOOLS_DATADIR)/cpumf
DATA_FILES = cpum-cf-hw-counter.map cpum-cf-generic.ctr \
DATA_FILES = cpum-cf-hw-counter.map \
cpum-cf-cfvn-1.ctr cpum-cf-cfvn-3.ctr \
cpum-cf-csvn-generic.ctr \
cpum-cf-extended-z10.ctr cpum-cf-extended-z196.ctr \
cpum-cf-extended-zEC12.ctr cpum-sf-modes.ctr \
cpum-cf-extended-z13.ctr
cpum-cf-extended-z13.ctr cpum-cf-extended-z14.ctr
LIB_FILES = bin/cpumf_helper
USRBIN_SCRIPTS = bin/lscpumf
USRSBIN_SCRIPTS = bin/chcpumf

View File

@@ -210,6 +210,7 @@ my $system_z_hwtype_map = {
2828 => 'IBM zEnterprise BC12',
2964 => 'IBM z13',
2965 => 'IBM z13s',
3906 => 'IBM z14',
};
sub get_hardware_type()
@@ -228,6 +229,28 @@ sub get_hardware_type()
return $type;
}
sub get_cpum_cf_version()
{
my $SL;
my $v = {
cfvn => 0,
csvn => 0,
};
return $v unless open($SL, '<', $SERVICE_LEVELS);
while (my $line = <$SL>) {
# CPU-MF: Counter facility: version=3.5
if ($line =~ m/^CPU-MF: Counter facility: version=(\d+)\.(\d+)/) {
$v->{cfvn} = $1; # Counter First Version Number
$v->{csvn} = $2; # Counter Second Version Number
last;
}
}
close($SL);
return $v
}
sub cpumf_load_ctrdef($;$)
{
my $hw_type = shift();
@@ -236,10 +259,20 @@ sub cpumf_load_ctrdef($;$)
my $ctrmap = cpumf_hardware_counter_map();
return unless $ctrmap;
# Obtain CPU-MF counter facility versions
my $version = get_cpum_cf_version();
# List of "generic" counter sets
my @def = ();
push @def, "cfvn-" . $version->{cfvn};
push @def, "csvn-generic";
my $h = {};
# Load generic counter sets
cpumf_parse_ctrdef($ctrmap->{0}, $h) or
croak "Failed to read generic counter definition: $!\n";
# Load counter set definition
foreach my $ent (@def) {
cpumf_parse_ctrdef($ctrmap->{$ent}, $h) or
croak "Failed to read counter definition for $ent: $!\n";
}
# Load hardware model specific counter set(s)
if ($hw_type && $ctrmap->{$hw_type}) {
# Hardware-model specific counter sets are:
@@ -322,7 +355,7 @@ sub cpumf_helper_main()
GetOptions(
"i|info" => \$conf->{opt_info},
"c|counter=i" => \$conf->{opt_ctr},
"ctr-def=i" => \$conf->{opt_ctrdef},
"ctr-def=s" => \$conf->{opt_ctrdef},
"hardware-type" => \$conf->{opt_hwtype},
"ctr-set-names" => \$conf->{opt_ctrset_names},
"ctr-set-ids" => \$conf->{opt_ctrset_ids},
@@ -427,11 +460,13 @@ B<--ctr-def> option and specify the System z hardware type.
Displays the System z hardware type.
=item B<--ctr-def> I<hardware_type>
=item B<--ctr-def> I<ctr-definition>
Displays detailed information about a particular counter set for the specified
System z hardware type, I<hardware_type>. If you specify zero for
I<hardware_type>, type-independent counter sets are displayed.
Displays detailed information about the specified counter definition.
Valid counter definitions start with C<cfvn-> or <csvn-> followed by
the counter first/second version number of the CPU-Measurement Counter
Facility. To display counter information of model-specific counter
sets, specify the System z hardware type for I<ctr-definition>.
=item B<--ctr-set-names>

View File

@@ -0,0 +1,48 @@
Counter: 0 Name:CPU_CYCLES
Description:
Cycle Count
.
Counter: 1 Name:INSTRUCTIONS
Description:
Instruction Count
.
Counter: 2 Name:L1I_DIR_WRITES
Description:
Level-1 I-Cache Directory Write Count
.
Counter: 3 Name:L1I_PENALTY_CYCLES
Description:
Level-1 I-Cache Penalty Cycle Count
.
Counter: 4 Name:L1D_DIR_WRITES
Description:
Level-1 D-Cache Directory Write Count
.
Counter: 5 Name:L1D_PENALTY_CYCLES
Description:
Level-1 D-Cache Penalty Cycle Count
.
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
Description:
Problem-State Cycle Count
.
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
Description:
Problem-State Instruction Count
.
Counter: 34 Name:PROBLEM_STATE_L1I_DIR_WRITES
Description:
Problem-State Level-1 I-Cache Directory Write Count
.
Counter: 35 Name:PROBLEM_STATE_L1I_PENALTY_CYCLES
Description:
Problem-State Level-1 I-Cache Penalty Cycle Count
.
Counter: 36 Name:PROBLEM_STATE_L1D_DIR_WRITES
Description:
Problem-State Level-1 D-Cache Directory Write Count
.
Counter: 37 Name:PROBLEM_STATE_L1D_PENALTY_CYCLES
Description:
Problem-State Level-1 D-Cache Penalty Cycle Count
.

View File

@@ -0,0 +1,32 @@
Counter: 0 Name:CPU_CYCLES
Description:
Cycle Count
.
Counter: 1 Name:INSTRUCTIONS
Description:
Instruction Count
.
Counter: 2 Name:L1I_DIR_WRITES
Description:
Level-1 I-Cache Directory Write Count
.
Counter: 3 Name:L1I_PENALTY_CYCLES
Description:
Level-1 I-Cache Penalty Cycle Count
.
Counter: 4 Name:L1D_DIR_WRITES
Description:
Level-1 D-Cache Directory Write Count
.
Counter: 5 Name:L1D_PENALTY_CYCLES
Description:
Level-1 D-Cache Penalty Cycle Count
.
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
Description:
Problem-State Cycle Count
.
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
Description:
Problem-State Instruction Count
.

View File

@@ -1,51 +1,3 @@
Counter: 0 Name:CPU_CYCLES
Description:
Cycle Count
.
Counter: 1 Name:INSTRUCTIONS
Description:
Instruction Count
.
Counter: 2 Name:L1I_DIR_WRITES
Description:
Level-1 I-Cache Directory Write Count
.
Counter: 3 Name:L1I_PENALTY_CYCLES
Description:
Level-1 I-Cache Penalty Cycle Count
.
Counter: 4 Name:L1D_DIR_WRITES
Description:
Level-1 D-Cache Directory Write Count
.
Counter: 5 Name:L1D_PENALTY_CYCLES
Description:
Level-1 D-Cache Penalty Cycle Count
.
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
Description:
Problem-State Cycle Count
.
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
Description:
Problem-State Instruction Count
.
Counter: 34 Name:PROBLEM_STATE_L1I_DIR_WRITES
Description:
Problem-State Level-1 I-Cache Directory Write Count
.
Counter: 35 Name:PROBLEM_STATE_L1I_PENALTY_CYCLES
Description:
Problem-State Level-1 I-Cache Penalty Cycle Count
.
Counter: 36 Name:PROBLEM_STATE_L1D_DIR_WRITES
Description:
Problem-State Level-1 D-Cache Directory Write Count
.
Counter: 37 Name:PROBLEM_STATE_L1D_PENALTY_CYCLES
Description:
Problem-State Level-1 D-Cache Penalty Cycle Count
.
Counter: 64 Name:PRNG_FUNCTIONS
Description:
Total number of the PRNG functions issued by the CPU

View File

@@ -0,0 +1,303 @@
# Counter decriptions for the
# IBM z14 extended counter and MT-diagnostic counter set
#
# Notes for transactional-execution mode symbolic names:
# TX .. transactional-execution mode
# NC .. nonconstrained
# C .. constrained
#
# Undefined counters in the extended counter set:
# 142
# 158-161
# 176-223
# 227-231
# 233-242
# 246-255
# Undefined counters in the MT-diagnostic counter set:
# 450-495
#
#
# Extended Counter Set
# ---------------------------------------------------------------------
Counter:128 Name:L1D_WRITES_RO_EXCL
A directory write to the Level-1 Data cache where the line was
originally in a Read-Only state in the cache but has been updated
to be in the Exclusive state that allows stores to the cache line
.
Counter:129 Name:DTLB2_WRITES
Description:
A translation has been written into The Translation Lookaside
Buffer 2 (TLB2) and the request was made by the data cache
.
Counter:130 Name:DTLB2_MISSES
Description:
A TLB2 miss is in progress for a request made by the data cache.
Incremented by one for every TLB2 miss in progress for the Level-1
Data cache on this cycle
.
Counter:131 Name:DTLB2_HPAGE_WRITES
Description:
A translation entry was written into the Combined Region and Segment
Table Entry array in the Level-2 TLB for a one-megabyte page or a
Last Host Translation was done
.
Counter:132 Name:DTLB2_GPAGE_WRITES
Description:
A translation entry for a two-gigabyte page was written into the
Level-2 TLB
.
Counter:133 Name:L1D_L2D_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the
returned cache line was sourced from the Level-2 Data cache
.
Counter:134 Name:ITLB2_WRITES
Description:
A translation entry has been written into the Translation Lookaside
Buffer 2 (TLB2) and the request was made by the instruction cache
.
Counter:135 Name:ITLB2_MISSES
Description:
A TLB2 miss is in progress for a request made by the instruction cache.
Incremented by one for every TLB2 miss in progress for the Level-1
Instruction cache in a cycle
.
Counter:136 Name:L1I_L2I_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from the Level-2 Instruction cache
.
Counter:137 Name:TLB2_PTE_WRITES
Description:
A translation entry was written into the Page Table Entry array in the
Level-2 TLB
.
Counter:138 Name:TLB2_CRSTE_WRITES
Description:
Translation entries were written into the Combined Region and Segment
Table Entry array and the Page Table Entry array in the Level-2 TLB
.
Counter:139 Name:TLB2_ENGINES_BUSY
Description:
The number of Level-2 TLB translation engines busy in a cycle
.
Counter:140 Name:TX_C_TEND
Description:
A TEND instruction has completed in a constrained transactional-execution
mode
.
Counter:141 Name:TX_NC_TEND
Description:
A TEND instruction has completed in a non-constrained
transactional-execution mode
.
Counter:143 Name:L1C_TLB2_MISSES
Description:
Increments by one for any cycle where a level-1 cache or level-2 TLB miss
is in progress
.
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Chip Level-3 cache without intervention
.
Counter:145 Name:L1D_ONCHIP_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Chip memory
.
Counter:146 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Chip Level-3 cache with intervention
.
Counter:147 Name:L1D_ONCLUSTER_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Cluster Level-3 cache withountervention
.
Counter:148 Name:L1D_ONCLUSTER_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Cluster memory
.
Counter:149 Name:L1D_ONCLUSTER_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an On-Cluster Level-3 cache with intervention
.
Counter:150 Name:L1D_OFFCLUSTER_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Cluster Level-3 cache without
intervention
.
Counter:151 Name:L1D_OFFCLUSTER_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from Off-Cluster memory
.
Counter:152 Name:L1D_OFFCLUSTER_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Cluster Level-3 cache with intervention
.
Counter:153 Name:L1D_OFFDRAWER_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Level-3 cache without
intervention
.
Counter:154 Name:L1D_OFFDRAWER_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from Off-Drawer memory
.
Counter:155 Name:L1D_OFFDRAWER_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from an Off-Drawer Level-3 cache with intervention
.
Counter:156 Name:L1D_ONDRAWER_L4_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Drawer Level-4 cache
.
Counter:157 Name:L1D_OFFDRAWER_L4_SOURCED_WRITES
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from Off-Drawer Level-4 cache
.
Counter:158 Name:L1D_ONCHIP_L3_SOURCED_WRITES_RO
Description:
A directory write to the Level-1 Data cache directory where the returned
cache line was sourced from On-Chip L3 but a read-only invalidate was
done to remove other copies of the cache line
.
Counter:162 Name:L1I_ONCHIP_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache ine was sourced from an On-Chip Level-3 cache without
intervention
.
Counter:163 Name:L1I_ONCHIP_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache ine was sourced from On-Chip memory
.
Counter:164 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache ine was sourced from an On-Chip Level-3 cache with
intervention
.
Counter:165 Name:L1I_ONCLUSTER_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On-Cluster Level-3 cache without
intervention
.
Counter:166 Name:L1I_ONCLUSTER_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an On-Cluster memory
.
Counter:167 Name:L1I_ONCLUSTER_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from On-Cluster Level-3 cache with
intervention
.
Counter:168 Name:L1I_OFFCLUSTER_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Cluster Level-3 cache without
intervention
.
Counter:169 Name:L1I_OFFCLUSTER_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from Off-Cluster memory
.
Counter:170 Name:L1I_OFFCLUSTER_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Cluster Level-3 cache with
intervention
.
Counter:171 Name:L1I_OFFDRAWER_L3_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Drawer Level-3 cache without
intervention
.
Counter:172 Name:L1I_OFFDRAWER_MEMORY_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from Off-Drawer memory
.
Counter:173 Name:L1I_OFFDRAWER_L3_SOURCED_WRITES_IV
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from an Off-Drawer Level-3 cache with
intervention
.
Counter:174 Name:L1I_ONDRAWER_L4_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from On-Drawer Level-4 cache
.
Counter:175 Name:L1I_OFFDRAWER_L4_SOURCED_WRITES
Description:
A directory write to the Level-1 Instruction cache directory where the
returned cache line was sourced from Off-Drawer Level-4 cache
.
Counter:224 Name:BCD_DFP_EXECUTION_SLOTS
Description:
Count of floating point execution slots used for finished Binary Coded
Decimal to Decimal Floating Point conversions. Instructions: CDZT,
CXZT, CZDT, CZXT
.
Counter:225 Name:VX_BCD_EXECUTION_SLOTS
Description:
Count of floating point execution slots used for finished vector arithmetic
Binary Coded Decimal instructions. Instructions: VAP, VSP, VMPVMSP, VDP,
VSDP, VRP, VLIP, VSRP, VPSOPVCP, VTP, VPKZ, VUPKZ, VCVB, VCVBG, VCVDVCVDG
.
Counter:226 Name:DECIMAL_INSTRUCTIONS
Description:
Decimal instructions dispatched. Instructions: CVB, CVD, AP, CP, DP, ED,
EDMK, MP, SRP, SP, ZAP
.
Counter:232 Name:LAST_HOST_TRANSLATIONS
Description:
Last Host Translation done
.
Counter:243 Name:TX_NC_TABORT
Description:
A transaction abort has occurred in a non-constrained
transactional-execution mode
.
Counter:244 Name:TX_C_TABORT_NO_SPECIAL
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is not using any special logic to allow the transaction
to complete
.
Counter:245 Name:TX_C_TABORT_SPECIAL
Description:
A transaction abort has occurred in a constrained transactional-execution
mode and the CPU is using special logic to allow the transaction to
complete
.
#
# MT-diagnostic counter set
# ---------------------------------------------------------------------
Counter:448 Name:MT_DIAG_CYCLES_ONE_THR_ACTIVE
Description:
Cycle count with one thread active
.
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
Description:
Cycle count with two threads active
.

View File

@@ -1,11 +1,22 @@
# CPU-measurement facilities
#
# Mapping of IBM System z hardware types to extended counter set defintions
# Mapping of:
# 1. CPU-MF counter first/second version numbers to "generic" counter
# definitions
# 2. IBM z Systems hardware to respective extended counter set definitions
#
#
{
# Definition # File name
0 => 'cpum-cf-generic.ctr',
# CFVN
'cfvn-1' => 'cpum-cf-cfvn-1.ctr',
'cfvn-3' => 'cpum-cf-cfvn-3.ctr',
# CSVN
'csvn-generic' => 'cpum-cf-csvn-generic.ctr',
# Extended counters
2097 => 'cpum-cf-extended-z10.ctr',
2098 => 'cpum-cf-extended-z10.ctr',
2817 => 'cpum-cf-extended-z196.ctr',
@@ -14,4 +25,5 @@
2828 => 'cpum-cf-extended-zEC12.ctr',
2964 => 'cpum-cf-extended-z13.ctr',
2965 => 'cpum-cf-extended-z13.ctr',
3906 => 'cpum-cf-extended-z14.ctr',
};

View File

@@ -197,10 +197,10 @@ int is_online(int cpuid);
long get_cmmpages_size();
void parse_options(int argc, char **argv);
void check_if_started_twice();
void store_pid(void);
void handle_signals(void);
void handle_sighup(void);
void reload_daemon(void);
int daemonize(void);
int check_cmmfiles(void);
void check_config();
void set_cmm_pages(long size);

View File

@@ -9,6 +9,10 @@
* it under the terms of the MIT license. See LICENSE for details.
*/
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "cpuplugd.h"
const char *name = NAME;
@@ -49,7 +53,7 @@ void print_version()
/*
* Store daemon's pid so it can be stopped
*/
void store_pid(void)
static int store_pid(void)
{
FILE *filp;
@@ -57,10 +61,62 @@ void store_pid(void)
if (!filp) {
cpuplugd_error("cannot open pid file %s: %s\n", pid_file,
strerror(errno));
exit(1);
return -1;
}
fprintf(filp, "%d\n", getpid());
fclose(filp);
return 0;
}
/*
* Run daemon in background and write pid file
*/
int daemonize(void)
{
int fd, pipe_fds[2], startup_rc = 1;
pid_t pid;
if (pipe(pipe_fds) == -1) {
cpuplugd_error("cannot create pipe\n");
return -1;
}
pid = fork();
if (pid < 0)
goto close_pipe;
if (pid != 0) {
/* Wait for startup return code from daemon */
if (read(pipe_fds[0], &startup_rc, sizeof(startup_rc)) == -1)
cpuplugd_error("cannot read from pipe\n");
/* On success daemon has written pid file at this point */
exit(startup_rc);
}
/* Create new session */
if (setsid() < 0)
goto notify_parent;
/* Redirect stdin/out/err to /dev/null */
fd = open("/dev/null", O_RDWR, 0);
if (fd == -1)
goto notify_parent;
if (dup2(fd, STDIN_FILENO) < 0)
goto notify_parent;
if (dup2(fd, STDOUT_FILENO) < 0)
goto notify_parent;
if (dup2(fd, STDERR_FILENO) < 0)
goto notify_parent;
/* Create pid file */
if (store_pid() < 0)
goto notify_parent;
startup_rc = 0;
notify_parent:
/* Inform waiting parent about startup return code */
if (write(pipe_fds[1], &startup_rc, sizeof(startup_rc)) == -1) {
cpuplugd_error("cannot write to pipe\n");
startup_rc = 1;
}
close_pipe:
close(pipe_fds[0]);
close(pipe_fds[1]);
return startup_rc ? -1 : 0;
}
/*

View File

@@ -418,13 +418,11 @@ int main(int argc, char *argv[])
check_config();
if (!foreground) {
rc = daemon(1, 0);
rc = daemonize();
if (rc < 0)
cpuplugd_exit("Detach from terminal failed: %s\n",
strerror(errno));
}
/* Store daemon pid */
store_pid();
/* Unlock lock file */
flock(fd, LOCK_UN);
close(fd);

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;
@@ -33,7 +36,6 @@ static char *prog_name;
static volatile sig_atomic_t program_interrupt_in_progress;
static int reqsize;
static const struct util_prg prg = {
.desc = "Use dasdfmt to format a DASD ECKD device for use by Linux.\n"
"DEVICE is the node of the device (e.g. '/dev/dasda').",
@@ -265,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 beeing 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.
*/
@@ -312,16 +296,18 @@ static unsigned int recs_per_track(struct dasd_eckd_characteristics *rdc,
kn = ceil_quot(kl + 6, 232) + 1;
return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
9 + ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
}
case 0x9345:
dn = ceil_quot(dl + 6, 232) + 1;
if (kl) {
kn = ceil_quot(kl + 6, 232) + 1;
return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
}
}
return 0;
}
@@ -404,7 +390,7 @@ static void evaluate_format_error(dasdfmt_info_t *info, format_check_t *cdata,
break;
case DASD_FMT_ERR_RECORD_ID:
ERRMSG("Invalid record ID at cyl: %d trk: %d rec: %d.\n",
cyl, head, cdata->rec);
cyl, head, cdata->rec);
break;
case DASD_FMT_ERR_KEY_LENGTH:
ERRMSG("Invalid key length (found %d, expected %d) "
@@ -414,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
@@ -428,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);
}
@@ -456,46 +457,34 @@ static void program_interrupt_signal(int sig)
/*
* check given device name for blanks and some special characters
*/
static void get_device_name(dasdfmt_info_t *info, char *name, int argc,
char *argv[])
static void get_device_name(char *devname,
int optind, int argc, char *argv[])
{
struct util_proc_dev_entry dev_entry;
struct stat dev_stat;
if (info->device_id + 1 < argc)
if (optind + 1 < argc)
ERRMSG_EXIT(EXIT_MISUSE,
"%s: More than one device specified!\n", prog_name);
if (info->device_id >= argc)
if (optind >= argc)
ERRMSG_EXIT(EXIT_MISUSE, "%s: No device specified!\n",
prog_name);
if (info->device_id < argc) {
strcpy(info->devname, argv[info->device_id]);
} else {
if ((strchr(name, ' ') != NULL) || (strchr(name, '#') != NULL) ||
(strchr(name, '[') != NULL) || (strchr(name, ']') != NULL) ||
(strchr(name, '!') != NULL) || (strchr(name, '>') != NULL) ||
(strchr(name, '(') != NULL) || (strchr(name, '<') != NULL) ||
(strchr(name, ')') != NULL) || (strchr(name, ':') != NULL) ||
(strchr(name, '&') != NULL) || (strchr(name, ';') != NULL))
ERRMSG_EXIT(EXIT_MISUSE, "%s: Your filename contains "
"blanks or special characters!\n",
prog_name);
if (strlen(argv[optind]) >= PATH_MAX)
ERRMSG_EXIT(EXIT_MISUSE, "%s: device name too long!\n",
prog_name);
strcpy(devname, argv[optind]);
strncpy(info->devname, name, PATH_MAX - 1);
info->devname[PATH_MAX - 1] = '\0';
}
if (stat(info->devname, &dev_stat) != 0)
if (stat(devname, &dev_stat) != 0)
ERRMSG_EXIT(EXIT_MISUSE, "%s: Could not get information for "
"device node %s: %s\n", prog_name, info->devname,
"device node %s: %s\n", prog_name, devname,
strerror(errno));
if (minor(dev_stat.st_rdev) & PARTN_MASK) {
ERRMSG_EXIT(EXIT_MISUSE, "%s: Unable to format partition %s. "
"Please specify a device.\n", prog_name,
info->devname);
devname);
}
if (util_proc_dev_get_entry(dev_stat.st_rdev, 1, &dev_entry) == 0) {
@@ -505,34 +494,19 @@ static void get_device_name(dasdfmt_info_t *info, char *name, int argc,
prog_name, dev_entry.name);
} else {
printf("%s WARNING: Unable to get driver name for device node %s",
prog_name, info->devname);
prog_name, 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));
}
/*
@@ -546,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 "
@@ -586,18 +560,17 @@ static void check_layout(dasdfmt_info_t *info, unsigned int intensity)
/*
* check for disk type and set some variables (e.g. usage count)
*/
static void check_disk(dasdfmt_info_t *info)
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");
@@ -609,13 +582,13 @@ static void check_disk(dasdfmt_info_t *info)
if (strncmp(info->dasd_info.type, "ECKD", 4) != 0) {
ERRMSG_EXIT(EXIT_FAILURE,
"%s: Unsupported disk type\n%s is not an "
"ECKD disk!\n", prog_name, info->devname);
"ECKD disk!\n", prog_name, devname);
}
if (dasd_sys_raw_track_access(info->devname)) {
if (dasd_sys_raw_track_access(devname)) {
ERRMSG_EXIT(EXIT_FAILURE,
"%s: Device '%s' is in raw-track access mode\n",
prog_name, info->devname);
prog_name, devname);
}
}
@@ -787,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) {
@@ -800,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;
@@ -816,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);
@@ -839,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;
@@ -935,7 +911,8 @@ static format_data_t ask_user_for_blksize(format_data_t params)
/*
* print all information needed to format the device
*/
static void dasdfmt_print_info(dasdfmt_info_t *info, volume_label_t *vlabel,
static void dasdfmt_print_info(dasdfmt_info_t *info, char *devname,
volume_label_t *vlabel,
unsigned int cylinders, unsigned int heads,
format_data_t *p)
{
@@ -945,7 +922,7 @@ static void dasdfmt_print_info(dasdfmt_info_t *info, volume_label_t *vlabel,
cylinders, heads, (cylinders * heads));
printf("\nI am going to format the device ");
printf("%s in the following way:\n", info->devname);
printf("%s in the following way:\n", devname);
printf(" Device number of device : 0x%x\n", info->dasd_info.devno);
printf(" Labelling device : %s\n",
(info->writenolabel) ? "no" : "yes");
@@ -970,28 +947,19 @@ static void dasdfmt_print_info(dasdfmt_info_t *info, volume_label_t *vlabel,
/*
* get volser
*/
static int dasdfmt_get_volser(dasdfmt_info_t *info, char *volser)
static int dasdfmt_get_volser(char *devname, dasd_information2_t *dasd_info,
char *volser)
{
unsigned int blksize;
int f;
volume_label_t vlabel;
f = open(info->devname, O_RDONLY);
if (f == -1)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device %s: %s\n",
prog_name, info->devname, strerror(errno));
get_blocksize(devname, &blksize);
get_blocksize(&blksize);
if (close(f) != 0)
ERRMSG("%s: error during close: %s\ncontinuing...\n",
prog_name, strerror(errno));
if ((strncmp(info->dasd_info.type, "ECKD", 4) == 0) &&
(!info->dasd_info.FBA_layout)) {
if ((strncmp(dasd_info->type, "ECKD", 4) == 0) &&
!dasd_info->FBA_layout) {
/* OS/390 and zOS compatible disk layout */
vtoc_read_volume_label(info->devname,
info->dasd_info.label_block * blksize,
vtoc_read_volume_label(devname,
dasd_info->label_block * blksize,
&vlabel);
vtoc_volume_label_get_volser(&vlabel, volser);
return 0;
@@ -1012,25 +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");
@@ -1056,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,
@@ -1091,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... ");
@@ -1124,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");
@@ -1245,27 +1245,25 @@ 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)))
if (!(info->withoutprompt && (info->verbosity < 1)))
printf("Formatting the device. This may take a while "
"(get yourself a coffee).\n");
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;
@@ -1280,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();
}
/*
@@ -1301,18 +1296,14 @@ static void dasdfmt_prepare_and_format(dasdfmt_info_t *info,
static void dasdfmt_expand_format(dasdfmt_info_t *info, unsigned int cylinders,
unsigned int heads, format_data_t *p)
{
if (!((info->withoutprompt) && (info->verbosity < 1)))
if (!(info->withoutprompt && (info->verbosity < 1)))
printf("Formatting the device. This may take a while "
"(get yourself a coffee).\n");
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);
@@ -1322,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();
}
/*
@@ -1338,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");
@@ -1364,33 +1352,29 @@ static void dasdfmt_quick_format(dasdfmt_info_t *info, unsigned int cylinders,
}
}
if (!((info->withoutprompt) && (info->verbosity < 1)))
if (!(info->withoutprompt && (info->verbosity < 1)))
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, volume_label_t *vlabel,
static void do_format_dasd(dasdfmt_info_t *info, char *devname,
volume_label_t *vlabel,
format_data_t *p, unsigned int cylinders,
unsigned int heads)
{
char inp_buffer[5];
int count;
int count, err;
p->start_unit = 0;
@@ -1408,19 +1392,19 @@ static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
}
if ((info->verbosity > 0) || !info->withoutprompt || info->testmode)
dasdfmt_print_info(info, vlabel, cylinders, heads, p);
dasdfmt_print_info(info, devname, vlabel, cylinders, heads, p);
count = u2s_get_host_access_count(info->devname);
count = u2s_get_host_access_count(devname);
if (info->force_host) {
if (count > 1) {
ERRMSG_EXIT(EXIT_FAILURE,
"\n%s: Disk %s is online on OS instances in %d different LPARs.\n"
"Note: Your installation might include z/VM systems that are configured to\n"
"automatically vary on disks, regardless of whether they are subsequently used.\n\n",
prog_name, info->devname, count);
prog_name, devname, count);
} else if (count < 0) {
ERRMSG("\nHosts access information not available for disk %s.\n\n",
info->devname);
devname);
return;
}
} else if (count > 1)
@@ -1429,7 +1413,7 @@ static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
"Ensure that the disk is not being used by a system outside your LPAR.\n"
"Note: Your installation might include z/VM systems that are configured to\n"
"automatically vary on disks, regardless of whether they are subsequently used.\n",
info->devname, count);
devname, count);
if (!info->testmode) {
if (!info->withoutprompt) {
@@ -1467,9 +1451,10 @@ static void do_format_dasd(dasdfmt_info_t *info, volume_label_t *vlabel,
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");
}
@@ -1480,12 +1465,10 @@ int main(int argc, char *argv[])
{
dasdfmt_info_t info = {
.dasd_info = {0},
{0}
};
volume_label_t vlabel;
char old_volser[7];
char dev_filename[PATH_MAX];
char str[ERR_LENGTH];
char buf[7];
@@ -1624,7 +1607,6 @@ int main(int argc, char *argv[])
break;
case -1:
/* End of options string - start of devices list */
info.device_id = optind;
break;
default:
ERRMSG_EXIT(EXIT_MISUSE, "Try '%s --help' for more"
@@ -1655,20 +1637,19 @@ int main(int argc, char *argv[])
if (info.print_hashmarks)
PARSE_PARAM_INTO(info.hashstep, hashstep_str, 10, "hashstep");
get_device_name(&info, dev_filename, argc, argv);
get_device_name(dev_filename, optind, argc, argv);
filedes = open(info.devname, O_RDWR);
if (filedes == -1)
ERRMSG_EXIT(EXIT_FAILURE, "%s: Unable to open device %s: %s\n",
prog_name, info.devname, 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);
}
@@ -1684,15 +1665,16 @@ int main(int argc, char *argv[])
exit(1);
}
if (dasdfmt_get_volser(&info, old_volser) == 0)
if (dasdfmt_get_volser(dev_filename,
&info.dasd_info, old_volser) == 0)
vtoc_volume_label_set_volser(&vlabel, old_volser);
else
ERRMSG_EXIT(EXIT_FAILURE,
"%s: VOLSER not found on device %s\n",
prog_name, info.devname);
prog_name, dev_filename);
}
check_disk(&info);
check_disk(&info, dev_filename);
if (check_param(str, ERR_LENGTH, &format_params) < 0)
ERRMSG_EXIT(EXIT_MISUSE, "%s: %s\n", prog_name, str);
@@ -1703,11 +1685,8 @@ int main(int argc, char *argv[])
if (info.check)
check_disk_format(&info, cylinders, heads, &format_params);
else
do_format_dasd(&info, &vlabel, &format_params, cylinders, heads);
if (close(filedes) != 0)
ERRMSG("%s: error during close: %s\ncontinuing...\n",
prog_name, strerror(errno));
do_format_dasd(&info, dev_filename, &vlabel,
&format_params, cylinders, heads);
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 *
****************************************************************************/
@@ -291,7 +121,6 @@ typedef struct bootstrap2 {
typedef struct dasdfmt_info {
dasd_information2_t dasd_info;
char devname[PATH_MAX];
int verbosity;
int testmode;
int withoutprompt;
@@ -304,7 +133,6 @@ typedef struct dasdfmt_info {
int cdl_format;
int blksize_specified;
int reqsize_specified;
int device_id;
int keep_volser;
int force_host;
int layout_specified;

View File

@@ -1,7 +1,8 @@
include ../common.mak
libs = $(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
$(rootdir)/libutil/libutil.a \
$(rootdir)/libdasd/libdasd.a
all: dasdinfo

View File

@@ -22,6 +22,7 @@
#include <sys/utsname.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#include "lib/util_base.h"
#include "lib/util_file.h"
#include "lib/util_opt.h"
@@ -29,10 +30,6 @@
#include "lib/zt_common.h"
#define RD_BUFFER_SIZE 80
#define BLKSSZGET _IO(0x12,104)
#define DASD_IOCTL_LETTER 'D'
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,struct dasd_information)
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER,3,struct dasd_information2)
#define TEMP_DEV_MAX_RETRIES 1000
static const struct util_prg prg = {
@@ -100,67 +97,7 @@ struct volume_label {
char volid[6];
} __attribute__ ((packed));
struct dasd_information2 {
unsigned int devno;
unsigned int real_devno;
unsigned int schid;
unsigned int cu_type : 16;
unsigned int cu_model : 8;
unsigned int dev_type : 16;
unsigned int dev_model : 8;
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len;
char type[4];
unsigned int status;
unsigned int label_block;
unsigned int FBA_layout;
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64];
char configuration_data[256];
unsigned int format;
unsigned int features;
unsigned int reserved0;
unsigned int reserved1;
unsigned int reserved2;
unsigned int reserved3;
unsigned int reserved4;
unsigned int reserved5;
unsigned int reserved6;
unsigned int reserved7;
};
struct dasd_information {
unsigned int devno;
unsigned int real_devno;
unsigned int schid;
unsigned int cu_type : 16;
unsigned int cu_model : 8;
unsigned int dev_type : 16;
unsigned int dev_model : 8;
unsigned int open_count;
unsigned int req_queue_len;
unsigned int chanq_len;
char type[4];
unsigned int status;
unsigned int label_block;
unsigned int FBA_layout;
unsigned int characteristics_size;
unsigned int confdata_size;
char characteristics[64];
char configuration_data[256];
};
struct dasd_data
{
struct dasd_information2 dasd_info;
int dasd_info_version;
int blksize;
};
static char EBCtoASC[256] =
{
static char EBCtoASC[256] = {
/* 0x00 NUL SOH STX ETX *SEL HT *RNL DEL */
0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
/* 0x08 -GE -SPS -RPT VT FF CR SO SI */
@@ -227,12 +164,12 @@ static char EBCtoASC[256] =
0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07
};
static char *dinfo_ebcdic_dec (char *source, char *target, int l)
static char *dinfo_ebcdic_dec(char *source, char *target, int l)
{
int i;
for (i = 0; i < l; i++)
target[i]=EBCtoASC[(unsigned char)(source[i])];
target[i] = EBCtoASC[(unsigned char)(source[i])];
return target;
}
@@ -242,51 +179,49 @@ static int dinfo_read_dasd_uid(char *uidfile, char *readbuf)
return util_file_read_line(readbuf, RD_BUFFER_SIZE, uidfile);
}
static int dinfo_read_dasd_vlabel (char *device, struct volume_label *vlabel,
char *readbuf)
static int dinfo_read_dasd_vlabel(char *device, struct volume_label *vlabel,
char *readbuf)
{
struct dasd_data data;
struct volume_label tmp;
int vlsize = sizeof(struct volume_label);
dasd_information2_t dasd_info;
unsigned long vlabel_start;
unsigned int blksize;
char vollbl[5];
int f;
char *space;
if ((f = open(device, O_RDONLY)) < 0) {
printf("Could not open device node.\n");
goto error;
}
if (ioctl(f, BLKSSZGET, &data.blksize) != 0) {
if (dasd_get_blocksize(device, &blksize) != 0) {
printf("Unable to figure out block size.\n");
goto error;
}
if (ioctl(f, BIODASDINFO2, &data.dasd_info) == 0)
data.dasd_info_version = 2;
else {
if (ioctl(f, BIODASDINFO, &data.dasd_info) != 0) {
printf("Unable to figure out DASD informations.\n");
goto error;
}
if (dasd_get_info(device, &dasd_info) != 0) {
printf("Unable to figure out DASD informations.\n");
goto error;
}
vlabel_start = data.dasd_info.label_block * data.blksize;
if (lseek(f, vlabel_start, SEEK_SET) < 0)
f = open(device, O_RDONLY);
if (f < 0) {
printf("Could not open device node.\n");
goto error;
}
vlabel_start = dasd_info.label_block * blksize;
if (lseek(f, vlabel_start, SEEK_SET) < 0)
goto error_close;
bzero(vlabel, vlsize);
if (read(f, vlabel, vlsize) != vlsize) {
printf("Could not read volume label.\n");
goto error;
goto error_close;
}
if (data.dasd_info.FBA_layout) {
if (dasd_info.FBA_layout) {
bzero(&tmp, vlsize);
memcpy(&tmp, vlabel, vlsize);
memcpy(vlabel->vollbl, &tmp, vlsize-4);
memcpy(vlabel->vollbl, &tmp, vlsize - 4);
}
close(f);
@@ -301,16 +236,17 @@ static int dinfo_read_dasd_vlabel (char *device, struct volume_label *vlabel,
(strncmp(vollbl, "CMS1", 4) == 0)) {
strncpy(readbuf, vlabel->volid, 6);
dinfo_ebcdic_dec(readbuf, readbuf, 6);
space = strchr(readbuf,' ');
space = strchr(readbuf, ' ');
if (space)
*space = 0;
} else
} else {
strcpy(readbuf, "");
}
return 0;
error:
error_close:
close(f);
error:
return -1;
}
@@ -321,7 +257,7 @@ static void *dinfo_malloc(size_t size)
result = malloc(size);
if (result == NULL) {
printf("Could not allocate %lld bytes of memory",
(unsigned long long) size);
(unsigned long long)size);
}
return result;
}
@@ -332,7 +268,7 @@ static char *dinfo_make_path(char *dirname, char *filename)
size_t len;
len = strlen(dirname) + strlen(filename) + 2;
result = (char *) dinfo_malloc(len);
result = (char *)dinfo_malloc(len);
if (result == NULL)
return NULL;
sprintf(result, "%s/%s", dirname, filename);
@@ -342,8 +278,8 @@ static char *dinfo_make_path(char *dirname, char *filename)
static int dinfo_create_devnode(dev_t dev, char **devno)
{
char *result;
char * pathname[] = { "/dev", getenv("TMPDIR"), "/tmp",
getenv("HOME"), "." , "/"};
char *pathname[] = { "/dev", getenv("TMPDIR"), "/tmp",
getenv("HOME"), ".", "/"};
char filename[] = "dasdinfo0000";
mode_t mode;
unsigned int path;
@@ -354,10 +290,10 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
mode = S_IFBLK | S_IRWXU;
/* Try several locations for the temporary device node. */
for (path=0; path < sizeof(pathname) / sizeof(pathname[0]); path++) {
for (path = 0; path < UTIL_ARRAY_SIZE(pathname); path++) {
if (pathname[path] == NULL)
continue;
for (retry=0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
for (retry = 0; retry < TEMP_DEV_MAX_RETRIES; retry++) {
sprintf(filename, "dasdinfo%04d", retry);
result = dinfo_make_path(pathname[path], filename);
if (result == NULL)
@@ -366,7 +302,8 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
if (rc == 0) {
/* Need this test to cover
* 'nodev'-mounted
* filesystems. */
* filesystems.
*/
fd = open(result, O_RDONLY);
if (fd != -1) {
close(fd);
@@ -375,8 +312,9 @@ static int dinfo_create_devnode(dev_t dev, char **devno)
}
remove(result);
retry = TEMP_DEV_MAX_RETRIES;
} else if (errno != EEXIST)
} else if (errno != EEXIST) {
retry = TEMP_DEV_MAX_RETRIES;
}
free(result);
}
}
@@ -400,7 +338,8 @@ static int dinfo_extract_dev(dev_t *dev, char *str)
bzero(tmp, RD_BUFFER_SIZE);
strncpy(tmp, str, RD_BUFFER_SIZE);
if ((p = strchr(tmp, ':')) == NULL) {
p = strchr(tmp, ':');
if (p == NULL) {
printf("Error: unable to extract major/minor\n");
return -1;
}
@@ -439,6 +378,7 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
char *tempdir;
char linkdir[128];
ssize_t i;
if (tflag != FTW_D || (strncmp((fpath + ftwbuf->base), searchbusid,
strlen(searchbusid)) != 0))
return FTW_CONTINUE;
@@ -454,7 +394,7 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
if ((i < 0) || (i >= 128))
return -1;
/* append '\0' because readlink returns non zero terminated string */
tempdir[i+1] = '\0';
tempdir[i + 1] = '\0';
if (strstr(linkdir, "dasd") == NULL)
return FTW_CONTINUE;
free(busiddir);
@@ -470,15 +410,17 @@ dinfo_find_entry(const char *dir, const char *searchstring,
{
DIR *directory = NULL;
struct dirent *dir_entry = NULL;
directory = opendir(dir);
if (directory == NULL)
return -1;
while ((dir_entry = readdir(directory)) != NULL) {
/* compare if the found entry has exactly the same name
and type as searched */
/* compare if the found entry has exactly the same name and type
* as searched
*/
if ((strncmp(dir_entry->d_name, searchstring,
strlen(searchstring)) == 0)
&& (dir_entry->d_type & type)) {
strlen(searchstring)) == 0) &&
(dir_entry->d_type & type)) {
*result = strdup(dir_entry->d_name);
if (*result == NULL)
goto out;
@@ -545,6 +487,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
char *readbuf;
DIR *directory = NULL;
struct dirent *dir_entry = NULL;
int rc = 0;
if (stat(devnode, &stat_buffer) != 0) {
printf("Error: could not stat %s\n", devnode);
@@ -554,7 +497,8 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
sprintf(stat_dev, "%d:%d", major(stat_buffer.st_rdev),
minor(stat_buffer.st_rdev));
if ((directory = opendir("/sys/block/")) == NULL) {
directory = opendir("/sys/block/");
if (directory == NULL) {
printf("Error: could not open directory /sys/block\n");
return -1;
}
@@ -572,9 +516,16 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
continue;
if (strncmp(stat_dev, readbuf,
MAX(strlen(stat_dev), strlen(readbuf)-1)) == 0) {
snprintf(*uidfile, RD_BUFFER_SIZE,
"/sys/block/%s/device/uid", dir_entry->d_name);
MAX(strlen(stat_dev), strlen(readbuf) - 1)) == 0) {
rc = snprintf(*uidfile, RD_BUFFER_SIZE,
"/sys/block/%s/device/uid",
dir_entry->d_name);
if (rc >= RD_BUFFER_SIZE) {
fprintf(stderr,
"Error: Device name was truncated\n");
return -1;
}
break;
}
}
@@ -583,7 +534,7 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
return 0;
}
int main(int argc, char * argv[])
int main(int argc, char *argv[])
{
struct utsname uname_buf;
int version, release;
@@ -627,13 +578,13 @@ int main(int argc, char * argv[])
print_vlabel = 1;
break;
case 'i':
busid=strdup(optarg);
busid = strdup(optarg);
break;
case 'b':
blockdev=strdup(optarg);
blockdev = strdup(optarg);
break;
case 'd':
devnode=strdup(optarg);
devnode = strdup(optarg);
break;
case 'e':
export = 1;
@@ -653,11 +604,11 @@ int main(int argc, char * argv[])
}
uname(&uname_buf);
sscanf(uname_buf.release, "%d.%d", &version,&release);
if (strcmp(uname_buf.sysname,"Linux") ||
sscanf(uname_buf.release, "%d.%d", &version, &release);
if (strcmp(uname_buf.sysname, "Linux") ||
version < 2 || (version == 2 && release < 6)) {
printf("%s %d.%d is not supported\n", uname_buf.sysname,
version,release);
version, release);
exit(1);
}
@@ -685,9 +636,9 @@ int main(int argc, char * argv[])
/* try to read the uid attribute */
if (busid) {
sprintf(uidfile,"/sys/bus/ccw/devices/%s/uid", busid);
sprintf(uidfile, "/sys/bus/ccw/devices/%s/uid", busid);
} else if (blockdev) {
sprintf(uidfile,"/sys/block/%s/device/uid", blockdev);
sprintf(uidfile, "/sys/block/%s/device/uid", blockdev);
} else if (devnode) {
if (dinfo_get_uid_from_devnode(&uidfile, devnode) != 0)
goto error;
@@ -707,13 +658,11 @@ int main(int argc, char * argv[])
if (!srchuid)
break;
}
if (srchuid) {
srchuid[0] = '\n';
srchuid[1] = 0;
}
if (export) {
if (srchuid)
srchuid[0] = '\0';
if (export)
printf("ID_UID=%s\n", readbuf);
} else
else
printf("%s\n", readbuf);
if (!print_vlabel && !print_extended_uid)
goto out;
@@ -722,9 +671,9 @@ int main(int argc, char * argv[])
if (print_extended_uid) {
if (dinfo_read_dasd_uid(uidfile, readbuf) == 0) {
if (export) {
if (export)
printf("ID_XUID=%s\n", readbuf);
} else
else
printf("%s\n", readbuf);
if (!print_vlabel)
goto out;
@@ -761,9 +710,9 @@ int main(int argc, char * argv[])
}
if (dinfo_read_dasd_vlabel(device, &vlabel, readbuf) == 0) {
if (export) {
printf("ID_SERIAL=%s\n",readbuf);
} else
if (export)
printf("ID_SERIAL=%s\n", readbuf);
else
printf("%s\n", readbuf);
goto out;
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,139 +17,6 @@
* SECTION: Definitions needed for DASD-API (see dasd.h)
*******************************************************************************/
#define DASD_IOCTL_LETTER 'D'
/*
* struct dasd_information_t
* represents any data about the device, which is visible to userspace.
* including foramt and features.
*/
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;
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;
unsigned char characteristics[64];/*from read_device_characteristics */
unsigned 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));
/*
* values to be used for dasd_information2_t.format
* 0x00: NOT formatted
@@ -170,21 +37,6 @@ struct dasd_eckd_characteristics {
#define DASD_FEATURE_READONLY 1
#define DASD_FEATURE_USEDIAG 2
/* Get information on a dasd device (enhanced) */
#define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
#define BIODASDINFO2 _IOR(DASD_IOCTL_LETTER,3,dasd_information2_t)
/********************************************************************************
* SECTION: Further IOCTL Definitions (see fs.h and hdreq.h)
*******************************************************************************/
/* get block device sector size */
#define BLKSSZGET _IO(0x12,104)
/* return device size in bytes (u64 *arg) */
#define BLKGETSIZE64 _IOR(0x12,114,size_t)
/* get device geometry */
#define HDIO_GETGEO 0x0301
/********************************************************************************
* SECTION: DASDVIEW internal types
*******************************************************************************/
@@ -215,7 +67,7 @@ typedef struct dasdview_info
char device[PATH_MAX];
dasd_information2_t dasd_info;
int dasd_info_version;
int blksize;
unsigned int blksize;
struct hd_geometry geo;
u_int32_t hw_cylinders;

16
etc/Makefile Normal file
View File

@@ -0,0 +1,16 @@
include ../common.mak
CONFIG_FILES =
ifneq (${SYSTEMDSYSTEMUNITDIR},)
CONFIG_FILES += cpuplugd.conf sysconfig/cpi sysconfig/dumpconf \
sysconfig/mon_fsstatd sysconfig/mon_procd
endif
install:
for file in $(CONFIG_FILES); do \
$(INSTALL) -g $(GROUP) -o $(OWNER) \
-m 644 $$file $(DESTDIR)$(SYSCONFDIR)/$$file ; \
done
.PHONY: all install clean

View File

@@ -11,6 +11,7 @@
#include <stdio.h>
#include <sys/sysmacros.h>
#include "lib/dasd_base.h"
#include "lib/dasd_sys.h"
#include "lib/util_base.h"
#include "lib/util_opt.h"
@@ -220,8 +221,7 @@ static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
return anc->f4->DS4DCYL;
/* normal volume */
if (anc->f4->DS4DEVCT.DS4DEVFG & ALTERNATE_CYLINDERS_USED)
cyl = anc->f4->DS4DEVCT.DS4DSCYL -
(u_int16_t) anc->f4->DS4DEVAC;
cyl = anc->f4->DS4DEVCT.DS4DSCYL - (u_int16_t)anc->f4->DS4DEVAC;
else
cyl = anc->f4->DS4DEVCT.DS4DSCYL;
@@ -230,9 +230,8 @@ static u_int32_t get_usable_cylinders(fdasd_anchor_t *anc)
static void get_addr_of_highest_f1_f8_label(fdasd_anchor_t *anc, cchhb_t *addr)
{
u_int8_t record;
/* We have to count the follwing labels:
/* We have to count the following labels:
* one format 4
* one format 5
* format 7 only if we have moren then BIG_DISK_SIZE tracks
@@ -769,7 +768,7 @@ static int fdasd_parse_conffile(fdasd_anchor_t *anc,
} else {
errno = 0;
anc->confdata[i].start = strtol(token[0],
(char **) NULL, 10);
(char **)NULL, 10);
if (errno != 0 || anc->confdata[i].start == 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"invalid partition start in config "
@@ -784,7 +783,7 @@ static int fdasd_parse_conffile(fdasd_anchor_t *anc,
} else {
errno = 0;
anc->confdata[i].stop = strtol(token[1],
(char **) NULL, 10);
(char **)NULL, 10);
if (errno != 0 || anc->confdata[i].stop == 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"invalid partition end in config "
@@ -884,9 +883,9 @@ static void fdasd_check_conffile_input(fdasd_anchor_t *anc,
anc->fspace_trk = start - FIRST_USABLE_TRK;
if (i < USABLE_PARTITIONS - 1) {
if (anc->confdata[i+1].start != 0)
if (anc->confdata[i + 1].start != 0)
part_info->fspace_trk =
anc->confdata[i+1].start-stop-1;
anc->confdata[i + 1].start - stop - 1;
else
part_info->fspace_trk = last_trk - stop;
} else if (i == USABLE_PARTITIONS - 1) {
@@ -916,8 +915,8 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
if (!S_ISBLK(dst.st_mode)) {
snprintf(err_str, ERROR_STRING_SIZE,
"Device '%s' (%d/%d) is not a block device\n", name,
(unsigned short) major(dst.st_rdev),
(unsigned short) minor(dst.st_rdev));
(unsigned short)major(dst.st_rdev),
(unsigned short)minor(dst.st_rdev));
fdasd_error(anc, device_verification_failed, err_str);
}
@@ -925,8 +924,8 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
snprintf(err_str, ERROR_STRING_SIZE,
"Partition '%s' (%d/%d) detected where device is "
"required\n", name,
(unsigned short) major(dst.st_rdev),
(unsigned short) minor(dst.st_rdev));
(unsigned short)major(dst.st_rdev),
(unsigned short)minor(dst.st_rdev));
fdasd_error(anc, device_verification_failed, err_str);
}
@@ -962,8 +961,8 @@ static void fdasd_verify_device(fdasd_anchor_t *anc, char *name)
if (anc->verbose) {
printf("Verification successful for '%s' (%d/%d)\n", name,
(unsigned short) major(dst.st_rdev),
(unsigned short) minor(dst.st_rdev));
(unsigned short)major(dst.st_rdev),
(unsigned short)minor(dst.st_rdev));
}
}
@@ -1028,15 +1027,13 @@ static void fdasd_verify_options(fdasd_anchor_t *anc)
}
}
if (anc->auto_partition &&
(options.conffile || anc->print_table)) {
if (anc->auto_partition && (options.conffile || anc->print_table)) {
fdasd_error(anc, parser_failed,
"Option 'auto' cannot be used with "
"'config' and 'table'.\n");
}
if (options.conffile &&
(anc->print_table)) {
if (options.conffile && anc->print_table) {
fdasd_error(anc, parser_failed,
"Option 'config' cannot be used with"
" 'table'.\n");
@@ -1232,26 +1229,13 @@ static int fdasd_get_volser(fdasd_anchor_t *anc, char *volser)
*/
static void fdasd_reread_partition_table(fdasd_anchor_t *anc)
{
char err_str[ERROR_STRING_SIZE];
int fd;
if (!anc->silent)
printf("rereading partition table...\n");
fd = open(options.device, O_RDONLY);
if (fd < 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"Could not open device '%s' "
"in read-only mode!\n", options.device);
fdasd_error(anc, unable_to_open_disk, err_str);
}
if (ioctl(fd, BLKRRPART, NULL) != 0) {
close(fd);
if (dasd_reread_partition_table(options.device, 1) != 0) {
fdasd_error(anc, unable_to_ioctl, "Error while rereading "
"partition table.\nPlease reboot!");
}
close(fd);
}
/*
@@ -1335,7 +1319,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
while (getpos(anc, k) > -1)
k++;
setpos(anc, k, i-1);
setpos(anc, k, i - 1);
strncpy(ch, "LINUX.V "
" ", 44);
@@ -1414,7 +1398,7 @@ static void fdasd_write_labels(fdasd_anchor_t *anc)
if (anc->vtoc_changed)
fdasd_write_vtoc_labels(anc);
if ((anc->vtoc_changed) || (anc->vlabel_changed))
if (anc->vtoc_changed || anc->vlabel_changed)
fdasd_reread_partition_table(anc);
}
@@ -1500,9 +1484,9 @@ static void fdasd_reuse_vtoc(fdasd_anchor_t *anc)
if (!anc->silent) {
snprintf(str, INPUT_BUF_SIZE,
"WARNING: this will re-create your VTOC "
"entries using the partition\n "
"information of your existing VTOC. Continue?");
"WARNING: this will re-create your VTOC "
"entries using the partition\n "
"information of your existing VTOC. Continue?");
if (yes_no(str) != 0)
return;
@@ -1637,9 +1621,11 @@ static void fdasd_change_part_type(fdasd_anchor_t *anc)
printf("\n");
part_type = 0;
while (part_type < 1 || part_type > UTIL_ARRAY_SIZE(partition_types) - 1) {
while (!isdigit(part_type =
read_char("new partition type: ")));
while (part_type < 1 ||
part_type > UTIL_ARRAY_SIZE(partition_types) - 1) {
do {
part_type = read_char("new partition type: ");
} while (!isdigit(part_type));
part_type -= 48;
}
@@ -2094,7 +2080,8 @@ static void fdasd_check_disk_access(fdasd_anchor_t *anc)
{
char err_str[ERROR_STRING_SIZE];
format1_label_t f1;
int fd, pos, ro;
int fd, pos;
bool ro;
fd = open(options.device, O_RDONLY);
if (fd == -1) {
@@ -2127,7 +2114,9 @@ static void fdasd_check_disk_access(fdasd_anchor_t *anc)
fdasd_error(anc, unable_to_seek_disk, err_str);
}
if (ioctl(fd, BLKROGET, &ro) != 0) {
close(fd);
if (dasd_is_ro(options.device, &ro) != 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"Could not get read-only status for device '%s'.",
options.device);
@@ -2138,8 +2127,6 @@ static void fdasd_check_disk_access(fdasd_anchor_t *anc)
"You will not be able to save any changes.\n\n",
options.device);
}
close(fd);
}
/*
@@ -2171,16 +2158,18 @@ static unsigned int recs_per_track(unsigned short dev_type, unsigned int kl,
kn = ceil_quot(kl + 6, 232) + 1;
return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
9 + ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
}
case DASD_9345_TYPE:
dn = ceil_quot(dl + 6, 232) + 1;
if (kl) {
kn = ceil_quot(kl + 6, 232) + 1;
return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
ceil_quot(dl + 6 * dn, 34));
} else
} else {
return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
}
}
return 0;
}
@@ -2214,21 +2203,12 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
struct dasd_eckd_characteristics *characteristics;
unsigned long long size_in_bytes;
char err_str[ERROR_STRING_SIZE];
dasd_information_t dasd_info;
int fd, blksize = 0;
dasd_information2_t dasd_info;
unsigned int blksize = 0;
fd = open(options.device, O_RDONLY);
if (fd < 0) {
snprintf(err_str, ERROR_STRING_SIZE,
"Could not open device '%s' "
"in read-only mode!\n", options.device);
fdasd_error(anc, unable_to_open_disk, err_str);
}
if (ioctl(fd, BLKGETSIZE64, &size_in_bytes) != 0) {
close(fd);
if (dasd_get_blocksize_in_bytes(options.device, &size_in_bytes) != 0)
fdasd_error(anc, unable_to_ioctl,
"Could not retrieve disk size.");
}
/*
* If anc->force_virtual is set, we do no real geometry detection.
* anc->dev_type and anc->blksize have already been set via command
@@ -2247,7 +2227,6 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
geo.start = 0;
anc->label_pos = 2 * anc->blksize;
anc->devno = 0;
close(fd);
if (anc->verbose) {
printf("The force option is active. "
"The following geometry will be used:\n"
@@ -2259,24 +2238,21 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
return;
}
if (ioctl(fd, HDIO_GETGEO, &geo) != 0) {
close(fd);
if (dasd_get_geo(options.device, &geo) != 0) {
fdasd_error(anc, unable_to_ioctl,
"Could not retrieve disk geometry information.");
}
if (ioctl(fd, BLKSSZGET, &blksize) != 0) {
close(fd);
if (dasd_get_blocksize(options.device, &blksize) != 0) {
fdasd_error(anc, unable_to_ioctl,
"Could not retrieve blocksize information.");
}
/* get disk type */
if (ioctl(fd, BIODASDINFO, &dasd_info) != 0) {
if (dasd_get_info(options.device, &dasd_info) != 0) {
if (anc->verbose)
printf("BIODASDINFO ioctl failed,"
" use disk geometry only.\n");
/* verify that the geometry matches a 3390 DASD */
if (!fdasd_verify_geometry(DASD_3390_TYPE, blksize, &geo)) {
close(fd);
fdasd_error(anc, wrong_disk_type,
"Disk geometry does not match a DASD device"
" of type 3390.");
@@ -2356,8 +2332,6 @@ static void fdasd_get_geometry(fdasd_anchor_t *anc)
anc->label_pos = dasd_info.label_block * blksize;
anc->devno = dasd_info.devno;
}
close(fd);
}
/*
@@ -2384,10 +2358,8 @@ fdasd_read_int(unsigned long low, unsigned long dflt, unsigned long high,
}
while (1) {
while (!isdigit(read_char(msg_txt))
&& (*line_ptr != '-' &&
*line_ptr != '+' &&
*line_ptr != '\0'))
while (!isdigit(read_char(msg_txt)) &&
(*line_ptr != '-' && *line_ptr != '+' && *line_ptr != '\0'))
continue;
if ((*line_ptr == '+' || *line_ptr == '-') && base != lower) {
if (*line_ptr == '+')
@@ -2411,13 +2383,13 @@ fdasd_read_int(unsigned long low, unsigned long dflt, unsigned long high,
break;
case 'm':
case 'M':
trk *= (1024*1024);
trk *= (1024 * 1024);
trk /= anc->blksize;
trk /= geo.sectors;
break;
case 'g':
case 'G':
trk *= (1024*1024*1024);
trk *= (1024 * 1024 * 1024);
trk /= anc->blksize;
trk /= geo.sectors;
break;
@@ -2546,7 +2518,6 @@ static int fdasd_get_partition_data(fdasd_anchor_t *anc, extent_t *part_extent,
limit = part_tmp->start_trk - 1;
break;
}
}
if (start == limit) {
@@ -2642,7 +2613,7 @@ static void fdasd_enqueue_new_partition(fdasd_anchor_t *anc)
FIRST_USABLE_TRK;
}
} else {
/* there are partitons in front of the new one */
/* there are partitions in front of the new one */
if (part_info->start_trk == part_info->prev->end_trk + 1) {
/* new partition is right behind the previous one */
part_info->fspace_trk = part_info->prev->fspace_trk -
@@ -2797,7 +2768,7 @@ static void fdasd_remove_partition(fdasd_anchor_t *anc)
/*
* writes a standard volume label and a standard VTOC with
* only one partition to disc. With this function is it
* possible to create one partiton in non-interactive mode,
* possible to create one partition in non-interactive mode,
* which can be used within shell scripts
*/
static void fdasd_auto_partition(fdasd_anchor_t *anc)
@@ -3067,7 +3038,6 @@ int main(int argc, char *argv[])
fdasd_recreate_vtoc(&anchor);
anchor.option_recreate = 0;
}
}
return -1;

View File

@@ -14,125 +14,8 @@
* 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 *
*****************************************************************************/

View File

@@ -49,7 +49,7 @@ install: all install-scripts
install-scripts: lshmc
@for i in $^; do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(USRSBINDIR)/$$i; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(USRSBINDIR)/$$i; \
chmod 755 $(DESTDIR)$(USRSBINDIR)/$$i; \

207
include/lib/dasd_base.h Normal file
View File

@@ -0,0 +1,207 @@
/*
* dasd_base - Library for DASD related functions
*
* DASD related helper functions for accessing device information
*
* Copyright IBM Corp. 2013, 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.
*/
#ifndef LIB_DASD_BASE_H
#define LIB_DASD_BASE_H
#ifdef __linux__
#include <linux/hdreg.h>
#endif
#include <stdbool.h>
#include <stdio.h>
#include <sys/ioctl.h>
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;
unsigned char characteristics[64];/*from read_device_characteristics */
unsigned 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));
/*
* 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;
/*
* 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;
#ifndef __linux__
/* definition from hdreg.h */
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
#endif
#define DASD_IOCTL_LETTER 'D'
/* 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)
*******************************************************************************/
/* get read-only status (0 = read_write) */
#define BLKROGET _IO(0x12, 94)
/* re-read partition table */
#define BLKRRPART _IO(0x12, 95)
/* get block device sector size */
#define BLKSSZGET _IO(0x12, 104)
/* return device size in bytes (u64 *arg) */
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#ifndef __linux__ /* from <linux/hdreg.h> */
#define HDIO_GETGEO 0x0301
#endif
int dasd_check_format(const char *device, format_check_t *p);
int dasd_format_disk(int fd, format_data_t *p);
int dasd_disk_disable(const char *device, int *fd);
int dasd_disk_enable(int fd);
int dasd_get_blocksize(const char *device, unsigned int *blksize);
int dasd_get_blocksize_in_bytes(const char *device, unsigned long long *blksize);
int dasd_get_geo(const char *device, struct hd_geometry *geo);
int dasd_get_info(const char *device, dasd_information2_t *info);
int dasd_is_ro(const char *device, bool *ro);
int dasd_reread_partition_table(const char *device, int ntries);
#endif /* LIB_DASD_BASE_H */

View File

@@ -20,5 +20,6 @@ bool util_path_is_readable(const char *fmt, ...);
bool util_path_is_writable(const char *fmt, ...);
bool util_path_is_dir(const char *fmt, ...);
bool util_path_is_reg_file(const char *fmt, ...);
bool util_path_exists(const char *fmt, ...);
#endif /** LIB_UTIL_PATH_H @} */

View File

@@ -18,12 +18,6 @@
#include <stdlib.h>
#include <string.h>
/**
* Copyright IBM Corp. 2016, 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.
*/
struct util_prg_copyright {
/** Name of the copyright owner, e.g. IBM */
const char *owner;

View File

@@ -19,6 +19,7 @@
#include <time.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#define LINE_LENGTH 80
#define VTOC_START_CC 0x0
@@ -40,14 +41,6 @@
#define VTOC_ERROR "VTOC error:"
/* definition from hdreq.h */
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
typedef struct ttr
{
u_int16_t tt;

View File

@@ -25,6 +25,7 @@
#define RELEASE_STRING STRINGIFY (S390_TOOLS_RELEASE)
#define TOOLS_LIBDIR STRINGIFY (S390_TOOLS_LIBDIR)
#define TOOLS_SYSCONFDIR STRINGIFY (S390_TOOLS_SYSCONFDIR)
#define TOOLS_BINDIR STRINGIFY (S390_TOOLS_BINDIR)
#define __noreturn __attribute__((noreturn))
#define __packed __attribute__((packed))

View File

@@ -8,7 +8,7 @@ clean:
rm -f *.o core xcec-bridge
install: ip_watcher.pl xcec-bridge start_hsnc.sh
$(SED) -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
$(SED) -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
< start_hsnc.sh >$(DESTDIR)$(USRSBINDIR)/start_hsnc.sh; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(USRSBINDIR)/start_hsnc.sh; \
chmod 755 $(DESTDIR)$(USRSBINDIR)/start_hsnc.sh; \

View File

@@ -24,7 +24,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <lib/zt_common.h>
#include "lib/zt_common.h"
#define IPL_TYPE_LEN_MAX 100
#define NSS_NAME_LEN_MAX 8

View File

@@ -15,7 +15,7 @@ SYSTOOLS = ttyrun
all: $(PROGRAMS) $(SYSTOOLS)
check:
install:
install: all
for prg in $(PROGRAMS); do \
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 $$prg $(DESTDIR)$(USRBINDIR) ; \
done

View File

@@ -8,6 +8,7 @@
* 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 <ctype.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>

View File

@@ -4,7 +4,7 @@ lib = libdasd.a
all: $(lib)
objects = dasd_sys.o
objects = dasd_sys.o dasd_ioctl.o
$(lib): $(objects) Makefile

263
libdasd/dasd_ioctl.c Normal file
View File

@@ -0,0 +1,263 @@
/*
* dasd_ioctl - Library for dasd-related ioctls
*
* DASD related helper functions for accessing device information via ioctls
*
* Copyright IBM Corp. 2013, 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.
*/
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#define COULD_NOT_OPEN_WARN(device) \
warn("Could not open device '%s'", device)
#define COULD_NOT_CLOSE_WARN \
warn("Unable to close device")
#define RUN_IOCTL(fd, req, argp) \
do { \
if (ioctl(fd, req, argp) != 0) { \
int err = errno; \
if (err != EBADF) \
dasd_close_device(fd); \
return err; \
} \
} while (0)
static int dasd_open_device(const char *device, int flags)
{
int fd;
fd = open(device, flags);
if (fd == -1)
COULD_NOT_OPEN_WARN(device);
return fd;
}
static void dasd_close_device(int fd)
{
if (close(fd) != 0)
COULD_NOT_CLOSE_WARN;
}
/*
* Get DASD block size information for device
*
* @param[in] device node device node's name
* @param[out] blksize the block size
*
* @retval 0 in case of success
* @retval errno in case of failure
*
*/
int dasd_get_blocksize(const char *device, unsigned int *blksize)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BLKSSZGET, blksize);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD block size information (in bytes) for device
*
* @param[in] device node device node's name
* @param[out] blksize block size in bytes
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_get_blocksize_in_bytes(const char *device, unsigned long long *blksize)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BLKGETSIZE64, blksize);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD disk information for device
*
* @param[in] device node device node's name
* @param[out] info pointer to dasd information
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_get_info(const char *device, dasd_information2_t *info)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDINFO2, info);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD disk geometry information for device
*
* @param[in] device node device node's name
* @param[out] geo pointer to device geometry information
*
* @retval errno in case of failure
* @retval 0 in case of success
*/
int dasd_get_geo(const char *device, struct hd_geometry *geo)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, HDIO_GETGEO, geo);
dasd_close_device(fd);
return 0;
}
/*
* Get DASD read/write status information for device
*
* @param[in] device node device node's name
* @param[out] ro read-only status (1 for ro, 0 for rw)
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_is_ro(const char *device, bool *ro)
{
int fd, val;
fd = dasd_open_device(device, O_RDWR);
RUN_IOCTL(fd, BLKROGET, &val);
*ro = (val != 0) ? true : false;
return 0;
}
/*
* Disable DASD disk.
*
* @param[in] device node device node's name
*
* @retval 0 in case of success
* @retval errno in case of failure
*
* Note: Before BIODASDFMT can be called, a DASD has to be disabled (or rather
* put into a BASIC state) via BIODASDDISABLE. However, if you disable the DASD,
* close the file descriptor, and then try to reopen it, it won't work as the
* device isn't fully usable anymore. For BIODASDFMT to work, the file
* descriptor opened for BIODASDISABLE has to be kept open until BIODASDFMT has
* finished.
*/
int dasd_disk_disable(const char *device, int *fd)
{
*fd = dasd_open_device(device, O_RDWR);
RUN_IOCTL(*fd, BIODASDDISABLE, NULL);
return 0;
}
/*
* Enable DASD disk
*
* @param[in] device node device node's name
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_disk_enable(int fd)
{
RUN_IOCTL(fd, BIODASDENABLE, NULL);
dasd_close_device(fd);
return 0;
}
/*
* Format DASD disk
*
* @param[in] fd device node's file descriptor
* @param[in] p format options
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_format_disk(int fd, format_data_t *p)
{
RUN_IOCTL(fd, BIODASDFMT, p);
return 0;
}
/*
* Check DASD format
*
* @param[in] device node device node's name
* @param[in] p format params
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_check_format(const char *device, format_check_t *p)
{
int fd;
fd = dasd_open_device(device, O_RDONLY);
RUN_IOCTL(fd, BIODASDCHECKFMT, p);
dasd_close_device(fd);
return 0;
}
/*
* Reread partition table
*
* @param[in] device node device node's name
* @param[in] ntries maximum number of tries
*
* @retval 0 in case of success
* @retval errno in case of failure
*/
int dasd_reread_partition_table(const char *device, int ntries)
{
int i, fd, err = 0;
fd = dasd_open_device(device, O_RDONLY);
/*
* 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.
*/
for (i = 0; i < ntries; i++) {
if (ioctl(fd, BLKRRPART, NULL) != 0) {
err = errno;
sleep(1);
} else {
err = 0;
break;
}
}
dasd_close_device(fd);
return err;
}

View File

@@ -28,17 +28,17 @@ objects = util_base.o \
util_proc.o \
util_rec.o
util_base_example: util_base_example.o $(rootdir)/libutil/libutil.a
util_panic_example: util_panic_example.o $(rootdir)/libutil/libutil.a
util_path_example: util_path_example.o $(rootdir)/libutil/libutil.a
util_scandir_example: util_scandir_example.o $(rootdir)/libutil/libutil.a
util_file_example: util_file_example.o $(rootdir)/libutil/libutil.a
util_libc_example: util_libc_example.o $(rootdir)/libutil/libutil.a
util_opt_example: util_opt_example.o $(rootdir)/libutil/libutil.a
util_opt_command_example: util_opt_command_example.o $(rootdir)/libutil/libutil.a
util_panic_example: util_panic_example.o $(rootdir)/libutil/libutil.a
util_prg_example: util_prg_example.o $(rootdir)/libutil/libutil.a
util_rec_example: util_rec_example.o $(rootdir)/libutil/libutil.a
util_base_example: util_base_example.o $(lib)
util_panic_example: util_panic_example.o $(lib)
util_path_example: util_path_example.o $(lib)
util_scandir_example: util_scandir_example.o $(lib)
util_file_example: util_file_example.o $(lib)
util_libc_example: util_libc_example.o $(lib)
util_opt_example: util_opt_example.o $(lib)
util_opt_command_example: util_opt_command_example.o $(lib)
util_panic_example: util_panic_example.o $(lib)
util_prg_example: util_prg_example.o $(lib)
util_rec_example: util_rec_example.o $(lib)
$(lib): $(objects)

View File

@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_libc.h"
#include "lib/util_list.h"
/*
@@ -45,10 +46,8 @@ void util_list_init_offset(struct util_list *list, unsigned long offset)
*/
struct util_list *util_list_new_offset(unsigned long offset)
{
struct util_list *list = malloc(sizeof(*list));
struct util_list *list = util_malloc(sizeof(*list));
if (!list)
return NULL;
util_list_init_offset(list, offset);
return list;
}

View File

@@ -194,3 +194,26 @@ free_str:
free(path);
return rc;
}
/**
* Test if path to directory or file exists
*
* This function has the same semantics as "-e path" in bash.
*
* @param[in] fmt Format string for path to test
* @param[in] ... Variable arguments for format string
*
* @returns true Path exists
* false Otherwise
*/
bool util_path_exists(const char *fmt, ...)
{
va_list ap;
char *path;
bool rc;
UTIL_VASPRINTF(&path, fmt, ap);
rc = access(path, F_OK) == 0 ? true : false;
free(path);
return rc;
}

View File

@@ -55,18 +55,22 @@ static void test_util_path_sysfs(void)
static void test_path(const char *path)
{
printf("%-20s: ", path);
if (util_path_exists(path))
printf("exists=yes ");
else
printf("exists=no ");
if (util_path_is_readable(path))
printf("read=yes, ");
printf("read=yes ");
else
printf("read=no , ");
printf("read=no ");
if (util_path_is_writable(path))
printf("write=yes, ");
printf("write=yes ");
else
printf("write=no , ");
printf("write=no ");
if (util_path_is_reg_file(path))
printf("reg_file=yes");
printf("reg_file=yes ");
else
printf("reg_file=no ");
printf("reg_file=no ");
if (util_path_is_dir(path))
printf("dir=yes");
else

View File

@@ -13,16 +13,13 @@
*/
#include <errno.h>
#include <fcntl.h>
#include <linux/types.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "lib/dasd_base.h"
#include "lib/libzds.h"
#include "lib/u2s.h"
#include "lib/util_base.h"
@@ -31,13 +28,6 @@
/** @cond PRIVATE */
/******************************************************************************/
/* ioctl related definitions */
/******************************************************************************/
/* device size in bytes (u64 *arg) */
#define BLKGETSIZE64 _IOR(0x12, 114, size_t)
/******************************************************************************/
/* libzds structure definitions */
@@ -415,17 +405,7 @@ int lzds_zdsroot_alloc(struct zdsroot **root)
memset(tmproot, 0, sizeof(*tmproot));
tmproot->dasdlist = util_list_new(struct dasd, list);
if (!tmproot->dasdlist) {
free(tmproot);
return ENOMEM;
}
tmproot->datasetlist = util_list_new(struct dataset, list);
if (!tmproot->dasdlist) {
util_list_free(tmproot->dasdlist);
free(tmproot);
return ENOMEM;
}
*root = tmproot;
@@ -480,18 +460,11 @@ void lzds_zdsroot_free(struct zdsroot *root)
*/
static int dasd_read_geometry(struct dasd *dasd)
{
int fd;
unsigned long long size_in_bytes;
errorlog_clear(dasd->log);
fd = open(dasd->device, O_RDONLY);
if (fd < 0)
return errorlog_add_message(
&dasd->log, NULL, EIO,
"read geometry: could not open device %s\n",
dasd->device);
if (ioctl(fd, BLKGETSIZE64, &size_in_bytes) != 0)
if (dasd_get_blocksize_in_bytes(dasd->device, &size_in_bytes) != 0)
return errorlog_add_message(
&dasd->log, NULL, EIO,
"read geometry: could not get size from device %s\n",
@@ -505,7 +478,6 @@ static int dasd_read_geometry(struct dasd *dasd)
dasd->label_block = 2;
dasd->heads = 15;
dasd->cylinders = (size_in_bytes / (dasd->heads * RAWTRACKSIZE));
close(fd);
return 0;
}
@@ -822,10 +794,6 @@ static int errorlog_alloc(struct errorlog **log)
return ENOMEM;
memset(tmplog, 0, sizeof(*tmplog));
tmplog->entries = util_list_new(struct errormsg, list);
if (!tmplog->entries) {
free(tmplog);
return ENOMEM;
}
*log = tmplog;
return 0;
}
@@ -2203,8 +2171,6 @@ static int dataset_member_analysis(struct dataset *ds)
dataset_free_memberlist(ds);
ds->memberlist = util_list_new(struct pdsmember, list);
if (!ds->memberlist)
return ENOMEM;
/* track buffer must be page aligned for O_DIRECT */
trackdata = memalign(4096, RAWTRACKSIZE);

View File

@@ -90,17 +90,18 @@ static void fsstatd_open_monwriter(void)
/*
* Store daemon's pid so it can be stopped
*/
static void store_pid(void)
static int store_pid(void)
{
FILE *f = fopen(pid_file, "w");
if (!f) {
syslog(LOG_ERR, "cannot open pid file %s: %s", pid_file,
strerror(errno));
exit(1);
return -1;
}
fprintf(f, "%d\n", getpid());
fclose(f);
return 0;
}
/*
@@ -244,41 +245,64 @@ static void fsstatd_write_ent(struct mntent *ent, time_t curr_time,
*/
static void fsstatd_daemonize(void)
{
int pipe_fds[2], startup_rc = 1;
pid_t pid;
if (pipe(pipe_fds) == -1) {
syslog(LOG_ERR, "pipe error: %s\n", strerror(errno));
exit(1);
}
/* Fork off the parent process */
pid = fork();
if (pid < 0) {
syslog(LOG_ERR, "fork error: %s\n", strerror(errno));
exit(1);
}
if (pid > 0)
exit(0);
if (pid > 0) {
/* Wait for startup return code from daemon */
if (read(pipe_fds[0], &startup_rc, sizeof(startup_rc)) == -1)
syslog(LOG_ERR, "pipe read error: %s\n", strerror(errno));
/* With startup_rc == 0, pid file was written at this point */
exit(startup_rc);
}
/* Change the file mode mask */
umask(0);
/* Store daemon pid */
store_pid();
/* Catch SIGINT and SIGTERM to clean up pid file on exit */
fsstatd_handle_signals();
/* Create a new SID for the child process */
if (setsid() < 0) {
syslog(LOG_ERR, "setsid error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Change the current working directory */
if (chdir("/") < 0) {
syslog(LOG_ERR, "chdir error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
/* Store daemon pid */
if (store_pid() < 0)
goto notify_parent;
startup_rc = 0;
notify_parent:
/* Inform waiting parent about startup return code */
if (write(pipe_fds[1], &startup_rc, sizeof(startup_rc)) == -1) {
syslog(LOG_ERR, "pipe write error: %s\n", strerror(errno));
exit(1);
}
if (startup_rc != 0)
exit(startup_rc);
}
static int fsstatd_do_work(void)

View File

@@ -109,17 +109,18 @@ static void procd_open_monwriter(void)
/*
* Store daemon's pid so it can be stopped
*/
static void store_pid(void)
static int store_pid(void)
{
FILE *f = fopen(pid_file, "w");
if (!f) {
syslog(LOG_ERR, "cannot open pid file %s: %s", pid_file,
strerror(errno));
exit(1);
return -1;
}
fprintf(f, "%d\n", getpid());
fclose(f);
return 0;
}
/*
@@ -897,41 +898,64 @@ static void read_tasks(void)
*/
static void procd_daemonize(void)
{
int pipe_fds[2], startup_rc = 1;
pid_t pid;
if (pipe(pipe_fds) == -1) {
syslog(LOG_ERR, "pipe error: %s\n", strerror(errno));
exit(1);
}
/* Fork off the parent process */
pid = fork();
if (pid < 0) {
syslog(LOG_ERR, "fork error: %s\n", strerror(errno));
exit(1);
}
if (pid > 0)
exit(0);
if (pid > 0) {
/* Wait for startup return code from daemon */
if (read(pipe_fds[0], &startup_rc, sizeof(startup_rc)) == -1)
syslog(LOG_ERR, "pipe read error: %s\n", strerror(errno));
/* With startup_rc == 0, pid file was written at this point */
exit(startup_rc);
}
/* Change the file mode mask */
umask(0);
/* Store daemon pid */
store_pid();
/* Catch SIGINT and SIGTERM to clean up pid file on exit */
procd_handle_signals();
/* Create a new SID for the child process */
if (setsid() < 0) {
syslog(LOG_ERR, "setsid error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Change the current working directory */
if (chdir("/") < 0) {
syslog(LOG_ERR, "chdir error: %s\n", strerror(errno));
exit(1);
goto notify_parent;
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
/* Store daemon pid */
if (store_pid() < 0)
goto notify_parent;
startup_rc = 0;
notify_parent:
/* Inform waiting parent about startup return code */
if (write(pipe_fds[1], &startup_rc, sizeof(startup_rc)) == -1) {
syslog(LOG_ERR, "pipe write error: %s\n", strerror(errno));
exit(1);
}
if (startup_rc != 0)
exit(startup_rc);
}
static int procd_do_work(void)

View File

@@ -172,11 +172,7 @@ cat <<'EOF' > $builddir/init
/sbin/modprobe virtio_net
/sbin/udhcpc -O pxeconffile -O pxepathprefix &
while true
do
/sbin/pxeboot.script
/bin/sleep 1
done
/sbin/pxeboot.script
EOF
# --- end init script
chmod +x $builddir/init
@@ -303,16 +299,26 @@ cat <<'EOF' > $builddir/sbin/pxeboot.script
set -e
# Check if a valid pxe conf is available
# so far a non configurable 600 sec timeout
PXE_CONF=/etc/pxe.conf
TIMEOUT=600
WAITED=0
echo "waiting for pxe config from DHCP (max $TIMEOUT sec)"
while [ ! -f $PXE_CONF ]
do
sleep 1
WAITED=$(($WAITED + 1))
if [ $WAITED -gt $TIMEOUT ]
then
echo Error waiting for PXE configuration from DHCP
exit
fi
done
# Source the DHCP-generated TFTP info
# Currently we are just looking for siaddr
PXE_CONF=/etc/pxe.conf
if [ -f $PXE_CONF ]
then
. $PXE_CONF
else
echo waiting for PXE configuration
exit
fi
. $PXE_CONF
# Retrieve the config (default only for now)
CONFIGS=""
@@ -347,6 +353,7 @@ then
set +e
for c in $CONFIGS
do
echo "fetching config pxelinux.cfg/$c from $siaddr"
if /usr/bin/tftp -g -l /tmp/config -r pxelinux.cfg/$c $siaddr
then
break
@@ -361,34 +368,35 @@ then
fi
# Simple config file parsing, only one entry allowed
kernel=$(/bin/grep "^[[:space:]]*kernel" /tmp/config | sed "s/^[[:space:]]*kernel[[:space:]]*//")
initrd=$(/bin/grep "^[[:space:]]*initrd" /tmp/config | sed "s/^[[:space:]]*initrd[[:space:]]*//")
append=$(/bin/grep "^[[:space:]]*append" /tmp/config | sed "s/^[[:space:]]*append[[:space:]]*//")
kernel=$(/bin/grep -i "^[[:space:]]*kernel" /tmp/config | sed "s/^[[:space:]]*kernel[[:space:]]*//I")
initrd=$(/bin/grep -i "^[[:space:]]*initrd" /tmp/config | sed "s/^[[:space:]]*initrd[[:space:]]*//I")
append=$(/bin/grep -i "^[[:space:]]*append" /tmp/config | sed "s/^[[:space:]]*append[[:space:]]*//I")
if [ -z "$kernel" ]
then
echo no kernel statement found in config
exit
else
echo fetch kernel $kernel from $siaddr
/usr/bin/tftp -g -l /tmp/kernel -r $kernel $siaddr
fi
if [ -n "$initrd" ]
then
echo fetch initrd $initrd from $siaddr
/usr/bin/tftp -g -l /tmp/initrd -r $initrd $siaddr
INITRD="--initrd=/tmp/initrd"
else
INITRD=""
fi
if [ -n "$append" ]
then
APPEND="--append=$append"
if [ -z "$append" ]; then
echo "Kexec load: kexec -l /tmp/kernel $INITRD"
kexec -l /tmp/kernel $INITRD
else
APPEND=""
echo "Kexec load: kexec -l /tmp/kernel $INITRD --append=\"$append\""
kexec -l /tmp/kernel $INITRD --append="$append"
fi
kexec -l /tmp/kernel $INITRD $APPEND
kexec -e
EOF
# -- end pxeboot script

View File

@@ -1,6 +1,9 @@
include ../common.mak
LDLIBS = `net-snmp-config --agent-libs`
CFLAGS += `net-snmp-config --cflags`
# On some Linux systems `net-snmp-config --agent-libs` introduces -pie,
# therefore add -fPIC to prevent link failures.
ALL_CFLAGS += -fPIC
ALL_CFLAGS += `net-snmp-config --cflags`
OBJS = ibmOSAMib.o ibmOSAMibUtil.o osasnmpd.o

View File

@@ -3,7 +3,7 @@ include ../common.mak
all:
install: qethconf
$(SED) -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
$(SED) -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
< qethconf >$(DESTDIR)$(BINDIR)/qethconf; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(BINDIR)/qethconf; \
chmod 755 $(DESTDIR)$(BINDIR)/qethconf; \

View File

@@ -10,13 +10,13 @@ install:
@for i in $(SCRIPTS); \
do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(BINDIR)/$$i; \
chown $(OWNER):$(GROUP) $(DESTDIR)$(BINDIR)/$$i; \
chmod 755 $(DESTDIR)$(BINDIR)/$$i; \
done
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' cpictl > \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' cpictl > \
$(DESTDIR)$(TOOLS_LIBDIR)/cpictl
chown $(OWNER):$(GROUP) $(DESTDIR)$(TOOLS_LIBDIR)/cpictl
chmod 775 $(DESTDIR)$(TOOLS_LIBDIR)/cpictl

View File

@@ -375,7 +375,8 @@ CMDS="uname -a\
:runlevel\
:iptables -L\
:ulimit -a\
:ps -eo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
:ps -emo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
:ps -eHo pid,tid,nlwp,policy,user,tname,ni,pri,psr,sgi_p,stat,wchan,start_time,time,pcpu,pmem,vsize,size,rss,share,command\
:ps axX\
:dmesg -s 1048576\
:last\
@@ -508,6 +509,7 @@ VM_CMDS="q userid\
:q cache\
:q nic\
:q pav\
:q proc\
:q proc topology\
:q mt\
:q qioass\

View File

@@ -35,10 +35,12 @@ clean:
real_usrbin_dir=$(USRBINDIR); \
real_usrsbin_dir=$(USRSBINDIR); \
real_toolslib_dir=$(TOOLS_LIBDIR); \
real_sysconf_dir=$(SYSCONFDIR); \
$(SED) -e "s#@bin_path@#$$real_bin_dir#g" \
-e "s#@usrbin_path@#$$real_usrbin_dir#g" \
-e "s#@usrsbin_path@#$$real_usrsbin_dir#g" \
-e "s#@toolslib_path@#$$real_toolslib_dir#g" \
-e "s#@sysconf_path@#$$real_sysconf_dir#g" \
-e 's#@S390_TOOLS_RELEASE@#$(S390_TOOLS_RELEASE)#g' \
< $< > $@

View File

@@ -19,7 +19,7 @@ Type=oneshot
# Specify a file with the environment variables using the EnvironmentFile=
# service property.
#
EnvironmentFile=/etc/sysconfig/cpi
EnvironmentFile=@sysconf_path@/sysconfig/cpi
#
# Alternatively, you can specify the environment variables directly,
# using the Environment= service properties, which can be overridden by
@@ -38,3 +38,6 @@ EnvironmentFile=/etc/sysconfig/cpi
#
# Sending data to the HMC/SE
ExecStart=@toolslib_path@/cpictl -e
[Install]
WantedBy=multi-user.target

View File

@@ -13,10 +13,11 @@ Documentation=man:cpuplugd(8) man:cpuplugd.conf(5)
After=remote-fs.target
[Service]
ExecStart=@usrsbin_path@/cpuplugd -f -c /etc/cpuplugd.conf
ExecStart=@usrsbin_path@/cpuplugd -c @sysconf_path@/cpuplugd.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=simple
Type=forking
PIDFile=/var/run/cpuplugd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -18,7 +18,7 @@ After=remote-fs.target
# Specify a file with the environment variables using the EnvironmentFile=
# service property.
#
EnvironmentFile=/etc/sysconfig/mon_fsstatd
EnvironmentFile=@sysconf_path@/sysconfig/mon_fsstatd
#
# Alternatively, you can specify the environment variables directly,
# using the Environment= service property, which can be overridden by
@@ -30,10 +30,11 @@ EnvironmentFile=/etc/sysconfig/mon_fsstatd
ExecStartPre=-/sbin/modprobe monwriter
ExecStartPre=/sbin/udevadm settle --timeout=10
ExecStart=@usrsbin_path@/mon_fsstatd -a -i $FSSTAT_INTERVAL
ExecStart=@usrsbin_path@/mon_fsstatd -i $FSSTAT_INTERVAL
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=simple
Type=forking
PIDFile=/var/run/mon_fsstatd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -18,7 +18,7 @@ After=remote-fs.target
# Specify a file with the environment variables using the EnvironmentFile=
# service property.
#
EnvironmentFile=/etc/sysconfig/mon_procd
EnvironmentFile=@sysconf_path@/sysconfig/mon_procd
#
# Alternatively, you can specify the environment variables directly,
# using the Environment= service property, which can be overridden by
@@ -30,10 +30,11 @@ EnvironmentFile=/etc/sysconfig/mon_procd
ExecStartPre=-/sbin/modprobe monwriter
ExecStartPre=/sbin/udevadm settle --timeout=10
ExecStart=@usrsbin_path@/mon_procd -a -i $PROC_INTERVAL
ExecStart=@usrsbin_path@/mon_procd -i $PROC_INTERVAL
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Type=simple
Type=forking
PIDFile=/var/run/mon_procd.pid
[Install]
WantedBy=multi-user.target

View File

@@ -4,9 +4,9 @@
include ../common.mak
SCRIPTS = lsdasd lstape chccwdev lszfcp cio_ignore znetconf dasdstat
USRSBIN_SCRIPTS = lsmem chmem lsluns
USRSBIN_SCRIPTS = lsluns
MANPAGES= lsdasd.8 lstape.8 chccwdev.8 lszfcp.8 lsluns.8 \
cio_ignore.8 znetconf.8 chmem.8 lsmem.8 dasdstat.8
cio_ignore.8 znetconf.8 dasdstat.8
SUB_DIRS = zcrypt scm chp css qeth
@@ -23,7 +23,7 @@ install: install-scripts install-manpages install-usrsbin-scripts $(SUB_DIRS)
install-scripts: $(SCRIPTS)
@for i in $^; do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(BINDIR)/$$i; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(BINDIR)/$$i; \
chmod 755 $(DESTDIR)$(BINDIR)/$$i; \
@@ -32,7 +32,7 @@ install-scripts: $(SCRIPTS)
install-usrsbin-scripts: $(USRSBIN_SCRIPTS)
@for i in $^; do \
cat $$i | \
sed -e 's+%S390_TOOLS_VERSION%+$(S390_TOOLS_RELEASE)+' \
sed -e 's/%S390_TOOLS_VERSION%/$(S390_TOOLS_RELEASE)/' \
>$(DESTDIR)$(USRSBINDIR)/$$i; \
chown $(OWNER).$(GROUP) $(DESTDIR)$(USRSBINDIR)/$$i; \
chmod 755 $(DESTDIR)$(USRSBINDIR)/$$i; \

View File

@@ -1,334 +0,0 @@
#!/usr/bin/perl
#
# chmem - Tool to change memory hotplug status
#
# Copyright IBM Corp. 2010, 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.
#
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case no_auto_abbrev);
use File::Basename;
my $script_name = fileparse($0);
my $online = 0;
my $offline = 0;
my $memdir = "/sys/devices/system/memory";
my $block_size = 0;
my $max_block_nr = 0;
my $devices = {};
my $dev_size;
my $blocks_per_dev = 0;
my $devs_per_block = 0;
my $ret = 0;
my @entries;
sub chmem_usage()
{
print <<HERE;
Usage: $script_name [OPTIONS] SIZE|RANGE
The $script_name command sets a particular size or range of memory online
or offline.
Specify SIZE as <size>[m|M|g|G]. With m or M, <size> specifies the memory
size in MB (1024 x 1024 bytes). With g or G, <size> specifies the memory size
in GB (1024 x 1024 x 1024 bytes). The default unit is MB.
Specify RANGE in the form 0x<start>-0x<end> as shown in the output of the
lsmem command. <start> is the hexadecimal address of the first byte and <end>
is the hexadecimal address of the last byte in the memory range.
SIZE and RANGE must be aligned to the Linux memory block size, as shown in
the output of the lsmem command.
OPTIONS
-e, --enable
Set the given RANGE or SIZE of memory online.
-d, --disable
Set the given RANGE or SIZE of memory offline.
-h, --help
Print a short help text, then exit.
-v, --version
Print the version number, then exit.
HERE
}
sub chmem_version()
{
print "$script_name: version %S390_TOOLS_VERSION%\n";
print "Copyright IBM Corp. 2010, 2017\n";
}
sub chmem_get_dev_size()
{
my ($device, $old_device, $block, $old_block) = (0, 0, 0, 0);
foreach (@entries) {
$_ =~ /memory(\d+)/;
$block = $1;
$device = `cat $_/phys_device`;
chomp($device);
if ($device > $old_device) {
$dev_size = int((($block - $old_block) * $block_size) /
($device - $old_device));
last;
}
$dev_size += $block_size;
$old_block = $block;
}
}
sub chmem_online($)
{
my $block = shift;
qx(echo online_movable > $memdir/memory$block/state 2>/dev/null);
if ($? >> 8 != 0) {
qx(echo online > $memdir/memory$block/state 2>/dev/null);
}
return $? >> 8;
}
sub chmem_offline($)
{
my $block = shift;
qx(echo offline > $memdir/memory$block/state 2>/dev/null);
return $? >> 8;;
}
sub chmem_read_attr($$$)
# parameters: state, device, block
{
my @attributes = qw(state phys_device);
foreach (0..1) {
$_[$_] = `cat $memdir/memory$_[2]/$attributes[$_]`;
chomp($_[$_]);
}
}
sub chmem_read_devices()
{
my $block = 0;
my $device = 0;
my $old_device = 0;
my $blocks = 0;
my $state;
foreach (@entries) {
$_ =~ /memory(\d+)/;
$block = $1;
chmem_read_attr($state, $device, $block);
if ($device != $old_device) {
$devices->{$old_device}->{'id'} = $old_device;
$devices->{$old_device}->{'blocks'} = $blocks;
$old_device = $device;
$blocks = 0;
}
if ($state eq "online") {
$blocks++;
}
}
$devices->{$old_device}->{'blocks'} = $blocks;
$devices->{$old_device}->{'id'} = $old_device;
}
sub chmem_dev_action($$)
{
my ($dev_id, $blocks) = @_;
my ($start_block, $end_block, $tmp_block, $max_blocks);
my $state;
my $i = 0;
my $count = 0;
if ($blocks_per_dev > 0) {
$start_block = $dev_id * $blocks_per_dev;
$end_block = $start_block + $blocks_per_dev - 1;
$max_blocks = $blocks_per_dev;
} else {
$start_block = int($dev_id / $devs_per_block);
$end_block = $start_block;
$max_blocks = 1;
}
if ($blocks > $max_blocks) {
$blocks = $max_blocks;
}
while ($count < $blocks && $i < $max_blocks) {
$tmp_block = $online ? $start_block + $i : $end_block - $i;
$state = `cat $memdir/memory$tmp_block/state`;
chomp($state);
if ($offline && $state eq "online") {
$count++ unless chmem_offline($tmp_block);
}
if ($online && $state eq "offline") {
$count++ unless chmem_online($tmp_block);
}
$i++;
}
return $count;
}
sub chmem_size($)
{
my $size = shift;
my ($blocks, $dev_blocks, $dev_id);
$blocks = int($size / $block_size);
if ($online) {
foreach my $device (sort {$b->{'blocks'} <=> $a->{'blocks'} ||
$a->{'id'} <=> $b->{'id'}}
values %{$devices}) {
$dev_blocks = $device->{'blocks'};
$dev_id = $device->{'id'};
if ($dev_blocks < $blocks_per_dev || $dev_blocks == 0) {
$blocks -= chmem_dev_action($dev_id, $blocks);
if ($blocks == 0) {
last;
}
}
}
if ($blocks > 0) {
printf(STDERR "chmem: Could only set %lu MB of memory ".
"online.\n", $size - $blocks * $block_size);
$ret = 1;
}
} else {
foreach my $device (sort {$a->{'blocks'} <=> $b->{'blocks'} ||
$b->{'id'} <=> $a->{'id'}}
values %{$devices}) {
$dev_blocks = $device->{'blocks'};
$dev_id = $device->{'id'};
if ($dev_blocks > 0) {
$blocks -= chmem_dev_action($dev_id, $blocks);
if ($blocks == 0) {
last;
}
}
}
if ($blocks > 0) {
printf(STDERR "chmem: Could only set %lu MB of memory ".
"offline.\n", $size - $blocks * $block_size);
$ret = 1;
}
}
}
sub chmem_range($$)
{
my ($start, $end) = @_;
my $block = 0;
my $state;
while ($start < $end && $block < $max_block_nr) {
$block = int($start / ($block_size << 20));
$state = `cat $memdir/memory$block/state`;
chomp($state);
if ($online && $state eq "offline") {
if (chmem_online($block)) {
printf(STDERR "chmem: Could not set ".
"0x%016x-0x%016x online\n", $start,
$start + ($block_size << 20) - 1);
$ret = 1;
}
}
if ($offline && $state eq "online") {
if (chmem_offline($block)) {
printf(STDERR "chmem: Could not set ".
"0x%016x-0x%016x offline\n", $start,
$start + ($block_size << 20) - 1);
$ret = 1;
}
}
$start += $block_size << 20;
}
}
sub chmem_check()
{
$block_size = `cat $memdir/block_size_bytes`;
chomp($block_size);
if ($block_size =~ /(?:0x)?([[:xdigit:]]+)/) {
$block_size = unpack("Q", pack("H16",
substr("0" x 16 . $1, -16)));
$block_size = $block_size >> 20;
} else {
die "chmem: Unknown block size format in sysfs.\n";
}
if ($online == 0 && $offline == 0) {
die "chmem: Please specify one of the options -e or -d.\n";
}
if ($online == 1 && $offline == 1) {
die "chmem: You cannot specify both options -e and -d.\n";
}
chmem_get_dev_size();
if ($dev_size >= $block_size) {
$blocks_per_dev = int($dev_size / $block_size);
} else {
$devs_per_block = int($block_size / $dev_size);
}
}
sub chmem_action()
{
my ($start, $end, $size, $unit);
if (!defined($ARGV[0])) {
die "chmem: Missing size or range.\n";
}
if ($ARGV[0] =~ /^0x([[:xdigit:]]+)-0x([[:xdigit:]]+)$/) {
$start = unpack("Q", pack("H16", substr("0" x 16 . $1, -16)));
$end = unpack("Q", pack("H16", substr("0" x 16 . $2, -16)));
if ($start % ($block_size << 20) ||
($end + 1) % ($block_size << 20)) {
die "chmem: Start address and (end address + 1) must ".
"be aligned to memory block size ($block_size MB).\n";
}
chmem_range($start, $end);
} else {
if ($ARGV[0] =~ m/^(\d+)([mg]?)$/i) {
$size = $1;
$unit = $2 || "";
if ($unit =~ /g/i) {
$size = $size << 10;
}
if ($size % $block_size) {
die "chmem: Size must be aligned to memory ".
"block size ($block_size MB).\n";
}
chmem_size($size);
} else {
printf(STDERR "chmem: Invalid size or range: %s\n",
$ARGV[0]);
exit 1;
}
}
}
# Main
unless (GetOptions('v|version' => sub {chmem_version(); exit 0;},
'h|help' => sub {chmem_usage(); exit 0;},
'e|enable' => \$online,
'd|disable' => \$offline)) {
die "Try '$script_name --help' for more information.\n";
};
@entries = (sort {length($a) <=> length($b) || $a cmp $b} <$memdir/memory*>);
if (@entries == 0) {
die "chmem: No memory hotplug interface in sysfs ($memdir).\n";
}
$entries[-1] =~ /memory(\d+)/;
$max_block_nr = $1;
chmem_read_devices();
chmem_check();
chmem_action();
exit $ret;

View File

@@ -1,75 +0,0 @@
.\" 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 CHMEM 8 "Apr 2010" "s390-tools"
.
.
.SH NAME
chmem \- set memory online or offline.
.
.SH SYNOPSIS
.B chmem
.RB OPTIONS
.RB [SIZE|RANGE]
.
.
.SH DESCRIPTION
The chmem command sets a particular size or range of memory online or offline.
.
.IP "\(hy" 2
Specify SIZE as <size>[m|M|g|G]. With m or M, <size> specifies the memory
size in MB (1024 x 1024 bytes). With g or G, <size> specifies the memory size
in GB (1024 x 1024 x 1024 bytes). The default unit is MB.
.
.IP "\(hy" 2
Specify RANGE in the form 0x<start>-0x<end> as shown in the output of the
lsmem command. <start> is the hexadecimal address of the first byte and <end>
is the hexadecimal address of the last byte in the memory range.
.
.PP
SIZE and RANGE must be aligned to the Linux memory block size, as shown in
the output of the lsmem command.
Setting memory online can fail if the hypervisor does not have enough memory
left, for example because memory was overcommitted. Setting memory offline can
fail if Linux cannot free the memory. If only part of the requested memory can
be set online or offline, a message tells you how much memory was set online
or offline instead of the requested amount.
.
.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Print a short help text, then exit.
.
.TP
.BR \-v ", " \-\-version
Print the version number, then exit.
.
.TP
.BR \-e ", " \-\-enable
Set the given RANGE or SIZE of memory online.
.
.TP
.BR \-d ", " \-\-disable
Set the given RANGE or SIZE of memory offline.
.
.
.SH EXAMPLES
.TP
.B chmem --enable 1024
This command requests 1024 MB of memory to be set online.
.
.TP
.B chmem -e 2g
This command requests 2 GB of memory to be set online.
.
.TP
.B chmem --disable 0x00000000e4000000-0x00000000f3ffffff
This command requests the memory range starting with 0x00000000e4000000
and ending with 0x00000000f3ffffff to be set offline.
.
.
.SH SEE ALSO
.BR lsmem (8)

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# lsluns - Tool to list all available LUNs
# lsluns - list LUNs discovered in the FC SAN, or show encryption state of attached LUNs
#
# Copyright IBM Corp. 2008, 2017
#
@@ -169,32 +169,51 @@ sub get_lun_hash
sub lsluns_usage {
print <<EOD;
Usage: $PROGRAM_NAME [<options>]
Usage:
This tool is designed for environments where all SCSI devices are attached
through the zfcp device driver. Expect error messages in mixed environments
such as with iSCSI.
lsluns provides information for LUNs.
$PROGRAM_NAME [-c <busid>] ... [-p <wwpn>] ... [-h] [-v]
The default is to list all LUNs that are available via the attached ports.
The display can be limited by specifying an adapter or a port.
List LUNs discovered in the Fibre Channel (FC) Storage Area Network (SAN).
This causes extra SAN traffic for each target port WWPN.
Discovering LUNs only makes sense for NPIV-enabled FCP devices
without zfcp automatic LUN scan. zfcp automatic LUN scan is available
as of kernel version 2.6.37, if not disabled with zfcp.allow_lun_scan=0.
For storage products that do not support a REPORT LUNS
well-known logical unit (such as IBM Storwize products),
ensure that LUN 0 represents a valid peripheral device type.
See the man page for more information.
$PROGRAM_NAME -a [-c <busid>] ... [-p <wwpn>] ... [-h] [-v]
Show encryption state of the attached LUNs.
This causes extra SAN traffic for each attached LUN.
For all other uses, such as listing attached LUNs or properties other than
encryption, use other tools such as "lszfcp -D" or "lsscsi -tv"
or "lszdev zfcp-lun -ii".
Limit the listing by specifying one or more adapters (FCP device
bus-IDs) or target port WWPNs or both.
Options:
-a, --active
Shows all activated LUNs.
In addition LUN encryption information is provided.
e.g. "lsluns -a"
-c <busid>, --ccw <busid>
Filter LUNs by adapter with the specified FCP device bus-ID. Can be
specified multiple times.
For example: "$PROGRAM_NAME -c 0.0.3922"
-c, --ccw
Shows LUNs for a specific ccw device.
e.g. "lsluns -c 0.0.3922"
-p, --port
Shows LUNs for a specific port.
e.g. "lsluns -p 0x5005123456789000"
-p <wwpn>, --port <wwpn>
Filter LUNs by target port with the specified WWPN. Can be specified
multiple times.
For example: "$PROGRAM_NAME -p 0x5005123456789000"
-h, --help
Print help message and exit.
Print help message and exit.
-v, --version
Display version info and exit.
Display version information and exit.
EOD
exit 0;
}
@@ -215,11 +234,9 @@ sub get_env_list
my $p_ref_list = shift();
my @res ;
my %res_hash;
my @t_arr;
@res = </sys/bus/ccw/drivers/zfcp/*.*.*/0x*>;
return () if (!@res);
reload:
foreach my $entry (@res) {
my $a = ${[split('/', $entry)]}[-2];
my $p = ${[split('/', $entry)]}[-1];
@@ -227,28 +244,9 @@ reload:
next if (@$p_ref_list && "@$p_ref_list" !~ /$p/);
push @{ $res_hash{$a} }, $p;
}
foreach my $a (sort @$a_ref_list) {
if ("@{[keys %res_hash]}" !~ /$a/) {
print "\tNo valid combination found for adapter '$a'. ",
"Removing from resource list.\n";
}
}
push @t_arr, map { @{$res_hash{$_}} } keys %res_hash;
foreach my $p (@$p_ref_list) {
if ("@t_arr" !~ /$p/) {
print "\tNo valid combination found for port '$p'. ",
"Removing from resource list.\n";
}
}
if (!%res_hash) {
print "\nNo valid parameters left, ",
"using all available resources in system.\n\n";
@$a_ref_list = ();
@$p_ref_list = ();
@t_arr = ();
goto reload;
print "$PROGRAM_NAME: Adapter and/or port filter(s) did not match anything\n";
}
return %res_hash;
}

View File

@@ -2,62 +2,140 @@
.\" 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 LSLUNS 8 "June 2008" "s390-tools"
.TH LSLUNS 8 "2017-02-17" "s390-tools"
.SH NAME
lsluns \- list available LUNs
lsluns \- list LUNs discovered in the FC SAN through zfcp, or show encryption state of
zfcp-attached LUNs
.SH SYNOPSIS
.B lsluns
.RB [ \-h]
.RB [ \-v]
.RB [ \-c
.IR adapter id:0.0.XXXX ]
.RB [ \-p
.IR port number:0xXXXXXXXXXXXXXXXX ]
.RB [\| \-c
.IR busid \|]\ .\|.\|.
.RB [\| \-p
.IR wwpn \|]\ .\|.\|.
.\" --active
.br
.B lsluns \-a
.RB [\| \-c
.IR busid \|]\ .\|.\|.
.RB [\| \-p
.IR wwpn \|]\ .\|.\|.
.\" --help and --version
.br
.B lsluns
.RB [\| \-h \|]
.RB [\| \-v \|]
.SH DESCRIPTION
.PP
.B lsluns
does a listing of all available LUNs.
This tool is designed for environments where all SCSI devices are attached
through the zfcp device driver. Expect error messages in mixed environments
such as with iSCSI.
The default is to list all LUNs that are found. The listing can be
limited by specifying an adapter or a port.
.B lsluns
lists all logical unit numbers (LUNs) discovered in the
Fibre Channel (FC) Storage Area Network (SAN).
This causes extra SAN traffic for each target port WWPN.
.B lsluns -a
shows the encryption state of the attached LUNs.
This causes extra SAN traffic for each attached LUN.
Limit the listing by specifying one or more adapters (FCP device
bus-IDs) or target port WWPNs or both.
For all other uses, such as listing attached LUNs or properties other than
encryption, use other tools such as
.B lszfcp \-D
or
.BR "lsscsi \-tv"
or
.BR "lszdev zfcp-lun \-ii" .
.SS Details on lsluns without -a option
.TP
Prerequisite
Discovering LUNs only makes sense for NPIV-enabled FCP devices
without zfcp automatic LUN scan. zfcp automatic LUN scan is available
as of kernel version 2.6.37, if not disabled with zfcp.allow_lun_scan=0.
With available and enabled zfcp automatic LUN scan,
the kernel already performs LUN discovery.
.TP
Temporary LUN Attachment
If not attached already, lsluns temporarily attaches LUN 0
(or if this fails the WLUN 0xc101000000000000) during runtime.
Do not terminate lsluns with a signal. Signals interfere
with the removal of temporarily attached LUNs.
.TP
Storage Products
Some storage products return a peripheral device type of 31==0x1f
with peripheral qualifier 0 in a SCSI standard INQUIRY command
for an unmapped FCP LUN 0. Examples are: IBM Storwize products,
including IBM V7000, IBM V840, IBM V9000, and IBM SAN Volume Controller.
For lsluns to work with such storage products,
you must have a host mapping on the storage, which maps some volume
to exported FCP LUN 0x0000000000000000 (Storwize host map property "SCSI ID" 0)
for each used FCP-device initiator WWPN. The volume can be
a minimum-sized thin-provisioned shared stand-in volume.
.SH OPTIONS
.TP
.B -h, --help
.BR \-a ", " \-\-active
Show the encryption state of the attached LUNs. Encrypted devices are indicated
with a bracketed X immediately following the LUN number.
.TP
.BI \-c\ busid \fR,\ \fB\-\-ccw= busid
Filter LUNs by adapter with the specified FCP device bus-ID. This option can be
specified multiple times. When used in conjunction with \fB\-p\fR, only those
LUNs are listed that also satisfy at least one of the \fB\-p\fR constraints.
.TP
.BI \-p\ wwpn \fR,\ \fB\-\-port= wwpn
Filter LUNs by target port with the specified WWPN. This option can be
specified multiple times. When used in conjunction with \fB\-c\fR, only those
LUNs are listed that also satisfy at least one of the \fB\-c\fR constraints.
.TP
.BR \-h ", " \-\-help
Print help message and exit.
.TP
.B -v, --version
Display version info and exit.
.TP
.B -c, --ccw
Shows LUNs for a specific adapter.
.TP
.B -p, --port
Shows LUNs for a specific port.
.TP
.B -a, --active
Shows all activated LUNs. In addition information is provided
whether the LUN is encrypted or not. This is indicated with a bracketed X
right after the LUN number.
.BR \-v ", " \-\-version
Display version information and exit.
.SH EXAMPLES
.PP
.IP "lsluns"
.TP
.B "lsluns"
.RS
Shows all available LUNs.
Lists all LUNs discovered in the FC SAN.
.RE
.IP "lsluns -c 0.0.3922"
Shows all LUNs found on adapter 0.0.3922.
.IP "lsluns -p 0x5005123456789000"
Shows all LUNs for port 0x5005123456789000.
.IP "lsluns -c 0.0.3922 -p 0x5005123456789000"
Shows all LUNs for adapter 0.0.3922 and port 0x5005123456789000.
.IP "lsluns -a "
.TP
.BI "lsluns \-c " 0.0.3922
Lists all LUNs discovered in the FC SAN on adapter \fI0.0.3922\fR.
.TP
.BI "lsluns \-p " 0x5005123456789000
Lists all LUNs discovered in the FC SAN on target port
\fI0x5005123456789000\fR.
.TP
.BI "lsluns \-c " 0.0.3922 " \-c " 0.0.fc00 \
" \-p " 0x5005123456789000 " \-p " 0x5005abcdefabc000
Lists all LUNs discovered in the FC SAN on:
adpater \fI0.0.3922\fR and port \fI0x5005123456789000\fR,
adapter \fI0.0.3922\fR and port \fI0x5005abcdefabc000\fR,
adapter \fI0.0.fc00\fR and port \fI0x5005123456789000\fR, or
adapter \fI0.0.fc00\fR and port \fI0x5005abcdefabc000\fR.
.TP
.B "lsluns -a"
adapter = 0.0.3c02
port = 0x500507630300c562
lun = 0x401040a200000000(X) /dev/sg0 Disk IBM:2107900
lun = 0x401040a300000000 /dev/sg1 Disk IBM:2107900
Shows all active LUNs including the information whether the device is encrypted or not.
Shows the encryption status of attached LUNs. A bracketed X suffixed to a LUN
indicates that the device is encrypted.
.SH "SEE ALSO"
.BR lszfcp (8),
.BR lsscsi (8),
.BR lszdev (8)

View File

@@ -1,172 +0,0 @@
#!/usr/bin/perl
#
# lsmem - Tool to show memory hotplug status
#
# Copyright IBM Corp. 2010, 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.
#
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case no_auto_abbrev);
use File::Basename;
my $script_name = fileparse($0);
my $memdir = "/sys/devices/system/memory";
my $block_size = 0;
my $list_all = 0;
my $dev_size = 0;
my @entries;
sub lsmem_read_attr($$$$)
# parameters: state, rem, device, block_nr
{
my @attributes = qw(state removable phys_device);
foreach (0..2) {
$_[$_] = `cat $memdir/memory$_[3]/$attributes[$_]`;
chomp($_[$_]);
}
}
sub lsmem_get_dev_size()
{
my ($device, $old_device, $block, $old_block) = (0, 0, 0, 0);
foreach (@entries) {
$_ =~ /memory(\d+)/;
$block = $1;
$device = `cat $_/phys_device`;
chomp($device);
if ($device > $old_device) {
$dev_size = int((($block - $old_block) * $block_size) /
($device - $old_device));
last;
}
$dev_size += $block_size;
$old_block = $block;
}
}
sub lsmem_list()
{
my $block = 0;
my ($start, $end, $size) = (0, 0, 0);
my ($state, $next_state) = (0, 0);
my ($rem, $next_rem) = (0, 0);
my ($device, $next_device, $end_dev) = (0, 0, 0);
my ($mem_online, $mem_offline) = (0, 0);
my $mem_hole;
$block_size = `cat $memdir/block_size_bytes`;
chomp($block_size);
if ($block_size =~ /(?:0x)?([[:xdigit:]]+)/) {
$block_size = unpack("Q", pack("H16",
substr("0" x 16 . $1, -16)));
$block_size = $block_size >> 20;
} else {
die "lsmem: Unknown block size format in sysfs.\n";
}
lsmem_get_dev_size();
# Start with $mem_hole = 1 to initialize $start, $state, $rem, $device
$mem_hole = 1;
print <<HERE;
Address Range Size (MB) State Removable Device
===============================================================================
HERE
foreach (@entries) {
$_ =~ /memory(\d+)/;
$block = $1;
if ($mem_hole) {
lsmem_read_attr($state, $rem, $device, $block);
$start = ($block) * ($block_size << 20);
$mem_hole = 0;
}
# check next block or memory hole
$block++;
if (-d "$memdir/memory".$block) {
lsmem_read_attr($next_state, $next_rem, $next_device,
$block);
} else {
$mem_hole = 1
}
if ($state ne $next_state || $rem != $next_rem || $list_all ||
$mem_hole) {
$end = ($block) * ($block_size << 20) - 1;
$size = ($end - $start + 1) >> 20;
if ($state eq "going-offline") {
$state = "on->off";
}
printf("0x%016x-0x%016x %10lu %-7s ", $start, $end,
$size, $state);
if ($state eq "online") {
printf(" %-9s ", $rem ? "yes" : "no");
$mem_online += $size;
} else {
printf(" %-9s ", "-");
$mem_offline += $size;
}
$end_dev = ($end / $dev_size) >> 20;
if ($device == $end_dev) {
printf("%d\n", $device);
} else {
printf("%d-%d\n", $device, $end_dev);
}
$state = $next_state;
$rem = $next_rem;
$device = $end_dev + 1;
$start = $end + 1;
}
}
printf("\n");
printf("Memory device size : %lu MB\n", $dev_size);
printf("Memory block size : %lu MB\n", $block_size);
printf("Total online memory : %lu MB\n", $mem_online);
printf("Total offline memory: %lu MB\n", $mem_offline);
}
sub lsmem_usage()
{
print <<HERE;
Usage: $script_name [OPTIONS]
The $script_name command lists the ranges of available memory with their online
status. The listed memory blocks correspond to the memory block representation
in sysfs. The command also shows the memory block size, the device size, and
the amount of memory in online and offline state.
OPTIONS
-a, --all
List each individual memory block, instead of combining memory blocks
with similar attributes.
-h, --help
Print a short help text, then exit.
-v, --version
Print the version number, then exit.
HERE
}
sub lsmem_version()
{
print "$script_name: version %S390_TOOLS_VERSION%\n";
print "Copyright IBM Corp. 2010, 2017\n";
}
# Main
unless (GetOptions('v|version' => sub {lsmem_version(); exit 0;},
'h|help' => sub {lsmem_usage(); exit 0;},
'a|all' => \$list_all)) {
die "Try '$script_name --help' for more information.\n";
};
@entries = (sort {length($a) <=> length($b) || $a cmp $b} <$memdir/memory*>);
if (@entries == 0) {
die "lsmem: No memory hotplug interface in sysfs ($memdir).\n";
}
lsmem_list();

View File

@@ -1,73 +0,0 @@
.\" 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 LSMEM 8 "Apr 2010" s390\-tools
.
.
.SH NAME
lsmem \- list the ranges of available memory with their online status.
.
.
.SH SYNOPSIS
.B lsmem
.RB [OPTIONS]
.
.
.SH DESCRIPTION
The lsmem command lists the ranges of available memory with their online
status. The listed memory blocks correspond to the memory block representation
in sysfs. The command also shows the memory block size, the device size, and
the amount of memory in online and offline state.
.
.SS "Column description"
.
.TP 4
Address Range
Start and end address of the memory range.
.
.TP 4
Size
Size of the memory range in MB (1024 x 1024 bytes).
.
.TP 4
State
Indication of the online status of the memory range. State on->off means
that the address range is in transition from online to offline.
.
.TP 4
Removable
"yes" if the memory range can be set offline, "no" if it cannot be set offline.
A dash ("\-") means that the range is already offline.
.
.TP 4
Device
Device number or numbers that correspond to the memory range.
Each device represents a memory unit for the hypervisor in control of the
memory. The hypervisor cannot reuse a memory unit unless the corresponding
memory range is completely offline. For best memory utilization, each device
should either be completely online or completely offline.
The chmem command with the size parameter automatically chooses the best suited
device or devices when setting memory online or offline. The device size depends
on the hypervisor and on the amount of total online and offline memory.
.
.
.SH OPTIONS
.TP
.BR \-a ", " \-\-all
List each individual memory block, instead of combining memory blocks with
similar attributes.
.
.TP
.BR \-h ", " \-\-help
Print a short help text, then exit.
.
.TP
.BR \-v ", " \-\-version
Print the version number, then exit.
.
.
.SH SEE ALSO
.BR chmem (8)

View File

@@ -2,7 +2,7 @@
.\" 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 CHZCRYPT 8 "AUG 2008" "s390-tools"
.TH CHZCRYPT 8 "OCT 2017" "s390-tools"
.SH NAME
chzcrypt \- modify zcrypt configuration
.SH SYNOPSIS

View File

@@ -10,7 +10,7 @@
.\" nroff -man lszcrypt.8
.\" to process this source
.\"
.TH LSZCRYPT 8 "AUG 2008" "s390-tools"
.TH LSZCRYPT 8 "OCT 2017" "s390-tools"
.SH NAME
lszcrypt \- display zcrypt device and configuration information
.SH SYNOPSIS
@@ -85,6 +85,13 @@ EP11 Secure Key
.IP "o"
Long RNG
.RE
.RS 8
The CCA Secure Key capability may be limited by a hypervisor
layer. The remarks 'full function set' or 'restricted function set' may
reflect this. For details about these limitations please check the
hypervisor documentation.
.RE
.TP 8
.B -d, --domains
Shows the usage and control domains of the cryptographic devices.

View File

@@ -42,11 +42,19 @@ struct lszcrypt_l *lszcrypt_l = &l;
/*
* Card types
*/
#define MASK_APSC 0x80000000
#define MASK_RSA4K 0x60000000
#define MASK_COPRO 0x10000000
#define MASK_ACCEL 0x08000000
#define MASK_EP11 0x04000000
#define MASK_APSC 0x80000000
#define MASK_RSA4K 0x60000000
#define MASK_COPRO 0x10000000
#define MASK_ACCEL 0x08000000
#define MASK_EP11 0x04000000
/*
* Classification
*/
#define MASK_CLASS_FULL 0x00800000
#define CLASS_FULL "full function set"
#define MASK_CLASS_STATELESS 0x00400000
#define CLASS_STATELESS "restricted function set"
/*
* Program configuration
@@ -226,7 +234,7 @@ static void show_capability(const char *id_str)
{
unsigned long func_val;
long hwtype, id;
char *p, *ap, *dev, card[16];
char *p, *ap, *dev, card[16], cbuf[256];
/* check if ap driver is available */
ap = util_path_sysfs("bus/ap");
@@ -250,6 +258,11 @@ static void show_capability(const char *id_str)
printf("Detailed capability information for %s (hardware type %ld) is not available.\n", card, hwtype);
return;
}
cbuf[0] = '\0';
if (func_val & MASK_CLASS_FULL)
snprintf(cbuf, sizeof(cbuf), "%s", CLASS_FULL);
else if (func_val & MASK_CLASS_STATELESS)
snprintf(cbuf, sizeof(cbuf), "%s", CLASS_STATELESS);
printf("%s provides capability for:\n", card);
switch (hwtype) {
case 6:
@@ -262,11 +275,15 @@ static void show_capability(const char *id_str)
case 7:
case 9:
printf("%s\n", CAP_RSA4K);
printf("%s\n", CAP_CCA);
if (cbuf[0])
printf("%s (%s)\n", CAP_CCA, cbuf);
else
printf("%s\n", CAP_CCA);
printf("%s", CAP_RNG);
break;
case 10:
case 11:
case 12:
if (func_val & MASK_ACCEL) {
if (func_val & MASK_RSA4K)
printf("%s", CAP_RSA4K);
@@ -274,12 +291,14 @@ static void show_capability(const char *id_str)
printf("%s", CAP_RSA2K);
} else if (func_val & MASK_COPRO) {
printf("%s\n", CAP_RSA4K);
printf("%s\n", CAP_CCA);
if (cbuf[0])
printf("%s (%s)\n", CAP_CCA, cbuf);
else
printf("%s\n", CAP_CCA);
printf("%s", CAP_RNG);
} else if (func_val & MASK_EP11) {
printf("%s", CAP_EP11);
} else {
printf("Detailed capability information for %s (hardware type %ld) is not available.", card, hwtype);
}
break;

View File

@@ -29,13 +29,21 @@ depends() {
}
installkernel() {
local _modules=$(lszdev --by-path / --columns MODULES --no-headings)
local _modules=$(lszdev --by-path / --columns MODULES --no-headings 2>/dev/null)
[ -z "$_modules" ] && return 0
[ ! -z "$_modules" ] && instmods $_modules
}
install() {
local _tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
local _tempfile
# Exit early if root device type is unknown
if ! lszdev --by-path / >/dev/null 2>&1 ; then
return 0
fi
_tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
if chzdev --export - --persistent --by-path / >/dev/null 2>&1 ; then
# Use persistent configuration

View File

@@ -157,10 +157,6 @@ char *misc_asprintf(const char *, ...);
int misc_system(err_t, const char *, ...);
bool misc_read_dir(const char *, struct util_list *,
bool (*)(const char *, void *), void *);
bool path_exists(const char *);
bool file_exists(const char *);
bool file_writable(const char *);
bool dir_exists(const char *);
bool file_is_devnode(const char *);
exit_code_t remove_file(const char *);
char *misc_read_text_file(const char *, int, err_t);

View File

@@ -27,7 +27,7 @@
#define PATH_PROC "/proc"
#define PATH_UDEVADM "udevadm"
#define PATH_VMCP "/usr/sbin/vmcp"
#define PATH_VMCP TOOLS_BINDIR "/vmcp"
#define PATH_IP "ip"
#define PATH_ROOT "/"

View File

@@ -620,13 +620,13 @@ Answer all confirmation questions with 'yes'.
.
.B Persistently configure root device:
.RS 4
.CL chzdev \-\-by\-path / \-\-persistent
.CL chzdev \-\-by\-path / \-\-persistent \-\-enable
.RE
.PP
.
.B Disable device that provides networking interface eth0:
.RS 4
.CL chzdev \-\-by\-interface eth0 \-\-active
.CL chzdev \-\-by\-interface eth0 \-\-active \-\-disable
.RE
.PP
.

View File

@@ -14,6 +14,7 @@
#include <string.h>
#include "lib/util_base.h"
#include "lib/util_path.h"
#include "attrib.h"
#include "ccw.h"
@@ -1165,15 +1166,10 @@ out:
static void read_grouped(struct ccw_devinfo *info, const char *path)
{
char *file_path;
file_path = misc_asprintf("%s/group_device", path);
if (path_exists(file_path))
if (util_path_exists("%s/group_device", path))
info->grouped = 1;
else
info->grouped = 0;
free(file_path);
}
static void read_cutype(struct ccw_devinfo *info, const char *path)
@@ -1229,7 +1225,7 @@ static struct ccw_devinfo *ccw_devinfo_read(struct ccw_devid *devid)
id = ccw_devid_to_str(devid);
path = path_get_ccw_device(NULL, id);
if (!dir_exists(path))
if (!util_path_is_dir(path))
goto out;
info->exists = 1;
@@ -1354,7 +1350,7 @@ bool ccw_exists(const char *drv, const char *mod, const char *id)
if (!path)
return false;
rc = dir_exists(path);
rc = util_path_is_dir(path);
free(path);
return rc;
@@ -1428,7 +1424,7 @@ static exit_code_t ccw_st_read_active(struct subtype *st, struct device *dev,
state->definable = 0;
path = path_get_ccw_device(drv, id);
if (path_exists(path)) {
if (util_path_exists(path)) {
state->exists = 1;
device_read_active_settings(dev, scope);
} else
@@ -1641,7 +1637,7 @@ static void ccw_st_add_errors(struct subtype *st, const char *id,
if (!path)
return;
if (!path_exists(path)) {
if (!util_path_exists(path)) {
strlist_add(errors, "CCW device %s does not exist", id);
goto out;
}
@@ -1662,9 +1658,7 @@ static void ccw_st_add_errors(struct subtype *st, const char *id,
"paths", id);
goto out;
}
free(apath);
apath = misc_asprintf("%s/driver", path);
if (!path_exists(apath)) {
if (!util_path_exists("%s/driver", path)) {
strlist_add(errors, "CCW device %s is not bound to a driver",
id);
goto out;

View File

@@ -12,6 +12,7 @@
#include <string.h>
#include "lib/util_base.h"
#include "lib/util_path.h"
#include "attrib.h"
#include "ccw.h"
@@ -557,7 +558,7 @@ static bool read_full_id(struct ccwgroup_devid *devid_ptr, const char *drv,
bool result = false;
path = path_get_ccwgroup_device(drv, id);
if (!dir_exists(path))
if (!util_path_is_dir(path))
goto out;
memset(&devid, 0, sizeof(struct ccwgroup_devid));
@@ -625,7 +626,7 @@ static void ccwgroup_add_ids(const char *drv, const char *mod,
path = path_get_ccwgroup_devices(drv);
if (mod)
module_try_load_once(mod, path);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, get_ids_cb, &cb_data);
free(path);
}
@@ -663,7 +664,7 @@ static exit_code_t ccwgroup_st_read_active(struct subtype *st,
state->definable = 0;
path = ccwgroup_get_dev_path_by_devid(drv, devid);
if (path_exists(path)) {
if (util_path_exists(path)) {
state->exists = 1;
device_read_active_settings(dev, scope);
} else

View File

@@ -16,6 +16,7 @@
#include <string.h>
#include <unistd.h>
#include "lib/util_path.h"
#include "lib/zt_common.h"
#include "attrib.h"
@@ -2502,7 +2503,7 @@ static exit_code_t do_export(struct options *opts)
info("Exporting configuration data to standard output\n");
} else {
info("Exporting configuration data to %s\n", opts->export);
if (!path_exists(opts->export)) {
if (!util_path_exists(opts->export)) {
rc = path_create(opts->export);
if (rc)
return rc;

View File

@@ -9,6 +9,8 @@
#include <string.h>
#include "lib/util_path.h"
#include "ccw.h"
#include "ccwgroup.h"
#include "ctc.h"
@@ -125,13 +127,13 @@ static struct util_list *read_sorted_ctc_devinfos(void)
/* Add CCW devices bound to the CTC CCW device driver. */
module_try_load_once(CTC_MOD_NAME, NULL);
path = path_get_sys_bus_drv(CCW_BUS_NAME, CTC_CCWDRV_NAME);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_cb, infos);
free(path);
/* Add CCW devices bound to the LCS CCW device driver. */
path = path_get_sys_bus_drv(CCW_BUS_NAME, LCS_CCWDRV_NAME);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_cb, infos);
free(path);

View File

@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "device.h"
#include "devtype.h"
@@ -480,7 +482,8 @@ void device_read_active_settings(struct device *dev, read_scope_t scope)
a = attrib_find(st->dev_attribs, name);
s = setting_list_apply_actual(dev->active.settings, a, name,
value);
if (link || (scope == scope_all && !file_writable(path)))
if (link || (scope == scope_all &&
!util_path_is_writable(path)))
s->readonly = 1;
if (link)
free(link);

View File

@@ -15,6 +15,8 @@
#include <sys/sysmacros.h>
#include <unistd.h>
#include "lib/util_path.h"
#include "devnode.h"
#include "misc.h"
#include "path.h"
@@ -230,7 +232,7 @@ static exit_code_t add_block_cb(const char *path, const char *filename,
/* Add additional nodes. */
cb_data->prefix = filename;
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_part_cb, cb_data);
return EXIT_OK;
@@ -249,7 +251,7 @@ int devnode_add_block_from_sysfs(struct util_list *list, const char *path)
cb_data.prefix = NULL;
blkpath = misc_asprintf("%s/block", path);
if (dir_exists(blkpath))
if (util_path_is_dir(blkpath))
path_for_each(blkpath, add_block_cb, &cb_data);
free(blkpath);
@@ -283,7 +285,7 @@ int devnode_add_net_from_sysfs(struct util_list *list, const char *path)
cb_data.prefix = NULL;
netpath = misc_asprintf("%s/net", path);
if (dir_exists(netpath))
if (util_path_is_dir(netpath))
path_for_each(netpath, add_net_cb, &cb_data);
free(netpath);

View File

@@ -9,6 +9,8 @@
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "ccw.h"
#include "ccwgroup.h"
@@ -162,7 +164,7 @@ static void generic_ccw_st_add_devnodes(struct subtype *st, const char *id,
cb_data.devnodes = devnodes;
cb_data.id = id;
path = path_get_sys_dev_char_devices();
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_cb, &cb_data);
free(path);
}

View File

@@ -9,6 +9,8 @@
#include <string.h>
#include "lib/util_path.h"
#include "ccw.h"
#include "ccwgroup.h"
#include "ctc.h"
@@ -129,13 +131,13 @@ static struct util_list *read_sorted_lcs_devinfos(void)
/* Add CCW devices bound to the LCS CCW device driver. */
module_try_load_once(LCS_MOD_NAME, NULL);
path = path_get_sys_bus_drv(CCW_BUS_NAME, LCS_CCWDRV_NAME);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_cb, infos);
free(path);
/* Add CCW devices bound to the CTC CCW device driver. */
path = path_get_sys_bus_drv(CCW_BUS_NAME, CTC_CCWDRV_NAME);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_cb, infos);
free(path);

View File

@@ -889,69 +889,6 @@ void ptrlist_move(struct util_list *to, struct util_list *from,
util_list_add_tail(to, node);
}
/* Check if a path exists. */
bool path_exists(const char *path)
{
struct stat s;
debug("Checking if file exists: %s\n", path);
if (stat(path, &s) != 0)
return false;
return true;
}
/* Check if a file exists. */
bool file_exists(const char *path)
{
struct stat s;
debug("Checking if regular file exists: %s\n", path);
if (stat(path, &s) != 0)
return false;
if (!S_ISREG(s.st_mode))
return false;
return true;
}
/* Check if a file is writable. */
bool file_writable(const char *path)
{
struct stat s;
debug("Checking if regular file is writable: %s\n", path);
if (stat(path, &s) != 0)
return false;
if (!S_ISREG(s.st_mode))
return false;
if (!(s.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
return false;
return true;
}
/* Check if a directory exists. */
bool dir_exists(const char *path)
{
bool result = false;
struct stat s;
debug("Checking if directory exists: %s\n", path);
if (stat(path, &s) != 0)
goto out;
if (!S_ISDIR(s.st_mode))
goto out;
result = true;
out:
debug("Result: %d\n", result);
return result;
}
/* Check if file is a block or character special file. */
bool file_is_devnode(const char *path)
{

View File

@@ -14,6 +14,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "misc.h"
#include "modprobe.h"
@@ -376,7 +378,7 @@ exit_code_t modprobe_read_settings(const char *path, const char *mod,
struct modprobe_file *mf;
exit_code_t rc;
if (!file_exists(path)) {
if (!util_path_is_reg_file(path)) {
*settings = NULL;
return EXIT_OK;
}
@@ -398,7 +400,7 @@ exit_code_t modprobe_write_settings(const char *path, const char *mod,
exit_code_t rc;
unsigned long lines;
if (file_exists(path)) {
if (util_path_is_reg_file(path)) {
rc = modprobe_read(path, &mf);
if (rc)
return rc;
@@ -414,7 +416,7 @@ exit_code_t modprobe_write_settings(const char *path, const char *mod,
lines = util_list_len(&mf->lines);
if (lines == 0 || (lines == 1 && find_chzdev_comment(mf))) {
/* Do not write empty files. */
if (file_exists(path))
if (util_path_is_reg_file(path))
rc = remove_file(path);
} else
rc = modprobe_write(mf);

View File

@@ -12,6 +12,8 @@
#include <string.h>
#include <sys/types.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "misc.h"
#include "module.h"
@@ -34,7 +36,7 @@ bool module_loaded(const char *mod)
char *path = path_get_sys_module(mod);
bool rc;
rc = dir_exists(path);
rc = util_path_is_dir(path);
free(path);
return rc;
@@ -229,7 +231,7 @@ void module_try_load_once(const char *mod, const char *path)
} else
tried_loading = strlist_new();
strlist_add(tried_loading, mod);
if (path && path_exists(path))
if (path && util_path_exists(path))
return;
if (module_loaded(mod))
return;
@@ -275,7 +277,7 @@ bool module_set_params(const char *mod, struct setting_list *settings)
return false;
}
path = path_get_sys_module_param(mod, s->name);
result = file_writable(path);
result = util_path_is_writable(path);
free(path);
if (!result) {
/* Sysfs file is not writable. */

View File

@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "ccw.h"
#include "ccwgroup.h"
#include "device.h"
@@ -277,7 +279,7 @@ static struct util_list *read_sorted_qeth_devinfos(void)
/* Get CHPID information for all devices bound to the QETH driver. */
infos = ptrlist_new();
path = path_get_sys_bus_drv(CCW_BUS_NAME, QETH_CCWDRV_NAME);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_cb, infos);
free(path);

View File

@@ -9,6 +9,8 @@
#include <stdlib.h>
#include "lib/util_path.h"
#include "device.h"
#include "devtype.h"
#include "misc.h"
@@ -35,9 +37,14 @@ exit_code_t root_check(void)
/* Get list of devices that provide the root device. */
selected = selected_dev_list_new();
rc = select_by_path(NULL, selected, config_active, scope_mandatory,
NULL, NULL, PATH_ROOT, err_print);
if (rc)
NULL, NULL, PATH_ROOT, err_ignore);
if (rc) {
/* Running from an unknown root device is not an error. */
verb("Note: Could not determine if root device configuration "
"needs to be updated\n");
rc = 0;
goto out;
}
/* Determine if any of the devices or device types has been modified. */
mod = strlist_new();
@@ -69,7 +76,7 @@ exit_code_t root_check(void)
"required.\n");
/* Check if script is available. */
if (!file_exists(PATH_ROOT_SCRIPT))
if (!util_path_is_reg_file(PATH_ROOT_SCRIPT))
goto out;
/* Ask for confirmation. */

View File

@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "misc.h"
#include "path.h"
#include "scsi.h"
@@ -253,7 +255,7 @@ static struct util_list *read_scsi_zfcp_list(void)
list = ptrlist_new();
path = path_get_sys_bus_dev("scsi", NULL);
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, add_ids_cb, list);
free(path);

View File

@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "blkinfo.h"
#include "ccw.h"
#include "device.h"
@@ -622,7 +624,7 @@ exit_code_t select_by_path(struct select_opts *select,
struct ptrlist_node *p;
exit_code_t rc;
if (!path_exists(path)) {
if (!util_path_exists(path)) {
err_t_print(err, "Path not found: %s\n", path);
return EXIT_DEVICE_NOT_FOUND;
}

View File

@@ -13,6 +13,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "ccw.h"
#include "device.h"
@@ -391,7 +393,7 @@ exit_code_t udev_remove_rule(const char *type, const char *id)
exit_code_t rc = EXIT_OK;
path = path_get_udev_rule(type, id);
if (file_exists(path))
if (util_path_is_reg_file(path))
rc = remove_file(path);
free(path);

View File

@@ -13,6 +13,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "ccw.h"
#include "device.h"
@@ -33,7 +35,7 @@ bool udev_ccw_exists(const char *type, const char *id)
return false;
path = path_get_udev_rule(type, normid);
rc = file_exists(path);
rc = util_path_is_reg_file(path);
free(path);
free(normid);
@@ -150,7 +152,7 @@ exit_code_t udev_ccw_write_device(struct device *dev)
path = path_get_udev_rule(type, id);
debug("Writing %s udev rule file %s\n", type, path);
if (!path_exists(path)) {
if (!util_path_exists(path)) {
rc = path_create(path);
if (rc)
goto out;
@@ -243,7 +245,7 @@ exit_code_t udev_ccw_write_cio_ignore(const char *id_list)
if (!*id_list) {
/* Empty id_list string - remove file. */
if (!file_exists(path)) {
if (!util_path_is_reg_file(path)) {
/* Already removed. */
goto out;
}
@@ -256,7 +258,7 @@ exit_code_t udev_ccw_write_cio_ignore(const char *id_list)
goto out;
debug("Writing cio-ignore udev rule file %s\n", path);
if (!path_exists(path)) {
if (!util_path_exists(path)) {
rc = path_create(path);
if (rc)
goto out;

View File

@@ -13,6 +13,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "ccwgroup.h"
#include "device.h"
@@ -53,7 +55,7 @@ bool udev_ccwgroup_exists(const char *type, const char *id)
path = get_rule_path(type, id);
if (!path)
return false;
rc = file_exists(path);
rc = util_path_is_reg_file(path);
free(path);
return rc;
@@ -215,7 +217,7 @@ exit_code_t udev_ccwgroup_write_device(struct device *dev)
list = setting_list_get_sorted(dev->persistent.settings);
debug("Writing %s udev rule file %s\n", type, path);
if (!path_exists(path)) {
if (!util_path_exists(path)) {
rc = path_create(path);
if (rc)
goto out;
@@ -364,7 +366,7 @@ void udev_ccwgroup_add_device_ids(const char *type, struct util_list *list)
cb_data.prefix = misc_asprintf("%s-%s-", UDEV_PREFIX, type);
cb_data.ids = list;
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, get_ids_cb, &cb_data);
free(cb_data.prefix);
@@ -382,7 +384,7 @@ exit_code_t udev_ccwgroup_remove_rule(const char *type, const char *id)
return EXIT_INVALID_ID;
path = path_get_udev_rule(type, partial_id);
if (file_exists(path))
if (util_path_is_reg_file(path))
rc = remove_file(path);
free(path);
free(partial_id);

View File

@@ -14,6 +14,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "device.h"
#include "misc.h"
@@ -376,7 +378,7 @@ void udev_zfcp_lun_add_device_ids(struct util_list *list)
cb_data.list = list;
path = path_get_udev_rules();
if (dir_exists(path))
if (util_path_is_dir(path))
path_for_each(path, lun_cb, &cb_data);
free(path);
@@ -497,7 +499,7 @@ static exit_code_t write_luns_rule(const char *path, struct util_list *list)
return EXIT_INTERNAL_ERROR;
hba_id = ccw_devid_to_str(&node->id.fcp_dev);
debug("Writing FCP LUN udev rule file %s\n", path);
if (!path_exists(path)) {
if (!util_path_exists(path)) {
rc = path_create(path);
if (rc)
goto out;
@@ -614,7 +616,7 @@ static exit_code_t update_lun_rule(const char *id, struct device_state *state)
/* Get previous rule data. */
luns = zfcp_lun_node_list_new();
exists = file_exists(path);
exists = util_path_is_reg_file(path);
if (exists)
udev_read_zfcp_lun_rule(path, luns);

View File

@@ -13,6 +13,8 @@
#include <stdlib.h>
#include <string.h>
#include "lib/util_path.h"
#include "attrib.h"
#include "ccw.h"
#include "device.h"
@@ -430,7 +432,7 @@ static exit_code_t zfcp_lun_st_read_active(struct subtype *st,
/* Check for FC unit. */
fc_path = path_get_zfcp_lun_dev(dev->devid);
fc_exists = path_exists(fc_path);
fc_exists = util_path_exists(fc_path);
free(fc_path);
/* Check for SCSI device. */
@@ -478,7 +480,7 @@ static exit_code_t zfcp_lun_add(struct device *dev)
/* Check if LUN already exists. */
fcp_dev_id = ccw_devid_to_str(&devid->fcp_dev);
lunpath = path_get_zfcp_lun_dev(devid);
if (dir_exists(lunpath)) {
if (util_path_is_dir(lunpath)) {
hctl = scsi_hctl_from_zfcp_lun_devid(devid);
if (!hctl)
goto check_failed;
@@ -486,7 +488,7 @@ static exit_code_t zfcp_lun_add(struct device *dev)
}
portpath = path_get_zfcp_port_dev(devid);
if (!dir_exists(portpath)) {
if (!util_path_is_dir(portpath)) {
delayed_err("Target port not found\n");
rc = EXIT_ZFCP_WWPN_NOT_FOUND;
goto out;
@@ -681,14 +683,14 @@ static exit_code_t zfcp_lun_st_device_undefine(struct subtype *st,
remove_lun:
path = path_get_zfcp_lun_dev(devid);
if (!path_exists(path))
if (!util_path_exists(path))
goto out;
free(path);
path = NULL;
/* Remove FCP LUN. */
devpath = path_get_zfcp_port_dev(devid);
if (!dir_exists(devpath)) {
if (!util_path_is_dir(devpath)) {
rc = EXIT_ZFCP_WWPN_NOT_FOUND;
goto out;
}
@@ -779,7 +781,7 @@ static bool zfcp_lun_fc_lun_exists(const char *id)
if (zfcp_lun_parse_devid(&devid, id, err_ignore) != EXIT_OK)
return false;
path = path_get_zfcp_lun_dev(&devid);
result = path_exists(path);
result = util_path_exists(path);
free(path);
return result;
@@ -910,7 +912,7 @@ static void add_sg_from_sysfs(struct util_list *list, const char *path)
char *sgpath;
sgpath = misc_asprintf("%s/scsi_generic", path);
if (dir_exists(sgpath))
if (util_path_is_dir(sgpath))
path_for_each(sgpath, add_sg_cb, list);
free(sgpath);
}

View File

@@ -3,7 +3,8 @@ include ../common.mak
libs = $(rootdir)/libzds/libzds.a \
$(rootdir)/libvtoc/libvtoc.a \
$(rootdir)/libu2s/libu2s.a \
$(rootdir)/libutil/libutil.a
$(rootdir)/libutil/libutil.a \
$(rootdir)/libdasd/libdasd.a
ifeq (${HAVE_FUSE},0)

View File

@@ -242,7 +242,7 @@ static void vol_init(struct vol *vol, struct vol_parm *vol_parm, int ssid,
sprintf(vol->bus_id, "0.%x.%04x", ssid, vol_parm->devno);
vol->blk_size = vol_parm->blk_size << 8;
vol->part_off = vol_parm->start_blk * vol->blk_size;
vol->part_off = (u64)vol_parm->start_blk * vol->blk_size;
vol->part_size = blk_cnt * vol->blk_size;
vol->status = dev_from_busid(vol->bus_id, &vol->dev);
vol->sign = SIGN_VALID;

View File

@@ -2,7 +2,25 @@ include ../common.mak
CPIOINIT = $(call echocmd," CPIOINI ",/$@)./cpioinit
all: $(ZFCPDUMP_PART_RD)
ifeq (${HAVE_LIBC_STATIC},0)
all:
$(SKIP) HAVE_LIBC_STATIC=0
install:
$(SKIP) HAVE_LIBC_STATIC=0
else
check_dep:
$(call check_dep, \
"zfcpdump", \
"stdio.h", \
"glibc-static or libc-dev", \
"HAVE_LIBC_STATIC=0", \
"-static")
all: check_dep $(ZFCPDUMP_PART_RD)
cpioinit: cpioinit.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
@@ -19,7 +37,9 @@ $(ZFCPDUMP_PART_RD): cpioinit zfcpdump_part
install: all
$(INSTALL) -m 611 $(ZFCPDUMP_PART_RD) $(DESTDIR)$(ZFCPDUMP_DIR)
endif
clean:
rm -f *.o *.gz *.tmp *~ zfcpdump_part cpioinit $(ZFCPDUMP_PART_RD)
.PHONY: all clean install
.PHONY: all clean install check_dep

View File

@@ -58,6 +58,7 @@ sub store_mapper_devices
my $src_dir = shift();
my @entries = grep { ! /^\./ } dir_content($src_dir);
foreach my $map_dev (@entries) {
my $tf = catfile($src_dir, "$map_dev");
my $mm = `stat -L -c%t:%T $tf`;
chomp($mm);

View File

@@ -662,7 +662,7 @@ static int init_adapters(struct adapters *all_adapters, struct options *opts)
malloc(sizeof(char)*MAX_HOST_PATH_LEN);
sprintf(adapter->q_full_path, "%s/queue_full",
opts->host_path[i]);
if (stat(adapter->path, &buf)) {
if (stat(adapter->q_full_path, &buf)) {
fprintf(stderr, "%s: Path does not exist: %s - correct kernel version?\n",
toolname, adapter->q_full_path);
rc++;
@@ -806,7 +806,7 @@ static int check_host_param(long *host_nr, char *host_path)
}
tmp = malloc(strlen(host_path) + strlen("/queue_full") + 1);
sprintf(tmp, "%s/queue_full", host_path);
if (stat(host_path, &buf)) {
if (stat(tmp, &buf)) {
fprintf(stderr, "%s: Cannot access %s."
" Your installed kernel is probably too old. Please"
" check that your kernel matches the level in the"
@@ -1009,7 +1009,7 @@ static int parse_params(int argc, char **argv, struct options *opts)
if (argc <= 1) {
print_help();
return 1;
return -1;
}
/* this is too much, but argc/2 is a reliable upper boundary
@@ -1296,6 +1296,7 @@ int main(int argc, char **argv)
struct timeval first_interval;
struct ioerr_wrp *ioerr = NULL;
int rc = 0;
int parse_params_rc;
verbose = 0;
keep_running = 1;
@@ -1304,9 +1305,13 @@ int main(int argc, char **argv)
init_opts(&opts);
if (parse_params(argc, argv, &opts)) {
parse_params_rc = parse_params(argc, argv, &opts);
if (parse_params_rc < 0) {
rc = -1;
goto out2;
} else if (parse_params_rc > 0) {
rc = 0;
goto out2;
}
if (opts.msg_q_path && setup_msg_q(&opts)) {

View File

@@ -1,7 +1,7 @@
# Common definitions
include ../../common.mak
CFLAGS_BOOT = -Os -g -I../include -D__ASSEMBLY__ \
CFLAGS_BOOT = $(NO_PIE_CFLAGS) -Os -g -I../include -D__ASSEMBLY__ \
-DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
-fno-delete-null-pointer-checks \
@@ -54,11 +54,11 @@ stage3.exec: head.o stage3.o kdump3.o libc.o sclp.o sclp_stage3.o \
}' \
); \
case $$STAGE in \
0) SFLAGS="-nostdlib -Wl,-Ttext,0";; \
1) SFLAGS="-nostdlib -Wl,-Ttext,0x18";; \
1b) SFLAGS="-nostdlib -Wl,-Ttext,0xE000";; \
2) SFLAGS="-nostdlib -Wl,-T,stage2.lds";; \
3) SFLAGS="-nostdlib -Wl,-T,stage3.lds";; \
0) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-Ttext,0";; \
1) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-Ttext,0x18";; \
1b) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-Ttext,0xE000";; \
2) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage2.lds";; \
3) SFLAGS="$(NO_PIE_LINKFLAGS) -nostdlib -Wl,-T,stage3.lds";; \
esac; \
$(LINK) $$SFLAGS -m64 $^ -o $@
@@ -77,7 +77,7 @@ stage3.exec: head.o stage3.o kdump3.o libc.o sclp.o sclp_stage3.o \
$< $@
data.o: $(FILES)
$(LD) -r -b binary -o data.o $(FILES)
$(LD) $(NO_PIE_LDFLAGS) -r -b binary -o data.o $(FILES)
data.h: data.o
rm -f data.h

View File

@@ -7,8 +7,8 @@ ALL_CPPFLAGS += -I../include -I../boot \
-DZFCPDUMP_FS_RD=$(ZFCPDUMP_FS_RD) \
-DZFCPDUMP_PART_IMAGE=$(ZFCPDUMP_PART_IMAGE) \
-DZFCPDUMP_PART_RD=$(ZFCPDUMP_PART_RD) \
-D_FILE_OFFSET_BITS=64
ALL_LDFLAGS += -Wl,-z,noexecstack
-D_FILE_OFFSET_BITS=64 $(NO_PIE_CFLAGS)
ALL_LDFLAGS += -Wl,-z,noexecstack $(NO_PIE_LDFLAGS)
libs = $(rootdir)/libutil/libutil.a \
$(rootdir)/libu2s/libu2s.a

View File

@@ -623,7 +623,7 @@ sub get_dasd_info($)
my $type;
local *HANDLE;
open(HANDLE, "$dasdview -x -f $dev 2>/dev/null|") or
open(HANDLE, "$dasdview -x $dev 2>/dev/null|") or
# dasdview returned with an error
return undef;
while (<HANDLE>) {