mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-09 13:42:56 +00:00
A little step further in the dev_t cleanups:
Refuse to register a bmajor if the D_DISK flag is not set in cdevsw. A little bit of cleanup while here.
This commit is contained in:
parent
aa4f4b695e
commit
662761a74b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51927
@ -119,25 +119,36 @@ cdevsw_add(struct cdevsw *newentry)
|
||||
if (newentry->d_maj < 0 || newentry->d_maj >= NUMCDEVSW) {
|
||||
printf("%s: ERROR: driver has bogus cdevsw->d_maj = %d\n",
|
||||
newentry->d_name, newentry->d_maj);
|
||||
return EINVAL;
|
||||
return (EINVAL);
|
||||
}
|
||||
if (newentry->d_bmaj >= NUMCDEVSW) {
|
||||
printf("%s: ERROR: driver has bogus cdevsw->d_bmaj = %d\n",
|
||||
newentry->d_name, newentry->d_bmaj);
|
||||
return (EINVAL);
|
||||
}
|
||||
if (newentry->d_bmaj >= 0 && (newentry->d_flags & D_DISK) == 0) {
|
||||
printf("ERROR: \"%s\" bmaj but is not a disk\n",
|
||||
newentry->d_name);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
if (cdevsw[newentry->d_maj]) {
|
||||
printf("WARNING: \"%s\" is usurping \"%s\"'s cdevsw[]\n",
|
||||
newentry->d_name, cdevsw[newentry->d_maj]->d_name);
|
||||
}
|
||||
|
||||
cdevsw[newentry->d_maj] = newentry;
|
||||
|
||||
if (newentry->d_bmaj >= 0 && newentry->d_bmaj < NUMCDEVSW) {
|
||||
if (newentry->d_bmaj < 0)
|
||||
return (0);
|
||||
|
||||
if (bmaj2cmaj[newentry->d_bmaj] != 254) {
|
||||
printf("WARNING: \"%s\" is usurping \"%s\"'s bmaj\n",
|
||||
newentry->d_name,
|
||||
cdevsw[bmaj2cmaj[newentry->d_bmaj]]->d_name);
|
||||
}
|
||||
bmaj2cmaj[newentry->d_bmaj] = newentry->d_maj;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user