Re: [PATCH 19/19] CacheFiles: Permit daemon to probe inuseness of a cache file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 14, 2006 at 08:07:02PM +0000, David Howells wrote:
> Permit the daemon to probe to see whether a cache file is in use by a netfs or
> not.
> 
> Signed-Off-By: David Howells <[email protected]>
> ---
> 
>  fs/cachefiles/cf-daemon.c |   73 +++++++++++++++++++
>  fs/cachefiles/cf-namei.c  |  170 +++++++++++++++++++++++++++++++++++++++++++++
>  fs/cachefiles/internal.h  |    3 +
>  3 files changed, 246 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/cachefiles/cf-daemon.c b/fs/cachefiles/cf-daemon.c
> index ae82685..ee07865 100644
> --- a/fs/cachefiles/cf-daemon.c
> +++ b/fs/cachefiles/cf-daemon.c
> @@ -38,6 +38,7 @@ static int cachefiles_daemon_cull(struct
>  static int cachefiles_daemon_debug(struct cachefiles_cache *cache, char *args);
>  static int cachefiles_daemon_dir(struct cachefiles_cache *cache, char *args);
>  static int cachefiles_daemon_tag(struct cachefiles_cache *cache, char *args);
> +static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args);
>  
>  static unsigned long cachefiles_open;
>  
> @@ -66,6 +67,7 @@ static const struct cachefiles_daemon_cm
>  	{ "frun",	cachefiles_daemon_frun	},
>  	{ "fcull",	cachefiles_daemon_fcull	},
>  	{ "fstop",	cachefiles_daemon_fstop	},
> +	{ "inuse",	cachefiles_daemon_inuse	},
>  	{ "tag",	cachefiles_daemon_tag	},
>  	{ "",		NULL			}
>  };
> @@ -602,3 +604,74 @@ inval:
>  	kerror("debug command requires mask");
>  	return -EINVAL;
>  }
> +
> +/*
> + * find out whether an object is in use or not
> + * - command: "inuse <dirfd> <name>"
> + */
> +static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
> +{
> +	struct dentry *dir;
> +	struct file *dirfile;
> +	uid_t fsuid;
> +	gid_t fsgid;
> +	u32 fscreatesid;
> +	int dirfd, fput_needed, ret;
> +
> +	_enter(",%s", args);
> +
> +	dirfd = simple_strtoul(args, &args, 0);
> +
> +	if (!isspace(*args))
> +		goto inval;
> +
> +	while (isspace(*args))
> +		args++;
> +
> +	if (!*args)
> +		goto inval;
> +
> +	if (strchr(args, '/'))
> +		goto inval;
> +
> +	if (!test_bit(CACHEFILES_READY, &cache->flags)) {
> +		kerror("inuse applied to unready cache");
> +		return -EIO;
> +	}
> +
> +	if (test_bit(CACHEFILES_DEAD, &cache->flags)) {
> +		kerror("inuse applied to dead cache");
> +		return -EIO;
> +	}
> +
> +	/* extract the directory dentry from the fd */
> +	dirfile = fget_light(dirfd, &fput_needed);

Once again a very strong NACK for anything that gets a fd argument as
text from userspace.  Also a very strong NACK for use of fget/fget_light
from non-core code and exports for either of them.

-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux