NetBSD Problem Report #57815

From mouse@Stone.Rodents-Montreal.ORG  Wed Jan  3 19:10:59 2024
Return-Path: <mouse@Stone.Rodents-Montreal.ORG>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 04E1A1A9239
	for <>; Wed,  3 Jan 2024 19:10:58 +0000 (UTC)
Message-Id: <202401031910.OAA11144@Stone.Rodents-Montreal.ORG>
Date: Wed, 3 Jan 2024 14:10:56 -0500 (EST)
From: Mouse <mouse@Rodents-Montreal.ORG>
Reply-To: mouse@Rodents-Montreal.ORG
Subject: swapctl(8) error is misleading
X-Send-Pr-Version: 3.95

>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
	Observed on 9.1/amd64 and 5.2/i386, probably present on
	everything from at least 5.2 on regardless of port.
	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.
	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.
	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
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.