25 Commits

Author SHA1 Message Date
Iustin Pop
e6f79d85ec Re-format code via clang-format
Technically, via `make reindent` :)
2025-01-05 16:27:41 +01:00
Kai Mäkisara
42dd44bb90 stinit: Change stinit to return one if setting one or more options fails
Previously, stinit returned zero even if it fails to set the options.
This patch changes the return value to one if one or more of the options
can't be set for a device if the tape numbers are given on command line.
If no numbers are given, stinit returns zero (as before this patch).
After this change, scripts (udev rules) can more easily detect when
stinit fails.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
2025-01-05 16:26:21 +01:00
Kai Mäkisara
ff108770be mt: stinit: Add support for setting and clearing MT_ST_NOWAIT_EOF
Add code to set/clear the MT_ST_NO_WAIT option bit for MTSETDRVBUFFER.
The string used in the user interface is 'weof-no-wait'.

Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
2025-01-05 14:54:06 +01:00
Iustin Pop
34978b4019 Fix a 25-year old bug \o/
This is a trivial bug, but a bug nevertheless. It's present in the
first commit in this (synthetic) Git repository, and from my
investigations into very old versions - mt-st-0.5 from an old RedHat
version - it was already present in the `stinit.c` version from Apr
11, 1998, which makes it 25 years and 9 days old. This is a new record
for me, which I don't think I'll beat :)

The bug is trivial, in retrospect, and was found just by accident
because with the 1.6 release uploaded in Debian, the new test suite is
run on multiple architectures. While amd64/x86 doesn't trigger this
bug in neither '-O2' nor '-g' build, mips64el, arm64, and s390x do
show the bug in the optimised builds (and only in them) as follows:

amd64:

```
$ /sbin/stinit -v -v -v -p -f ./tests/data/bad-definition.data

Parsing modes for ('XYZ', 'UVW1', '').
Mode 1 definition:  blocksize=
Warning: errors in definition for ('XYZ', 'UVW1', ''):
 blocksize=

Definition parse completed. Errors found!
```

s390x:

```
$ ./stinit -p -v -v -v -f tests/data/bad-definition.data

Parsing modes for ('XYZ', 'UVW1', '').
Mode 1 definition:  blocksize=
Warning: errors in definition for ('XYZ', 'UVW1', ''):
 �H

Definition parse completed. Errors found!
```

And shelltest fails to parse that binary output, in 4/5 cases, which
by luck caused the builds to fail. From there it was a fun
investigation into trying to find why it behaves like that.

This bug is caught by the recently introduced MSAN build in the GitHub
CI, so will rely less on luck in the future.

I'm not 100% sure on the semantics of the fix, but it should only
affect this case (missing value to argument), so should be a well
localised fix.

Signed-off-by: Iustin Pop <iustin@k1024.org>
2023-04-20 23:18:23 +02:00
Iustin Pop
d5720ee85e Fix stinit file parsing broken in 874d58d9
For some reason I missed this during the pull request (even if
trivial), thanks travis-ci for letting me know (indirectly :).

Fixes #14.
2019-10-13 20:14:39 +02:00
Iustin Pop
a15c02e572 More formatting fixes
Just another run of clang-format.
2019-02-16 14:13:02 +01:00
Gris Ge
874d58d952 Fix coverity scan warnings.
* Fix the leaking `fd`.
 * Fix the possible overflow of strcat().

Signed-off-by: Gris Ge <fge@redhat.com>
2019-02-16 14:08:35 +01:00
Iustin Pop
0442de1f7c stinit: mark usage() as non-returning
So that we don't have to fake it's non-returnness.
2016-05-06 22:18:30 +02:00
Iustin Pop
013135f604 stinit: check that tape index values are fully correct
Right now stinit ignores leftover chars in strings such as '9a'; let's
make sure we don't miss these (at least the warning message might give
a hint)..
2016-05-06 22:13:02 +02:00
Iustin Pop
14a9ca5df4 LARGE CHURN: reindent source code
The source code seems to have, over time, become less self-consistent
in style. In order to not have to keep this up manually, switch over
indenting to clang-format. A .clang-format file is provided to give
repeatable results.

The main difference is switching from tabs to non-tabs
usage. Otherwise the changes are mostly minor and leading to more
consistency. Contributions to the format style welcome!

