Stefan writes:
> After modifying sys_open() by prepending a namei(filename),
> all devices mounted while the modified sys_open is in place,
> report an EBUSY when trying to umount them. Doesn't matter if sys_open 
> has been restored to the original before umount.
> 
> asmlinkage int my_sys_open(const char *filename, int flags, int mode)
> {
>   struct dentry *d_entry=NULL;
> 
>   lock_kernel();
>   d_entry=namei(filename);
>   unlock_kernel();
>   if (IS_ERR(d_entry))
>      return orig_sys_open(filename, flags, mode);
>   
>   if (d_entry->d_inode)      
-      printk("<1> device=%d\n",MAJOR(d_entry->d_inode->i_dev));
+      printk(KERN_INFO "device=%s\n", kdevname(dentry->d_inode->i_dev));
> 
+   dput(d_entry);
>   return orig_sys_open(filename, flags, mode);
> }

> I would be very grateful if someone could point out to me where the 
> problem is - and tell me how to solve it :-)

When you have a dentry reference, you need to free it via dput(), so that
the kernel knows the file is no longer in use.  This is the same with
iget() and iput() - you always need to free your inode references.

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to