Пример #1
0
static int create_path(const char *nodepath)
{
	int err;

	mutex_lock(&dirlock);
	err = dev_mkdir(nodepath, 0755);
	if (err == -ENOENT) {
		char *path;
		char *s;

		/* parent directories do not exist, create them */
		path = kstrdup(nodepath, GFP_KERNEL);
		if (!path) {
			err = -ENOMEM;
			goto out;
		}
		s = path;
		for (;;) {
			s = strchr(s, '/');
			if (!s)
				break;
			s[0] = '\0';
			err = dev_mkdir(path, 0755);
			if (err && err != -EEXIST)
				break;
			s[0] = '/';
			s++;
		}
		kfree(path);
	}
out:
	mutex_unlock(&dirlock);
	return err;
}
Пример #2
0
static int create_path(const char *nodepath)
{
    char *path;
    char *s;
    int err = 0;

    /* parent directories do not exist, create them */
    path = kstrdup(nodepath, GFP_KERNEL);
    if (!path)
        return -ENOMEM;

    s = path;
    for (;;) {
        s = strchr(s, '/');
        if (!s)
            break;
        s[0] = '\0';
        err = dev_mkdir(path, 0755);
        if (err && err != -EEXIST)
            break;
        s[0] = '/';
        s++;
    }
    kfree(path);
    return err;
}
Пример #3
0
static int create_path(const char *nodepath)
{
	char *path;
	struct nameidata nd;
	int err = 0;
	struct vfsmount *dev_mnt = ve_devmnt();

	path = kstrdup(nodepath, GFP_KERNEL);
	if (!path)
		return -ENOMEM;

	err = vfs_path_lookup(dev_mnt->mnt_root, dev_mnt,
			      path, LOOKUP_PARENT, &nd);
	if (err == 0) {
		struct dentry *dentry;

		/* create directory right away */
		dentry = lookup_create(&nd, 1);
		if (!IS_ERR(dentry)) {
			err = vfs_mkdir(nd.path.dentry->d_inode,
					dentry, 0755);
			dput(dentry);
		}
		mutex_unlock(&nd.path.dentry->d_inode->i_mutex);

		path_put(&nd.path);
	} else if (err == -ENOENT) {
		char *s;

		/* parent directories do not exist, create them */
		s = path;
		while (1) {
			s = strchr(s, '/');
			if (!s)
				break;
			s[0] = '\0';
			err = dev_mkdir(path, 0755);
			if (err && err != -EEXIST)
				break;
			s[0] = '/';
			s++;
		}
	}

	kfree(path);
	return err;
}