From d93ad5245d40e2887d36fe6e876a870d16f1dc0d Mon Sep 17 00:00:00 2001 From: jh Date: Thu, 7 Oct 2010 18:00:55 +0000 Subject: Check the device name validity on device registration. A new function prep_devname() sanitizes a device name by removing leading and redundant sequential slashes. The function returns an error for names which already exist or are considered invalid. A new flag MAKEDEV_CHECKNAME for make_dev_p(9) and make_dev_credf(9) indicates that the caller is prepared to handle an error related to the device name. An invalid name triggers a panic if the flag is not specified. Document the MAKEDEV_CHECKNAME flag in the make_dev(9) manual page. Idea from: kib Reviewed by: kib --- share/man/man9/make_dev.9 | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'share/man') diff --git a/share/man/man9/make_dev.9 b/share/man/man9/make_dev.9 index 9cc755f..2e35f5f 100644 --- a/share/man/man9/make_dev.9 +++ b/share/man/man9/make_dev.9 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 5, 2010 +.Dd October 7, 2010 .Dt MAKE_DEV 9 .Os .Sh NAME @@ -131,12 +131,18 @@ argument alters the operation of .Fn make_dev_credf . The following values are currently accepted: .Pp -.Bd -literal -offset indent -compact -MAKEDEV_REF reference the created device -MAKEDEV_NOWAIT do not sleep, may return NULL -MAKEDEV_WAITOK allow the function to sleep to satisfy malloc -MAKEDEV_ETERNAL created device will be never destroyed -.Ed +.Bl -tag -width "MAKEDEV_CHECKNAME" -compact -offset indent +.It MAKEDEV_REF +reference the created device +.It MAKEDEV_NOWAIT +do not sleep, may return NULL +.It MAKEDEV_WAITOK +allow the function to sleep to satisfy malloc +.It MAKEDEV_ETERNAL +created device will be never destroyed +.It MAKEDEV_CHECKNAME +return NULL if the device name is invalid or already exists +.El .Pp The .Dv MAKEDEV_WAITOK @@ -166,6 +172,9 @@ For the convenience, use the flag for the code that can be compiled into kernel or loaded (and unloaded) as loadable module. .Pp +A panic will occur if the MAKEDEV_CHECKNAME flag is not specified +and the device name is invalid or already exists. +.Pp The .Fn make_dev_cred function is equivalent to the call -- cgit v1.1