linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
	viro@ZenIV.linux.org.uk, adilger@sun.com,
	alan@lxorguk.ukuu.org.uk, akpm@linux-foundation.org
Subject: Re: [RFC] O_NOACC: open without any access
Date: Tue, 23 Jun 2009 17:59:16 +0100	[thread overview]
Message-ID: <17246.1245776356@redhat.com> (raw)
In-Reply-To: <E1MHBX7-0001Mv-Li@pomaz-ex.szeredi.hu>

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

  parent reply	other threads:[~2009-06-23 17:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-18  6:55 [RFC] O_NOACC: open without any access Miklos Szeredi
2009-06-23 13:46 ` Christoph Hellwig
2009-06-23 14:12   ` Miklos Szeredi
2009-06-23 14:34     ` Christoph Hellwig
2009-06-23 15:13       ` Miklos Szeredi
2009-06-23 15:52       ` David Howells
2009-06-23 16:06         ` Alan Cox
2009-06-23 16:10         ` David Howells
2009-06-23 16:31           ` Miklos Szeredi
2009-06-23 16:33           ` Alan Cox
2009-06-23 17:05           ` David Howells
2009-06-23 17:34             ` Linus Torvalds
2009-06-23 20:04               ` Miklos Szeredi
2009-06-24 10:53               ` Al Viro
2009-06-24 11:12                 ` Miklos Szeredi
2009-06-24 16:40                 ` Linus Torvalds
2009-06-23 22:44             ` David Howells
2009-06-23 17:20           ` David Howells
2009-06-23 16:53         ` Christoph Hellwig
2009-06-23 16:59     ` David Howells [this message]
2009-06-24 17:02 ` Ulrich Drepper
2009-06-24 18:06   ` Miklos Szeredi
2009-06-24 18:34     ` Ulrich Drepper

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=17246.1245776356@redhat.com \
    --to=dhowells@redhat.com \
    --cc=adilger@sun.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).