From 510da6adaa8de35828c319b5ad5004e85546a695 Mon Sep 17 00:00:00 2001 From: Mike Shaver Date: Mon, 11 Aug 1997 15:16:52 +0000 Subject: OK, another (better, I think) way to handle the clone-device issue. I'm now doing filp->d_entry swaps, which will require the creation of /dev/usema###, but which should make the rest of the system much happier with me. I'm also beginning to think that /dev/usema should be a misc device, and that /dev/usemaclone should be associated with the major. Makes no difference, really, except conceptually. --- drivers/sgi/char/usema.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'drivers/sgi') diff --git a/drivers/sgi/char/usema.c b/drivers/sgi/char/usema.c index 43eaa1538..416dc167e 100644 --- a/drivers/sgi/char/usema.c +++ b/drivers/sgi/char/usema.c @@ -32,12 +32,15 @@ #include #include #include +#include +#include #include #include #include #define NUM_USEMAS (1 << MINORBITS - 1) +#define USEMA_FORMAT "/dev/usema%d" static struct irix_usema{ int used; @@ -60,6 +63,8 @@ static int sgi_usemaclone_open(struct inode *inode, struct file *filp) { int semanum; + char semaname[14]; + struct dentry * semadentry; printk("[%s:%d] wants a new usema", current->comm, current->pid); for (semanum = 0; @@ -71,8 +76,19 @@ sgi_usemaclone_open(struct inode *inode, struct file *filp) current->pid); return -EBUSY; } - /* XXX is this the right way to do it? */ - filp->f_dentry->d_inode->i_rdev = MKDEV(USEMA_MAJOR,semanum); + /* We find a dentry for the clone device that we're + * allocating and pull a switcheroo on filp->d_entry. + */ + sprintf(semaname, USEMA_FORMAT, semanum); + semadentry = namei(semaname, 0); + if (!semadentry) { + /* This Shouldn't Happen(tm) */ + printk("[%s:%d] usemaclone_open: can't find dentry for %s", + current->comm, current->pid, semaname); + return -EINVAL; /* ??? */ + } + dput(filp->f_dentry); + filp->f_dentry = semadentry; usema_list[semanum].used = 1; usema_list[semanum].filp = filp; printk("[%s:%d] got usema %d", -- cgit v1.2.3