From: Frank Mori Hess Date: Mon, 1 Sep 2003 02:26:55 +0000 (+0000) Subject: print some debug messages on ENODEV errors in open, and changed one X-Git-Tag: r0_7_69~243 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=033b44b22f7513ddb72434cfc895686d7e328038;p=comedi.git print some debug messages on ENODEV errors in open, and changed one to an EPERM --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 78792d77..47fdcf82 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -1594,12 +1594,14 @@ static int comedi_fop_open(struct inode *inode,struct file *file) comedi_device *dev; char mod[32]; - if(minor>=COMEDI_NDEVICES)return -ENODEV; - + if(minor>=COMEDI_NDEVICES){ + DPRINTK("invalid minor number\n"); + return -ENODEV; + } dev=comedi_get_device_by_minor(minor); /* This is slightly hacky, but we want module autoloading - * to work for root. + * to work for root. * case: user opens device, attached -> ok * case: user opens device, unattached, in_request_module=0 -> autoload * case: user opens device, unattached, in_request_module=1 -> fail @@ -1613,8 +1615,10 @@ static int comedi_fop_open(struct inode *inode,struct file *file) */ if(dev->attached) goto ok; - if(!capable(CAP_SYS_ADMIN) && dev->in_request_module) + if(!capable(CAP_SYS_ADMIN) && dev->in_request_module){ + DPRINTK("in request module\n"); return -ENODEV; + } if(capable(CAP_SYS_ADMIN) && dev->in_request_module) goto ok; @@ -1627,9 +1631,8 @@ static int comedi_fop_open(struct inode *inode,struct file *file) dev->in_request_module=0; - if(dev->attached || capable(CAP_SYS_ADMIN)) - goto ok; - return -ENODEV; + if(!dev->attached && !capable(CAP_SYS_ADMIN)) + return -EPERM; ok: if(!try_module_get(THIS_MODULE))