Commit Graph

19 Commits

Author SHA1 Message Date
Jan Höppner
3a60b4caa8 fdasd: Fix missing hyphen escapes in the man page
Hyphens are converted by groff to a different unicode character leading
to failing command execution of copy-pasted options or examples.

Ensure that all hyphens are properly escaped.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-05-27 16:51:19 +02:00
Jan Höppner
0695c79f4e fdasd: Improve -k/--keep_volser description slightly
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-11-07 14:13:38 +01:00
Jan Höppner
8837ea24cb fdasd: Fix trailing whitespace in man page
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2023-11-07 14:13:38 +01:00
Viktor Mihajlovski
a0a71efde0 fdasd: Fix endless menu loop on EOF
Hitting CTRL-D anywhere will cause fdasd to go into an endless loop
displaying the main menu over and over again. Killing fdasd (e.g.
via CTR-C) is the only way out.
The issue is that read_line() is just ignoring the resulting EOF
condition on stdin. Subsequent invocations of read_line() will return
immediately and thus cause the loop. A simple fix is to reset stdin
after EOF. A caller of read_line() will see the same behavior as for
EOL with no input.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2022-04-06 16:11:19 +02:00
Nikita Dubrovskii
bf9482709f fdasd: Use increased retry count for dasd_reread_partition_table
If fdasd is used right after dasdfmt, it may fail with the following
error due to udev still processing events for the device:

```
fdasd error:  IOCTL error: Error while rereading partition table.
```

Call dasd_reread_partition_table() with an increased retry value to
circumvent this issue.

Closes: https://github.com/ibm-s390-tools/s390-tools/pull/103
Signed-off-by: Nikita Dubrovskii <nikita@linux.ibm.com>
[hoeppner@linux.ibm.com: Reword commit message]
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-12-15 11:10:50 +01:00
Marc Hartmayer
c673bacd7e Replace UTIL_ARRAY_SIZE with ARRAY_SIZE
Replace `UTIL_ARRAY_SIZE` with `ARRAY_SIZE` and remove it from
`util_base.h`.

Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2020-05-06 17:36:39 +02:00
Jan Höppner
80443ab629 fdasd: Fix exit status in error cases
In error cases, fdasd returns -1 which results in the return value 255.
This is due to the fact that only the low-order 8 bits are used for the
status value. See 2.13 Status Information [1] in the POSIX standard and
the exit() POSIX man page [2] for more details.

Instead of returning -1, use the EXIT_FAILURE constant to indicate
unsuccessful termination properly.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/exit.html

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-07-31 16:00:40 +02:00
Jan Höppner
57a797350c libu2s: Remove the library
There are no users of libu2s anymore. Remove it.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
75e3afb6a0 libdasd: Move get_host_access_count() to libdasd
Reading DASD specific sysfs attributes should be collected in one
library. Move get_host_access_count() to libdasd/dasd_sys.

Remove the old implementation and update any user accordingly.
Also, fix the build order for zdsfs.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2019-05-21 14:16:53 +02:00
Jan Höppner
a931428908 fdasd: Replace strncpy() with memcpy()
While assembling the volume label, strncpy() is used. As we don't care
about NUL termination of the strings here, safely replace strncpy() with
memcpy() and get rid of the following compile warnings:

fdasd.c: In function ‘fdasd_write_vtoc_labels’:
fdasd.c:1324:4: warning: ‘strncpy’ output truncated before terminating
nul copying 44 bytes from a string of the same length
[-Wstringop-truncation]
    strncpy(ch, "LINUX.V               "
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     "                      ", 44);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1332:4: warning: ‘strncpy’ output truncated before terminating
nul copying 5 bytes from a string of the same length
[-Wstringop-truncation]
    strncpy(c1, ".PART", 5);
    ^~~~~~~~~~~~~~~~~~~~~~~
In function ‘fdasd_write_vtoc_labels’,
    inlined from ‘fdasd_write_labels’ at fdasd.c:1399:3:
fdasd.c:1329:4: warning: ‘strncpy’ output may be truncated copying 6
bytes from a string of length 6 [-Wstringop-truncation]
    strncpy(c1, volser, VOLSER_LENGTH);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1336:4: warning: ‘strncpy’ output may be truncated copying 5
