Commit Graph

7431 Commits

Author SHA1 Message Date
rin f5d5d6d50b bioctl(8): bio_show_volumes(): Do not return pointer to stack.
Found by GCC 12.
2023-08-04 03:45:07 +00:00
mrg 2ff65d1cde avoid double-free.
found by GCC 12.
2023-08-03 08:06:11 +00:00
gutteridge 1b68370975 gpt.8: fix some grammar
(The BUGS section seems perhaps a little outdated in its warnings of
potential incompatible changes.)
2023-07-15 21:18:06 +00:00
gutteridge f2907125f8 gpt.8: drop cross-reference to cvs(1)
It's no more useful to reference cvs(1) than, say, openssl(1), and
should be self-evident, anyway.
2023-07-15 21:11:58 +00:00
riastradh 976fa97423 Revert "fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S)."
C17 lifted this restriction.
2023-07-05 10:59:08 +00:00
riastradh 1e73453c9d Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."
C17 lifted this restriction.
2023-07-05 10:58:58 +00:00
riastradh e1ba8d75ab Revert "nvmectl(8): Ensure A divides S before aligned_alloc(A, S)."
C17 lifted this restriction.
2023-07-05 10:58:46 +00:00
riastradh 252616f8e4 fsck_ffs(8): Fix whitespace issues.
- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.
2023-07-04 20:40:53 +00:00
riastradh 8d8fdc5894 nvmectl(8): Ensure A divides S before aligned_alloc(A, S).
Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10
2023-07-04 20:40:43 +00:00
riastradh 5ebd7a0afa newfs(8): Ensure A divides S before aligned_alloc(A, S).
Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10
2023-07-04 20:40:34 +00:00
riastradh 573d5c8231 fsck_ffs(8): Ensure A divides S before aligned_alloc(A, S).
Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10
2023-07-04 20:40:22 +00:00
lukem a9a927dd92 adapt to ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
Simplify CWARNFLAGS to use ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
which works for both clang and gcc, and remove compiler-specific
equivalents.
2023-06-03 21:26:27 +00:00
lukem c4b7a9e794 bsd.own.mk: rename GCC_NO_* to CC_WNO_*
Rename compiler-warning-disable variables from
	GCC_NO_warning
to
	CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 09:09:01 +00:00
lukem f937c412f3 bsd.own.mk: rename to CC_WNO_ADDRESS_OF_PACKED_MEMBER
Provide a single variable
	CC_WNO_ADDRESS_OF_PACKED_MEMBER
with options for both clang and gcc, to replace
	CLANG_NO_ADDR_OF_PACKED_MEMBER
	CC_NO_ADDR_OF_PACKED_MEMBER
	GCC_NO_ADDR_OF_PACKED_MEMBER

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 08:52:53 +00:00
kre a83f9264e8 pathadj() is required to succeed. If it cannot, simply issuing a
warning and continuing is not good enough.  Change the warning to
an error (and hence immediate exit) instead, that's all we can do.

Problem pointed out by tlaronde@polynum.com

XXX - pullup -10 (others?)
2023-05-25 17:37:05 +00:00
pgoyette 29d8ffc91f ALso fix chgrp Synopsis to include -d option 2023-05-20 09:41:34 +00:00
pgoyette b1c9211c1b dd -d to the Synopsis 2023-05-20 00:54:15 +00:00
tsutsui 2b88da67b5 Use https for Ext2 documentation URLs. 2023-05-17 09:54:59 +00:00
rillig 33e56a937d newfs_udf: fix wording in comment 2023-05-10 12:23:42 +00:00
christos b7424e7c5d KNF: no space after ( and before ), constants on the RHS (like everywhere else
in this file).
2023-05-04 18:34:55 +00:00
martin 5495155076 Cast -1 to expected type and fix a edititing mishap to make this build. 2023-05-04 18:04:55 +00:00
pgoyette 0f8326b377 Add a -d flag to avoid changing a file's owner/group to the current
value.  This avoids some unnecessary operations on the file.

