NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/57815: swapctl(8) error is misleading
>Number: 57815
>Category: bin
>Synopsis: swapctl(8) on a non-VREG/VBLK device prints a confusing message
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Jan 03 19:15:00 +0000 2024
>Originator: Mouse
>Release: NetBSD 9.1 and 5.2, probably others
>Organization:
Dis-
>Environment:
Observed on 9.1/amd64 and 5.2/i386, probably present on
everything from at least 5.2 on regardless of port.
>Description:
Upon attempting to swapctl -a a character special device,
swapctl does not translate the resulting ENXIO, leading to (in
9.1) "Device not configured" being printed. This is, at the
very least, somewhat misleading; I just helped someone on IRC
who was confused by the apparent statement that ld1a wasn't
there upon trying to swapctl -a /dev/rld1a.
>How-To-Repeat:
Try to swapctl -a something other than a plain file or a block
device. For example (9.1/amd64):
# swapctl -a /dev/rwd0b
swapctl: /dev/rwd0b: Device not configured
# disklabel wd0
...
b: 3975152 230466496 swap # (Cyl. 228637*-232580)
...
5.2/i386 behaves similarly.
>Fix:
I'm not sure whether it's better to have swapctl(8) check that
the object named is either S_IFREG or S_IFBLK before calling
swapctl(2), or to add special handling for ENXIO to discover
whether it really is a case of a non-configured device or a
case of trying to swap on something inappropriate.
Arguably th ENXIO return for this case should be changed, but
I'm not sure what to change it to (and that would mean
reclassifying this PR as kern). What we really want is a
combination if ENOTBLK and the error returned for
open(O_REGULAR) on a non-VREG object (9.1's open(2) doesn't say
what error is returned in this case as far as I can see - when
I added O_PLAIN to my systems I also added ENOTPLAIN, but I
don't see anything analogous in 9.1). On an eyeball scan of
9.1's sys/sys/errno.h, EFTYPE is the least inappropriate thing
I see, but I could be missing something.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Home |
Main Index |
Thread Index |
Old Index