Beispiel #1
0
char *npm_getcwd(char *buf, unsigned long bufsize)
{
	struct path pwd;
	char *res;

	ASSERT(bufsize >= PAGE_SIZE - 1);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) || defined CONFIG_VE
	get_fs_pwd(current->fs, &pwd);
#else
	read_lock(&current->fs->lock);
	pwd = current->fs->pwd;
	path_get(&pwd);
	read_unlock(&current->fs->lock);
#endif

	res = d_path(&pwd, buf, bufsize);

	if (IS_ERR(res))
		res = NULL;

	path_put(&pwd);

	return res;
}
Beispiel #2
0
/*
 * find out whether an object in the current working directory is in use or not
 * - command: "inuse <name>"
 */
static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
{
	struct path path;
	const struct cred *saved_cred;
	int ret;

	//_enter(",%s", args);

	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 cwd */
	get_fs_pwd(current->fs, &path);

	if (!S_ISDIR(path.dentry->d_inode->i_mode))
		goto notdir;

	cachefiles_begin_secure(cache, &saved_cred);
	ret = cachefiles_check_in_use(cache, path.dentry, args);
	cachefiles_end_secure(cache, saved_cred);

	path_put(&path);
	//_leave(" = %d", ret);
	return ret;

notdir:
	path_put(&path);
	kerror("inuse command requires dirfd to be a directory");
	return -ENOTDIR;

inval:
	kerror("inuse command requires dirfd and filename");
	return -EINVAL;
}
Beispiel #3
0
/*
 * request a node in the cache be culled from the current working directory
 * - command: "cull <name>"
 */
static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
{
	struct path path;
	const struct cred *saved_cred;
	int ret;

	_enter(",%s", args);

	if (strchr(args, '/'))
		goto inval;

	if (!test_bit(CACHEFILES_READY, &cache->flags)) {
		pr_err("cull applied to unready cache\n");
		return -EIO;
	}

	if (test_bit(CACHEFILES_DEAD, &cache->flags)) {
		pr_err("cull applied to dead cache\n");
		return -EIO;
	}

	/* extract the directory dentry from the cwd */
	get_fs_pwd(current->fs, &path);

	if (!d_can_lookup(path.dentry))
		goto notdir;

	cachefiles_begin_secure(cache, &saved_cred);
	ret = cachefiles_cull(cache, path.dentry, args);
	cachefiles_end_secure(cache, saved_cred);

	path_put(&path);
	_leave(" = %d", ret);
	return ret;

notdir:
	path_put(&path);
	pr_err("cull command requires dirfd to be a directory\n");
	return -ENOTDIR;

inval:
	pr_err("cull command requires dirfd and filename\n");
	return -EINVAL;
}
Beispiel #4
0
void my_get_path(void){
	struct path pwd;
	get_fs_pwd(current->fs,&pwd);
	printk("Farhan: path is %s\n",pwd.dentry->d_name.name);

}