As discussed on tech-userlevel@
2023-05-04 17:07:56 +00:00
pgoyette 2c712e3804 Fix typo in comment 2023-04-28 09:56:45 +00:00
jkoshy c2d5d65bef mount_procfs(8): Document the format of the region descriptor
lines contained in the 'map' and 'maps' special files.
2023-04-18 18:42:20 +00:00
riastradh eaeecb4f73 rndctl(8): Take omitted name/type as empty device name.
This can now be used to change flags for all sources at once.

XXX pullup-10
2023-04-11 13:17:32 +00:00
rillig dd57c37d01 mount_portal: fix lint warnings about extern and empty declarations 2023-04-04 20:39:36 +00:00
ryo 65f9de9e0d commonize case block 2023-04-02 18:15:24 +00:00
ryo 60536c5379 don't pass add=1 to print_tree() when displaying by specifying nodes.
For example, "sysctl -w kern.mbuf=" had been displayed extra node names in the MIB.
 # sysctl -w kern.mbuf=
 kern.mbuf.mbuf.msize = 512
 kern.mbuf.mbuf.mclbytes = 2048
 :
2023-04-02 18:11:26 +00:00
chs 8f4d5a45a2 Apply this commit from FreeBSD:
commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Wed Aug 17 14:19:59 2022 -0700

    Improve handling of missing '.' and '..' in UFS directories.

    The UFS filesystem expects to find '.' and '..' as the first two entries
    in a directory. The kernel's UFS name cache can become quite confused
    when these two entries are not present as the first two entries.

    Prior to this change, when the fsck_ffs(8) utility detected that
    '.' and/or '..' were missing, it would report them, but only offered
    to replace them if the space at the beginning of the directory was
    available. Otherwise it was left to the system administrator to
    move the offending file(s) out of the way and then rerun fsck_ffs(8)
    to create the '.' and '..' entries.

    With this change, fsck_ffs(8) will always be able to create the '.'
    and/or '..' entries. It moves any files in the way elsewhere in the
    directory block. If there is no room in the directory block to which
    to move them, they are placed in the lost+found directory.

    Reported by:  Peter Holm
    Sponsored by: The FreeBSD Foundation
2023-03-27 22:53:37 +00:00
mlelstv 6029abdb95 Fix parser for carp state.
The state values are uppercase words INIT, BACKUP and MASTER.
2023-03-26 01:04:16 +00:00
simonb 1145fafc6f In "devlist" mode, exit with a 0 return code if any nvme devices are
found, rather than exiting with 1 return code always.
2023-03-05 23:24:06 +00:00
kre 5747acc12f Fix a typo in a newly added comment.
Someone please tell me why these things become obvious only after
the code has been committed!

NFC
2023-03-01 15:18:18 +00:00
kre 5a71a00fea When processing swapon -a (or swapctl -A, or swapctl -U) ignore lines in
fstab that have nothing to do with swapping (fs_type is neither "sw" nor "dp")
before running getfsspecname() on the fs_spec field of the line.

This avoids entries like this:

NAME=OFTEN_UNCONNECTED   /local/archived ffs     rw,log,noauto    0 0

in fstab from generating spurious error messages when the wedge named
is not currently connected to the system - that is the drive on which the
wedge exists is not connected, or not powered on.   "noauto" handles that
for some other uses, the "0"s in fs_freq and fs_passno work for other uses,
but swap{on,ctl} never look at those fields (not for this purpose).

