public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Kepplinger <martink@posteo.de>
To: rusty@rustcorp.com.au
Cc: lguest@lists.ozlabs.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: lguest: lguest_user.c is open() called by the user?
Date: Sun, 19 Oct 2014 02:10:08 +0200	[thread overview]
Message-ID: <54430160.6020503@posteo.de> (raw)

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

             reply	other threads:[~2014-10-19  0:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19  0:10 Martin Kepplinger [this message]
2014-10-20  0:32 ` lguest: lguest_user.c is open() called by the user? Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54430160.6020503@posteo.de \
    --to=martink@posteo.de \
    --cc=lguest@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox