lguest: lguest_user.c is open() called by the user?
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?
drivers/lguest/lguest_user.c +0 -0
@@ -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,
Signature · 2 lines
thanks
martinQuoted 10 lines · Martin Kepplinger
hi
Just a question for understanding:
open()is not implemented in lguest_user.c's miscdevice. The miscdevice core, in this case, does _not_ setfile->private_dataon a user'sopen()call. Isopen()called by the user here? and do you here _depend_ onfile->private_databeing NULL afteropen()? (could you even?)Would the following force to NULL be necessary if the miscdevice core _would_ set
private_data?
Hi Martin!
Yes, the private_data is NULL on a new file. Seeget_empty_filp in fs/file_table.c, which does kmem_cache_zalloc (zeroing all the contents).
So this isn't necessary here.
Thanks!
Rusty.
Quoted 35 lines
drivers/lguest/lguest_user.c +6
-0@@ -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! *
drivers/lguest/lguest_user.c +1
-0@@ -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,Signature · 7 lines
thanks martin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/