Non "sw"/"dp" lines were being ignored anyway, but not until (a little) later.
2023-03-01 15:15:56 +00:00
andvar 19c1490f61 fix some typos in comments. 2023-02-27 22:00:25 +00:00
andvar 45db36d858 s/superblok/superblock/ in comment. 2023-02-26 22:55:02 +00:00
uwe 295421a2f9 shutdown(8): markup fixes 2023-02-15 13:05:21 +00:00
uwe c1371239a4 shutdown(8): fix -width cargo cult 2023-02-15 10:31:52 +00:00
jschauma 653e2a3e27 adjust width of flag arg to align more nicely 2023-02-15 01:55:16 +00:00
mlelstv e66f4605a1 Data units read/written are counted in 1000s of 512 bytes.
Convert to human-readable value.
2023-02-02 08:21:32 +00:00
mlelstv 19722ca2cf Use opendisk when looking for filesystem type, otherwise the detection
only works if the correct device path is given as an argument.
2023-01-24 08:09:37 +00:00
mlelstv 3e7f0f50ca Work on swapped-endian FFS. 2023-01-24 08:05:07 +00:00
kre 4bc7e3cb63 Use %zu rather than %lu to print a size_t (should fix i386 build).
But, philosophical question, shouldn't the product of two size_t
variables really be an area_t, or something like that?
2023-01-14 17:01:10 +00:00
christos 4616d0425d catch up with sign changes in the fs.h 2023-01-14 12:12:50 +00:00
chs 908deb24fa ufs: more signed/unsigned fixes
Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Sun Oct 25 21:04:07 2020 +0000

    Use proper type (ino_t) for inode numbers to avoid improper sign extention
    in the Pass 5 checks. The manifestation was fsck_ffs exiting with this error:

      ** Phase 5 - Check Cyl groups
      fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

    The error only manifests itself for filesystems bigger than about 100Tb.

    Reported by:  Nikita Grechikhin <ngrechikhin at yandex.ru>
    MFC after:    2 weeks
    Sponsored by: Netflix
2023-01-08 05:25:24 +00:00
chs f298a94b73 ufs: fixed signed/unsigned bugs affecting large file systems
Apply these commits from FreeBSD:

  commit e870d1e6f97cc73308c11c40684b775bcfa906a2
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Wed Feb 10 20:10:35 2010 +0000

    This fix corrects a problem in the file system that treats large
    inode numbers as negative rather than unsigned. For a default
    (16K block) file system, this bug began to show up at a file system
    size above about 16Tb.

    To fully handle this problem, newfs must be updated to ensure that
    it will never create a filesystem with more than 2^32 inodes. That
    patch will be forthcoming soon.

    Reported by: Scott Burns, John Kilburg, Bruce Evans
    Followup by: Jeff Roberson
    PR:          133980
    MFC after:   2 weeks

  commit 81479e688b0f643ffacd3f335b4b4bba460b769d
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Thu Feb 11 18:14:53 2010 +0000

    One last pass to get all the unsigned comparisons correct.


In additional to the changes from FreeBSD, this commit includes quite a few
related changes to appease -Wsign-compare.
2023-01-07 19:41:29 +00:00
hannken 7b77b9376c Change getdiskinfo() to no longer infer the partition from the device name.
Since 2016-06-16 we create disk devices "<type><<unit>" as an alias
for "<type><<unit><part>" where "<part>" is the raw partition.
These devices are treated as invalid partitions and a zero geometry
is returned.

Take the partition from "st_rdev" instead.

Fix for PR kern/57134: st_size of stat on vnd raw partition sometimes
is 0, causing newfs to fail
2023-01-02 16:08:13 +00:00
chs fc887601fd mount_nfs: add missing "A" to getopt string 2022-12-21 19:00:52 +00:00
chs 062d5b230d tunefs: clarify that "-a" refers to NFSv4 ACLs 2022-12-19 21:13:16 +00:00
chs b04cd074cb apply this commit from FreeBSD:
commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95
  Author: Chuck Silvers <chs@FreeBSD.org>
  Date:   Mon Dec 12 08:14:17 2022 -0800

      restore: fix restore of NFS4 ACLs

      Changing the mode bits on a file with an NFS4 ACL results in the
      NFS4 ACL being replaced by one matching the new mode bits being set,
      so when restoring a file with an NFS4 ACL, set the owner/group/mode first
      and then set the NFS4 ACL, so that setting the mode does not throw away
      the ACL that we just set.

      Reviewed by:    mckusick
      Differential Revision:  https://reviews.freebsd.org/D37618
