public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* lguest: lguest_user.c is open() called by the user?
@ 2014-10-19  0:10 Martin Kepplinger
  2014-10-20  0:32 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kepplinger @ 2014-10-19  0:10 UTC (permalink / raw)
  To: rusty; +Cc: lguest, linux-kernel@vger.kernel.org

hi

Just a question for understanding: open() is not implemented in
lguest_user.c's miscdevice. The miscdevice core, in this case, does
_not_ set file->private_data on a user's open() call. Is open() called
by the user here? and do you here _depend_ on file->private_data being
NULL after open()? (could you even?)

Would the following force to NULL be necessary if the miscdevice core
_would_ set private_data?


diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 4263f4c..3d472ea 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -497,6 +497,12 @@ static int close(struct inode *inode, struct file
*file)
        return 0;
 }

+static int open(struct inode *inode, struct file *file)
+{
+       /* assuming the miscdevice core sets private_data on open() */
+       file->private_data = NULL;
+}
+
 /*L:000
  * Welcome to our journey through the Launcher!
  *
@@ -514,6 +520,7 @@ static int close(struct inode *inode, struct file *file)
  */
 static const struct file_operations lguest_fops = {
        .owner   = THIS_MODULE,
+       .open    = open,
        .release = close,
        .write   = write,
        .read    = read,
-- 

thanks
                               martin

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-20  0:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-19  0:10 lguest: lguest_user.c is open() called by the user? Martin Kepplinger
2014-10-20  0:32 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox