2004-04-21 00:27:15

by John McCutchan

[permalink] [raw]
Subject: holding a reference on an inode?

Hello,

I am writing a kernel module, and I would like to allow user space to
hand me a FILE, and then for my kernel module to keep a reference on its
inode regardless what the user space program does with the FILE.

1) Is this good practice?
2) How do I get notified when the filesystem the inode is on is being
unmounted so I can release my reference? So that I don't block the
unmount.


I am not subscribed so please CC on my replies.

Thank you.


2004-04-23 12:48:24

by Jan Kara

[permalink] [raw]
Subject: Re: holding a reference on an inode?

Hello,

> I am writing a kernel module, and I would like to allow user space to
> hand me a FILE, and then for my kernel module to keep a reference on its
> inode regardless what the user space program does with the FILE.
>
> 1) Is this good practice?
Generally passing a file is not a problem - a lot of other syscalls
does that... The question is what would you like to do with the file
(you must be rather careful because you should not trust the contents of
the file, the contents can change etc...).

> 2) How do I get notified when the filesystem the inode is on is being
> unmounted so I can release my reference? So that I don't block the
> unmount.
The umount calls a filesystem callback umount_begin() which you could
probably use...

Honza

--
Jan Kara <[email protected]>
SuSE CR Labs