2022-12-12 16:53:30 +00:00
chs a932562d1e apply this change from FreeBSD:
commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
  Author: Kirk McKusick <mckusick@FreeBSD.org>
  Date:   Fri Apr 11 21:48:14 2008 +0000

      Correctly set file group when restore is run by a user other than root.
2022-12-10 18:49:44 +00:00
christos 98f1b42d37 fix sign. 2022-12-01 14:42:12 +00:00
christos 1bf8465593 Add a sanity check for the ip header length (from FreeBSD) 2022-12-01 14:40:53 +00:00
knakahara f66ad936b7 ifconfig(8) support unnumbered flag. 2022-11-25 08:41:05 +00:00
mlelstv 27a040a8a9 Big-Endian fixes. 2022-11-22 00:25:52 +00:00
mlelstv 0bf6d48843 Fix destroying and moving GPT header also for truncated/extended
images.
2022-11-20 11:57:02 +00:00
martin 1b5f3a1b0a Fix clearing of permissions when finding unexpected extended attributs
for swapped endian file systems. Ok: chs
2022-11-18 07:41:31 +00:00
martin 2627930cb6 Make the "non-zero exattr fields" message show the inode number. 2022-11-17 18:57:16 +00:00
chs 87ba0e2a31 Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new	fsck_ffs operations "-c	ea" and	"-c no-ea" to convert file systems
from UFS2 to UFS2ea and	vice-versa (both of which delete all existing extended
attributes in the process).
2022-11-17 06:40:38 +00:00
andvar 8a36802c94 fix various typos in comments and one output message. 2022-10-31 21:22:05 +00:00
rillig 29f817563f mount_cd9660: remove unhandled option -i from getopt
Found by lint. While here, fix the other lint warning as well, as lint
still doesn't know that exit(3) doesn't return normally.
2022-10-16 16:26:35 +00:00
andvar c3ad0bdd7e fix various typos in documentation and comments.
mainly in words functionality, functional, function.
2022-10-15 21:53:21 +00:00
riastradh 811e9ec794 wdogctl(8): Minor tweak suggested by a passing umarell.
Plus another wording improvement.
2022-09-23 12:35:00 +00:00
uwe 7bdf691e15 wdogctl(8): fix -width in previous 2022-09-22 21:40:42 +00:00
riastradh 30c75eaa64 wdogctl(8): Rework prose and markup in man page.
No functional change.
2022-09-22 14:02:45 +00:00
riastradh 9b5a6c4d5c cgdconfig(8): Restore loop for password re-entry for non-shared keys.
Fixes mistake in previous which changed the semantics in the case
where _no_ keys are shared.
2022-09-13 10:14:32 +00:00
riastradh 4b3ee8b4fa cgdconfig(8): Gracefully handle failed verification with shared keys.
The first time each key is verified, if verification fails, we chuck
the failed key and try again with passphrase re-entry.