Nota bene: this should have had no code impact. Any actual code
changes (beyond indenting) are bugs in the re-indent process.
2016-05-06 21:54:34 +02:00
Iustin Pop
95c0789085 Small cleanup: use passed buflen in stinit:next_block
Instead of assuming all passed buffers are DEFMAX, use the given
buflen. Also change some types (int→size_t) since these are all
related to string sizes.
2016-05-02 01:09:36 +02:00
Iustin Pop
22df208f19 Fix config file parsing bug in stinit
There is a long-standing (it was already present in 0.7, so around 15
years) bug in stinit's find_pars function, related to parsing per-mode
configurations. Due to the way the temporary buffers are used, at one
point a strcat() is called on overlapping strings. This is documented
not to work, but it seems the behaviour is not deterministic: for some
pairs of strings it works, for some not (possibly related to distance
between strings, etc.). This results in the fact that parsing the
provided example file fails for _some_ entries, but not for all, with
a seemingly wrong error message (showing snippets of the input file
that do not exist).

Fix this issue in a trivial way by simply using a different (new)
buffer during the mode parsing.
2016-05-02 01:01:30 +02:00
Alexey Svistunov
a0f5b83bd7 Code cleanup patch from SUSE package
This adds annotations for unused arguments to a few functions, and
cleans a bit the typedefs.

Closes #6.
2016-05-01 04:17:00 +02:00
Felix Janda
0c7dd2a8de Fix compilation with musl libc
It is necessary to include <limits.h> to expose PATH_MAX.
2016-04-22 18:17:06 +02:00
Iustin Pop
0ee3591e51 Rework the dist target and drop LSM file
Short of moving to autotools, this is the best that can be done:

- move the version from hardcoded in the .c files, to a
  dynamically-built `version.h` file so that we only declare the
  version in one place
- build a better dist file (.tar.gz) by explicitly selecting which
  files to copy, instead of unbounded recursion from the source
  directory
- ensure that the files being copied to the archive have a sane
  user/group and mode
- add a distcheck target that simply reuses the archive to build and
  run the programs, and then regenerate the archive from itself

autotools would solve all this by default, but still feels too
heavyweight for just two .c files.

Additionall, drop the .lsm file. It seems mostly useless these days;
I'll be happy to reinstate it however if anyone cares.
2016-02-07 20:38:27 +01:00
Iustin Pop
506424dc37 Update maintainership info in the remaining places
Also remove the 'last modified' entries as they're available from the VCS.
2016-02-07 18:21:29 +01:00
Iustin Pop
e4367cfb8c Recode all ISO8859-1 files in UTF-8
While looking at Fedora's build spec for mt-st, I saw that they recode
the README.stinit file to UTF-8; this makes a lot of sense, so let's
recode all non-UTF files in UTF-8.
2016-02-04 20:14:04 +01:00
Dan Horák
6f410d3e51 Print all options in stinit's help
[iustin@k1024.org: import fedora patches]
2016-02-04 20:12:30 +01:00
Iustin Pop
ffb34b5ca9 Silence two further warnings
These two local variables seem unused, probably artifacts from some
older refactoring.
2015-05-29 10:57:59 +02:00
Jan Christoph Nordholz
4d88fb7a01 Get rid of all those gcc warnings
For the stinit.c change, buflen is positive in all cases, so use a
cast. The other changes are straightforward.
2015-05-29 10:28:47 +02:00
David Binderman
1f4613eb2b Fix pointer/char comparison
[stinit.c:151]: (warning) Char literal compared with pointer
'cp2'. Did you intend to dereference it?
2015-05-16 17:48:13 +02:00
Kai Mäkisara
c232ed0dd2 Backdated import of mt-st version 1.1
This is an import of the mt-st upstream release 1.1 as it appeared in
the Debian archives and on ftp://ftp.ibiblio.org/pub/linux/system/backup.
2015-05-16 17:46:05 +02:00
Kai Mäkisara
be12266b61 Backdated import of mt-st version 0.9b
This is an import of the mt-st upstream release 0.9b as it appeared in
the Debian archives.
2015-05-16 17:39:25 +02:00
Kai Mäkisara
11875969cd Backdated import of mt-st version 0.8
This is an import of the mt-st upstream release 0.8 as it appeared in
the Debian archives.
2015-05-16 17:33:19 +02:00
Kai Mäkisara
fcb4fbe0d1 Backdated import of mt-st version 0.7
This is an import of the mt-st upstream release 0.7 as it appeared in
the Debian archives.
2015-05-16 17:26:03 +02:00