summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-02-04 10:32:40 +0000
committerphk <phk@FreeBSD.org>2003-02-04 10:32:40 +0000
commit9d6d3f16738b4468cf07e93bd017adae88c16871 (patch)
tree9f5f3c6b75f01b4b8fd3121c797b479bf00e432b
parent1abb95308bcc72d0a245f8d4c0f779f3cbe67d90 (diff)
downloadFreeBSD-src-9d6d3f16738b4468cf07e93bd017adae88c16871.zip
FreeBSD-src-9d6d3f16738b4468cf07e93bd017adae88c16871.tar.gz
Pave the road to removing the fixed size limit on device nodes:
Change the si_name of dev_t's to be a char * and put a private buffer for holding the name at then end of the struct. Initialize si_name to point to the private buffer. Put a KASSERT in geom_disk to prevent overrun on the fake dev_t we still have to generate for the disk_drivers.
-rw-r--r--sys/geom/geom_disk.c2
-rw-r--r--sys/kern/kern_conf.c2
-rw-r--r--sys/sys/conf.h3
-rw-r--r--sys/sys/linedisc.h3
4 files changed, 8 insertions, 2 deletions
diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index eb134a9..ebb4ebb 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -296,8 +296,10 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, void *
KASSERT(dp->d_strategy != NULL, ("disk_create need d_strategy"));
KASSERT(dp->d_name != NULL, ("disk_create need d_name"));
KASSERT(*dp->d_name != 0, ("disk_create need d_name"));
+ KASSERT(strlen(dp->d_name) < SPECNAMELEN - 4, ("disk name too long"));
dev->si_disk = dp;
dev->si_udev = 0x10002; /* XXX: Needed ? */
+ dev->si_name = dev->__si_namebuf;
sprintf(dev->si_name, "%s%d", dp->d_name, unit);
g_call_me(g_disk_create, dev);
return (dev);
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 6aedd81..e405d11 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -155,6 +155,8 @@ allocdev(void)
bzero(si, sizeof *si);
si->si_flags |= SI_STASHED;
}
+ si->__si_namebuf[0] = '\0';
+ si->si_name = si->__si_namebuf;
LIST_INIT(&si->si_children);
TAILQ_INIT(&si->si_snapshots);
return (si);
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 46aa54f..f91ebf3 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -73,7 +73,7 @@ struct cdev {
LIST_ENTRY(cdev) si_siblings;
dev_t si_parent;
u_int si_inode;
- char si_name[SPECNAMELEN + 1];
+ char *si_name;
void *si_drv1, *si_drv2;
struct cdevsw *si_devsw;
int si_iosize_max; /* maximum I/O size (for physio &al) */
@@ -96,6 +96,7 @@ struct cdev {
int (*__sid_copyonwrite)(struct vnode *, struct buf *);
} __si_disk;
} __si_u;
+ char __si_namebuf[SPECNAMELEN + 1];
};
#define si_tty __si_u.__si_tty.__sit_tty
diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h
index 46aa54f..f91ebf3 100644
--- a/sys/sys/linedisc.h
+++ b/sys/sys/linedisc.h
@@ -73,7 +73,7 @@ struct cdev {
LIST_ENTRY(cdev) si_siblings;
dev_t si_parent;
u_int si_inode;
- char si_name[SPECNAMELEN + 1];
+ char *si_name;
void *si_drv1, *si_drv2;
struct cdevsw *si_devsw;
int si_iosize_max; /* maximum I/O size (for physio &al) */
@@ -96,6 +96,7 @@ struct cdev {
int (*__sid_copyonwrite)(struct vnode *, struct buf *);
} __si_disk;
} __si_u;
+ char __si_namebuf[SPECNAMELEN + 1];
};
#define si_tty __si_u.__si_tty.__sit_tty
OpenPOWER on IntegriCloud