|
@@ -27,6 +27,8 @@
|
|
|
#include <linux/types.h>
|
|
|
#include <linux/kallsyms.h>
|
|
|
#include <linux/mm.h>
|
|
|
+#include <linux/namei.h>
|
|
|
+#include <linux/mount.h>
|
|
|
#include <linux/slab.h>
|
|
|
#include <linux/utsname.h>
|
|
|
#include <linux/workqueue.h>
|
|
@@ -97,6 +99,12 @@ static int
|
|
|
rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
|
|
|
{
|
|
|
static uint32_t clntid;
|
|
|
+ struct nameidata nd;
|
|
|
+ struct path path;
|
|
|
+ char name[15];
|
|
|
+ struct qstr q = {
|
|
|
+ .name = name,
|
|
|
+ };
|
|
|
int error;
|
|
|
|
|
|
clnt->cl_path.mnt = ERR_PTR(-ENOENT);
|
|
@@ -104,26 +112,36 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)
|
|
|
if (dir_name == NULL)
|
|
|
return 0;
|
|
|
|
|
|
- clnt->cl_path.mnt = rpc_get_mount();
|
|
|
- if (IS_ERR(clnt->cl_path.mnt))
|
|
|
- return PTR_ERR(clnt->cl_path.mnt);
|
|
|
+ path.mnt = rpc_get_mount();
|
|
|
+ if (IS_ERR(path.mnt))
|
|
|
+ return PTR_ERR(path.mnt);
|
|
|
+ error = vfs_path_lookup(path.mnt->mnt_root, path.mnt, dir_name, 0, &nd);
|
|
|
+ if (error)
|
|
|
+ goto err;
|
|
|
|
|
|
for (;;) {
|
|
|
- snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname),
|
|
|
- "%s/clnt%x", dir_name,
|
|
|
- (unsigned int)clntid++);
|
|
|
- clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0';
|
|
|
- clnt->cl_path.dentry = rpc_create_client_dir(clnt->cl_pathname, clnt);
|
|
|
- if (!IS_ERR(clnt->cl_path.dentry))
|
|
|
- return 0;
|
|
|
- error = PTR_ERR(clnt->cl_path.dentry);
|
|
|
+ q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
|
|
|
+ name[sizeof(name) - 1] = '\0';
|
|
|
+ q.hash = full_name_hash(q.name, q.len);
|
|
|
+ path.dentry = rpc_create_client_dir(nd.path.dentry, &q, clnt);
|
|
|
+ if (!IS_ERR(path.dentry))
|
|
|
+ break;
|
|
|
+ error = PTR_ERR(path.dentry);
|
|
|
if (error != -EEXIST) {
|
|
|
- printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n",
|
|
|
- clnt->cl_pathname, error);
|
|
|
- rpc_put_mount();
|
|
|
- return error;
|
|
|
+ printk(KERN_INFO "RPC: Couldn't create pipefs entry"
|
|
|
+ " %s/%s, error %d\n",
|
|
|
+ dir_name, name, error);
|
|
|
+ goto err_path_put;
|
|
|
}
|
|
|
}
|
|
|
+ path_put(&nd.path);
|
|
|
+ clnt->cl_path = path;
|
|
|
+ return 0;
|
|
|
+err_path_put:
|
|
|
+ path_put(&nd.path);
|
|
|
+err:
|
|
|
+ rpc_put_mount();
|
|
|
+ return error;
|
|
|
}
|
|
|
|
|
|
static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt)
|