summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-08-30 16:53:29 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-08-30 16:53:29 +0000
commit332e32dfae223e3a862b103652259829f9cb4566 (patch)
tree24cf06a2dff4c43b5699e3b34941a09f6d645f7e /sys
parente24137f98ce3a12bef76f04a4f7e60c4c7dbd9b8 (diff)
Add a device number to struct disk and populate it on disk attach. Whilst
here also expose disklist for future use. ok deraadt@ miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_disk.c12
-rw-r--r--sys/sys/disk.h6
2 files changed, 15 insertions, 3 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index df64b68f465..966b2929159 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.105 2010/08/18 14:04:16 jasper Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.106 2010/08/30 16:53:28 jsing Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -792,6 +792,8 @@ disk_construct(struct disk *diskp, char *lockname)
void
disk_attach(struct disk *diskp)
{
+ struct device *dv;
+ dev_t *dev;
if (!ISSET(diskp->dk_flags, DKF_CONSTRUCTED))
disk_construct(diskp, diskp->dk_name);
@@ -818,6 +820,14 @@ disk_attach(struct disk *diskp)
++disk_count;
disk_change = 1;
+ /*
+ * Lookup and store device number for later use.
+ */
+ dev = &diskp->dk_devno;
+ dv = parsedisk(diskp->dk_name, strlen(diskp->dk_name), RAW_PART, dev);
+ if (dv == NULL)
+ diskp->dk_devno = NODEV;
+
if (softraid_disk_attach)
softraid_disk_attach(diskp, 1);
}
diff --git a/sys/sys/disk.h b/sys/sys/disk.h
index 7dc81cc6d44..97f37767764 100644
--- a/sys/sys/disk.h
+++ b/sys/sys/disk.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.h,v 1.22 2010/08/28 20:23:22 matthew Exp $ */
+/* $OpenBSD: disk.h,v 1.23 2010/08/30 16:53:28 jsing Exp $ */
/* $NetBSD: disk.h,v 1.11 1996/04/28 20:22:50 thorpej Exp $ */
/*
@@ -76,6 +76,7 @@ struct disk {
struct rwlock dk_lock; /* disk lock */
struct mutex dk_mtx; /* busy/unbusy mtx */
char *dk_name; /* disk name */
+ dev_t dk_devno; /* disk device number. */
int dk_flags; /* disk flags */
#define DKF_CONSTRUCTED 0x0001
@@ -105,7 +106,7 @@ struct disk {
* must be dynamically allocated, otherwise the size of this
* structure becomes machine-dependent.
*/
- daddr64_t dk_labelsector; /* sector containing label */
+ daddr64_t dk_labelsector; /* sector containing label */
struct disklabel *dk_label; /* label */
};
@@ -142,6 +143,7 @@ struct disksort_stats {
TAILQ_HEAD(disklist_head, disk); /* the disklist is a TAILQ */
#ifdef _KERNEL
+extern struct disklist_head disklist; /* list of disks attached to system */
extern int disk_count; /* number of disks in global disklist */
extern int disk_change; /* disk attached/detached */