Only match raw devices. Only match against the char major as extracted

from the kernel. Prevents aliasing nwt0 and rwd0e. OK haad@
This commit is contained in:
joerg 2009-10-16 21:00:41 +00:00
parent 29e22ac027
commit c954cd0eee
2 changed files with 9 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dev-cache.c,v 1.2 2008/12/22 00:56:58 haad Exp $ */ /* $NetBSD: dev-cache.c,v 1.3 2009/10/16 21:00:41 joerg Exp $ */
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
@ -435,11 +435,14 @@ static int _insert(const char *path, int rec)
* raw and block. I can insert only existing * raw and block. I can insert only existing
* raw and block device. * raw and block device.
*/ */
if (nbsd_check_dev(MAJOR(info.st_rdev),path) < 0) { if (S_ISBLK(info.st_mode)) {
log_debug("%s: Not a block device.", path); log_debug("%s: Not a raw device", path);
return_0;
}
if (nbsd_check_dev(MAJOR(info.st_rdev),path) < 0) {
log_debug("%s: Not a known raw device", path);
return_0; return_0;
} }
#else #else
if (!S_ISBLK(info.st_mode)) if (!S_ISBLK(info.st_mode))
log_debug("%s: Not a block device", path); log_debug("%s: Not a block device", path);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dev.c,v 1.1 2008/12/22 00:56:59 haad Exp $ */ /* $NetBSD: dev.c,v 1.2 2009/10/16 21:00:41 joerg Exp $ */
/* /*
* NetBSD specific device routines are added to this file. * NetBSD specific device routines are added to this file.
@ -61,11 +61,7 @@ nbsd_check_dev(int major, const char *path)
if (kd[i].d_cmajor != -1 && kd[i].d_bmajor != -1) { if (kd[i].d_cmajor != -1 && kd[i].d_bmajor != -1) {
if (kd[i].d_cmajor == major) if (kd[i].d_cmajor == major)
return kd[i].d_bmajor; return 0;
if (kd[i].d_bmajor == major)
return kd[i].d_cmajor;
} }
return LVM_FAILURE; return LVM_FAILURE;