diff options
author | Mike Shaver <shaver@ingenia.com> | 1997-08-11 15:16:52 +0000 |
---|---|---|
committer | Mike Shaver <shaver@ingenia.com> | 1997-08-11 15:16:52 +0000 |
commit | 510da6adaa8de35828c319b5ad5004e85546a695 (patch) | |
tree | 7d0b51ce9909f278bfb5b5420525f86b0f66fe71 /drivers/sgi | |
parent | deda755fcc1e20cd3776c8cab89abb0da7b06462 (diff) |
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.
Diffstat (limited to 'drivers/sgi')
-rw-r--r-- | drivers/sgi/char/usema.c | 20 |
1 files changed, 18 insertions, 2 deletions
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 <linux/sched.h> #include <linux/file.h> #include <linux/major.h> +#include <linux/string.h> +#include <linux/dcache.h> #include <asm/smp_lock.h> #include <asm/usioctl.h> #include <asm/mman.h> #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", |