Disable use of pseudo-devices defined "defpseudo" with interface

attributes, but provide compatibility for older source trees (according
to the "version" in conf/files and other files.*.
reviewed by cube
This commit is contained in:
drochner 2008-06-10 18:11:31 +00:00
parent c097615632
commit b66156c7c9
4 changed files with 24 additions and 34 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: config.5,v 1.17 2008/06/10 12:56:33 wiz Exp $
.\" $NetBSD: config.5,v 1.18 2008/06/10 18:11:31 drochner Exp $
.\"
.\" Copyright (c) 2006, 2007 The NetBSD Foundation.
.\" All rights reserved.
@ -453,16 +453,10 @@ It is then possible to use the associated
as a conditional element in a
.Ic file
statement.
.It Ic defpseudo Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
.It Ic defpseudo Ar base Oo : dependencies Oc
Declares a pseudo-device.
Those devices don't need an attachment to be declared, they will always be
attached if they were selected by the user.
For compatibility, an optional list of
.Ar locators
can be defined, which makes the declaration identical to the
.Dq defpseudodev
declaration below.
This feature might be removed eventually.
.It Ic defpseudodev Ar base Oo Bro Ar locators Brc Oc Oo : dependencies Oc
Declares a pseudo-device.
Those devices don't need an attachment to be declared, they will always be
@ -470,9 +464,9 @@ attached if they were selected by the user.
This declaration should be used if the pseudodevice uses
.Xr autoconf 9
functions to manage its instances or attach children.
As normal devices, an optional list of
As for normal devices, an optional list of
.Ar locators
can be defined, which defines an interface attribute named
can be defined, which implies an interface attribute named
.Ar base ,
allowing the pseudo-device to have children.
Interface attributes can also be defined in the

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: gram.y,v 1.16 2008/06/10 12:35:32 drochner Exp $ */
/* $NetBSD: gram.y,v 1.17 2008/06/10 18:11:31 drochner Exp $ */
/*
* Copyright (c) 1992, 1993
@ -297,6 +297,7 @@ one_def:
MAXPARTITIONS NUMBER { maxpartitions = $2.val; } |
MAXUSERS NUMBER NUMBER NUMBER { setdefmaxusers($2.val, $3.val, $4.val); } |
MAKEOPTIONS condmkopt_list |
/* interface_opt in DEFPSEUDO is for backwards compatibility */
DEFPSEUDO devbase interface_opt attrs_opt
{ defdev($2, $3, $4, 1); } |
DEFPSEUDODEV devbase interface_opt attrs_opt

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.26 2008/06/10 12:35:32 drochner Exp $ */
/* $NetBSD: main.c,v 1.27 2008/06/10 18:11:31 drochner Exp $ */
/*
* Copyright (c) 1992, 1993
@ -1055,28 +1055,11 @@ devbase_has_instances(struct devbase *dev, int unit)
*
* 1. Included in this kernel configuration.
*
* 2. Be declared "defpseudodev", or (for transition)
* have one or more interface attributes.
* 2. Be declared "defpseudodev".
*/
if (dev->d_ispseudo) {
struct nvlist *nv;
struct attr *a;
if (ht_lookup(devitab, dev->d_name) == NULL)
return (0);
if (dev->d_ispseudo > 1)
return (1);
for (nv = dev->d_attrs; nv != NULL; nv = nv->nv_next) {
a = nv->nv_ptr;
if (a->a_iattr) {
cfgwarn("warning: %s should be defined "
"\"defpseudodev\"", dev->d_name);
/* XXX shut up further warnings */
dev->d_ispseudo = 2;
return (1);
}
}
return (0);
return ((ht_lookup(devitab, dev->d_name) != NULL)
&& (dev->d_ispseudo > 1));
}
for (da = dev->d_ahead; da != NULL; da = da->d_bsame)

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.28 2007/04/06 19:21:09 cube Exp $ */
/* $NetBSD: sem.c,v 1.29 2008/06/10 18:11:31 drochner Exp $ */
/*
* Copyright (c) 1992, 1993
@ -362,9 +362,21 @@ defdev(struct devbase *dev, struct nvlist *loclist, struct nvlist *attrs,
for (nv = attrs; nv != NULL; nv = nv->nv_next)
if (((struct attr *)(nv->nv_ptr))->a_iattr)
break;
if (nv != NULL)
if (nv != NULL) {
if (ispseudo < 2) {
if (version >= 20080610)
cfgerror("interface attribute on "
"non-device pseudo `%s'", dev->d_name);
else {
cfgwarn("warning: `%s' should be "
"defined \"defpseudodev\"",
dev->d_name);
ispseudo = 2;
}
}
ht_insert(devroottab, dev->d_name, dev);
}
}
/* Committed! Set up fields. */
dev->d_ispseudo = ispseudo;