lkml.org 
[lkml]   [2008]   [Nov]   [22]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateFri, 21 Nov 2008 21:16:07 -0800
FromAndrew Morton <>
SubjectRe: [PATCH 5/5] CUSE: implement CUSE - Character device in Userspace
On Thu, 20 Nov 2008 23:23:03 +0900 Tejun Heo <tj@kernel.org> wrote:

> CUSE enables implementing character devices in userspace.  With recent
> additions of nonblock, lseek, ioctl and poll support, FUSE already has
> most of what's necessary to implement character devices.  All CUSE has
> to do is bonding all those components - FUSE, chardev and the driver
> model - nicely.
> 
> Due to the number of different objects involved and many ways an
> instance can fail, object lifetime rules are a tad bit complex.
> Please take a look at the comment on top of fs/fuse/cuse.c for
> details.
> 
> Other than that, it's mostly straight forward.  Client opens
> /dev/cuse, kernel starts conversation with CUSE_INIT.  The client
> tells CUSE which device it wants to create.  CUSE creates the device
> for the client and the rest works the same way as in a direct IO FUSE
> session.
> 
> Each CUSE device has a corresponding directory /sys/class/cuse/DEVNAME
> (which is symlink to /sys/devices/virtual/class/DEVNAME if
> SYSFS_DEPRECATED is turned off) which hosts "waiting" and "abort"
> among other things.  Those two files have the same meaning as the FUSE
> control files.
> 
> The only notable lacking feature compared to in-kernel implementation
> is mmap support.
> 
> ...
>
> +struct cuse_conn {
> +	struct fuse_conn	fc;
> +	struct cdev		cdev;
> +	struct vfsmount		*mnt;
> +	struct device		*dev;
> +
> +	/* init parameters */
> +	bool			unrestricted_ioctl:1;

I'd suggest removal of the :1 here.  If someone later comes along and
adds another bitfield next to it, locking will be needed to prevent
racess accessing the bitfields, and I seeno appropriate lock here, nor
any comment explaining the locking..

> +static int cuse_init_worker(void *data)
> +{
> +	struct cuse_init_in iin = { };
> +	struct cuse_init_out iout = { };
> +	struct cuse_devinfo devinfo = { };

You might want to check the generated code here.  gcc has a habit of
assembling a temp structure on the stack then memcpying it over, which
is just junk.  This will be gcc version dependent.  Fixable by using an
old-fashioned memset instead.



\
 
 \ /
  Last update: 2008-11-22 06:19    [from the cache]
©2003-2008