But if a key has already been verified, and verification fails,
assume something is wrong with the disk and fail.
2022-08-30 08:48:41 +00:00
mlelstv 1736420841 fix 32bit builds 2022-08-28 11:32:19 +00:00
hgutch ec184f3bfb Change back various occurrences of \*[Le], \*[Ge] (less/greater equal)
and \*(ua (upwards arrow) to literal "<=", ">=" and "^" whenever
appropriate (e.g., in code examples).
2022-08-28 10:48:15 +00:00
mlelstv c6dcfc105b Fix writing of corrected fsinfo.
Continue when fsinfo has been rewritten.
2022-08-28 10:20:25 +00:00
mlelstv 100b2229a1 Add REPORT_LUNS command. 2022-08-21 12:44:16 +00:00
mlelstv 657333c966 When extracting properties, don't bail for non-existent or invalid path
elements, but continue with next properry.
2022-08-21 07:51:30 +00:00
nat 5fc22d500a Revert to previous as the atf tests are still failing. 2022-08-17 23:36:48 +00:00
nat 5f38985994 Use existing address when setting parameters.
No need to specify address every time when setting broadcast address or
netmask.

Hopefully successfully re addresses PR bin/10911.
2022-08-17 12:35:10 +00:00
nat 2d7b3c2cc9 Revert to previous as atf tests were failing. 2022-08-16 22:31:24 +00:00
nat 728612bd0e No need address every time to specify broadcast and netmask.
Previously ifconfig would fail silently.

Addresses PR bin/10911.
2022-08-16 10:47:10 +00:00
riastradh 7605cff464 cgdconfig(8): Handle -P/-S for shared keys with -G too.
This way you can convert an existing parameters file to one that is
derived from a shared key, and derive other subkeys for other disks
from the same shared key.

	cgdconfig -G -S -o /etc/cgd/wd0.shared /etc/cgd/wd0
	cgdconfig -G -S -o /etc/cgd/wd1.shared \
		-P /etc/cgd/wd0.shared /etc/cgd/wd1

This way, if you enter the same new password both times, wd0.shared
and wd1.shared generate the same keys as wd0 and wd1, but only need
one password entry with `cgdconfig -C'.
2022-08-12 10:49:47 +00:00
riastradh 3adc7246cf cgdconfig(8): Add support for generating shared-key parameters files.
Usage model:

- Generate a parameters file that supports sharing its main key:

	cgdconfig -g -S -o /etc/cgd/wd0e -V gpt adiantum

- Make another parameters file that uses the same shared main key but
  derives an independent subkey from it:

	cgdconfig -g -S -P /etc/cgd/wd0e -o /etc/cgd/ld1e \
	    -V disklabel aes-cbc 256
2022-08-12 10:49:35 +00:00
riastradh 920e28df65 cgdconfig(8): Add support for shared keys.
New clause `shared <id> algorithm <alg> subkey <info>' in a keygen
block enables `cgdconfig -C' to reuse a key between different params
files, so you can, e.g., use a single password for multiple disks.
This is better than simply caching the password itself because:

- Hashing the password is expensive, so it should only be done once.

  Suppose your budget is time t before you get bored, and you
  calibrate password hash parameters to unlock n disks before you get
  bored waiting for `cgdconfig -C'.

  . With n password hashings the adversary's cost goes up only by a
    factor of t/n.
  . With one password hashing and n subkeys the adversary's cost goes
    up by a factor of n.

  And if you ever add a disk, rehashing it will make `cgdconfig -C'
  go over budget, whereas another subkey adds negligible cost to you.

- Subkeys work for other types of keygen blocks, like shell_cmd,
  which could be used to get a key from a hardware token that needs a
  button press.

The <info> parameter must be different for each params file;
everything else in the keygen block must be the same.  With this
clause, the keygen block determines a shared key used only to derive
keys; the actual key used by cgdconfig is derived from the shared key
by the specified algorithm.

The only supported algorithm is hkdf-hmac-sha256, which uses
HKDF-Expand of RFC 5869 instantiated with SHA-256.

Example:

	algorithm aes-cbc;
	iv-method encblkno1;
	keylength 128;
	verify_method none;
	keygen pkcs5_pbkdf2/sha1 {
		iterations 39361;
		salt AAAAgMoHiYonye6KogdYJAobCHE=;
		shared "pw" algorithm hkdf-hmac-sha256
		    subkey AAAAgFlw0BMQ5gY+haYkZ6JC+yY=;
	};

The key used for this disk will be derived by

	HKDF-HMAC-SHA256_k(WXDQExDmBj6FpiRnokL7Jg==),

where k is the outcome of PBKDF2-SHA1 with the given parameters.

Note that <info> encodes a four-byte prefix giving the big-endian
length in bits of the info argument to HKDF, just like all other bit
strings in cgdconfig parameters files.

If you have multiple disks configured using the same keygen block
except for the info parameter, `cgdconfig -C' will only prompt once
for your passphrase, generate a shared key k with PBKDF2 as usual,
and then reuse it for each of the disks.
2022-08-12 10:49:17 +00:00
riastradh 732db29a3c cgdconfig(8): New -T operation prints all generated keys in cgd.conf.
For testing purposes.
2022-08-12 10:48:44 +00:00
riastradh a7c16118d0 cgdconfig(8): New -t operation just prints the derived key in base64.
For testing purposes.
2022-08-12 10:48:27 +00:00
andvar 5a58ccfbec fix various typos in comments, documentation and messages.
mainly s/paramater/parameter/ and s/reduntant/redundant/.
2022-08-07 11:06:18 +00:00
rin 422de7d163 Assert postts only if we really obtained a timestamp. 2022-08-06 10:22:22 +00:00
rin eb7145dc97 Do not declare unused tstamp for SMALL. NFC. 2022-08-06 10:19:44 +00:00
rin 82dbd18ccf Get back to the statically-allocated tbuf.
If a string is longer than tbuf, it cannot be a timestamp.
Therefore, no need for buffering anymore in this case.
2022-08-06 10:16:18 +00:00
rin df7debb42d Oops, fix thinko in the previous. 2022-08-06 09:42:33 +00:00
rin 2a3cf2bf71 Do not discard \[.*\] which is not identified as a timestamp. 2022-08-06 09:39:32 +00:00
rin d67befb65b KNF. Do not unnecessarily define ADDC() for SMALL. No binary changes. 2022-08-06 09:33:56 +00:00
mlelstv 876fd04d2a Fix build on 32bit. 2022-07-31 13:49:23 +00:00
mlelstv fa449f06f2 Report error code (SCT/SC). 2022-07-31 12:11:44 +00:00
dholland 3ad018779f Fix misleading fsck_ffs messages about wapbl journal replay.
Apparently fsck doesn't have a way to replay it to its internal memory
only. (Someone(TM) should implement this...)

This means that if you use -n, it can't replay the journal. But the
sequence of prints is such that it looks like it did. This is quite
misleading. Add an additional specific warning.
2022-07-25 05:15:08 +00:00
kre 5c922bdb9e PR bin/56917
If getfsspecname() fails that will usually mean that a NAME=wedge or
ROOT.x partition is unabailable.   raidframe specified unavailable
partitions as "absent" so in this case, pass "absent" rather than the
unaltered NAME= or ROOT.x string, which the kernel has no clue what
do do with, and doesn't configure the raid at all.
2022-07-21 09:19:53 +00:00
mlelstv ac9df4c9d7 Whitespace 2022-07-16 12:57:14 +00:00
snj 91e84632a7 drop reference to smbfs, which was removed in 2020.
while here, s/file-system/file system/
2022-07-10 18:52:34 +00:00
wiz 52bbdadeb2 Fix At argument and remove superfluous Pp. 2022-07-01 16:58:02 +00:00
kre e1c098e157 Bring shutdown(8) into the 21st century.
I found this juxtaposition in the shutdown man page kind of
interesting:

     time  Time is the time at which shutdown will bring the system down
	   and may be the word now or a future time in one of two formats:
	   ... [2nd format:] [[[[[cc]yy]mm]dd]hh]mm,  ...
	   If the century [cc] is not specified, it defaults to 1900 for
	   years [yy] between 69 and 99, ...

In that, all the "[text]" except the one "[[[[["(etc) sequence are my
interjections, The ellipses ("...") represent where I omitted irrelevant
(for here) text.

Interesting yes, bizarre also.   Requiring a future time, and then
defaulting to the (long gone) 20th century (for any random year)
makes no sense at all.    So I fixed it.

In another hundred years or so, anytime from 2100 onwards, but best
left at least a decade into the new century, it will need altering again.
[One could write the code to automate this adjustment, but the man
page would still need updating.]   More significant changes will be
needed as the 101st century approaches (years 10000 and beyond), as
then a 2 digit century will no longer be adequate.   Call me then, and
if I'm able, I'll fix it.

If someone really has a need to schedule a shutdown for sometime
between 1969 and 1999 that can still be done by explicitly giving
the "19" cc value.  It is just no longer ever the default.

Otherwise, now, years 20..90 mean the 21st century (2020..2099)
(the first 2 of those are already unusable, but, IMO, that's OK)
and years 00..19 mean the 22nd century (2100..2119) (except that
00, 2100, is still technically the final year of the 21st century).

This is advance planning for near the end of the 21st century when
someone wants to schedule a shutdown for early in the following
century, and can't be bothered typing the 2 century digits.
2022-07-01 16:45:12 +00:00
kre d73b978a64 Implement "raidctl -t config-file"
This does the same config file parse  that -c/-C do, but only
that (hence no raidframe device is needed, or accepted).

Any syntax errors in the config file will be reported, nothing
else happens.
2022-06-14 08:06:18 +00:00
kre b958b2dc5a Fix some config file parsing.
First, and what got me started on this set of cleanups, the queue
length in the "queue" section (START queue) is limited to what will
fit in a char without losing accuracy (I tried setting it to 200,
rather than the more common (universal?) 100 and found that the
value configured into the array was -56 instead.

Why the value needs to be passed through a char variable I have no
idea (it is an int in the filesystem raidframe headers) - but that's
the way it is done, and changing it would be an ABI change I believe
(and so need versioning to alter) and that isn't worth it for this
(or not now, IMO).

Instead check that the value in the char is the same value as was
read from the config file, and complain if not.   Those of you with
unsigned chars will be able to have queue lengths up to 255, the
rest of us are limited to 127.

While looking at that, I noticed some code that obviously fails to
understand that scanf("%s") will never return a string containing
spaces, and proceeded to attempt to remove trailing spaces from the
result ... amusingly, after having used the result for its intended
purpose (non existent trailing spaces unremoved), after which that
buffer was never used again.   That code is now gone (but for now,
just #if 0'd rather than actually deleted - it should be cleaned up
sometime).

Then I saw some other issues with how the config was parsed - a
simple (unbounded) scanf("%s") into a buffer, which hypothetically
might not be large enough (not a security issue really, raidctl has
no special privs, and it isn't likely that root could easily be
tricked into running it on a bogus config file - or not without
looking first anyway, and a huge long string would rather stand
out).   Bound the string length to something reasonable, and
assert() that the buffer is big enough to contain it.

Lastly, in the event of one particular detected error in the
config file, the code would write a warning, but then just go
ahead and use the bad data (or nothing perhaps) anyway - a
failure of logic flow (unlikely to have ever happened, everyone
seems to simply copy the sample config from the man page, and
make minor adjustments as needed).

If any of these changes make any difference to anyone (except
me with my attempt to make longer queues - for no particularly
well thought out reason), I'd be very surprised.
2022-06-14 08:06:13 +00:00
kre 5a1ff55a3a In the previous (and some earlier) version(s) of raidctl.c
the following comment appeared:

	/*
	 * After NetBSD 9, convert this to not output the numRow's value,
	 * which is no longer required or ever used.
	 */

We are after NetBSD 9 (well after).   The change requested in that
comment is made here, and the comment is thus removed.

A couple of places in rf_configure.c where a value for the "rows"
parameter was output in an error message (always simply as the
constant 0) have also been updated (those messages will no longer
include "row 0", which they always said previously).   One of them
was also slightly reworded to be clearer what problem it was
experiencing (when it said 'unable to get device file' it meant
it was unable to locate the name for the device in the config file,
not that it was found, and there was some other problem with it).
2022-06-14 08:06:07 +00:00
kre 681f9ba5c2 Reorder the getopts() switch () (slightly) to sort the options. NFCI. 2022-06-14 08:06:01 +00:00
kre ee1e729e87 KNF (whitespace & 80 column limits) - NFCI.
This is the first of a series of 5 commits in this
directory, all coming within minutes or now.
2022-06-14 08:05:55 +00:00