lkml.org 
[lkml]   [2009]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC] O_NOACC: open without any access
Date
Miklos Szeredi <miklos@szeredi.hu> wrote:

> Not sure if it's a good base for what AFS/pioctl is trying to do, but
> it's something that I personally would very much like to see.

It could be useful. The problem is that I then need to do an ioctl() on it.

To emulate a pioctl with this, I'd need something like the following in a
library:

long pioctl(char *path, int cmd, struct ViceIoctl *arg, int nofollow)
{
struct ioctl_pioctl {
int cmd;
struct ViceIoctl *arg;
} ip;
long ret;
int fd;

switch (cmd) {
case VIOC_CMD1:
case VIOC_CMD2:
case VIOC_CMD3:
fd = open(path, O_NOACC | (nofollow ? O_NOFOLLOW : 0));
ip.cmd = cmd;
ip.arg = arg;
ret = ioctl(fd, DO_PIOCTL, &ip);
close(fd);
break;
}

return ret;
}

Now, the DO_PIOCTL constant could be dispensed with, and each VIOC_CMDx be
mapped to a different ioctl command number. Note that you may not assume that
the set of pioctl numbers shares with the set of ioctl numbers, so you can't
just hand the cmd number through as-is.

Not all pioctl commands need to be emulated this way. Some could call getxattr
instead, for instance, and some could muck around with /proc and /sys files.

> 2) open with "3" calls driver's ->open() with any side effect that
> may have. Open with O_NOACC doesn't do that, and hence if we
> want to allow ioctls they need a new interface which gets a
> "struct path" instead of a "struct file".

You don't actually need that. struct file contains a struct path. You just
need a way to come up with an alternative set of file ops for an O_NOACC open
- perhaps through struct inode_operations.

Alternatively, you could install a special set of generic file ops that only
has an ioctl op. This could then redirect through another ioctl op in the
inode_operations struct.

As I mentioned in another email, for emulation of pioctl(), I need O_NOACC to
_not_ call device_driver->open() on device files, and to not install the
device driver file ops table. pioctl() operates on the underlying file in the
underlying fs.

David


\
 
 \ /
  Last update: 2009-06-23 19:07    [W:0.036 / U:2.908 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site