Subject: Re: kern/22774: there is no way to swapctl -a to a wrongly typed partition
To: None <gnats-bugs@gnats.netbsd.org, netbsd-bugs@netbsd.org>
From: Alan Barrett <apb@cequrux.com>
List: netbsd-bugs
Date: 09/13/2003 19:38:36
On Sat, 13 Sep 2003, Roland Dowdeswell wrote:
> Alan Barrett wrote:
> >Anyway, the appended patch to sys/dev/dksubr.c 
> >allows swap to /dev/cgd0d to work.
> 
> This isn't how the rest of the disk devices work, though, which is why
> I did not do it.

I believe that my patch would allow swap to /dev/${any_disk}${rawpart)
to work.  It make dk_size() understand that, whether or not there's a
disklabel, the size of the raw partition is the same as the size of the
disk.

> I posted a note about some strategies that could be
> taken to tech-kern quite some time back:
> 
> 	http://mail-index.netbsd.org/tech-kern/2003/04/17/0004.html
> 
> No conclusion was reached.

My patch implements something similar to your first suggested strategy.

> The decision to not allow swap directly to the raw partition is [I
> think] quite deliberate, since it would allow typos to destroy the
> contents of the disk.

If it's deliberate, it would be nice if it were implemented via a
deliberate test, rather than as a side effect of what looks like a bug
in dk_size() [returning zero for the size of the raw partition of an
unlabeled disk].

If you are worried about typos destroying disks, dd(8) can do that just
as easily as enabling swap.

--apb (Alan Barrett)