bytes from a string of length 5 [-Wstringop-truncation]
    strncpy(c1, dsno, 5);
    ^~~~~~~~~~~~~~~~~~~~
fdasd.c:1340:4: warning: ‘strncpy’ output truncated before terminating
nul copying as many bytes from a string as its length
[-Wstringop-truncation]
    strncpy(c1, dsname, strlen(dsname)); /* We don't want \0 */
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdasd.c:1313:4: warning: ‘strncpy’ output may be truncated copying 31
bytes from a string of length 44 [-Wstringop-truncation]
    strncpy(c1, s2, 31);
    ^~~~~~~~~~~~~~~~~~~
In function ‘fdasd_change_part_type’,
    inlined from ‘main’ at fdasd.c:3000:4:
fdasd.c:1639:3: warning: ‘strncpy’ output may be truncated copying 6
bytes from a string of length 19 [-Wstringop-truncation]
   strncpy(ch, str, 6);
   ^~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:42 +01:00
Jens Remus
17cade6e7f fdasd: fix resource leak in fdasd_parse_conffile()
Deallocate the file descriptor.

Found with Cppcheck:
[fdasd/fdasd.c:731]: (error) Resource leak: fd

Cc: Stefan Haberland <sth@linux.ibm.com>
Cc: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
90ea5d9e5d fdasd: check array limits before indexing
Found using Cppcheck:
[fdasd/fdasd.c:261]: (style) Array index 'from' is used before limits check.

Cc: Stefan Haberland <sth@linux.ibm.com>
Cc: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Jens Remus
6accffd583 fdasd: fix possible integer overflow
The computation of blk in functions fdasd_check_volume() and
fdasd_write_vtoc_labels() contained the possibility for an undetected
unsigned integer overflow. Unconditionally subtracting one from the
return value of function cchhb2blk() may cause an unsigned integer
overflow, as cchhb2blk() may return zero if cc, hh, and b are all zero.

Resolves Cppcheck style warning:
[fdasd/fdasd.c:1260]: (style) Checking if unsigned variable 'blk' is less than zero.

Cc: Stefan Haberland <sth@linux.ibm.com>
Cc: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2018-11-16 15:01:41 +01:00
Rafael Fonseca
8b11ea73ac fdasd: Use libdasd for DASD ioctls
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:05:02 +01:00
Rafael Fonseca
45e20a5044 fdasd: Apply project's coding conventions
GitHub-ID: #19

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Acked-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.vnet.ibm.com>
2017-12-14 16:04:19 +01:00
Jan Höppner
cd085dc721 fdasd: Skip partition check with the force option
Before writing data to the disk, fdasd always checks whether a partition
is specified to prevent writing partition tables to a partition.

However, this also prevents the user from writing partition tables to
loop devices > loop0, even when the force option is specified.
Technically, those are not partitions.

Therefore, allow writing partition tables to partitions when the force
option is specified.

Fixes: #4

Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-15 05:05:58 +02:00
Michael Holzheu
221e74c27c Get rid of gcc 7 "fall through" warnings
With gcc 7 we get warnings like the following:

 fdasd.c: In function 'main':
 fdasd.c:3055:4: warning: this statement may fall through
                          [-Wimplicit-fallthrough=]
     fdasd_exit(&anchor, 0);
     ^~~~~~~~~~~~~~~~~~~~~~
 fdasd.c:3056:3: note: here
    default:
    ^~~~~~~

Fix this by marking functions with "__noreturn" to help gcc.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-09-06 13:05:01 +02:00
Michael Holzheu
e0c48d6af8 Fix copyright dates
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 12:06:12 +02:00
Michael Holzheu
b627b8d8e1 Initial s390-tools-2.0.0 import
This commit is based on the s390-tools-1.39.0 version.

Changes on top of s390-tools-1.39.0:

 - Add MIT license to all source files
 - Add LICENSE file
 - Transform REAMDE to README.md (markdown)
 - Add AUTHORS.md file
 - Add CONTRIBUTING.md file
 - Move changelog from README to CHANGELOG.md file

Reviewed-by: Stefan Haberland <sth@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
2017-08-21 10:55:40 +02:00