mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Compare commits
302 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f1fa2a83c | ||
|
|
7677d3c0b4 | ||
|
|
6f7cb68dcf | ||
|
|
4d008849f7 | ||
|
|
d921c230ab | ||
|
|
6151889dcd | ||
|
|
224dc2e414 | ||
|
|
5a10aa73a9 | ||
|
|
428d41034e | ||
|
|
cf265cc46a | ||
|
|
84623f39dc | ||
|
|
8cbdfebc4f | ||
|
|
4951044213 | ||
|
|
667516681e | ||
|
|
10ce432196 | ||
|
|
320a49fc1a | ||
|
|
f0d18ddf2b | ||
|
|
2962248e7b | ||
|
|
773c8672ac | ||
|
|
637750f299 | ||
|
|
a17b52a043 | ||
|
|
d14051e309 | ||
|
|
d85cf20981 | ||
|
|
7df8edd88a | ||
|
|
6d382d30d9 | ||
|
|
9f8d245f92 | ||
|
|
cf39f26dee | ||
|
|
83106991ab | ||
|
|
b631c74df5 | ||
|
|
c675096899 | ||
|
|
5a9e93fb5b | ||
|
|
aefc8cd3ff | ||
|
|
a208463e49 | ||
|
|
a931428908 | ||
|
|
c2297a0a7e | ||
|
|
70a79fab3c | ||
|
|
b5a7b13e71 | ||
|
|
52b2cb8424 | ||
|
|
03b2bf028b | ||
|
|
81f9a67d6f | ||
|
|
c15f481181 | ||
|
|
4170cceb52 | ||
|
|
a648dbb014 | ||
|
|
322d51e5e4 | ||
|
|
a1db08160d | ||
|
|
31b77e1646 | ||
|
|
a4acf7c991 | ||
|
|
17cade6e7f | ||
|
|
90ea5d9e5d | ||
|
|
6accffd583 | ||
|
|
4e5afb9b71 | ||
|
|
9f247795f3 | ||
|
|
71976f8e4b | ||
|
|
851f685993 | ||
|
|
9100327092 | ||
|
|
e2d433bb10 | ||
|
|
d6925a30da | ||
|
|
fe4cc7c479 | ||
|
|
fa3cabc8af | ||
|
|
5a9b56f814 | ||
|
|
20145b6d06 | ||
|
|
9561a0b983 | ||
|
|
97fa88299f | ||
|
|
aaaebb2030 | ||
|
|
ff2a403bd2 | ||
|
|
66ed1727f9 | ||
|
|
c33cc5a619 | ||
|
|
cd46297d7c | ||
|
|
07b11982e3 | ||
|
|
35348c302b | ||
|
|
35312d0c47 | ||
|
|
342c6a3707 | ||
|
|
e2a8d85916 | ||
|
|
8f0496b26a | ||
|
|
d03be73536 | ||
|
|
a87268d62e | ||
|
|
9cc06a0529 | ||
|
|
3b1ccce515 | ||
|
|
ffe91d1b30 | ||
|
|
f35c5d01fd | ||
|
|
b23c35c390 | ||
|
|
177cf8cfeb | ||
|
|
f05f7d656b | ||
|
|
0bf4f1b957 | ||
|
|
cd38119888 | ||
|
|
cadef5c0ff | ||
|
|
02e1c783f6 | ||
|
|
07e30951f8 | ||
|
|
0a0b4c3826 | ||
|
|
eade995185 | ||
|
|
0eba8d11df | ||
|
|
257490366b | ||
|
|
5ef1320a7b | ||
|
|
f2f572fa70 | ||
|
|
e655f0cd7b | ||
|
|
68b46eea7a | ||
|
|
9894e391ef | ||
|
|
5982fd98bf | ||
|
|
d5291eed1c | ||
|
|
34260f1736 | ||
|
|
b9b3d2d230 | ||
|
|
4cf8f5f46c | ||
|
|
eba744a25e | ||
|
|
80e0c41b89 | ||
|
|
cdc787db1b | ||
|
|
ef4dc7a45b | ||
|
|
cb3e949772 | ||
|
|
f02de298c1 | ||
|
|
eb0dc13c88 | ||
|
|
d08bd23c1e | ||
|
|
724f1fea2c | ||
|
|
dcc63e6dfc | ||
|
|
576034e94a | ||
|
|
3ec49ba7bd | ||
|
|
60c687238d | ||
|
|
57b992ffa1 | ||
|
|
1f07a41d5a | ||
|
|
512b47c004 | ||
|
|
818ffbc4b0 | ||
|
|
5e65df7375 | ||
|
|
4eb80d14a0 | ||
|
|
7247a61e0b | ||
|
|
c856f28e11 | ||
|
|
ca30cfd341 | ||
|
|
58ecf1f363 | ||
|
|
d36ff82999 | ||
|
|
d4398aea89 | ||
|
|
672548ce30 | ||
|
|
344965bd29 | ||
|
|
d6a96f07c1 | ||
|
|
6a99d95d4f | ||
|
|
3f1bd3bb66 | ||
|
|
0fbc4edd29 | ||
|
|
b8a9f0d1d3 | ||
|
|
d280e5b1fa | ||
|
|
e04acab0ed | ||
|
|
d868ce5ec7 | ||
|
|
dec58c349e | ||
|
|
d82f5e1f49 | ||
|
|
156450f359 | ||
|
|
c0392efa39 | ||
|
|
3c5644ccfd | ||
|
|
3fb356ebd2 | ||
|
|
fe68ec513d | ||
|
|
a86fb8b091 | ||
|
|
f32bff9688 | ||
|
|
7d355b0fec | ||
|
|
ab4445c261 | ||
|
|
e14363373b | ||
|
|
d9ca409978 | ||
|
|
13596f18da | ||
|
|
80b66da1d8 | ||
|
|
3eb9af9c97 | ||
|
|
f093d0bfd4 | ||
|
|
6a2f4fd376 | ||
|
|
e2f92e4079 | ||
|
|
c944f23d7e | ||
|
|
5872f8a21b | ||
|
|
a090a1ffe8 | ||
|
|
5e24f74fde | ||
|
|
340da73bb7 | ||
|
|
f642019bcc | ||
|
|
7cc542352e | ||
|
|
cf99ea019e | ||
|
|
15c22ec742 | ||
|
|
45ac847dc9 | ||
|
|
4a223c70f2 | ||
|
|
26d636f234 | ||
|
|
aade05b01d | ||
|
|
c3821f0821 | ||
|
|
ac0ac48f6f | ||
|
|
54519b4465 | ||
|
|
9f2e406525 | ||
|
|
edaad2a927 | ||
|
|
262a827ab4 | ||
|
|
4b33d80595 | ||
|
|
4c401162c0 | ||
|
|
168acec5ea | ||
|
|
aab339d3e3 | ||
|
|
1f459af568 | ||
|
|
46f09a0adc | ||
|
|
f65003a14e | ||
|
|
e092b4024a | ||
|
|
9d7bab18a4 | ||
|
|
8688d47e3d | ||
|
|
04bb72c0dc | ||
|
|
1c065082d2 | ||
|
|
38642e6905 | ||
|
|
ebdf888a2f | ||
|
|
9745e4678a | ||
|
|
33a17df9fc | ||
|
|
4ff7aeff39 | ||
|
|
edb75870b5 | ||
|
|
a3c746846d | ||
|
|
4044accf03 | ||
|
|
943e7e7198 | ||
|
|
4f00cb6346 | ||
|
|
9d55086720 | ||
|
|
eaa2ef6ba4 | ||
|
|
37c3752b31 | ||
|
|
8585efadbe | ||
|
|
13648dd6f4 | ||
|
|
427dff3450 | ||
|
|
08bc0a947a | ||
|
|
c3d583fe9c | ||
|
|
983a72dab9 | ||
|
|
811152c08a | ||
|
|
6a1b9cf10a | ||
|
|
599b141b8a | ||
|
|
b9e47e356b | ||
|
|
5e2a477bbf | ||
|
|
bba34cb975 | ||
|
|
a674011c0d | ||
|
|
c78b5cd2ba | ||
|
|
f3e374ac77 | ||
|
|
1e6a9dbd56 | ||
|
|
564a2601f6 | ||
|
|
f4eb7e4907 | ||
|
|
c5a91199e3 | ||
|
|
144bddbf5b | ||
|
|
36ef451e6b | ||
|
|
1064e5b9cc | ||
|
|
d121ffa3f0 | ||
|
|
57f18c5f59 | ||
|
|
3b2a8777b1 | ||
|
|
89ead069f9 | ||
|
|
05de40cdeb | ||
|
|
a74103dba7 | ||
|
|
b4868c21bf | ||
|
|
8826028bdc | ||
|
|
09aa7f2010 | ||
|
|
e7d3638c6b | ||
|
|
68b0b4c268 | ||
|
|
caeb4470cd | ||
|
|
8b11ea73ac | ||
|
|
45e20a5044 | ||
|
|
105b30a805 | ||
|
|
70a7fc3e72 | ||
|
|
2d3774932b | ||
|
|
a5c1923d32 | ||
|
|
0348a8443e | ||
|
|
dba9616a5b | ||
|
|
44598496c5 | ||
|
|
2a6a28023b | ||
|
|
e581fa3fea | ||
|
|
0382659f4f | ||
|
|
e767a2b99d | ||
|
|
869f629746 | ||
|
|
7b8d09e62e | ||
|
|
5a8eee163b | ||
|
|
75a45158ad | ||
|
|
16c4074e47 | ||
|
|
2b92bc4c08 | ||
|
|
d0e2caf0ff | ||
|
|
d542138868 | ||
|
|
df133846b5 | ||
|
|
283e0bd5ea | ||
|
|
5ae3ec72b2 | ||
|
|
d9e9f7185f | ||
|
|
532d87d281 | ||
|
|
8600296030 | ||
|
|
3908725d3b | ||
|
|
780133f825 | ||
|
|
82c8148983 | ||
|
|
c12c4af760 | ||
|
|
f595bce3c0 | ||
|
|
0768fbbb20 | ||
|
|
523d833eb3 | ||
|
|
3fc01e7520 | ||
|
|
9259370891 | ||
|
|
7b84e30471 | ||
|
|
9c2a0649f2 | ||
|
|
778292e771 | ||
|
|
c21e464856 | ||
|
|
a060dc22db | ||
|
|
66f0090989 | ||
|
|
5d10b925c8 | ||
|
|
7076d19c7f | ||
|
|
69199219bc | ||
|
|
f0116ee79c | ||
|
|
4ad5e29f2f | ||
|
|
a0d3e3a1a8 | ||
|
|
1261105fe2 | ||
|
|
31866fbfa4 | ||
|
|
e179b7a9ac | ||
|
|
5e4577d76b | ||
|
|
496c257bf2 | ||
|
|
0028f166aa | ||
|
|
97047896ab | ||
|
|
94fcd8dc18 | ||
|
|
afdecb4a57 | ||
|
|
e5f9279295 | ||
|
|
55f0b001d1 | ||
|
|
5f768dd52d | ||
|
|
0daa7ba0b5 | ||
|
|
e748fff347 | ||
|
|
d81c423429 | ||
|
|
c993ad89c5 | ||
|
|
398f9ceac8 | ||
|
|
f0d8bc02a7 | ||
|
|
aba46da2d0 | ||
|
|
ddfe2bf59b |
13
.gitignore
vendored
13
.gitignore
vendored
@@ -3,7 +3,7 @@
|
||||
#
|
||||
*.o
|
||||
*.a
|
||||
*.d
|
||||
*.o.d
|
||||
|
||||
#
|
||||
# Ignore generated executables and other generated files
|
||||
@@ -46,6 +46,7 @@ libutil/util_prg_example
|
||||
libutil/util_rec_example
|
||||
libutil/util_scandir_example
|
||||
libzds/libzds.a
|
||||
libvmcp/vmcp_example
|
||||
mon_tools/mon_fsstatd
|
||||
mon_tools/mon_procd
|
||||
osasnmpd/osasnmpd
|
||||
@@ -67,6 +68,7 @@ zconf/qeth/lsqeth
|
||||
zconf/scm/lsscm
|
||||
zconf/zcrypt/chzcrypt
|
||||
zconf/zcrypt/lszcrypt
|
||||
zconf/zcrypt/zcryptctl
|
||||
zdev/src/chzdev
|
||||
zdev/src/chzdev_usage.c
|
||||
zdev/src/lszdev
|
||||
@@ -75,7 +77,8 @@ zdsfs/zdsfs
|
||||
zdump/zgetdump
|
||||
zfcpdump/cpioinit
|
||||
zfcpdump/zfcpdump_part
|
||||
zfcpdump/zfcpdump_part.rd
|
||||
zfcpdump/zfcpdump-initrd
|
||||
zfcpdump/10-zfcpdump.install
|
||||
ziomon/ziomon_mgr
|
||||
ziomon/ziomon_util
|
||||
ziomon/ziomon_zfcpdd
|
||||
@@ -86,4 +89,10 @@ zipl/boot/*.exec
|
||||
zipl/boot/data.h
|
||||
zipl/src/chreipl_helper.device-mapper
|
||||
zipl/src/zipl
|
||||
zipl/src/zipl_helper.device-mapper
|
||||
zkey/zkey
|
||||
zkey/zkey-cryptsetup
|
||||
zkey/check-dep-zkey
|
||||
zkey/check-dep-zkey-cryptsetup
|
||||
zkey/detect-libcryptsetup.dep
|
||||
zpcictl/zpcictl
|
||||
|
||||
14
AUTHORS.md
14
AUTHORS.md
@@ -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
|
||||
- Dan Horak
|
||||
- Despina Papadopoulou
|
||||
- Dimitri John Ledkov
|
||||
- Eberhard Pasch
|
||||
- Einar Lueck
|
||||
- Eric Sandeen
|
||||
- Erwin Vicari
|
||||
- Eugene Crosser
|
||||
- Eugene 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
|
||||
@@ -41,6 +47,7 @@ List of all individuals having contributed content to s390-tools
|
||||
- Jan Glauber
|
||||
- Jan Hoeppner
|
||||
- Jan Willeke
|
||||
- Javier Martinez Canillas
|
||||
- Jean-Baptiste Joret
|
||||
- Jens Remus
|
||||
- Jochen Roehrig
|
||||
@@ -64,6 +71,8 @@ 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
|
||||
@@ -90,6 +99,7 @@ List of all individuals having contributed content to s390-tools
|
||||
- Thomas Weber
|
||||
- Ursula Braun
|
||||
- Utz Bacher
|
||||
- Vasily Gorbik
|
||||
- Viktor Mihajlovski
|
||||
- Volker Sameske
|
||||
- Wolfgang Taphorn
|
||||
|
||||
134
CHANGELOG.md
134
CHANGELOG.md
@@ -1,8 +1,142 @@
|
||||
Release history for s390-tools (MIT version)
|
||||
--------------------------------------------
|
||||
* __v2.7.1 (2018-12-13)__
|
||||
|
||||
For Linux kernel version: 4.19
|
||||
|
||||
Changes of existing tools:
|
||||
- zkey: Enhance file read/write error handling
|
||||
- cmsfs-fuse: Write more than a single line in linefeed mode
|
||||
- zpcictl: Add warning for unsupported operations
|
||||
- zipl: Use the BLS "title" field as the IPL section name
|
||||
|
||||
Bug Fixes:
|
||||
- cmsfs-fuse: Fix iconv buffer aliasing
|
||||
- cmsfs-fuse: Fix memory leak in cmsfs_rename()
|
||||
- fdasd: Fix possible integer overflow
|
||||
- fdasd: Fix resource leak in fdasd_parse_conffile()
|
||||
- zdev: Fix memory leak in misc_readlink()
|
||||
- dasdinfo: Display error messages on stderr
|
||||
- zkey: Include /sbin into PATH when executing commands
|
||||
- Makefile: Fix parallel build
|
||||
- GCC8 warning fixes across the board for:
|
||||
cmsfs-fuse, dasdinfo, dasdview, dump2tar, fdasd, hmcdrvfs, hyptop,
|
||||
ip_watcher, libvmdump, libvtoc, lsqeth, lszcrypt, qethqoat, zdev, zdsfs,
|
||||
zgetdump, zipl, zpcictl
|
||||
|
||||
* __v2.7.0 (2018-10-31)__
|
||||
|
||||
For Linux kernel version: 4.19
|
||||
|
||||
Add new tool:
|
||||
- zcryptctl: Add zcryptctl for multiple zcrypt node management
|
||||
- zpcictl: Add zpcictl for reporting defective PCI devices
|
||||
|
||||
Changes of existing tools:
|
||||
- qethqoat: Add OSA-Express7S support
|
||||
- lszcrypt: Add support for alternative zcrypt device drivers
|
||||
- zfcpdump: Add install script for zfcpdump
|
||||
- zipl: Make zipl work with XFS by using the FIEMAP mapping ioctl
|
||||
|
||||
Bug Fixes:
|
||||
- lstape: Fix output with SCSI lin_tape and multiple paths to same unit
|
||||
- lstape: Fix output without SCSI generic (sg)
|
||||
- lsluns: Fix to prevent error messages if there are non-zfcp SCSI devices
|
||||
- lstape: Fix to prevent error messages if there are non-zfcp SCSI devices
|
||||
- lstape: Fix description of --type and <devbusid> filter for channel tapes
|
||||
- lstape: Fix SCSI output description in man page
|
||||
- lstape: Fix SCSI HBA CCW device bus-ID e.g. for virtio-scsi-ccw
|
||||
- Direct --help and --version output to stdout for several tools
|
||||
- osasnmpd: Start without real OSA devices
|
||||
|
||||
* __v2.6.0 (2018-08-10)__
|
||||
|
||||
For Linux kernel version: 4.18
|
||||
|
||||
Add new tool:
|
||||
- zkey: Add zkey-cryptsetup tool
|
||||
Changes of existing tools:
|
||||
- netboot: add BOOTIF support
|
||||
|
||||
Bug Fixes:
|
||||
- mon_procd: fix parsing of /proc/<pid>/stat
|
||||
- netboot: Include compressed kernel modules in initramfs
|
||||
- netboot: Send client architecture and handle path prefix
|
||||
|
||||
* __v2.5.0 (2018-06-08)__
|
||||
|
||||
For Linux kernel version: 4.17
|
||||
|
||||
Changes of existing tools:
|
||||
- zdev: Add support for reading firmware configuration files
|
||||
- zipl: Add BootLoaderSpec support
|
||||
- scripts: Add script to switch zipl config to a BootLoaderSpec setup
|
||||
|
||||
Bug Fixes:
|
||||
- lsluns: Print a message if no adapter or port exists
|
||||
|
||||
* __v2.4.0 (2018-05-07)__
|
||||
|
||||
For Linux kernel version: 4.16
|
||||
|
||||
Changes of existing tools:
|
||||
- dbginfo: Gather nvme related data
|
||||
- zipl: Rewrite helper script in C
|
||||
- libutil: Add function util_strstrip
|
||||
- libvmcp: Introduce libvmcp
|
||||
- zipl: Extend DASD stand-alone dumpers to drop zero pages
|
||||
- zgetdump: Add verbose option
|
||||
- zgetdump: Add 'Dump file size' field for zgetdump -i output
|
||||
- cpumf: Add IBM z14 ZR1 to the CPU Measurement Facility model list
|
||||
- zkey: Add build dependency to OpenSSL (libcrypto)
|
||||
- zkey: Add keystore implementation
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
- hmcdrvfs: fix parsing of link count >= 1000
|
||||
- zgetdump: Avoid Segfault on processing dumps with memory limit
|
||||
- chreipl: correct fcp reipl sysfs write sequence
|
||||
- udev: Replace WAIT_FOR with TEST keyword
|
||||
|
||||
* __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
47
CODINGSTYLE.md
Normal 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 |
|
||||
218
CONTRIBUTING.md
218
CONTRIBUTING.md
@@ -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
|
||||
```
|
||||
|
||||
4
Makefile
4
Makefile
@@ -3,12 +3,12 @@ ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/ar
|
||||
# Include common definitions
|
||||
include common.mak
|
||||
|
||||
LIB_DIRS = libvtoc libu2s libutil libzds libdasd libvmdump libccw
|
||||
LIB_DIRS = libvtoc libu2s libutil libzds libdasd libvmdump libccw libvmcp
|
||||
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 zpcictl
|
||||
SUB_DIRS = $(LIB_DIRS) $(TOOL_DIRS)
|
||||
|
||||
all: $(TOOL_DIRS)
|
||||
|
||||
43
README.md
43
README.md
@@ -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,19 +256,24 @@ 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 |
|
||||
| openssl | `HAVE_OPENSSL` | zkey |
|
||||
| cryptsetup | `HAVE_CRYPTSETUP2` | zkey-cryptsetup |
|
||||
| json-c | `HAVE_JSONC` | zkey-cryptsetup |
|
||||
|
||||
This table lists additional build or install options:
|
||||
|
||||
| __COMPONENT__ | __OPTION__ | __TOOLS__ |
|
||||
|----------------|:----------------:|:-------------------------------:|
|
||||
| dracut | `HAVE_DRACUT` | zdev |
|
||||
| initramfs-tools| `HAVE_INITRAMFS` | zdev |
|
||||
|
||||
The s390-tools build process uses "pkg-config" if available and hard-coded
|
||||
compiler and linker options otherwise.
|
||||
@@ -286,9 +291,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:
|
||||
@@ -365,3 +370,15 @@ the different tools are provided:
|
||||
For running znetconf these programs are required:
|
||||
- modprobe (kmod)
|
||||
- vmcp (s390-tools)
|
||||
|
||||
* zkey:
|
||||
For building the zkey tools you need openssl version 0.9.7 or newer installed
|
||||
(openssl-devel.rpm). Also required are cryptsetup version 2.0.3 or newer
|
||||
(cryptsetup-devel.rpm), and json-c version 0.12 or newer (json-c-devel.rpm).
|
||||
Tip: you may skip the zkey build by adding `HAVE_OPENSSL=0`, and you may
|
||||
may skip the zkey-cryptsetup build by adding `HAVE_CRYPTSETUP2=0`, or
|
||||
`HAVE_JSONC=0` to the make invocation.
|
||||
A new group 'zkeyadm' needs to be created and all users intending to use the
|
||||
tool must be added to this group. The owner of the default key repository
|
||||
'/etc/zkey/repository' must be set to group 'zkeyadm' with write permission
|
||||
for this group.
|
||||
|
||||
@@ -165,7 +165,7 @@ cmsfs-fuse uses a configuration file for automatic translation based on the file
|
||||
Upon startup, cmsfs-fuse evaluates the file .cmsfs-fuse/filetypes.conf in the user's home directory. If the file does not
|
||||
exist cmsfs-fuse evaluates the file /etc/cmsfs-fuse/filetypes.conf.
|
||||
|
||||
The filetypes.conf file contains the CMS file types that are automaticaly translated to ASCII if cmsfs-fuse is started
|
||||
The filetypes.conf file contains the CMS file types that are automatically translated to ASCII if cmsfs-fuse is started
|
||||
with the -t option. The syntax of the configuration file is one file type per line. Lines that start with a # followed by a space are treated as
|
||||
comments and are ignored. The file type is 8 characters long and must consist of valid CMS file name characters only.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Main function
|
||||
*
|
||||
* Copyright IBM Corp. 2010, 2017
|
||||
* Copyright IBM Corp. 2010, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <fuse.h>
|
||||
#include <fuse_opt.h>
|
||||
#include <iconv.h>
|
||||
#include <limits.h>
|
||||
#include <linux/fs.h>
|
||||
#ifdef HAVE_SETXATTR
|
||||
#include <linux/xattr.h>
|
||||
@@ -36,6 +37,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_base.h"
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_list.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
@@ -76,7 +78,7 @@ static const struct fuse_opt cmsfs_opts[] = {
|
||||
|
||||
static void usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(stdout,
|
||||
"Usage: %s DEVICE MOUNTPOINT [OPTIONS]\n"
|
||||
"\n"
|
||||
"Use the cmsfs-fuse command to read and write files stored on a z/VM CMS disk.\n"
|
||||
@@ -232,6 +234,8 @@ struct file {
|
||||
int null_records;
|
||||
/* write cache for text mode */
|
||||
char *wcache;
|
||||
/* buffer for iconv */
|
||||
char *iconv_buf;
|
||||
/* used bytes in write cache */
|
||||
int wcache_used;
|
||||
/* committed written bytes to FUSE */
|
||||
@@ -601,7 +605,7 @@ static struct file *file_open(const char *name)
|
||||
char uc_name[MAX_FNAME];
|
||||
struct file *f;
|
||||
|
||||
strncpy(uc_name, name, MAX_FNAME);
|
||||
util_strlcpy(uc_name, name, MAX_FNAME);
|
||||
str_toupper(uc_name);
|
||||
|
||||
util_list_iterate(&open_file_list, f)
|
||||
@@ -923,7 +927,6 @@ static void set_record(struct file *f, int *record, off_t addr, int len,
|
||||
static void add_record_ext(struct record *rec, struct record_ext *ext)
|
||||
{
|
||||
struct record_ext *tmp;
|
||||
int i = 0;
|
||||
|
||||
if (rec->ext == NULL) {
|
||||
rec->ext = ext;
|
||||
@@ -931,9 +934,7 @@ static void add_record_ext(struct record *rec, struct record_ext *ext)
|
||||
ext->next = NULL;
|
||||
} else {
|
||||
tmp = rec->ext;
|
||||
i++;
|
||||
while (tmp->next != NULL) {
|
||||
i++;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
tmp->next = ext;
|
||||
@@ -1567,7 +1568,7 @@ static off_t lookup_file(const char *name, struct fst_entry *fst, int flag)
|
||||
off_t faddr = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(uc_name, name, MAX_FNAME);
|
||||
util_strlcpy(uc_name, name, MAX_FNAME);
|
||||
str_toupper(uc_name);
|
||||
|
||||
if (flag == HIDE_UNLINKED && file_unlinked(uc_name))
|
||||
@@ -1851,7 +1852,26 @@ static int cmsfs_open(const char *path, struct fuse_file_info *fi)
|
||||
if (f->wcache == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
strncpy(f->path, path, MAX_FNAME + 1);
|
||||
/*
|
||||
* For fixed-length records f->fst->record_len contains
|
||||
* the fixed record length, which will not change. For
|
||||
* variable-length records it contains the (current) maximum
|
||||
* record length, which could be increased later by appending
|
||||
* new records, so use MAX_RECORD_LEN for the iconv buffer.
|
||||
* The MAX_RECORD_LEN is not valid for fixed-length records,
|
||||
* only for variable-length records, so use the actual record
|
||||
* length (f->fst->record_len) for fixed-length records.
|
||||
*/
|
||||
if (f->fst->record_format == RECORD_LEN_FIXED)
|
||||
f->iconv_buf = malloc(f->fst->record_len + 1);
|
||||
else
|
||||
f->iconv_buf = malloc(MAX_RECORD_LEN + 1);
|
||||
if (f->iconv_buf == NULL) {
|
||||
destroy_file_object(f);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
util_strlcpy(f->path, path, MAX_FNAME + 1);
|
||||
str_toupper(f->path);
|
||||
|
||||
f->use_count = 1;
|
||||
@@ -2108,7 +2128,7 @@ static int cmsfs_create(const char *path, mode_t mode,
|
||||
return rc;
|
||||
|
||||
/* force uppercase */
|
||||
strncpy(uc_name, path + 1, MAX_FNAME);
|
||||
util_strlcpy(uc_name, path + 1, MAX_FNAME);
|
||||
str_toupper(uc_name);
|
||||
|
||||
rc = encode_edf_name(uc_name, fname, ftype);
|
||||
@@ -2550,14 +2570,13 @@ static void get_block_data_from_record(struct record *rec, off_t offset,
|
||||
}
|
||||
}
|
||||
|
||||
static int convert_text(iconv_t conv, char *buf, int size)
|
||||
static int convert_text(iconv_t conv, char *in_buf, char *out_buf, int size)
|
||||
{
|
||||
size_t out_count = size;
|
||||
size_t in_count = size;
|
||||
char *data_ptr = buf;
|
||||
int rc;
|
||||
|
||||
rc = iconv(conv, &data_ptr, &in_count, &data_ptr, &out_count);
|
||||
rc = iconv(conv, &in_buf, &in_count, &out_buf, &out_count);
|
||||
if ((rc == -1) || (in_count != 0)) {
|
||||
DEBUG("Code page translation EBCDIC-ASCII failed\n");
|
||||
return -EIO;
|
||||
@@ -2618,14 +2637,15 @@ static int cmsfs_read(const char *path, char *buf, size_t size, off_t offset,
|
||||
/* read one record */
|
||||
if (addr == NULL_BLOCK)
|
||||
memset(buf, 0, chunk);
|
||||
else {
|
||||
rc = _read(buf, chunk, addr);
|
||||
else if (f->translate) {
|
||||
rc = _read(f->iconv_buf, chunk, addr);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (f->translate) {
|
||||
rc = convert_text(cmsfs.iconv_from, buf, chunk);
|
||||
rc = convert_text(cmsfs.iconv_from, f->iconv_buf, buf, chunk);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
} else {
|
||||
rc = _read(buf, chunk, addr);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
}
|
||||
@@ -2757,7 +2777,7 @@ static int delete_file(const char *path)
|
||||
fst_last = find_last_fdir_entry(cmsfs.fdir, cmsfs.dir_levels);
|
||||
|
||||
/* remove unlinked file from fcache */
|
||||
strncpy(file, path + 1, MAX_FNAME);
|
||||
util_strlcpy(file, path + 1, MAX_FNAME);
|
||||
str_toupper(file);
|
||||
invalidate_htab_entry(file);
|
||||
|
||||
@@ -2841,20 +2861,21 @@ static int cmsfs_rename(const char *path, const char *new_path)
|
||||
str_toupper(uc_new_name);
|
||||
|
||||
rc = encode_edf_name(uc_new_name, fname, ftype);
|
||||
free(uc_new_name);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
memcpy(&fst.name[0], fname, 8);
|
||||
memcpy(&fst.type[0], ftype, 8);
|
||||
|
||||
strncpy(uc_old_name, path + 1, MAX_FNAME);
|
||||
util_strlcpy(uc_old_name, path + 1, MAX_FNAME);
|
||||
str_toupper(uc_old_name);
|
||||
invalidate_htab_entry(uc_old_name);
|
||||
|
||||
/* update name in file object if the file is opened */
|
||||
f = file_open(uc_old_name);
|
||||
if (f != NULL) {
|
||||
strncpy(f->path, new_path, MAX_FNAME + 1);
|
||||
util_strlcpy(f->path, new_path, MAX_FNAME + 1);
|
||||
str_toupper(f->path);
|
||||
memcpy(f->fst->name, fname, 8);
|
||||
memcpy(f->fst->type, ftype, 8);
|
||||
@@ -3743,7 +3764,7 @@ static int extend_block_variable(struct file *f, const char *buf, int len,
|
||||
}
|
||||
|
||||
DEBUG("%s: wrote %d record bytes\n", __func__, rlen);
|
||||
if (size <= 0)
|
||||
if (size == 0)
|
||||
return copied;
|
||||
}
|
||||
|
||||
@@ -4167,22 +4188,13 @@ static ssize_t find_newline(const char *buf, int len)
|
||||
return pos - buf;
|
||||
}
|
||||
|
||||
static int cmsfs_write(const char *path, const char *buf, size_t size,
|
||||
off_t offset, struct fuse_file_info *fi)
|
||||
static int cmsfs_write_strings(struct file *f, const char *buf,
|
||||
size_t size, off_t offset)
|
||||
{
|
||||
int scan_len = MIN(size, (size_t)MAX_RECORD_LEN + 1);
|
||||
int rc, nl_byte = 1, null_record = 0, pad = 0;
|
||||
struct file *f = get_fobj(fi);
|
||||
ssize_t rsize;
|
||||
|
||||
(void) path;
|
||||
|
||||
if (cmsfs.readonly)
|
||||
return -EROFS;
|
||||
|
||||
if (!f->linefeed)
|
||||
return do_write(f, buf, size, offset);
|
||||
|
||||
/* remove already committed bytes */
|
||||
offset -= f->wcache_commited;
|
||||
|
||||
@@ -4222,7 +4234,7 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
|
||||
}
|
||||
|
||||
/* translate */
|
||||
rc = convert_text(cmsfs.iconv_to, f->wcache, f->wcache_used);
|
||||
rc = convert_text(cmsfs.iconv_to, f->wcache, f->iconv_buf, f->wcache_used);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
@@ -4232,6 +4244,7 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
|
||||
*/
|
||||
if (!f->wcache_used) {
|
||||
*f->wcache = FILLER_EBCDIC;
|
||||
*f->iconv_buf = FILLER_EBCDIC;
|
||||
f->wcache_used = 1;
|
||||
nl_byte = 0;
|
||||
null_record = 1;
|
||||
@@ -4242,7 +4255,7 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
|
||||
offset += f->pad_bytes;
|
||||
BUG(offset < 0);
|
||||
|
||||
rc = do_write(f, f->wcache, f->wcache_used, offset);
|
||||
rc = do_write(f, f->iconv_buf, f->wcache_used, offset);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
@@ -4257,6 +4270,36 @@ static int cmsfs_write(const char *path, const char *buf, size_t size,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cmsfs_write(const char *path, const char *buf, size_t size,
|
||||
off_t offset, struct fuse_file_info *fi)
|
||||
{
|
||||
struct file *f = get_fobj(fi);
|
||||
int rc, written, nbytes;
|
||||
|
||||
(void) path;
|
||||
|
||||
if (cmsfs.readonly)
|
||||
return -EROFS;
|
||||
|
||||
if (!f->linefeed)
|
||||
return do_write(f, buf, size, offset);
|
||||
|
||||
/* Limit the size to what we can report back as written */
|
||||
nbytes = MIN(size, (size_t) INT_MAX);
|
||||
|
||||
written = 0;
|
||||
while (nbytes) {
|
||||
rc = cmsfs_write_strings(f, buf, nbytes, offset);
|
||||
if (rc < 0)
|
||||
return written ? written : rc;
|
||||
written += rc;
|
||||
offset += rc;
|
||||
buf += rc;
|
||||
nbytes -= rc;
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
static int cmsfs_unlink(const char *path)
|
||||
{
|
||||
struct fst_entry fst;
|
||||
@@ -4284,7 +4327,7 @@ static int flush_wcache(struct file *f)
|
||||
int rc;
|
||||
|
||||
/* translate */
|
||||
rc = convert_text(cmsfs.iconv_to, f->wcache, f->wcache_used);
|
||||
rc = convert_text(cmsfs.iconv_to, f->wcache, f->iconv_buf, f->wcache_used);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
@@ -4292,7 +4335,7 @@ static int flush_wcache(struct file *f)
|
||||
offset -= (f->fst->nr_records - f->null_records);
|
||||
BUG(offset < 0);
|
||||
|
||||
rc = do_write(f, f->wcache, f->wcache_used, offset);
|
||||
rc = do_write(f, f->iconv_buf, f->wcache_used, offset);
|
||||
purge_wcache(f);
|
||||
f->null_records = 0;
|
||||
if (rc < 0)
|
||||
@@ -4415,6 +4458,7 @@ static void destroy_file_object(struct file *f)
|
||||
struct record *rec;
|
||||
int i;
|
||||
|
||||
free(f->iconv_buf);
|
||||
free(f->wcache);
|
||||
free(f->wstate);
|
||||
|
||||
@@ -4498,14 +4542,23 @@ static int cmsfs_process_args(void *data, const char *arg, int key,
|
||||
return 1;
|
||||
case KEY_HELP:
|
||||
usage(outargs->argv[0]);
|
||||
|
||||
/*
|
||||
* Usage output needs to go to stdout to be consistent with
|
||||
* coding guidelines. FUSE versions before 3.0.0 print help
|
||||
* output to stderr. Redirect stderr to stdout here to enforce
|
||||
* consistent behavior.
|
||||
*/
|
||||
fflush(stderr);
|
||||
dup2(STDOUT_FILENO, STDERR_FILENO);
|
||||
|
||||
fuse_opt_add_arg(outargs, "-ho");
|
||||
cmsfs_fuse_main(outargs, &cmsfs_oper);
|
||||
exit(0);
|
||||
case KEY_VERSION:
|
||||
fprintf(stderr, COMP "FUSE file system for CMS disks "
|
||||
fprintf(stdout, COMP "FUSE file system for CMS disks "
|
||||
"program version %s\n", RELEASE_STRING);
|
||||
fprintf(stderr, "Copyright IBM Corp. 2010, 2017\n");
|
||||
fuse_opt_add_arg(outargs, "--version");
|
||||
fprintf(stdout, "Copyright IBM Corp. 2010, 2017\n");
|
||||
exit(0);
|
||||
|
||||
default:
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "cmsfs-fuse.h"
|
||||
@@ -65,7 +66,7 @@ static void add_filetype(char *name, struct util_list *list)
|
||||
entry = malloc(sizeof(*entry));
|
||||
if (entry == NULL)
|
||||
DIE_PERROR("malloc failed");
|
||||
strncpy(entry->name, name, MAX_TYPE_LEN);
|
||||
util_strlcpy(entry->name, name, MAX_TYPE_LEN);
|
||||
util_list_add_head(list, entry);
|
||||
}
|
||||
|
||||
|
||||
39
common.mak
39
common.mak
@@ -5,8 +5,8 @@ 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
|
||||
PATCHLEVEL = 0
|
||||
RELEASE = 7
|
||||
PATCHLEVEL = 1
|
||||
DISTRELEASE = build-$(shell date +%Y%m%d)
|
||||
S390_TOOLS_RELEASE = $(VERSION).$(RELEASE).$(PATCHLEVEL)-$(DISTRELEASE)
|
||||
export S390_TOOLS_RELEASE
|
||||
@@ -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,22 +168,24 @@ 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)
|
||||
export INSTALLDIR BINDIR LIBDIR MANDIR OWNER GROUP
|
||||
|
||||
# Special defines for zfcpdump
|
||||
ZFCPDUMP_PART_IMAGE = zfcpdump_part.image
|
||||
ZFCPDUMP_PART_RD = zfcpdump_part.rd
|
||||
export ZFCPDUMP_DIR ZFCPDUMP_PART_IMAGE ZFCPDUMP_PART_RD
|
||||
ZFCPDUMP_IMAGE = zfcpdump-image
|
||||
ZFCPDUMP_INITRD = zfcpdump-initrd
|
||||
ZFCPDUMP_FLAVOR = zfcpdump
|
||||
export ZFCPDUMP_DIR ZFCPDUMP_IMAGE ZFCPDUMP_INITRD ZFCPDUMP_FLAVOR
|
||||
|
||||
CFLAGS ?= $(DEFAULT_CFLAGS) $(OPT_FLAGS)
|
||||
HOSTCFLAGS ?= $(DEFAULT_CFLAGS) $(OPT_FLAGS)
|
||||
@@ -193,12 +196,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,18 +219,28 @@ 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 $@
|
||||
|
||||
%: %.o
|
||||
$(LINK) $(ALL_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
|
||||
%.a:
|
||||
$(AR) rcs $@ $^
|
||||
@@ -324,6 +339,10 @@ $(rootdir)/libvmdump/libvmdump.a: $(rootdir)/libvmdump
|
||||
$(MAKE) -C $(rootdir)/libvmdump/ libvmdump.a
|
||||
.PHONY: $(rootdir)/libvmdump
|
||||
|
||||
$(rootdir)/libvmcp/libvmcp.a: $(rootdir)/libvmcp
|
||||
$(MAKE) -C $(rootdir)/libvmcp/ libvmcp.a
|
||||
.PHONY: $(rootdir)/libvmcp
|
||||
|
||||
$(rootdir)/zipl/boot/data.o:
|
||||
$(MAKE) -C $(rootdir)/zipl/boot/ data.o
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
54
cpumf/bin/cpumf_helper.in
Normal file → Executable file
54
cpumf/bin/cpumf_helper.in
Normal file → Executable file
@@ -172,7 +172,7 @@ sub cpumf_parse_ctrdef($;$)
|
||||
|
||||
# Parse short description (optional)
|
||||
if ($line =~ m/^Short-Description:\s*(\S.*)?$/) {
|
||||
$h->{ctr}->{shortdesc} = $1 || "";
|
||||
$h->{$ctr}->{shortdesc} = $1 || "";
|
||||
|
||||
# Parse start of counter description
|
||||
} elsif ($line =~ m/^Description:\s*(\S.*)?$/) {
|
||||
@@ -210,6 +210,8 @@ my $system_z_hwtype_map = {
|
||||
2828 => 'IBM zEnterprise BC12',
|
||||
2964 => 'IBM z13',
|
||||
2965 => 'IBM z13s',
|
||||
3906 => 'IBM z14',
|
||||
3907 => 'IBM z14 ZR1',
|
||||
};
|
||||
|
||||
sub get_hardware_type()
|
||||
@@ -228,6 +230,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 +260,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 +356,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 +461,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>
|
||||
|
||||
|
||||
60
cpumf/data/cpum-cf-cfvn-1.ctr
Normal file
60
cpumf/data/cpum-cf-cfvn-1.ctr
Normal file
@@ -0,0 +1,60 @@
|
||||
Counter: 0 Name:CPU_CYCLES
|
||||
Short-Description:CPU Cycles
|
||||
Description:
|
||||
Cycle Count
|
||||
.
|
||||
Counter: 1 Name:INSTRUCTIONS
|
||||
Short-Description:Instructions
|
||||
Description:
|
||||
Instruction Count
|
||||
.
|
||||
Counter: 2 Name:L1I_DIR_WRITES
|
||||
Short-Description:L1I Directory Writes
|
||||
Description:
|
||||
Level-1 I-Cache Directory Write Count
|
||||
.
|
||||
Counter: 3 Name:L1I_PENALTY_CYCLES
|
||||
Short-Description:L1I Penalty Cycles
|
||||
Description:
|
||||
Level-1 I-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 4 Name:L1D_DIR_WRITES
|
||||
Short-Description:L1D Directory Writes
|
||||
Description:
|
||||
Level-1 D-Cache Directory Write Count
|
||||
.
|
||||
Counter: 5 Name:L1D_PENALTY_CYCLES
|
||||
Short-Description:L1D Penalty Cycles
|
||||
Description:
|
||||
Level-1 D-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
|
||||
Short-Description:Problem-State CPU Cycles
|
||||
Description:
|
||||
Problem-State Cycle Count
|
||||
.
|
||||
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
|
||||
Short-Description:Problem-State Instructions
|
||||
Description:
|
||||
Problem-State Instruction Count
|
||||
.
|
||||
Counter: 34 Name:PROBLEM_STATE_L1I_DIR_WRITES
|
||||
Short-Description:Problem-State L1I Directory Writes
|
||||
Description:
|
||||
Problem-State Level-1 I-Cache Directory Write Count
|
||||
.
|
||||
Counter: 35 Name:PROBLEM_STATE_L1I_PENALTY_CYCLES
|
||||
Short-Description:Problem-State L1I Penalty Cycles
|
||||
Description:
|
||||
Problem-State Level-1 I-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 36 Name:PROBLEM_STATE_L1D_DIR_WRITES
|
||||
Short-Description:Problem-State L1D Directory Writes
|
||||
Description:
|
||||
Problem-State Level-1 D-Cache Directory Write Count
|
||||
.
|
||||
Counter: 37 Name:PROBLEM_STATE_L1D_PENALTY_CYCLES
|
||||
Short-Description:Problem-State L1D Penalty Cycles
|
||||
Description:
|
||||
Problem-State Level-1 D-Cache Penalty Cycle Count
|
||||
.
|
||||
40
cpumf/data/cpum-cf-cfvn-3.ctr
Normal file
40
cpumf/data/cpum-cf-cfvn-3.ctr
Normal file
@@ -0,0 +1,40 @@
|
||||
Counter: 0 Name:CPU_CYCLES
|
||||
Short-Description:CPU Cycles
|
||||
Description:
|
||||
Cycle Count
|
||||
.
|
||||
Counter: 1 Name:INSTRUCTIONS
|
||||
Short-Description:Instructions
|
||||
Description:
|
||||
Instruction Count
|
||||
.
|
||||
Counter: 2 Name:L1I_DIR_WRITES
|
||||
Short-Description:L1I Directory Writes
|
||||
Description:
|
||||
Level-1 I-Cache Directory Write Count
|
||||
.
|
||||
Counter: 3 Name:L1I_PENALTY_CYCLES
|
||||
Short-Description:L1I Penalty Cycles
|
||||
Description:
|
||||
Level-1 I-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 4 Name:L1D_DIR_WRITES
|
||||
Short-Description:L1D Directory Writes
|
||||
Description:
|
||||
Level-1 D-Cache Directory Write Count
|
||||
.
|
||||
Counter: 5 Name:L1D_PENALTY_CYCLES
|
||||
Short-Description:L1D Penalty Cycles
|
||||
Description:
|
||||
Level-1 D-Cache Penalty Cycle Count
|
||||
.
|
||||
Counter: 32 Name:PROBLEM_STATE_CPU_CYCLES
|
||||
Short-Description:Problem-State CPU Cycles
|
||||
Description:
|
||||
Problem-State Cycle Count
|
||||
.
|
||||
Counter: 33 Name:PROBLEM_STATE_INSTRUCTIONS
|
||||
Short-Description:Problem-State Instructions
|
||||
Description:
|
||||
Problem-State Instruction Count
|
||||
.
|
||||
@@ -1,130 +1,98 @@
|
||||
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
|
||||
Short-Description:PRNG Functions
|
||||
Description:
|
||||
Total number of the PRNG functions issued by the CPU
|
||||
.
|
||||
Counter: 65 Name:PRNG_CYCLES
|
||||
Short-Description:PRNG Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the DEA/AES coprocessor is busy
|
||||
performing PRNG functions issued by the CPU
|
||||
.
|
||||
Counter: 66 Name:PRNG_BLOCKED_FUNCTIONS
|
||||
Short-Description:PRNG Blocked Functions
|
||||
Description:
|
||||
Total number of the PRNG functions that are issued by the CPU and are
|
||||
blocked because the DEA/AES coprocessor is busy performing a function
|
||||
issued by another CPU
|
||||
.
|
||||
Counter: 67 Name:PRNG_BLOCKED_CYCLES
|
||||
Short-Description:PRNG Blocked Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the PRNG functions issued by
|
||||
the CPU because the DEA/AES coprocessor is busy performing a function
|
||||
issued by another CPU
|
||||
.
|
||||
Counter: 68 Name:SHA_FUNCTIONS
|
||||
Short-Description:SHA Functions
|
||||
Description:
|
||||
Total number of SHA functions issued by the CPU
|
||||
.
|
||||
Counter: 69 Name:SHA_CYCLES
|
||||
Short-Description:SHA Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the SHA coprocessor is busy performing
|
||||
the SHA functions issued by the CPU
|
||||
.
|
||||
Counter: 70 Name:SHA_BLOCKED_FUNCTIONS
|
||||
Short-Description:SHA Blocked Functions
|
||||
Description:
|
||||
Total number of the SHA functions that are issued by the CPU and are
|
||||
blocked because the SHA coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 71 Name:SHA_BLOCKED_CYCLES
|
||||
Short-Description:SHA Bloced Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the SHA functions issued by the
|
||||
CPU because the SHA coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 72 Name:DEA_FUNCTIONS
|
||||
Short-Description:DEA Functions
|
||||
Description:
|
||||
Total number of the DEA functions issued by the CPU
|
||||
.
|
||||
Counter: 73 Name:DEA_CYCLES
|
||||
Short-Description:DEA Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the DEA/AES coprocessor is busy
|
||||
performing the DEA functions issued by the CPU
|
||||
.
|
||||
Counter: 74 Name:DEA_BLOCKED_FUNCTIONS
|
||||
Short-Description:DEA Blocked Functions
|
||||
Description:
|
||||
Total number of the DEA functions that are issued by the CPU and are
|
||||
blocked because the DEA/AES coprocessor is busy performing a function
|
||||
issued by another CPU
|
||||
.
|
||||
Counter: 75 Name:DEA_BLOCKED_CYCLES
|
||||
Short-Description:DEA Blocked Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the DEA functions issued by the
|
||||
CPU because the DEA/AES coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 76 Name:AES_FUNCTIONS
|
||||
Short-Description:AES Functions
|
||||
Description:
|
||||
Total number of AES functions issued by the CPU
|
||||
.
|
||||
Counter: 77 Name:AES_CYCLES
|
||||
Short-Description:AES Cycles
|
||||
Description:
|
||||
Total number of CPU cycles when the DEA/AES coprocessor is busy
|
||||
performing the AES functions issued by the CPU
|
||||
.
|
||||
Counter: 78 Name:AES_BLOCKED_FUNCTIONS
|
||||
Short-Description:AES Blocked Functions
|
||||
Description:
|
||||
Total number of AES functions that are issued by the CPU and are blocked
|
||||
because the DEA/AES coprocessor is busy performing a function issued
|
||||
by another CPU
|
||||
.
|
||||
Counter: 79 Name:AES_BLOCKED_CYCLES
|
||||
Short-Description:AES Blocked Cycles
|
||||
Description:
|
||||
Total number of CPU cycles blocked for the AES functions issued by the
|
||||
CPU because the DEA/AES coprocessor is busy performing a function issued
|
||||
@@ -1,96 +1,114 @@
|
||||
Counter: 128 Name:L1I_L2_SOURCED_WRITES
|
||||
Short-Description:L1I L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from the Level-2 (L1.5) cache
|
||||
.
|
||||
Counter: 129 Name:L1D_L2_SOURCED_WRITES
|
||||
Short-Description:L1D L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installed
|
||||
cache line was sourced from the Level-2 (L1.5) cache
|
||||
.
|
||||
Counter: 130 Name:L1I_L3_LOCAL_WRITES
|
||||
Short-Description:L1I L3 Local Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the installed
|
||||
cache line was sourced from the Level-3 cache that is on the same book
|
||||
as the Instruction cache (Local L2 cache)
|
||||
.
|
||||
Counter: 131 Name:L1D_L3_LOCAL_WRITES
|
||||
Short-Description:L1D L3 Local Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installtion
|
||||
cache line was source from the Level-3 cache that is on the same book
|
||||
as the Data cache (Local L2 cache)
|
||||
.
|
||||
Counter: 132 Name:L1I_L3_REMOTE_WRITES
|
||||
Short-Description:L1I L3 Remote Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the installed
|
||||
cache line was sourced from a Level-3 cache that is not on the same
|
||||
book as the Instruction cache (Remote L2 cache)
|
||||
.
|
||||
Counter: 133 Name:L1D_L3_REMOTE_WRITES
|
||||
Short-Description:L1D L3 Remote Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installed
|
||||
cache line was sourced from a Level-3 cache that is not on the same
|
||||
book as the Data cache (Remote L2 cache)
|
||||
.
|
||||
Counter: 134 Name:L1D_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1D Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the installed
|
||||
cache line was sourced from memory that is attached to the same book
|
||||
as the Data cache (Local Memory)
|
||||
.
|
||||
Counter: 135 Name:L1I_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1I Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache where the installed cache
|
||||
line was sourced from memory that is attached to the s ame book as the
|
||||
Instruction cahe (local Memory)
|
||||
Instruction cache (Local Memory)
|
||||
.
|
||||
Counter: 136 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-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: 137 Name:L1I_CACHELINE_INVALIDATES
|
||||
Short-Description:L1I Cacheline Invalidates
|
||||
Description:
|
||||
A cache line in the Level-1 I-Cache has been invalidated by a store on
|
||||
the same CPU as the Level-1 I-Cache
|
||||
.
|
||||
Counter: 138 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written into the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter: 139 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter: 140 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter: 141 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter: 142 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter: 145 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle an ITLB1 miss is in progress
|
||||
.
|
||||
Counter: 146 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
an DTLB1 miss is in progress
|
||||
.
|
||||
Counter: 147 Name:L2C_STORES_SENT
|
||||
Short-Description:L2C Stores Sent
|
||||
Description:
|
||||
Incremented by one for every store sent to Level-2 (L1.5) cache
|
||||
.
|
||||
|
||||
@@ -16,288 +16,343 @@
|
||||
#
|
||||
# Extended Counter Set
|
||||
# ---------------------------------------------------------------------
|
||||
Counter:128 Name:L1D_WRITES_RO_EXCL
|
||||
Counter:128 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
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:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter:130 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
a DTLB1 miss is in progress.
|
||||
.
|
||||
Counter:131 Name:DTLB1_HPAGE_WRITES
|
||||
Short-Description:DTLB1 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a one-megabyte page
|
||||
.
|
||||
Counter:132 Name:DTLB1_GPAGE_WRITES
|
||||
Short-Description:DTLB1 Two-Gigabyte Page Writes
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a two-gigabyte page.
|
||||
.
|
||||
Counter:133 Name:L1D_L2D_SOURCED_WRITES
|
||||
Short-Description: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:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter:135 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle an ITLB1 miss is in progress
|
||||
.
|
||||
Counter:136 Name:L1I_L2I_SOURCED_WRITES
|
||||
Short-Description: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
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter:138 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Combined Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter:139 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Combined Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter:140 Name:TX_C_TEND
|
||||
Short-Description:Completed TEND instructions in constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a constrained transactional-execution
|
||||
mode
|
||||
.
|
||||
Counter:141 Name:TX_NC_TEND
|
||||
Short-Description:Completed TEND instructions in non-constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:143 Name:L1C_TLB1_MISSES
|
||||
Short-Description:L1C TLB1 Misses
|
||||
Description:
|
||||
Increments by one for any cycle where a Level-1 cache or Level-1 TLB miss
|
||||
is in progress.
|
||||
.
|
||||
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip 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_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
|
||||
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:146 Name:L1D_ONNODE_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Node L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Node Level-4 cache
|
||||
.
|
||||
Counter:147 Name:L1D_ONNODE_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Node L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Node Level-3 cache with intervention
|
||||
.
|
||||
Counter:148 Name:L1D_ONNODE_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Node L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Node Level-3 cache without intervention
|
||||
.
|
||||
Counter:149 Name:L1D_ONDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Drawer Level-4 cache
|
||||
.
|
||||
Counter:150 Name:L1D_ONDRAWER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Drawer L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Drawer Level-3 cache with intervention
|
||||
.
|
||||
Counter:151 Name:L1D_ONDRAWER_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On-Drawer Level-3 cache without intervention
|
||||
.
|
||||
Counter:152 Name:L1D_OFFDRAWER_SCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Same-Column L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Same-Column Level-4 cache
|
||||
.
|
||||
Counter:153 Name:L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Drawer Same-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Same-Column Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:154 Name:L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Same-Column 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 Same-Column Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:155 Name:L1D_OFFDRAWER_FCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Far-Column 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 Far-Column Level-4 cache
|
||||
.
|
||||
Counter:156 Name:L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Drawer Far-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off-Drawer Far-Column Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:157 Name:L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Far-Column 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 Far-Column Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:158 Name:L1D_ONNODE_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D On-Node Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Node memory
|
||||
.
|
||||
Counter:159 Name:L1D_ONDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D On-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:160 Name:L1D_OFFDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:161 Name:L1D_ONCHIP_MEM_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip 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:162 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On-Chip Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:163 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Chip Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:164 Name:L1I_ONNODE_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On-Node Level-4 cache
|
||||
.
|
||||
Counter:165 Name:L1I_ONNODE_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Node L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Node Level-3 cache
|
||||
with intervention
|
||||
.
|
||||
Counter:166 Name:L1I_ONNODE_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Node L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Node Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:167 Name:L1I_ONDRAWER_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Drawer Level-4 cache
|
||||
.
|
||||
Counter:168 Name:L1I_ONDRAWER_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Drawer L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Drawer Level-3 cache
|
||||
with intervention
|
||||
.
|
||||
Counter:169 Name:L1I_ONDRAWER_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an On-Drawer Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:170 Name:L1I_OFFDRAWER_SCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Same-Column L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Same-Column
|
||||
Level-4 cache
|
||||
.
|
||||
Counter:171 Name:L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Drawer Same-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Same-Column
|
||||
Level-3 cache with intervention
|
||||
.
|
||||
Counter:172 Name:L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Same-Column 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 Same-Column
|
||||
Level-3 cache without intervention
|
||||
.
|
||||
Counter:173 Name:L1I_OFFDRAWER_FCOL_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Far-Column L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Far-Column
|
||||
Level-4 cache
|
||||
.
|
||||
Counter:174 Name:L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Drawer Far-Column L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from an Off-Drawer Far-Column
|
||||
Level-3 cache with intervention
|
||||
.
|
||||
Counter:175 Name:L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Far-Column 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 Far-Column
|
||||
Level-3 cache without intervention
|
||||
.
|
||||
Counter:176 Name:L1I_ONNODE_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I On-Node Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Node memory
|
||||
.
|
||||
Counter:177 Name:L1I_ONDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I On-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:178 Name:L1I_OFFDRAWER_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Drawer Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Drawer memory
|
||||
.
|
||||
Counter:179 Name:L1I_ONCHIP_MEM_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where
|
||||
the returned cache line was sourced from On-Chip memory
|
||||
.
|
||||
Counter:218 Name:TX_NC_TABORT
|
||||
Short-Description:Aborted transactions in non-constrained TX mode
|
||||
Description:
|
||||
A transaction abort has occurred in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:219 Name:TX_C_TABORT_NO_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
|
||||
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:220 Name:TX_C_TABORT_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is using special logic to allow the transaction to
|
||||
@@ -307,10 +362,12 @@ complete
|
||||
# MT-diagnostic counter set
|
||||
# ---------------------------------------------------------------------
|
||||
Counter:448 Name:MT_DIAG_CYCLES_ONE_THR_ACTIVE
|
||||
Short-Description:Cycle count with one thread active
|
||||
Description:
|
||||
Cycle count with one thread active
|
||||
.
|
||||
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
|
||||
Short-Description:Cycle count with two threads active
|
||||
Description:
|
||||
Cycle count with two threads active
|
||||
.
|
||||
|
||||
357
cpumf/data/cpum-cf-extended-z14.ctr
Normal file
357
cpumf/data/cpum-cf-extended-z14.ctr
Normal file
@@ -0,0 +1,357 @@
|
||||
# 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_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
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
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description:DTLB2 One-Megabyte Page 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
|
||||
Short-Description:DTLB2 Two-Gigabyte Page Writes
|
||||
Description:
|
||||
A translation entry for a two-gigabyte page was written into the
|
||||
Level-2 TLB
|
||||
.
|
||||
Counter:133 Name:L1D_L2D_SOURCED_WRITES
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description:TLB2 Engines Busy
|
||||
Description:
|
||||
The number of Level-2 TLB translation engines busy in a cycle
|
||||
.
|
||||
Counter:140 Name:TX_C_TEND
|
||||
Short-Description:Completed TEND instructions in constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a constrained transactional-execution
|
||||
mode
|
||||
.
|
||||
Counter:141 Name:TX_NC_TEND
|
||||
Short-Description:Completed TEND instructions in non-constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:143 Name:L1C_TLB2_MISSES
|
||||
Short-Description: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
|
||||
Short-Description:L1D On-Chip 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
|
||||
Short-Description:L1D On-Chip 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
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1D On-Cluster 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
|
||||
Short-Description:L1D On-Cluster 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
|
||||
Short-Description:L1D On-Cluster L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1D Off-Cluster 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
|
||||
Short-Description:L1D Off-Cluster 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
|
||||
Short-Description:L1D Off-Cluster L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1D Off-Drawer 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
|
||||
Short-Description:L1D Off-Drawer 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
|
||||
Short-Description:L1D Off-Drawer L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1D On-Drawer 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
|
||||
Short-Description:L1D Off-Drawer 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
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes read-only
|
||||
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
|
||||
Short-Description:L1I On-Chip 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
|
||||
Short-Description:L1I On-Chip 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
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1I On-Cluster 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
|
||||
Short-Description:L1I On-Cluster 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
|
||||
Short-Description:L1I On-Cluster L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1I Off-Cluster 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
|
||||
Short-Description:L1I Off-Cluster 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
|
||||
Short-Description:L1I Off-Cluster L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1I Off-Drawer 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
|
||||
Short-Description:L1I Off-Drawer 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
|
||||
Short-Description:L1I Off-Drawer L3 Sourced Writes with Intervention
|
||||
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
|
||||
Short-Description:L1I On-Drawer 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
|
||||
Short-Description:L1I Off-Drawer 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
|
||||
Short-Description: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
|
||||
Short-Description: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
|
||||
Short-Description:Decimal Instructions
|
||||
Description:
|
||||
Decimal instructions dispatched. Instructions: CVB, CVD, AP, CP, DP, ED,
|
||||
EDMK, MP, SRP, SP, ZAP
|
||||
.
|
||||
Counter:232 Name:LAST_HOST_TRANSLATIONS
|
||||
Short-Description:Last host translation done
|
||||
Description:
|
||||
Last Host Translation done
|
||||
.
|
||||
Counter:243 Name:TX_NC_TABORT
|
||||
Short-Description:Aborted transactions in non-constrained TX mode
|
||||
Description:
|
||||
A transaction abort has occurred in a non-constrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:244 Name:TX_C_TABORT_NO_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
|
||||
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
|
||||
Short-Description:Aborted transactions in constrained TX mode using special completion logic
|
||||
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
|
||||
Short-Description:Cycle count with one thread active
|
||||
Description:
|
||||
Cycle count with one thread active
|
||||
.
|
||||
Counter:449 Name:MT_DIAG_CYCLES_TWO_THR_ACTIVE
|
||||
Short-Description:Cycle count with two threads active
|
||||
Description:
|
||||
Cycle count with two threads active
|
||||
.
|
||||
@@ -1,121 +1,145 @@
|
||||
Counter: 128 Name:L1D_L2_SOURCED_WRITES
|
||||
Short-Description:L1D L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from the Level-2 cache
|
||||
.
|
||||
Counter: 129 Name:L1I_L2_SOURCED_WRITES
|
||||
Short-Description:L1I L2 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from the Level-2 cache
|
||||
.
|
||||
Counter: 130 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
a DTLB1 miss is in progress.
|
||||
.
|
||||
Counter: 131 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle a ITLB1 miss is in progress.
|
||||
.
|
||||
Counter: 133 Name:L2C_STORES_SENT
|
||||
Short-Description:L2C Stores Sent
|
||||
Description:
|
||||
Incremented by one for every store sent to Level-2 cache
|
||||
.
|
||||
Counter: 134 Name:L1D_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache
|
||||
.
|
||||
Counter: 135 Name:L1D_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter: 136 Name:L1I_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter: 137 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-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: 138 Name:L1D_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-4 cache
|
||||
.
|
||||
Counter: 139 Name:L1I_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-4 cache
|
||||
.
|
||||
Counter: 140 Name:DTLB1_HPAGE_WRITES
|
||||
Short-Description:DTLB1 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a one-megabyte page
|
||||
.
|
||||
Counter: 141 Name:L1D_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1D Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache where the installed cache line
|
||||
was sourced from memory that is attached to the same book as the Data
|
||||
cache (Local Memory)
|
||||
.
|
||||
Counter: 142 Name:L1I_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1I Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache where the installed cache
|
||||
line was sourced from memory that is attached to the same book as the
|
||||
Instruction cache (Local Memory)
|
||||
.
|
||||
Counter: 143 Name:L1I_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache
|
||||
.
|
||||
Counter: 144 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter: 145 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter: 146 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter: 147 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter: 148 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter: 150 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an On Chip Level-3 cache
|
||||
.
|
||||
Counter: 152 Name:L1D_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-Cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
.
|
||||
Counter: 153 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an On Chip Level-3 cache
|
||||
.
|
||||
Counter: 155 Name:L1I_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 I-Cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
|
||||
@@ -1,98 +1,117 @@
|
||||
Counter: 128 Name:DTLB1_MISSES
|
||||
Short-Description:DTLB1 Misses
|
||||
Description:
|
||||
Level-1 Data TLB miss in progress. Incremented by one for every cycle
|
||||
a DTLB1 miss is in progress.
|
||||
.
|
||||
Counter:129 Name:ITLB1_MISSES
|
||||
Short-Description:ITLB1 Misses
|
||||
Description:
|
||||
Level-1 Instruction TLB miss in progress. Incremented by one for every
|
||||
cycle a ITLB1 miss is in progress.
|
||||
.
|
||||
Counter:130 Name:L1D_L2I_SOURCED_WRITES
|
||||
Short-Description:L1D L2I Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from the Level-2 Instruction cache
|
||||
.
|
||||
Counter:131 Name:L1I_L2I_SOURCED_WRITES
|
||||
Short-Description: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:132 Name:L1D_L2D_SOURCED_WRITES
|
||||
Short-Description: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:133 Name:DTLB1_WRITES
|
||||
Short-Description:DTLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer
|
||||
.
|
||||
Counter:135 Name:L1D_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1D Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache where the installed cache line
|
||||
was sourced from memory that is attached to the same book as the Data
|
||||
cache (Local Memory)
|
||||
.
|
||||
Counter:137 Name:L1I_LMEM_SOURCED_WRITES
|
||||
Short-Description:L1I Local Memory Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache where the installed cache
|
||||
line was sourced from memory that is attached to the same book as the
|
||||
Instruction cache (Local Memory)
|
||||
.
|
||||
Counter:138 Name:L1D_RO_EXCL_WRITES
|
||||
Short-Description:L1D Read-only Exclusive Writes
|
||||
Description:
|
||||
A directory write to the Level-1 D-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:139 Name:DTLB1_HPAGE_WRITES
|
||||
Short-Description:DTLB1 One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Data Translation
|
||||
Lookaside Buffer for a one-megabyte page
|
||||
.
|
||||
Counter:140 Name:ITLB1_WRITES
|
||||
Short-Description:ITLB1 Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-1 Instruction
|
||||
Translation Lookaside Buffer
|
||||
.
|
||||
Counter:141 Name:TLB2_PTE_WRITES
|
||||
Short-Description:TLB2 PTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Page Table
|
||||
Entry arrays
|
||||
.
|
||||
Counter:142 Name:TLB2_CRSTE_HPAGE_WRITES
|
||||
Short-Description:TLB2 CRSTE One-Megabyte Page Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays for a one-megabyte large page translation
|
||||
.
|
||||
Counter:143 Name:TLB2_CRSTE_WRITES
|
||||
Short-Description:TLB2 CRSTE Writes
|
||||
Description:
|
||||
A translation entry has been written to the Level-2 TLB Common Region
|
||||
Segment Table Entry arrays
|
||||
.
|
||||
Counter:144 Name:L1D_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D On-Chip 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_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:146 Name:L1D_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache without intervention
|
||||
.
|
||||
Counter:147 Name:L1D_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter:148 Name:L1D_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1D Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-4 cache
|
||||
@@ -104,16 +123,19 @@ cache line was sourced from an Off Book Level-4 cache
|
||||
# C .. constrained
|
||||
#
|
||||
Counter:149 Name:TX_NC_TEND
|
||||
Short-Description:Completed TEND instructions in non-constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a nonconstrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:150 Name:L1D_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from a On Chip Level-3 cache with intervention
|
||||
.
|
||||
Counter:151 Name:L1D_OFFCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Chip/On Book Level-3 cache with
|
||||
@@ -121,73 +143,86 @@ intervention
|
||||
.
|
||||
# XXX Remove SOURCED from L1D_OFFBOOK_L3_SOURCED_WRITES...
|
||||
Counter:152 Name:L1D_OFFBOOK_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1D Off-Book L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Data cache directory where the returned
|
||||
cache line was sourced from an Off Book Level-3 cache with intervention
|
||||
.
|
||||
Counter:153 Name:L1I_ONCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Chip Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:154 Name:L1I_OFFCHIP_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Chip L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
without intervention
|
||||
.
|
||||
Counter:155 Name:L1I_OFFBOOK_L3_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L3 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Book Level-3 cache without
|
||||
intervention
|
||||
.
|
||||
Counter:156 Name:L1I_ONBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I On-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Book Level-4 cache
|
||||
.
|
||||
Counter:157 Name:L1I_OFFBOOK_L4_SOURCED_WRITES
|
||||
Short-Description:L1I Off-Book L4 Sourced Writes
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Book Level-4 cache
|
||||
.
|
||||
Counter:158 Name:TX_C_TEND
|
||||
Short-Description:Completed TEND instructions in constrained TX mode
|
||||
Description:
|
||||
A TEND instruction has completed in a constrained transactional-execution
|
||||
mode
|
||||
.
|
||||
Counter:159 Name:L1I_ONCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I On-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an On Chip Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:160 Name:L1I_OFFCHIP_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Chip L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Chip/On Book Level-3 cache
|
||||
with intervention
|
||||
.
|
||||
Counter:161 Name:L1I_OFFBOOK_L3_SOURCED_WRITES_IV
|
||||
Short-Description:L1I Off-Book L3 Sourced Writes with Intervention
|
||||
Description:
|
||||
A directory write to the Level-1 Instruction cache directory where the
|
||||
returned cache line was sourced from an Off Book Level-3 cache with
|
||||
intervention
|
||||
.
|
||||
Counter:177 Name:TX_NC_TABORT
|
||||
Short-Description:Aborted transactions in non-constrained TX mode
|
||||
Description:
|
||||
A transaction abort has occurred in a nonconstrained
|
||||
transactional-execution mode
|
||||
.
|
||||
Counter:178 Name:TX_C_TABORT_NO_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode not using special completion logic
|
||||
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:179 Name:TX_C_TABORT_SPECIAL
|
||||
Short-Description:Aborted transactions in constrained TX mode using special completion logic
|
||||
Description:
|
||||
A transaction abort has occurred in a constrained transactional-execution
|
||||
mode and the CPU is using special logic to allow the transaction to
|
||||
|
||||
@@ -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,6 @@
|
||||
2828 => 'cpum-cf-extended-zEC12.ctr',
|
||||
2964 => 'cpum-cf-extended-z13.ctr',
|
||||
2965 => 'cpum-cf-extended-z13.ctr',
|
||||
3906 => 'cpum-cf-extended-z14.ctr',
|
||||
3907 => 'cpum-cf-extended-z14.ctr',
|
||||
};
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
#
|
||||
# Basic-sampling mode
|
||||
Counter: 0xB0000 Name:SF_CYCLES_BASIC
|
||||
Short-Description:Sample CPU Cycles Using Basic-sampling Mode
|
||||
Description:
|
||||
Sample CPU cycles using basic-sampling mode
|
||||
.
|
||||
# Diagnostic-sampling mode (includes basic-sampling)
|
||||
Counter: 0xBD000 Name:SF_CYCLES_BASIC_DIAG
|
||||
Short-Description:Sample CPU Cycle Using Diagnostic-sampling Mode (not for ordinary use)
|
||||
Description:
|
||||
Sample CPU cycle using diagnostic-sampling mode (not for ordinary use)
|
||||
.
|
||||
|
||||
@@ -7,7 +7,7 @@ LDLIBS += -lm
|
||||
OBJECTS = daemon.o cpu.o info.o terms.o config.o main.o getopt.o mem.o
|
||||
|
||||
cpuplugd: $(OBJECTS)
|
||||
$(LINK) $(ALL_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
|
||||
clean:
|
||||
rm -f cpuplugd $(OBJECTS)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Config file parsing
|
||||
*
|
||||
* Copyright IBM Corp. 2007, 2017
|
||||
* Copyright IBM Corp. 2007, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -201,6 +201,7 @@ void parse_configfile(char *file)
|
||||
linebuffer);
|
||||
parse_configline(linebuffer);
|
||||
}
|
||||
fclose(filp);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Print DASD uid
|
||||
This option prints the full uid of the DASD. When z/VM provides two
|
||||
virtual devices that are actually located on the same real device, the
|
||||
first four tokens of the uid will be identical for both devices. z/VM
|
||||
may provide an additional token that allows to distinguish between
|
||||
may provide an additional token that can be used to distinguish between
|
||||
different minidisks. You need both support in the Linux kernel and
|
||||
z/VM to receive such an additional token.
|
||||
|
||||
@@ -45,7 +45,7 @@ available by applying the PTFs for VM APAR VM64273 on z/VM 5.2.0 and higher.
|
||||
.BI "-u|--uid"
|
||||
Print DASD uid without z/VM minidisk token
|
||||
|
||||
z/VM may provide an additional token that allows to distinguish
|
||||
z/VM may provide an additional token that can be used to distinguish
|
||||
between different minidisks (see --extended-uid option). To remain
|
||||
compatibile with systems that were installed on older Linux or z/VM
|
||||
levels, the -u option will print the uid excluding any z/VM-provided
|
||||
|
||||
@@ -22,17 +22,15 @@
|
||||
#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_libc.h"
|
||||
#include "lib/util_opt.h"
|
||||
#include "lib/util_prg.h"
|
||||
#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 +98,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 +165,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 +180,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");
|
||||
if (dasd_get_blocksize(device, &blksize) != 0) {
|
||||
warnx("Unable to figure out block size");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ioctl(f, BLKSSZGET, &data.blksize) != 0) {
|
||||
printf("Unable to figure out block size.\n");
|
||||
if (dasd_get_info(device, &dasd_info) != 0) {
|
||||
warnx("Unable to figure out DASD information");
|
||||
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;
|
||||
}
|
||||
f = open(device, O_RDONLY);
|
||||
if (f < 0) {
|
||||
warnx("Could not open device node");
|
||||
goto error;
|
||||
}
|
||||
|
||||
vlabel_start = data.dasd_info.label_block * data.blksize;
|
||||
vlabel_start = dasd_info.label_block * blksize;
|
||||
if (lseek(f, vlabel_start, SEEK_SET) < 0)
|
||||
goto error;
|
||||
goto error_close;
|
||||
|
||||
bzero(vlabel, vlsize);
|
||||
|
||||
if (read(f, vlabel, vlsize) != vlsize) {
|
||||
printf("Could not read volume label.\n");
|
||||
goto error;
|
||||
warnx("Could not read volume label");
|
||||
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 +237,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;
|
||||
}
|
||||
|
||||
@@ -319,10 +256,9 @@ static void *dinfo_malloc(size_t size)
|
||||
void *result;
|
||||
|
||||
result = malloc(size);
|
||||
if (result == NULL) {
|
||||
printf("Could not allocate %lld bytes of memory",
|
||||
(unsigned long long) size);
|
||||
}
|
||||
if (result == NULL)
|
||||
warnx("Could not allocate %lu bytes of memory", 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,21 +312,20 @@ 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);
|
||||
}
|
||||
}
|
||||
printf("Error: Unable to create temporary device node");
|
||||
warnx("Error: Unable to create temporary device node");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void dinfo_free_devnode(char *device)
|
||||
{
|
||||
if (remove(device)) {
|
||||
printf("Warning: Could not remove "
|
||||
"temporary file %s", device);
|
||||
}
|
||||
if (remove(device))
|
||||
warnx("Warning: Could not remove temporary file %s", device);
|
||||
}
|
||||
|
||||
static int dinfo_extract_dev(dev_t *dev, char *str)
|
||||
@@ -399,9 +335,10 @@ static int dinfo_extract_dev(dev_t *dev, char *str)
|
||||
int ma, mi;
|
||||
|
||||
bzero(tmp, RD_BUFFER_SIZE);
|
||||
strncpy(tmp, str, RD_BUFFER_SIZE);
|
||||
if ((p = strchr(tmp, ':')) == NULL) {
|
||||
printf("Error: unable to extract major/minor\n");
|
||||
util_strlcpy(tmp, str, RD_BUFFER_SIZE);
|
||||
p = strchr(tmp, ':');
|
||||
if (p == NULL) {
|
||||
warnx("Error: unable to extract major/minor");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -420,7 +357,7 @@ static int dinfo_get_dev_from_blockdev(char *blockdev, dev_t *dev)
|
||||
|
||||
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
|
||||
if (!readbuf) {
|
||||
printf("Error: Not enough memory to allocate readbuffer\n");
|
||||
warnx("Error: Not enough memory to allocate readbuffer");
|
||||
return -1;
|
||||
}
|
||||
if (util_file_read_line(readbuf, RD_BUFFER_SIZE,
|
||||
@@ -439,6 +376,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 +392,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 +408,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,23 +485,25 @@ 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);
|
||||
warnx("Error: could not stat %s", devnode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf(stat_dev, "%d:%d", major(stat_buffer.st_rdev),
|
||||
minor(stat_buffer.st_rdev));
|
||||
|
||||
if ((directory = opendir("/sys/block/")) == NULL) {
|
||||
printf("Error: could not open directory /sys/block\n");
|
||||
directory = opendir("/sys/block/");
|
||||
if (directory == NULL) {
|
||||
warnx("Error: could not open directory /sys/block");
|
||||
return -1;
|
||||
}
|
||||
|
||||
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
|
||||
if (!readbuf) {
|
||||
printf("Error: Not enough memory to allocate readbuffer\n");
|
||||
warnx("Error: Not enough memory to allocate readbuffer");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -572,9 +514,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 +532,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 +576,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,28 +602,26 @@ 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);
|
||||
warnx("%s %d.%d is not supported", uname_buf.sysname,
|
||||
version, release);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!busid && !blockdev && !devnode) {
|
||||
printf("Error: please specify a device using either -b, -i "
|
||||
"or -d\n");
|
||||
warnx("Error: please specify a device using either -b, -i or -d");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((busid && blockdev) || (busid && devnode) || (blockdev && devnode)) {
|
||||
printf("Error: please specify device only once, either -b, -i "
|
||||
"or -d\n");
|
||||
warnx("Error: please specify device only once, either -b, -i or -d");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!print_uid && !print_extended_uid && !print_vlabel) {
|
||||
printf("Error: no action specified (e.g. -u)\n");
|
||||
warnx("Error: no action specified (e.g. -u)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -685,9 +632,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 +654,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 +667,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,15 +706,15 @@ 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;
|
||||
}
|
||||
|
||||
error:
|
||||
printf("Error: could not read unique DASD ID\n");
|
||||
warnx("Error: could not read unique DASD ID");
|
||||
rc = 1;
|
||||
|
||||
out:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static void set_time(char *dest, size_t len, time_t value)
|
||||
#define SET_TIME_FIELD(obj, name, value) \
|
||||
set_time((obj)->name, sizeof((obj)->name), (time_t) (value))
|
||||
#define SET_STR_FIELD(obj, name, value) \
|
||||
strncpy((obj)->name, (value), sizeof((obj)->name))
|
||||
util_strlcpy((obj)->name, (value), sizeof((obj)->name))
|
||||
|
||||
/* Initialize the tar file @header with the provided data */
|
||||
static void init_header(struct tar_header *header, const char *filename,
|
||||
|
||||
16
etc/Makefile
Normal file
16
etc/Makefile
Normal 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
|
||||
@@ -7,7 +7,7 @@ SUBSYSTEM!="block", GOTO="ra_end"
|
||||
|
||||
ACTION!="add", GOTO="ra_change"
|
||||
# on device add set initial readahead to 512 (instead of in kernel 128)
|
||||
KERNEL=="sd*[!0-9]", WAIT_FOR="queue/read_ahead_kb", ATTR{queue/read_ahead_kb}="512"
|
||||
KERNEL=="sd*[!0-9]", TEST=="queue/read_ahead_kb", ATTR{queue/read_ahead_kb}="512"
|
||||
|
||||
LABEL="ra_change"
|
||||
|
||||
|
||||
148
fdasd/fdasd.c
148
fdasd/fdasd.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* fdasd - Create or modify partitions on ECKD DASDs
|
||||
*
|
||||
* Copyright IBM Corp. 2001, 2017
|
||||
* Copyright IBM Corp. 2001, 2018
|
||||
*
|
||||
* s390-tools is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -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
|
||||
@@ -259,7 +258,7 @@ static void fdasd_check_volser(char *volser, int devno)
|
||||
{
|
||||
int from, to;
|
||||
|
||||
for (from = 0, to = 0; volser[from] && from < VOLSER_LENGTH; from++)
|
||||
for (from = 0, to = 0; from < VOLSER_LENGTH && volser[from]; from++)
|
||||
if ((volser[from] >= 0x23 &&
|
||||
volser[from] <= 0x25) || /* # $ % */
|
||||
(volser[from] >= 0x30 &&
|
||||
@@ -728,9 +727,9 @@ static int fdasd_parse_conffile(fdasd_anchor_t *anc,
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
rc = read(fd, buffer, sizeof(buffer) - 1);
|
||||
close(fd);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
close(fd);
|
||||
|
||||
for (i = 0; i < rc; i++)
|
||||
buffer[i] = toupper(buffer[i]);
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1273,7 +1257,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
|
||||
printf("DSCBs: ");
|
||||
|
||||
blk = (cchhb2blk(&anc->vlabel->vtoc, &geo) - 1) * anc->blksize;
|
||||
if (blk <= 0)
|
||||
if (cchhb2blk(&anc->vlabel->vtoc, &geo) == 0 || blk == 0)
|
||||
fdasd_error(anc, vlabel_corrupted, "");
|
||||
maxblk = blk + anc->blksize * 9; /* f4+f5+f7+3*f8+3*f9 */
|
||||
|
||||
@@ -1326,7 +1310,7 @@ static void fdasd_write_vtoc_labels(fdasd_anchor_t *anc)
|
||||
volser[VOLSER_LENGTH] = ' ';
|
||||
strncpy(c1, volser, VOLSER_LENGTH + 1);
|
||||
c1 = strchr(ch, ' ');
|
||||
strncpy(c1, s2, 31);
|
||||
memcpy(c1, s2, 31);
|
||||
} else {
|
||||
if (get_part_type_by_dsname(ch, &part_info->type))
|
||||
part_info->type = PARTITION_NATIVE;
|
||||
@@ -1335,25 +1319,25 @@ 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 "
|
||||
memcpy(ch, "LINUX.V "
|
||||
" ", 44);
|
||||
|
||||
strncpy(volser, anc->vlabel->volid, VOLSER_LENGTH);
|
||||
vtoc_ebcdic_dec(volser, volser, VOLSER_LENGTH);
|
||||
strncpy(c1, volser, VOLSER_LENGTH);
|
||||
memcpy(c1, volser, VOLSER_LENGTH);
|
||||
|
||||
c1 = strchr(ch, ' ');
|
||||
strncpy(c1, ".PART", 5);
|
||||
memcpy(c1, ".PART", 5);
|
||||
c1 += 5;
|
||||
|
||||
sprintf(dsno, "%04d.", k + 1);
|
||||
strncpy(c1, dsno, 5);
|
||||
memcpy(c1, dsno, 5);
|
||||
c1 += 5;
|
||||
|
||||
get_part_dsname_by_type(part_info->type, &dsname);
|
||||
strncpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
|
||||
memcpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
|
||||
}
|
||||
vtoc_ebcdic_enc(ch, ch, 44);
|
||||
if (anc->verbose)
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1650,7 +1636,7 @@ static void fdasd_change_part_type(fdasd_anchor_t *anc)
|
||||
|
||||
ch = strstr(part_info->f1->DS1DSNAM, "PART") + 9;
|
||||
if (ch != NULL)
|
||||
strncpy(ch, str, 6);
|
||||
memcpy(ch, str, 6);
|
||||
vtoc_ebcdic_enc(part_info->f1->DS1DSNAM, part_info->f1->DS1DSNAM, 44);
|
||||
anc->vtoc_changed++;
|
||||
}
|
||||
@@ -2008,7 +1994,7 @@ static int fdasd_check_volume(fdasd_anchor_t *anc)
|
||||
printf(" VOL1\n");
|
||||
|
||||
blk = (cchhb2blk(&vlabel->vtoc, &geo) - 1) * anc->blksize;
|
||||
if (blk > 0) {
|
||||
if (cchhb2blk(&vlabel->vtoc, &geo) > 0 && blk > 0) {
|
||||
rc = fdasd_valid_vtoc_pointer(anc, blk);
|
||||
|
||||
if (anc->print_table && (rc < 0))
|
||||
@@ -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;
|
||||
|
||||
117
fdasd/fdasd.h
117
fdasd/fdasd.h
@@ -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 *
|
||||
*****************************************************************************/
|
||||
|
||||
@@ -31,12 +31,13 @@ LDLIBS += $(FUSE_LDLIBS) -lpthread -lrt -ldl -lm
|
||||
|
||||
OBJECTS = hmcdrvfs.o
|
||||
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
|
||||
all: check_dep hmcdrvfs
|
||||
|
||||
$(OBJECTS): Makefile
|
||||
|
||||
hmcdrvfs: $(OBJECTS)
|
||||
hmcdrvfs: $(OBJECTS) $(libs)
|
||||
|
||||
install: all install-scripts
|
||||
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 755 hmcdrvfs \
|
||||
@@ -49,7 +50,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; \
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#define HMCDRV_FUSE_LOGNAME "hmcdrvfs" /* log prefix */
|
||||
@@ -276,7 +277,7 @@ static void hmcdrv_cache_symlink(struct hmcdrv_fuse_file *fp,
|
||||
fp->symlnk = malloc(HMCDRV_FUSE_MAXPATH);
|
||||
|
||||
if (fp->symlnk != NULL) {
|
||||
strncpy(fp->symlnk, symlink, HMCDRV_FUSE_MAXPATH);
|
||||
util_strlcpy(fp->symlnk, symlink, HMCDRV_FUSE_MAXPATH);
|
||||
fp->symlnk[HMCDRV_FUSE_MAXPATH - 1] = '\0';
|
||||
}
|
||||
}
|
||||
@@ -483,8 +484,7 @@ static ssize_t hmcdrv_ftp_transfer(struct hmcdrv_fuse_file *fp, char *buf,
|
||||
}
|
||||
|
||||
current_offset += retlen;
|
||||
strncpy(last_ftpcmd, fp->ftpcmd, HMCDRV_FUSE_MAXCMDLEN);
|
||||
last_ftpcmd[HMCDRV_FUSE_MAXCMDLEN - 1] = '\0';
|
||||
util_strlcpy(last_ftpcmd, fp->ftpcmd, HMCDRV_FUSE_MAXCMDLEN);
|
||||
return retlen;
|
||||
}
|
||||
|
||||
@@ -821,10 +821,13 @@ static char *hmcdrv_parse_line(char *line, char *namebuf,
|
||||
if ((*line != '\0') && (*line != '\n')) {
|
||||
field = hmcdrv_parse_ntoken(field, line, &attr);
|
||||
|
||||
while ((*line != '\0') &&
|
||||
(*line != '\n') &&
|
||||
!isspace(*line))
|
||||
while ((*line != '\0') && (*line != '\n')) {
|
||||
if (isspace(*line))
|
||||
break;
|
||||
if (field == 1 && isdigit(*line))
|
||||
break;
|
||||
++line; /* search end of field */
|
||||
}
|
||||
}
|
||||
} /* while */
|
||||
|
||||
@@ -850,13 +853,12 @@ static char *hmcdrv_parse_line(char *line, char *namebuf,
|
||||
*arrow = '\0';
|
||||
}
|
||||
|
||||
strncpy(namebuf, attr.fname, bufsize);
|
||||
namebuf[bufsize - 1] = '\0'; /* safety */
|
||||
util_strlcpy(namebuf, attr.fname, bufsize);
|
||||
|
||||
if (arrow == NULL) {
|
||||
symlink[0] = '\0';
|
||||
} else {
|
||||
strncpy(symlink, arrow + 4, HMCDRV_FUSE_MAXPATH);
|
||||
util_strlcpy(symlink, arrow + 4, HMCDRV_FUSE_MAXPATH);
|
||||
*arrow = ' '; /* restore */
|
||||
}
|
||||
|
||||
@@ -1145,8 +1147,7 @@ static int hmcdrv_fuse_readlink(const char *path, char *buf, size_t size)
|
||||
if (!S_ISLNK(fp->st.st_mode)) {
|
||||
rc = -EINVAL;
|
||||
} else {
|
||||
strncpy(buf, fp->symlnk, size);
|
||||
buf[size - 1] = '\0';
|
||||
util_strlcpy(buf, fp->symlnk, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1335,7 +1336,7 @@ static int hmcdrv_fuse_main(struct fuse_args *args)
|
||||
*/
|
||||
static void hmcdrv_fuse_usage(const char *progname)
|
||||
{
|
||||
fprintf(stderr,
|
||||
fprintf(stdout,
|
||||
"Usage: %s MOUNTPOINT [OPTIONS]\n\n"
|
||||
"Use the %s command to read files from a HMC drive DVD.\n"
|
||||
"\n"
|
||||
@@ -1447,7 +1448,7 @@ static int hmcdrv_fuse_optproc(void *data, const char *arg,
|
||||
return 1;
|
||||
|
||||
case HMCDRV_FUSE_OPTKEY_VERSION:
|
||||
fprintf(stderr, HMCDRV_FUSE_LOGHEAD
|
||||
fprintf(stdout, HMCDRV_FUSE_LOGHEAD
|
||||
"HMC drive DVD file system, version %s\n"
|
||||
"Copyright IBM Corp. 2015, 2017\n",
|
||||
HMCDRV_FUSE_RELEASE);
|
||||
@@ -1455,6 +1456,16 @@ static int hmcdrv_fuse_optproc(void *data, const char *arg,
|
||||
|
||||
case HMCDRV_FUSE_OPTKEY_HELP:
|
||||
hmcdrv_fuse_usage(outargs->argv[0]);
|
||||
|
||||
/*
|
||||
* Usage output needs to go to stdout to be consistent with
|
||||
* coding guidelines. FUSE versions before 3.0.0 print help
|
||||
* output to stderr. Redirect stderr to stdout here to enforce
|
||||
* consistent behavior.
|
||||
*/
|
||||
fflush(stderr);
|
||||
dup2(STDOUT_FILENO, STDERR_FILENO);
|
||||
|
||||
fuse_opt_add_arg(outargs, "-ho");
|
||||
hmcdrv_fuse_main(outargs);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
@@ -55,8 +55,7 @@ struct l_x_sys_hdr {
|
||||
|
||||
static inline void l_sys_hdr__sys_name(struct l_x_sys_hdr *hdr, char *name)
|
||||
{
|
||||
memcpy(name, hdr->sys_name, LPAR_NAME_LEN);
|
||||
ht_ebcdic_to_ascii(name, LPAR_NAME_LEN);
|
||||
ht_ebcdic_to_ascii(hdr->sys_name, name, LPAR_NAME_LEN);
|
||||
name[LPAR_NAME_LEN] = 0;
|
||||
ht_strstrip(name);
|
||||
}
|
||||
@@ -176,7 +175,6 @@ static void l_sd_cpu_phys_fill(struct sd_sys *sys,
|
||||
sd_cpu_state_set(cpu, SD_CPU_STATE_UNKNOWN);
|
||||
}
|
||||
sd_cpu_mgm_time_us_set(cpu, cpu_info->mgm_time);
|
||||
sd_cpu_real_type_set(cpu, cpu_type);
|
||||
sd_cpu_commit(cpu);
|
||||
}
|
||||
|
||||
|
||||
@@ -245,8 +245,7 @@ static void l_sd_sys_root_fill(struct sd_sys *sys)
|
||||
struct sd_sys *guest;
|
||||
|
||||
guest_name[NAME_LEN] = 0;
|
||||
memcpy(guest_name, data->guest_name, NAME_LEN);
|
||||
ht_ebcdic_to_ascii(guest_name, NAME_LEN);
|
||||
ht_ebcdic_to_ascii(data->guest_name, guest_name, NAME_LEN);
|
||||
ht_strstrip(guest_name);
|
||||
|
||||
guest = sd_sys_get(sys, guest_name);
|
||||
|
||||
@@ -98,9 +98,15 @@ void *ht_realloc(void *old_ptr, size_t size)
|
||||
/*
|
||||
* Convert EBCDIC string to ASCII
|
||||
*/
|
||||
void ht_ebcdic_to_ascii(char *inout, size_t len)
|
||||
void ht_ebcdic_to_ascii(char *in, char *out, size_t size)
|
||||
{
|
||||
iconv(l_iconv_ebcdic_ascii, &inout, &len, &inout, &len);
|
||||
size_t size_out = size;
|
||||
size_t size_in = size;
|
||||
size_t rc;
|
||||
|
||||
rc = iconv(l_iconv_ebcdic_ascii, &in, &size_in, &out, &size_out);
|
||||
if (rc == (size_t) -1)
|
||||
ERR_EXIT_ERRNO("Code page translation EBCDIC-ASCII failed");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "lib/util_base.h"
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#define G0(x) MAX(0, (s64) (x))
|
||||
@@ -29,7 +30,7 @@ extern char *ht_strstrip(char *str);
|
||||
extern char *ht_strdup(const char *str);
|
||||
extern void ht_print_head(const char *sys);
|
||||
extern void ht_print_help_icon(void);
|
||||
extern void ht_ebcdic_to_ascii(char *inout, size_t len);
|
||||
extern void ht_ebcdic_to_ascii(char *in, char *out, size_t len);
|
||||
extern char *ht_mount_point_get(const char *fs_type);
|
||||
extern u64 ht_ext_tod_2_us(void *tod_ext);
|
||||
extern void ht_print_time(void);
|
||||
|
||||
@@ -195,7 +195,6 @@ struct sd_cpu {
|
||||
struct sd_info i;
|
||||
char id[9];
|
||||
struct sd_cpu_type *type;
|
||||
char real_type[CPU_TYPE_ID_LEN];
|
||||
struct sd_cpu_info d1;
|
||||
struct sd_cpu_info d2;
|
||||
struct sd_cpu_info *d_cur;
|
||||
@@ -228,11 +227,6 @@ static inline void sd_cpu_state_set(struct sd_cpu *cpu, enum sd_cpu_state state)
|
||||
cpu->state = state;
|
||||
}
|
||||
|
||||
static inline void sd_cpu_real_type_set(struct sd_cpu *cpu, const char *type)
|
||||
{
|
||||
strncpy(cpu->real_type, type, sizeof(cpu->real_type));
|
||||
}
|
||||
|
||||
static inline void sd_cpu_cpu_time_us_set(struct sd_cpu *cpu, u64 value)
|
||||
{
|
||||
cpu->d_cur->cpu_time_us = value;
|
||||
|
||||
@@ -219,7 +219,7 @@ struct sd_cpu *sd_cpu_new(struct sd_sys *parent, const char *id,
|
||||
|
||||
cpu = ht_zalloc(sizeof(*cpu));
|
||||
cpu->i.parent = parent;
|
||||
strncpy(cpu->id, id, sizeof(cpu->id));
|
||||
util_strlcpy(cpu->id, id, sizeof(cpu->id));
|
||||
cpu->type = l_cpu_type_by_id(type);
|
||||
cpu->d_cur = &cpu->d1;
|
||||
cpu->cnt = cnt;
|
||||
@@ -251,7 +251,7 @@ struct sd_sys *sd_sys_new(struct sd_sys *parent, const char *id)
|
||||
struct sd_sys *sys_new;
|
||||
|
||||
sys_new = ht_zalloc(sizeof(*sys_new));
|
||||
strncpy(sys_new->id, id, sizeof(sys_new->id));
|
||||
util_strlcpy(sys_new->id, id, sizeof(sys_new->id));
|
||||
util_list_init(&sys_new->child_list, struct sd_sys, list);
|
||||
util_list_init(&sys_new->cpu_list, struct sd_cpu, list);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ static void l_mark_key_add(struct table *t, char *str)
|
||||
struct table_mark_key *key;
|
||||
|
||||
key = ht_zalloc(sizeof(*key));
|
||||
strncpy(key->str, str, sizeof(key->str));
|
||||
util_strlcpy(key->str, str, sizeof(key->str));
|
||||
util_list_add_tail(&t->mark_key_list, key);
|
||||
}
|
||||
|
||||
@@ -617,7 +617,7 @@ void table_row_select_key_get(struct table *t, char str[TABLE_STR_MAX])
|
||||
struct table_row *row;
|
||||
|
||||
row = l_selected_row(t);
|
||||
strncpy(str, row->entries[0].str, TABLE_STR_MAX);
|
||||
util_strlcpy(str, row->entries[0].str, TABLE_STR_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -157,7 +157,7 @@ static void l_print_line(const char *line)
|
||||
char line_cpy[TBOX_MAX_STR + 1];
|
||||
char *ptr_old, *ptr;
|
||||
|
||||
strncpy(line_cpy, line, sizeof(line_cpy));
|
||||
util_strlcpy(line_cpy, line, sizeof(line_cpy));
|
||||
ptr_old = ptr = line_cpy;
|
||||
do {
|
||||
ptr = strchr(ptr, '\\');
|
||||
|
||||
@@ -326,7 +326,7 @@ void win_sys_set(const char *sys_id)
|
||||
{
|
||||
if (l_initialized)
|
||||
table_reset(l_t);
|
||||
strncpy(l_sys_id, sys_id, sizeof(l_sys_id));
|
||||
util_strlcpy(l_sys_id, sys_id, sizeof(l_sys_id));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
207
include/lib/dasd_base.h
Normal file
207
include/lib/dasd_base.h
Normal 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 */
|
||||
@@ -42,6 +42,9 @@ static inline void util_ptr_vec_free(void **ptr_vec, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!ptr_vec || count < 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
free(ptr_vec[i]);
|
||||
free(ptr_vec);
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocate memory or panic in case of failure
|
||||
*
|
||||
@@ -125,4 +129,11 @@ int __util_vsprintf(const char *func, const char *file, int line,
|
||||
char *util_strcat_realloc(char *str1, const char *str2);
|
||||
void util_str_toupper(char *str);
|
||||
|
||||
char *util_strstrip(char *s);
|
||||
size_t util_strlcpy(char *dest, const char *src, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /** LIB_UTIL_LIBC_H @} */
|
||||
|
||||
@@ -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 @} */
|
||||
|
||||
@@ -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;
|
||||
|
||||
52
include/lib/vmcp.h
Normal file
52
include/lib/vmcp.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* vmcp - z/VM CP command library
|
||||
*
|
||||
* Copyright IBM Corp. 2005, 2018
|
||||
*
|
||||
* 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_VMCP_H
|
||||
#define LIB_VMCP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define VMCP_DEVICE_NODE "/dev/vmcp" /* VMCP device name */
|
||||
#define VMCP_DEFAULT_BUFSZ 0x4000 /* VMCP default buffer size */
|
||||
|
||||
/*
|
||||
* Error codes returned by vmcp() function. This enables the caller
|
||||
* to emit a detailed error message on the type of failure.
|
||||
*/
|
||||
#define VMCP_SUCCESS 0 /* VMCP operation completed successfully */
|
||||
#define VMCP_ERR_OPEN (-1) /* Error Open of VMCP device */
|
||||
#define VMCP_ERR_SETBUF (-2) /* Error VMCP_SETBUF ioctl */
|
||||
#define VMCP_ERR_READ (-3) /* Error VMCP read system call */
|
||||
#define VMCP_ERR_GETCODE (-4) /* Error VMCP_GETCODE ioctl */
|
||||
#define VMCP_ERR_GETSIZE (-5) /* Error VMCP_GETSIZE ioctl */
|
||||
#define VMCP_ERR_TOOSMALL (-6) /* Error VMCP buffer too small for
|
||||
* response
|
||||
*/
|
||||
#define VMCP_ERR_WRITE (-7) /* Error VMCP write system call */
|
||||
|
||||
struct vmcp_parm {
|
||||
const char *cpcmd;
|
||||
unsigned int buffer_size;
|
||||
bool do_upper;
|
||||
int cprc;
|
||||
char *response;
|
||||
unsigned int response_size;
|
||||
};
|
||||
|
||||
int vmcp(struct vmcp_parm *cp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -2,13 +2,15 @@ include ../common.mak
|
||||
|
||||
all: xcec-bridge
|
||||
|
||||
xcec-bridge: xcec-bridge.o
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
|
||||
xcec-bridge: xcec-bridge.o $(libs)
|
||||
|
||||
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; \
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
/* a signal causes the interfaces to be re-checked */
|
||||
@@ -40,7 +41,7 @@
|
||||
|
||||
#define UPDATE_SIGNAL SIGUSR1
|
||||
|
||||
#define DEV_NAME_LEN IFNAMSIZ
|
||||
#define DEV_NAME_SIZE IFNAMSIZ
|
||||
|
||||
#define BUFFER_LEN 65536
|
||||
|
||||
@@ -55,7 +56,7 @@ struct int_sock {
|
||||
int features;
|
||||
int i_fd;
|
||||
int o_fd;
|
||||
char dev_name[DEV_NAME_LEN];
|
||||
char dev_name[DEV_NAME_SIZE];
|
||||
int mtu_warning;
|
||||
|
||||
struct int_sock *next;
|
||||
@@ -91,7 +92,7 @@ int open_incoming_socket(char *dev_name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
strncpy(if_req.ifr_name,dev_name,DEV_NAME_LEN);
|
||||
util_strlcpy(if_req.ifr_name, dev_name, DEV_NAME_SIZE);
|
||||
retval=ioctl(fd,SIOCGIFINDEX,&if_req);
|
||||
if (retval==-1) {
|
||||
syslog(LOG_ERR,"can't ioctl on raw packet socket, " \
|
||||
@@ -192,7 +193,7 @@ int open_outgoing_socket(char *dev_name)
|
||||
int interface_in_list(struct int_sock *item,struct int_sock *list)
|
||||
{
|
||||
for (;list;list=list->next) {
|
||||
if (!strncmp(item->dev_name,list->dev_name,DEV_NAME_LEN)) {
|
||||
if (!strncmp(item->dev_name,list->dev_name,DEV_NAME_SIZE)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -281,7 +282,7 @@ int read_sys(struct int_sock **nlist)
|
||||
do_broadcast_bridging=0;
|
||||
|
||||
is->mtu_warning=0;
|
||||
strncpy(is->dev_name, if_name, DEV_NAME_LEN);
|
||||
util_strlcpy(is->dev_name, if_name, DEV_NAME_SIZE);
|
||||
if (!strncmp(if_name,"hsi",3)) {
|
||||
is->features=I_S_FEATURE_PASSTHROUGH;
|
||||
}
|
||||
@@ -317,7 +318,7 @@ void update_interfaces()
|
||||
prev=NULL;
|
||||
while (j) {
|
||||
if (!strncmp(j->dev_name,i->dev_name,
|
||||
DEV_NAME_LEN)) {
|
||||
DEV_NAME_SIZE)) {
|
||||
if (!prev) {
|
||||
select_set.i_s_list=j->next;
|
||||
} else {
|
||||
@@ -360,7 +361,7 @@ void update_interfaces()
|
||||
continue;
|
||||
}
|
||||
|
||||
strncpy(new_int->dev_name,i->dev_name,DEV_NAME_LEN);
|
||||
util_strlcpy(new_int->dev_name, i->dev_name, DEV_NAME_SIZE);
|
||||
new_int->i_fd=i_fd;
|
||||
new_int->o_fd=o_fd;
|
||||
new_int->features=i->features;
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
include ../common.mak
|
||||
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
|
||||
all: chreipl lsreipl chshut lsshut
|
||||
|
||||
libs = $(rootdir)/libutil/libutil.a
|
||||
|
||||
objects = main.o ccw.o fcp.o system.o shutdown.o \
|
||||
cmd_lsshut.o cmd_chshut.o cmd_lsreipl.o cmd_chreipl.o proc.o
|
||||
|
||||
chreipl: $(objects)
|
||||
$(LINK) $(ALL_LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||
chreipl: $(objects) $(libs)
|
||||
$(LINK) $(ALL_LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
|
||||
lsreipl:
|
||||
ln -sf chreipl lsreipl
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <ctype.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "ipl_tools.h"
|
||||
@@ -182,7 +183,7 @@ static void set_bootprog(const char *bootprog)
|
||||
ERR_EXIT("Bootprog \"%s\" is not a decimal number", bootprog);
|
||||
if (bootprog_int > UINT_MAX)
|
||||
ERR_EXIT("Invalid bootprog specified");
|
||||
strncpy(l.bootprog, bootprog, sizeof(l.bootprog));
|
||||
util_strlcpy(l.bootprog, bootprog, sizeof(l.bootprog));
|
||||
l.bootprog_set = 1;
|
||||
}
|
||||
|
||||
@@ -294,7 +295,7 @@ static int set_reipl_type(const char *dev_name)
|
||||
else
|
||||
return -1;
|
||||
|
||||
strncpy(l.dev, dev_name, sizeof(l.dev));
|
||||
util_strlcpy(l.dev, dev_name, sizeof(l.dev));
|
||||
dev_from_part(l.dev);
|
||||
l.dev_set = 1;
|
||||
return 0;
|
||||
@@ -302,19 +303,21 @@ static int set_reipl_type(const char *dev_name)
|
||||
|
||||
static int get_chreipl_helper_cmd(dev_t dev, char cmd[PATH_MAX])
|
||||
{
|
||||
char chreipl_helper[PATH_MAX];
|
||||
char *chreipl_helper;
|
||||
struct proc_dev_entry pde;
|
||||
|
||||
if (proc_dev_get_entry(dev, 1, &pde) != 0)
|
||||
return -1;
|
||||
snprintf(chreipl_helper, PATH_MAX,
|
||||
"%s/%s.%s", TOOLS_LIBDIR, "chreipl_helper", pde.name);
|
||||
util_asprintf(&chreipl_helper,
|
||||
"%s/%s.%s", TOOLS_LIBDIR, "chreipl_helper", pde.name);
|
||||
if (access(chreipl_helper, X_OK) != 0) {
|
||||
proc_dev_free_entry(&pde);
|
||||
free(chreipl_helper);
|
||||
return -1;
|
||||
}
|
||||
sprintf(cmd, "%s %d:%d", chreipl_helper, major(dev), minor(dev));
|
||||
proc_dev_free_entry(&pde);
|
||||
free(chreipl_helper);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -445,7 +448,7 @@ static void set_target_type_auto(const char *arg)
|
||||
{
|
||||
char busid[10];
|
||||
|
||||
if (access(arg, R_OK) == 0) {
|
||||
if (access(arg, F_OK) == 0) {
|
||||
set_target_type(TT_NODE, 1);
|
||||
return;
|
||||
}
|
||||
@@ -539,12 +542,19 @@ static void parse_chreipl_options(int argc, char *argv[])
|
||||
parse_pos_args(&argv[optind], argc - optind);
|
||||
}
|
||||
|
||||
static void verify_write_access(const char *path, const char *attr)
|
||||
static void check_exists(const char *path, const char *attr)
|
||||
{
|
||||
char fpath[PATH_MAX];
|
||||
|
||||
snprintf(fpath, sizeof(fpath), "/sys/firmware/%s", path);
|
||||
if (access(fpath, W_OK) != 0)
|
||||
if (access(fpath, F_OK) != 0)
|
||||
ERR_EXIT("System does not allow to set %s", attr);
|
||||
}
|
||||
|
||||
static void write_str_optional(char *string, char *file, int exit_on_fail,
|
||||
const char *attr)
|
||||
{
|
||||
if (write_str_errno(string, file) && exit_on_fail)
|
||||
ERR_EXIT("System does not allow to set %s", attr);
|
||||
}
|
||||
|
||||
@@ -585,22 +595,18 @@ static void chreipl_ccw(void)
|
||||
ERR_EXIT("Could not find DASD CCW device \"%s\"", l.busid);
|
||||
}
|
||||
|
||||
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_CCW_MAX) {
|
||||
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
|
||||
strlen(l.bootparms), BOOTPARMS_CCW_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* On old systems that use CCW reipl loadparm cannot be set
|
||||
*/
|
||||
if (l.loadparm_set)
|
||||
verify_write_access("reipl/ccw/loadparm", "loadparm");
|
||||
if (l.bootparms_set) {
|
||||
verify_write_access("reipl/ccw/parm", "boot parameters");
|
||||
if (strlen(l.bootparms) > BOOTPARMS_CCW_MAX)
|
||||
ERR_EXIT("Maximum boot parameter length exceeded "
|
||||
"(%zu/%u)", strlen(l.bootparms),
|
||||
BOOTPARMS_CCW_MAX);
|
||||
}
|
||||
if (access("/sys/firmware/reipl/ccw/parm", W_OK) == 0)
|
||||
write_str(l.bootparms, "reipl/ccw/parm");
|
||||
if (access("/sys/firmware/reipl/ccw/loadparm", W_OK) == 0)
|
||||
write_str(l.loadparm, "reipl/ccw/loadparm");
|
||||
write_str_optional(l.loadparm, "reipl/ccw/loadparm", l.loadparm_set,
|
||||
"loadparm");
|
||||
write_str_optional(l.bootparms, "reipl/ccw/parm", l.bootparms_set,
|
||||
"boot parameters");
|
||||
write_str(l.busid, "reipl/ccw/device");
|
||||
write_str("ccw", "reipl/reipl_type");
|
||||
|
||||
@@ -616,27 +622,21 @@ static void chreipl_fcp(void)
|
||||
ERR_EXIT("Device is on cio_ignore list, try \"cio_ignore -r %s\"?", l.busid);
|
||||
ERR_EXIT("Could not find FCP device \"%s\"", l.busid);
|
||||
}
|
||||
verify_write_access("reipl/fcp/device", "\"fcp\" re-IPL target");
|
||||
check_exists("reipl/fcp/device", "\"fcp\" re-IPL target");
|
||||
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_FCP_MAX) {
|
||||
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
|
||||
strlen(l.bootparms), BOOTPARMS_FCP_MAX);
|
||||
}
|
||||
/*
|
||||
* On old systems the FCP reipl loadparm cannot be set
|
||||
*/
|
||||
if (l.loadparm_set)
|
||||
verify_write_access("reipl/fcp/loadparm", "loadparm");
|
||||
if (l.bootparms_set) {
|
||||
verify_write_access("reipl/fcp/scp_data", "boot parameters");
|
||||
if (strlen(l.bootparms) > BOOTPARMS_FCP_MAX)
|
||||
ERR_EXIT("Maximum boot parameter length exceeded "
|
||||
"(%zu/%u)", strlen(l.bootparms),
|
||||
BOOTPARMS_FCP_MAX);
|
||||
}
|
||||
if (access("/sys/firmware/reipl/fcp/scp_data", W_OK) == 0)
|
||||
write_str(l.bootparms, "reipl/fcp/scp_data");
|
||||
if (access("/sys/firmware/reipl/fcp/loadparm", W_OK) == 0)
|
||||
write_str(l.loadparm, "reipl/fcp/loadparm");
|
||||
write_str_optional(l.loadparm, "reipl/fcp/loadparm", l.loadparm_set,
|
||||
"loadparm");
|
||||
write_str_optional(l.bootparms, "reipl/fcp/scp_data", l.bootparms_set,
|
||||
"boot parameters");
|
||||
write_str(l.busid, "reipl/fcp/device");
|
||||
write_str(l.wwpn, "reipl/fcp/wwpn");
|
||||
write_str(l.lun, "reipl/fcp/lun");
|
||||
write_str("fcp", "reipl/reipl_type");
|
||||
/*
|
||||
* set the boot record logical block address. Master boot
|
||||
* record. It is always 0 for Linux
|
||||
@@ -645,6 +645,7 @@ static void chreipl_fcp(void)
|
||||
if (!l.bootprog_set)
|
||||
sprintf(l.bootprog, "0");
|
||||
write_str(l.bootprog, "reipl/fcp/bootprog");
|
||||
write_str("fcp", "reipl/reipl_type");
|
||||
|
||||
print_fcp(0, 0);
|
||||
}
|
||||
@@ -652,17 +653,14 @@ static void chreipl_fcp(void)
|
||||
static void chreipl_nss(void)
|
||||
{
|
||||
check_nss_opts();
|
||||
verify_write_access("reipl/nss/name", "\"nss\" re-IPL target");
|
||||
if (l.bootparms_set) {
|
||||
verify_write_access("reipl/nss/parm", "boot parameters");
|
||||
if (strlen(l.bootparms) > BOOTPARMS_NSS_MAX)
|
||||
ERR_EXIT("Maximum boot parameter length exceeded "
|
||||
"(%zu/%u)", strlen(l.bootparms),
|
||||
BOOTPARMS_NSS_MAX);
|
||||
check_exists("reipl/nss/name", "\"nss\" re-IPL target");
|
||||
if (l.bootparms_set && strlen(l.bootparms) > BOOTPARMS_NSS_MAX) {
|
||||
ERR_EXIT("Maximum boot parameter length exceeded (%zu/%u)",
|
||||
strlen(l.bootparms), BOOTPARMS_NSS_MAX);
|
||||
}
|
||||
write_str_optional(l.bootparms, "reipl/nss/parm", l.bootparms_set,
|
||||
"boot parameters");
|
||||
write_str(l.nss_name, "reipl/nss/name");
|
||||
if (access("/sys/firmware/reipl/nss/parm", W_OK) == 0)
|
||||
write_str(l.bootparms, "reipl/nss/parm");
|
||||
write_str("nss", "reipl/reipl_type");
|
||||
print_nss(0);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "ipl_tools.h"
|
||||
|
||||
/*
|
||||
@@ -30,7 +31,7 @@ int fcp_is_device(const char *devno)
|
||||
*/
|
||||
void fcp_wwpn_get(const char *device, char *wwpn)
|
||||
{
|
||||
char path[PATH_MAX], buf[4096];
|
||||
char path[PATH_MAX], buf[20];
|
||||
FILE *fh;
|
||||
int rc;
|
||||
|
||||
@@ -41,7 +42,7 @@ void fcp_wwpn_get(const char *device, char *wwpn)
|
||||
rc = fscanf(fh, "%s", buf);
|
||||
if (rc <= 0)
|
||||
ERR_EXIT("Could not lookup WWPN \"%s\"", path);
|
||||
strncpy(wwpn, buf, 20);
|
||||
util_strlcpy(wwpn, buf, 20);
|
||||
fclose(fh);
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ void fcp_wwpn_get(const char *device, char *wwpn)
|
||||
*/
|
||||
void fcp_lun_get(const char *device, char *lun)
|
||||
{
|
||||
char path[PATH_MAX], buf[4096];
|
||||
char path[PATH_MAX], buf[20];
|
||||
FILE *fh;
|
||||
int rc;
|
||||
|
||||
@@ -62,7 +63,7 @@ void fcp_lun_get(const char *device, char *lun)
|
||||
rc = fscanf(fh, "%s", buf);
|
||||
if (rc <= 0)
|
||||
ERR_EXIT("Could not lookup LUN \"%s\"", path);
|
||||
strncpy(lun, buf, 20);
|
||||
util_strlcpy(lun, buf, 20);
|
||||
fclose(fh);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#include "ipl_tools.h"
|
||||
|
||||
struct globals g;
|
||||
@@ -31,7 +33,7 @@ void __noreturn print_version_exit(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
strncpy(g.prog_name, argv[0], sizeof(g.prog_name));
|
||||
util_strlcpy(g.prog_name, argv[0], sizeof(g.prog_name));
|
||||
if (strstr(argv[0], "chreipl") != NULL) {
|
||||
cmd_chreipl(argc, argv);
|
||||
return 0;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "ipl_tools.h"
|
||||
|
||||
/*
|
||||
@@ -81,10 +82,11 @@ void read_str(char *string, const char *path, size_t len)
|
||||
*/
|
||||
void read_fw_str(char *string, const char *file, size_t len)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char *path;
|
||||
|
||||
snprintf(path, sizeof(path), "/sys/firmware/%s", file);
|
||||
return read_str(string, path, len);
|
||||
util_asprintf(&path, "/sys/firmware/%s", file);
|
||||
read_str(string, path, len);
|
||||
free(path);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -129,7 +131,7 @@ int write_str_errno(char *string, char *file)
|
||||
snprintf(path, sizeof(path), "/sys/firmware/%s", file);
|
||||
fh = open(path, O_WRONLY);
|
||||
if (fh < 0)
|
||||
ERR_EXIT_ERRNO("Could not open \"%s\"", file);
|
||||
return errno;
|
||||
if (write(fh, value, strlen(value)) < 0)
|
||||
return errno;
|
||||
close(fh);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
@@ -74,9 +75,11 @@ static const struct tool_info iucv_tool[2] = {
|
||||
static void __noreturn usage_exit(const struct tool_info *prg, int is_error,
|
||||
const char *msg)
|
||||
{
|
||||
FILE *file = is_error ? stderr : stdout;
|
||||
|
||||
if (msg != NULL)
|
||||
fprintf(stderr, _("%s: %s\n"), prg->name, msg);
|
||||
fprintf(stderr, _(prg->usage), prg->name, prg->name);
|
||||
fprintf(file, _("%s: %s\n"), prg->name, msg);
|
||||
fprintf(file, _(prg->usage), prg->name, prg->name);
|
||||
exit(is_error ? 1 : 0); /* rc=1 .. invalid args */
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ lib = libdasd.a
|
||||
|
||||
all: $(lib)
|
||||
|
||||
objects = dasd_sys.o
|
||||
objects = dasd_sys.o dasd_ioctl.o
|
||||
|
||||
$(lib): $(objects) Makefile
|
||||
$(lib): $(objects)
|
||||
|
||||
install: all
|
||||
|
||||
|
||||
263
libdasd/dasd_ioctl.c
Normal file
263
libdasd/dasd_ioctl.c
Normal 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;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ lib = libu2s.a
|
||||
|
||||
all: $(lib)
|
||||
|
||||
objects = u2s.o misc.o
|
||||
objects = u2s.o
|
||||
|
||||
$(lib): $(objects)
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Misc - Local helper functions
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "lib/util_base.h"
|
||||
|
||||
/*
|
||||
* Helper function that copies a string safely
|
||||
*/
|
||||
size_t misc_strlcpy(char *dest, const char *src, size_t size)
|
||||
{
|
||||
size_t str_len = strlen(src);
|
||||
size_t len;
|
||||
|
||||
if (size) {
|
||||
len = MIN(size - 1, str_len);
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = '\0';
|
||||
}
|
||||
return str_len;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Misc - Local helper functions
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
size_t misc_strlcpy(char *, const char *, size_t);
|
||||
|
||||
#endif /* MISC_H */
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <wait.h>
|
||||
|
||||
#include "lib/u2s.h"
|
||||
#include "misc.h"
|
||||
#include "lib/util_libc.h"
|
||||
|
||||
#define DEV_BUFFER_LENGTH 20
|
||||
#define PATH_BUFFER_LENGTH 256
|
||||
@@ -113,7 +113,7 @@ static int extract_busid(char *name, char *busid) {
|
||||
if (!start)
|
||||
return -1;
|
||||
start++;
|
||||
len = misc_strlcpy(busid, start, BUSIDSIZE);
|
||||
len = util_strlcpy(busid, start, BUSIDSIZE);
|
||||
if (len >= BUSIDSIZE)
|
||||
return -1;
|
||||
|
||||
@@ -246,7 +246,7 @@ static int find_busid_in_proc(int maja, int mina, char *busid)
|
||||
while (fscanf(filp, "%[^(] %*[^)] ) at ( %d : %d %*[^\n]\n",
|
||||
bus, &majb, &minb) != EOF) {
|
||||
if ((maja == majb) && (mina == minb)) {
|
||||
len = misc_strlcpy(busid, bus, BUSIDSIZE);
|
||||
len = util_strlcpy(busid, bus, BUSIDSIZE);
|
||||
if (len < BUSIDSIZE)
|
||||
rc = 0;
|
||||
break;
|
||||
|
||||
@@ -13,7 +13,8 @@ examples = util_base_example \
|
||||
util_prg_example \
|
||||
util_rec_example
|
||||
|
||||
all: $(lib) $(examples)
|
||||
all: $(lib)
|
||||
examples: $(lib) $(examples)
|
||||
|
||||
objects = util_base.o \
|
||||
util_path.o \
|
||||
@@ -28,17 +29,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)
|
||||
|
||||
|
||||
@@ -198,3 +198,60 @@ int __util_vsprintf(const char *func, const char *file, int line,
|
||||
rc != -1, "Could not format string\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip leading and trailing spaces from string
|
||||
*
|
||||
* Remove string \a s leading and trailing spaces
|
||||
*
|
||||
* @param[in,out] s String to manipulate
|
||||
*
|
||||
* @returns Pointer to first non-space character in string \a s
|
||||
*/
|
||||
char *util_strstrip(char *s)
|
||||
{
|
||||
size_t size;
|
||||
char *end;
|
||||
|
||||
size = strlen(s);
|
||||
|
||||
if (!size)
|
||||
return s;
|
||||
|
||||
end = s + size - 1;
|
||||
while (end >= s && isspace(*end))
|
||||
end--;
|
||||
*(end + 1) = '\0';
|
||||
|
||||
while (*s && isspace(*s))
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy \a src to buffer \a dest of size \a size. At most size - 1
|
||||
* chars will be copied. \a dest will always be NUL terminated.
|
||||
*
|
||||
* Note: If the return value is greater than or equal to size truncation
|
||||
* occurred.
|
||||
*
|
||||
* @param[in] dest Destination buffer
|
||||
* @param[in] src Source string
|
||||
* @param[in] size Size of destination buffer
|
||||
*
|
||||
* @returns strlen Length of \a src string
|
||||
*/
|
||||
size_t util_strlcpy(char *dest, const char *src, size_t size)
|
||||
{
|
||||
size_t str_len = strlen(src);
|
||||
size_t len;
|
||||
|
||||
if (size) {
|
||||
len = MIN(size - 1, str_len);
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = '\0';
|
||||
}
|
||||
|
||||
return str_len;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@
|
||||
//! [code]
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_panic.h"
|
||||
|
||||
#define EXAMPLE_WORD " /sys/devices/system/cpu "
|
||||
|
||||
/*
|
||||
* Demonstrate that out of memory is automatically handled via panic()
|
||||
*/
|
||||
@@ -22,6 +25,12 @@ int main(void)
|
||||
unsigned long ulong_max = (unsigned long)-1;
|
||||
void *ptr;
|
||||
char *zeroes, *str;
|
||||
char buffer[sizeof(EXAMPLE_WORD)];
|
||||
|
||||
strcat(buffer, EXAMPLE_WORD);
|
||||
fprintf(stderr, "Try to remove leading and trailing spaces from "
|
||||
"\"%s\"\nresult = \"%s\"\n", EXAMPLE_WORD,
|
||||
util_strstrip(buffer));
|
||||
|
||||
/* Use util_strcat_realloc() for string concatenation */
|
||||
fprintf(stderr, "Try to concatenate \"Hello\", \", \" and \"world!\": ");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -86,7 +90,7 @@ static void test_util_path_is_xxx(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Usage: util_path_example [sysfs mount point] | "is_xxx"
|
||||
* Usage: util_path_example sysfs [MOUNT_POINT] | is_xxx
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -107,6 +111,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
out_fail:
|
||||
errx(EXIT_FAILURE, "Usage: %s sysfs <path> | is_xxx", argv[0]);
|
||||
errx(EXIT_FAILURE, "Usage: %s sysfs [MOUNT_POINT] | is_xxx", argv[0]);
|
||||
}
|
||||
//! [code]
|
||||
|
||||
@@ -34,6 +34,12 @@ const struct util_prg prg = {
|
||||
}
|
||||
};
|
||||
|
||||
static const struct option opt_list[] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "version", no_argument, NULL, 'v' },
|
||||
{ NULL, no_argument, NULL, 0 },
|
||||
};
|
||||
|
||||
/*
|
||||
* Demonstrate the util_prg_print() functions
|
||||
*/
|
||||
@@ -49,7 +55,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
util_prg_init(&prg);
|
||||
|
||||
while ((opt = getopt(argc, argv, "vhe")) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "vhe", opt_list, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'v':
|
||||
util_prg_print_version();
|
||||
|
||||
@@ -442,9 +442,9 @@ util_proc_dev_get_entry(dev_t device, int blockdev,
|
||||
|
||||
|
||||
/*
|
||||
* Provide one record form a /proc/mounts like file
|
||||
* Provide one record from a /proc/mounts like file
|
||||
*
|
||||
* The parameter file_name distinguishes the file form procfs which
|
||||
* The parameter file_name distinguishes the file from procfs which
|
||||
* is read, the parameter spec is the selector for the record.
|
||||
*/
|
||||
int util_proc_mnt_get_entry(const char *file_name, const char *spec,
|
||||
@@ -456,7 +456,6 @@ int util_proc_mnt_get_entry(const char *file_name, const char *spec,
|
||||
rc = get_file_buffer(&file, file_name);
|
||||
if (rc)
|
||||
return rc;
|
||||
rc = -1;
|
||||
while (!eof(&file)) {
|
||||
rc = scan_mnt_entry(&file, entry);
|
||||
if (rc)
|
||||
@@ -467,6 +466,7 @@ int util_proc_mnt_get_entry(const char *file_name, const char *spec,
|
||||
}
|
||||
util_proc_mnt_free_entry(entry);
|
||||
}
|
||||
rc = -1;
|
||||
out_free:
|
||||
free_file_buffer(&file);
|
||||
return rc;
|
||||
|
||||
@@ -59,6 +59,7 @@ static int __scandir(struct dirent ***de_vec, const char *path,
|
||||
int count = 0;
|
||||
DIR *dirp;
|
||||
|
||||
*de_vec = NULL;
|
||||
dirp = opendir(path);
|
||||
if (!dirp)
|
||||
return -1;
|
||||
@@ -134,13 +135,13 @@ int util_scandir_hexsort(const struct dirent **de1, const struct dirent **de2)
|
||||
* directory entries. The entries as well as the pointer array itself are
|
||||
* allocated by the function and has to be released by the user via free.
|
||||
*
|
||||
* @param[out] de_vec Vector of matched directory entries
|
||||
* @param[out] de_vec Vector of matched directory entries, or NULL
|
||||
* @param[in] compar_fn Callback function for sorting the entry list
|
||||
* @param[in] path Path to the directory to scan
|
||||
* @param[in] fmt Format string, describes the search pattern as POSIX regex
|
||||
* @param[in] ... Values for format string
|
||||
*
|
||||
* @returns Number of returned directory entries
|
||||
* @returns Number of returned directory entries, or -1 on error
|
||||
*/
|
||||
int util_scandir(struct dirent ***de_vec,
|
||||
int compar_fn(const struct dirent **first,
|
||||
|
||||
19
libvmcp/Makefile
Normal file
19
libvmcp/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
include ../common.mak
|
||||
|
||||
lib = libvmcp.a
|
||||
|
||||
examples = vmcp_example
|
||||
|
||||
all: $(lib)
|
||||
examples: $(lib) $(examples)
|
||||
|
||||
objects = vmcp.o
|
||||
|
||||
$(lib): $(objects)
|
||||
|
||||
install: all
|
||||
|
||||
vmcp_example: vmcp_example.o $(lib) $(rootdir)/libutil/libutil.a
|
||||
|
||||
clean:
|
||||
rm -f *.o $(lib) $(examples)
|
||||
134
libvmcp/vmcp.c
Normal file
134
libvmcp/vmcp.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* vmcp - z/VM CP function library
|
||||
*
|
||||
* Copyright IBM Corp. 2018
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/vmcp.h"
|
||||
|
||||
#define VMCP_DEVICE_NODE "/dev/vmcp"
|
||||
#define VMCP_GETSIZE _IOR(0x10, 3, int)
|
||||
#define VMCP_SETBUF _IOW(0x10, 2, int)
|
||||
#define VMCP_GETCODE _IOR(0x10, 1, int)
|
||||
|
||||
/*
|
||||
* Read at most COUNT bytes from FD into memory at location BUF.
|
||||
* Return number of bytes read on success, -1 on error.
|
||||
*/
|
||||
static ssize_t read_buffer(int fd, char *buf, ssize_t count)
|
||||
{
|
||||
ssize_t ret, done;
|
||||
|
||||
for (done = 0; done < (ssize_t)count; done += ret) {
|
||||
ret = read(fd, &buf[done], count - done);
|
||||
if (ret == -1 && errno == EINTR)
|
||||
continue;
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
if (ret == 0)
|
||||
break;
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a command to z/VM CP and return the response, the size in bytes
|
||||
* of the response and CP command response code.
|
||||
*
|
||||
* The member response contains the response from CP. It is a pointer
|
||||
* to a malloc'ed buffer which must be freed by the caller when the return
|
||||
* code is zero or VMCP_ERR_TOOSMALL.
|
||||
*
|
||||
* @param[in,out] cmd Pointer to struct vmcp_parm.
|
||||
* @param[in] cpcmd Pointer to CP command string.
|
||||
* @param[in] do_upper If true convert cpcmd string to upper case.
|
||||
* @param[out] cprc Return code of the CP command.
|
||||
* @param[out] response Return buffer, has been allocated via malloc()
|
||||
* must be freed by caller, see below.
|
||||
* @param[out] response_size Size of the response in bytes, can be larger
|
||||
* than buffer_size.
|
||||
*
|
||||
* @returns Zero on success or a negative error number on failure.
|
||||
* @retval VMCP_SUCCESS Success valid members: cprc, response,
|
||||
* response_size
|
||||
* @retval VMCP_ERR_OPEN Error opening VMCP device, valid members: none
|
||||
* @retval VMCP_ERR_SETBUF Error setting buffer, valid members: none
|
||||
* @retval VMCP_ERR_GETCODE Error getting cp exit code, valid members: none
|
||||
* @retval VMCP_ERR_WRITE Error write CP command, valid members: none
|
||||
* @retval VMCP_ERR_GETSIZE Error reading response size,
|
||||
* valid members: cprc
|
||||
* @retval VMCP_ERR_READ Error reading resp
|
||||
* @retval VMCP_ERR_TOOSMALL Error response buffer too small, response
|
||||
* truncated, valid members: cprc, response,
|
||||
* response_size
|
||||
*/
|
||||
int vmcp(struct vmcp_parm *cmd)
|
||||
{
|
||||
int rc = VMCP_SUCCESS, fd, len;
|
||||
char *cpcmd;
|
||||
|
||||
cmd->response = NULL;
|
||||
cmd->response_size = 0;
|
||||
cmd->cprc = 0;
|
||||
|
||||
fd = open(VMCP_DEVICE_NODE, O_RDWR);
|
||||
if (fd == -1)
|
||||
return VMCP_ERR_OPEN;
|
||||
|
||||
cpcmd = util_strdup(cmd->cpcmd); /* Exits on failure */
|
||||
if (cmd->do_upper)
|
||||
util_str_toupper(cpcmd);
|
||||
|
||||
if (ioctl(fd, VMCP_SETBUF, &cmd->buffer_size) == -1) {
|
||||
rc = VMCP_ERR_SETBUF;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (write(fd, cpcmd, strlen(cpcmd)) == -1) {
|
||||
rc = VMCP_ERR_WRITE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ioctl(fd, VMCP_GETCODE, &cmd->cprc) == -1) {
|
||||
rc = VMCP_ERR_GETCODE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ioctl(fd, VMCP_GETSIZE, &cmd->response_size) == -1) {
|
||||
rc = VMCP_ERR_GETSIZE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (cmd->response_size <= cmd->buffer_size) {
|
||||
len = cmd->response_size;
|
||||
} else {
|
||||
len = cmd->buffer_size;
|
||||
rc = VMCP_ERR_TOOSMALL;
|
||||
}
|
||||
|
||||
/* Exits on failure */
|
||||
cmd->response = (char *)util_zalloc(len + 1);
|
||||
|
||||
if (read_buffer(fd, cmd->response, len) == -1) {
|
||||
rc = VMCP_ERR_READ;
|
||||
free(cmd->response);
|
||||
cmd->response = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
close(fd);
|
||||
free(cpcmd);
|
||||
return rc;
|
||||
}
|
||||
65
libvmcp/vmcp_example.c
Normal file
65
libvmcp/vmcp_example.c
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* vmcp_example - Example program for vmcp.c
|
||||
*
|
||||
* Copyright 2018 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.
|
||||
*/
|
||||
|
||||
//! [code]
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "lib/vmcp.h"
|
||||
|
||||
/*
|
||||
* Demonstrate vmcp() function usage
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
struct vmcp_parm cp;
|
||||
int rc;
|
||||
|
||||
cp.cpcmd = "q osa";
|
||||
cp.buffer_size = VMCP_DEFAULT_BUFSZ;
|
||||
cp.do_upper = true;
|
||||
|
||||
rc = vmcp(&cp);
|
||||
|
||||
switch (rc) {
|
||||
case VMCP_SUCCESS:
|
||||
printf("%s\n", cp.response);
|
||||
free(cp.response);
|
||||
break;
|
||||
case VMCP_ERR_OPEN:
|
||||
errx(EXIT_FAILURE, "Could not open device %s", VMCP_DEVICE_NODE);
|
||||
break;
|
||||
case VMCP_ERR_SETBUF:
|
||||
errx(EXIT_FAILURE, "Could not set buffer size");
|
||||
break;
|
||||
case VMCP_ERR_GETCODE:
|
||||
errx(EXIT_FAILURE, "Could not query return code");
|
||||
break;
|
||||
case VMCP_ERR_GETSIZE:
|
||||
errx(EXIT_FAILURE, "Could not query response size");
|
||||
break;
|
||||
case VMCP_ERR_WRITE:
|
||||
errx(EXIT_FAILURE, "Could not issue CP command");
|
||||
break;
|
||||
case VMCP_ERR_READ:
|
||||
errx(EXIT_FAILURE, "Could not read CP response");
|
||||
break;
|
||||
case VMCP_ERR_TOOSMALL:
|
||||
free(cp.response);
|
||||
printf("Response truncated (requires %u bytes)\n",
|
||||
cp.response_size);
|
||||
errx(EXIT_FAILURE, "Response buffer (%u bytes) too small",
|
||||
cp.buffer_size);
|
||||
break;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
//! [code]
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
const char *what(void) const { return msg; }
|
||||
int code(void) const { return errorCode; }
|
||||
protected:
|
||||
char msg[200];
|
||||
char msg[2048];
|
||||
int errorCode;
|
||||
};
|
||||
|
||||
|
||||
@@ -98,19 +98,20 @@ VMDump::VMDump(const char *fileName) : Dump(fileName, "rb")
|
||||
dump_read(&adsrRecord,sizeof(adsrRecord),1,fh);
|
||||
|
||||
if(debug) {
|
||||
char buf_asc[1024];
|
||||
char buf[1024];
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "off=%d\n", adsrRecord.sec5_offset);
|
||||
dump_seek(fh, adsrRecord.sec5_offset, SEEK_SET);
|
||||
dump_read(buf, adsrRecord.sec5_len, 1, fh);
|
||||
ebcAsc(buf, adsrRecord.sec5_len);
|
||||
ebcAsc(buf, buf_asc, adsrRecord.sec5_len);
|
||||
for (i=0; i < adsrRecord.sec5_len; i++) {
|
||||
if ((buf[i]==0) || iscntrl(buf[i]))
|
||||
buf[i]=' ';
|
||||
if ((buf_asc[i]==0) || iscntrl(buf_asc[i]))
|
||||
buf_asc[i]=' ';
|
||||
}
|
||||
buf[adsrRecord.sec5_len] = 0;
|
||||
printf("symptom string1: %s\n",buf);
|
||||
buf_asc[adsrRecord.sec5_len] = 0;
|
||||
printf("symptom string1: %s\n",buf_asc);
|
||||
}
|
||||
|
||||
/* Record 2: fmbk */
|
||||
@@ -142,7 +143,8 @@ struct timeval VMDump::getDumpTime(void) const
|
||||
void VMDump::printDebug(void)
|
||||
{
|
||||
struct timeval time;
|
||||
char buf[1024];
|
||||
char fmbk_id[8];
|
||||
char albk_id[8];
|
||||
|
||||
s390TodToTimeval(adsrRecord.tod, &time);
|
||||
|
||||
@@ -165,9 +167,9 @@ void VMDump::printDebug(void)
|
||||
|
||||
/* fmbk */
|
||||
|
||||
ebcAsc(fmbkRecord.id, sizeof(fmbkRecord.id));
|
||||
fmbkRecord.id[7] = 0;
|
||||
printf("id : %s\n", fmbkRecord.id);
|
||||
ebcAsc(fmbkRecord.id, fmbk_id, sizeof(fmbkRecord.id));
|
||||
fmbk_id[7] = 0;
|
||||
printf("id : %s\n", fmbk_id);
|
||||
printf("fir rec nr: %i\n", fmbkRecord.rec_nr_fir);
|
||||
printf("vec rec nr: %i\n", fmbkRecord.rec_nr_vector);
|
||||
printf("access rec nr: %i\n", fmbkRecord.rec_nr_access);
|
||||
@@ -175,21 +177,9 @@ void VMDump::printDebug(void)
|
||||
|
||||
/* albk */
|
||||
|
||||
memcpy(buf, albkRecord.id, sizeof(albkRecord.id));
|
||||
ebcAsc(buf, sizeof(albkRecord.id));
|
||||
buf[8]=0;
|
||||
printf("ALBK id : %s\n",buf);
|
||||
|
||||
/* asibk */
|
||||
/*
|
||||
XXX
|
||||
memcpy(buf,asibkRecord.id,sizeof(asibkRecord.id));
|
||||
ebcAsc(buf,sizeof(asibkRecord.id));
|
||||
asibkRecord.id[8]=0;
|
||||
printf("ASIBK id : %s\n",buf);
|
||||
printf("storage : %x\n",asibkRecord.storage_size_2GB);
|
||||
printf("bitmapsrecs : %i\n",asibkRecord.nr_of_recs_of_first_bit_map);
|
||||
*/
|
||||
ebcAsc(albkRecord.id, albk_id, sizeof(albkRecord.id));
|
||||
albk_id[7]=0;
|
||||
printf("ALBK id : %s\n",albk_id);
|
||||
}
|
||||
|
||||
void VMDump::printInfo(void)
|
||||
|
||||
@@ -140,9 +140,15 @@ protected:
|
||||
} __packed;
|
||||
|
||||
/* Methods */
|
||||
inline void ebcAsc(char *inout, size_t len) const
|
||||
inline void ebcAsc(char *in, char *out, size_t size) const
|
||||
{
|
||||
iconv(ebcdicAsciiConv, &inout, &len, &inout, &len);
|
||||
size_t size_out = size;
|
||||
size_t size_in = size;
|
||||
size_t rc;
|
||||
|
||||
rc = iconv(ebcdicAsciiConv, &in, &size_in, &out, &size_out);
|
||||
if (rc == (size_t) -1)
|
||||
throw(DumpException("Code page translation EBCDIC-ASCII failed"));
|
||||
}
|
||||
|
||||
/* Members */
|
||||
|
||||
@@ -398,7 +398,7 @@ void vtoc_volume_label_set_volser (volume_label_t *vlabel, char *volser)
|
||||
|
||||
strcpy(s, " ");
|
||||
vtoc_ebcdic_enc(s, s, VOLSER_LENGTH);
|
||||
strncpy(vlabel->volid, s, VOLSER_LENGTH);
|
||||
memcpy(vlabel->volid, s, VOLSER_LENGTH);
|
||||
|
||||
if (i > VOLSER_LENGTH) i = VOLSER_LENGTH;
|
||||
|
||||
@@ -743,8 +743,8 @@ static void vtoc_init_format_1_8_label (
|
||||
bzero(f1->DS1DSNAM, sizeof(f1->DS1DSNAM));
|
||||
sprintf(str, "PART .NEW ");
|
||||
vtoc_ebcdic_enc(str, str, 44);
|
||||
strncpy(f1->DS1DSNAM, str, 44);
|
||||
strncpy((char *) f1->DS1DSSN, " ", 6);
|
||||
memcpy(f1->DS1DSNAM, str, 44);
|
||||
memcpy((char *) f1->DS1DSSN, " ", 6);
|
||||
f1->DS1VOLSQ = 0x0001;
|
||||
|
||||
vtoc_set_date(&f1->DS1CREDT,
|
||||
@@ -758,7 +758,7 @@ static void vtoc_init_format_1_8_label (
|
||||
f1->DS1NOBDB = 0x00;
|
||||
f1->DS1FLAG1 = 0x00;
|
||||
vtoc_ebcdic_enc("IBM LINUX ", str, 13);
|
||||
strncpy((char *)f1->DS1SYSCD, str, 13);
|
||||
memcpy((char *)f1->DS1SYSCD, str, 13);
|
||||
vtoc_set_date(&f1->DS1REFD,
|
||||
(u_int8_t) creatime->tm_year,
|
||||
(u_int16_t) creatime->tm_yday);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -593,17 +594,18 @@ static void cal_task_pcpu(struct task_t *task, const unsigned long long tics)
|
||||
*/
|
||||
static int read_stat(struct task_t *task)
|
||||
{
|
||||
int ppid, tty, proc;
|
||||
unsigned long flags, pri, nice;
|
||||
unsigned long long maj_flt, utime, stime, cutime, cstime;
|
||||
unsigned long long maj_flt = 0, utime = 0, stime = 0, cutime = 0,
|
||||
cstime = 0;
|
||||
unsigned long flags = 0, pri = 0, nice = 0;
|
||||
char *cmd_start, *cmd_end, *cmdlenp, *cmdp;
|
||||
int ppid = 0, tty = 0, proc = 0, rc;
|
||||
|
||||
snprintf(fname, sizeof(fname), "/proc/%u/stat", task->pid);
|
||||
if (read_file(fname, buf, sizeof(buf) - 1) == -1)
|
||||
return 0;
|
||||
|
||||
cmd_start = strchr(buf, '(') + 1;
|
||||
cmd_end = strchr(cmd_start, ')');
|
||||
cmd_end = strrchr(cmd_start, ')');
|
||||
name_lens.cmd_len = cmd_end - cmd_start;
|
||||
cmdlenp = mon_record + sizeof(struct monwrite_hdr);
|
||||
cmdlenp += sizeof(struct procd_hdr);
|
||||
@@ -624,7 +626,7 @@ static int read_stat(struct task_t *task)
|
||||
memcpy(cmdlenp, &name_lens.cmd_len, sizeof(__u16));
|
||||
|
||||
cmd_end += 2;
|
||||
sscanf(cmd_end,
|
||||
rc = sscanf(cmd_end,
|
||||
"%c %d %*d %*d %d %*d "
|
||||
"%lu %*s %*s %Lu %*s "
|
||||
"%Lu %Lu %Lu %Lu "
|
||||
@@ -641,6 +643,8 @@ static int read_stat(struct task_t *task)
|
||||
&utime, &stime, &cutime, &cstime,
|
||||
&pri, &nice,
|
||||
&proc);
|
||||
if (rc != 12)
|
||||
syslog(LOG_ERR, "bad data in %s \n", fname);
|
||||
task->ppid = (__u32)ppid;
|
||||
task->tty = (__u16)tty;
|
||||
task->flags = (__u32)flags;
|
||||
@@ -897,41 +901,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)
|
||||
|
||||
@@ -134,8 +134,8 @@ echo "$cmd: Copying virtio modules"
|
||||
mkdir -p $builddir/$netdir
|
||||
mkdir -p $builddir/$blkdir
|
||||
set +e
|
||||
cp $netdir/virtio_net.ko $builddir/$netdir 2> /dev/null
|
||||
cp $blkdir/virtio_blk.ko $builddir/$blkdir 2> /dev/null
|
||||
cp $netdir/virtio_net.ko* $builddir/$netdir 2> /dev/null
|
||||
cp $blkdir/virtio_blk.ko* $builddir/$blkdir 2> /dev/null
|
||||
set -e
|
||||
|
||||
# Busybox (+ dependencies)
|
||||
@@ -170,13 +170,9 @@ cat <<'EOF' > $builddir/init
|
||||
/bin/mount -t tmpfs none /run
|
||||
|
||||
/sbin/modprobe virtio_net
|
||||
/sbin/udhcpc -O pxeconffile -O pxepathprefix &
|
||||
/sbin/udhcpc -O pxeconffile -O pxepathprefix -x 93:001F &
|
||||
|
||||
while true
|
||||
do
|
||||
/sbin/pxeboot.script
|
||||
/bin/sleep 1
|
||||
done
|
||||
/sbin/pxeboot.script
|
||||
EOF
|
||||
# --- end init script
|
||||
chmod +x $builddir/init
|
||||
@@ -241,6 +237,7 @@ case "$1" in
|
||||
echo " router: $router"
|
||||
echo " domain: $domain $dns"
|
||||
echo " tftp: $siaddr"
|
||||
echo " pxepathprefix: $pxepathprefix"
|
||||
# flush routes
|
||||
/sbin/ip route flush table all
|
||||
# setup if link
|
||||
@@ -276,6 +273,7 @@ case "$1" in
|
||||
echo "siaddr=$siaddr" > $PXECONF
|
||||
echo "interface=$interface" >> $PXECONF
|
||||
echo "ip=$ip" >> $PXECONF
|
||||
echo "pxepathprefix=$pxepathprefix" >> $PXECONF
|
||||
fi
|
||||
;;
|
||||
|
||||
@@ -303,16 +301,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,7 +355,8 @@ then
|
||||
set +e
|
||||
for c in $CONFIGS
|
||||
do
|
||||
if /usr/bin/tftp -g -l /tmp/config -r pxelinux.cfg/$c $siaddr
|
||||
echo "fetching config pxelinux.cfg/$c from $siaddr"
|
||||
if /usr/bin/tftp -g -l /tmp/config -r ${pxepathprefix}pxelinux.cfg/$c $siaddr
|
||||
then
|
||||
break
|
||||
fi
|
||||
@@ -361,34 +370,39 @@ 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")
|
||||
ipappend=$(/bin/grep -i "^[[:space:]]*ipappend" /tmp/config | sed "s/^[[:space:]]*ipappend[[:space:]]*//I")
|
||||
|
||||
if [ -z "$kernel" ]
|
||||
then
|
||||
echo no kernel statement found in config
|
||||
exit
|
||||
else
|
||||
/usr/bin/tftp -g -l /tmp/kernel -r $kernel $siaddr
|
||||
echo fetch kernel $kernel from $siaddr
|
||||
/usr/bin/tftp -g -l /tmp/kernel -r $pxepathprefix$kernel $siaddr
|
||||
fi
|
||||
|
||||
if [ -n "$initrd" ]
|
||||
then
|
||||
/usr/bin/tftp -g -l /tmp/initrd -r $initrd $siaddr
|
||||
echo fetch initrd $initrd from $siaddr
|
||||
/usr/bin/tftp -g -l /tmp/initrd -r $pxepathprefix$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=""
|
||||
if [ "$ipappend" = "2" ]; then
|
||||
$append="$append BOOTIF=01-$ifaddr"
|
||||
fi
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -85,20 +85,12 @@ void init_ibmOSAMib(void) {
|
||||
|
||||
/* query OSA-E device driver for OSA-E devices and mark them in IF-MIB interface list */
|
||||
osaexp_num = query_OSA_EXP ( &if_list, ifNumber );
|
||||
if ( osaexp_num < 0 )
|
||||
if ( osaexp_num == 0 )
|
||||
{
|
||||
fprintf( stderr, "init_ibmOSAMib(): "
|
||||
"OSA-E device driver query interface ioctl() failed\n"
|
||||
"check agent log file for more details\n"
|
||||
"Cannot start subagent...exiting...\n");
|
||||
exit(1);
|
||||
}
|
||||
else if ( osaexp_num == 0 )
|
||||
{
|
||||
fprintf( stderr, "init_ibmOSAMib(): bad or no OSA-E devices reported\n"
|
||||
"check agent log file for more details\n"
|
||||
"Cannot start subagent...exiting...\n");
|
||||
exit(1);
|
||||
get_time( time_buf );
|
||||
snmp_log( LOG_ERR, "%s init_ibmOSAMib(): none of the %d interfaces is a real "
|
||||
"OSA-E device - starting subagent anyway\n", time_buf, ifNumber);
|
||||
return;
|
||||
}
|
||||
/* end if */
|
||||
|
||||
|
||||
@@ -1204,18 +1204,7 @@ void update_mib_info ()
|
||||
* and mark them in IF-MIB interface list
|
||||
* */
|
||||
osaexp_num = query_OSA_EXP( &tmp_list, if_num );
|
||||
if ( osaexp_num < 0 )
|
||||
{
|
||||
get_time( time_buf );
|
||||
fprintf( stderr, "%s update_mib_info(): "
|
||||
"OSA-E device driver query interface ioctl() "
|
||||
"failed\nupdate_mib_info(): going to stop osasnmpd daemon\n"
|
||||
"update_mib_info(): check subagent logfile for more details\n"
|
||||
"update_mib_info(): sending termination signal to osasnmpd...\n",
|
||||
time_buf );
|
||||
exit(-1);
|
||||
}
|
||||
else if ( osaexp_num == 0 )
|
||||
if ( osaexp_num == 0 )
|
||||
{
|
||||
get_time( time_buf );
|
||||
snmp_log( LOG_ERR, "%s update_mib_info(): "
|
||||
@@ -1698,9 +1687,8 @@ int query_IF_MIB ( IF_LIST** ifList )
|
||||
* IN int if_Number: number of network interfaces
|
||||
* returns: int num - number of OSA Express devices found on this
|
||||
* system (>=0)
|
||||
* -1 -an error occurred , no valid info avail
|
||||
*********************************************************************/
|
||||
int query_OSA_EXP ( IF_LIST** ifList, int if_Number )
|
||||
unsigned int query_OSA_EXP ( IF_LIST** ifList, int if_Number )
|
||||
{
|
||||
int j, num = 0;
|
||||
char time_buf[TIME_BUF_SIZE]; /* date/time buffer */
|
||||
|
||||
@@ -91,7 +91,7 @@ void update_mib_info ( );
|
||||
int query_IF_MIB( IF_LIST** );
|
||||
|
||||
/* retrieves OSA Express interface information from kernel */
|
||||
int query_OSA_EXP ( IF_LIST** ,int );
|
||||
unsigned int query_OSA_EXP ( IF_LIST** ,int );
|
||||
|
||||
/* get time of day */
|
||||
int get_time( char* );
|
||||
|
||||
@@ -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; \
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user