]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
rpc_gssd_dummy_populate(): don't bother with rpc_populate()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 23 Mar 2025 00:26:21 +0000 (20:26 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:44:55 +0000 (22:44 -0400)
Just have it create gssd (in root), clntXX in gssd, then info and gssd in clntXX
- all with explicit rpc_new_dir()/rpc_new_file()/rpc_mkpipe_dentry().

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
net/sunrpc/rpc_pipe.c

index a52fe3bbf9dc6f07371524f0bde2a66e04cac32e..9051842228ec23dd2de0417aba750d1b9c6f729d 100644 (file)
@@ -997,7 +997,6 @@ enum {
        RPCAUTH_nfsd4_cb,
        RPCAUTH_cache,
        RPCAUTH_nfsd,
-       RPCAUTH_gssd,
        RPCAUTH_RootEOF
 };
 
@@ -1034,10 +1033,6 @@ static const struct rpc_filelist files[] = {
                .name = "nfsd",
                .mode = S_IFDIR | 0555,
        },
-       [RPCAUTH_gssd] = {
-               .name = "gssd",
-               .mode = S_IFDIR | 0555,
-       },
 };
 
 /*
@@ -1097,13 +1092,6 @@ void rpc_put_sb_net(const struct net *net)
 }
 EXPORT_SYMBOL_GPL(rpc_put_sb_net);
 
-static const struct rpc_filelist gssd_dummy_clnt_dir[] = {
-       [0] = {
-               .name = "clntXX",
-               .mode = S_IFDIR | 0555,
-       },
-};
-
 static ssize_t
 dummy_downcall(struct file *filp, const char __user *src, size_t len)
 {
@@ -1132,14 +1120,6 @@ rpc_dummy_info_show(struct seq_file *m, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(rpc_dummy_info);
 
-static const struct rpc_filelist gssd_dummy_info_file[] = {
-       [0] = {
-               .name = "info",
-               .i_fop = &rpc_dummy_info_fops,
-               .mode = S_IFREG | 0400,
-       },
-};
-
 /**
  * rpc_gssd_dummy_populate - create a dummy gssd pipe
  * @root:      root of the rpc_pipefs filesystem
@@ -1151,35 +1131,22 @@ static const struct rpc_filelist gssd_dummy_info_file[] = {
 static int
 rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
 {
-       int ret = 0;
-       struct dentry *gssd_dentry;
-       struct dentry *clnt_dentry = NULL;
+       struct dentry *gssd_dentry, *clnt_dentry;
+       int err;
 
-       /* We should never get this far if "gssd" doesn't exist */
-       gssd_dentry = try_lookup_noperm(&QSTR(files[RPCAUTH_gssd].name), root);
-       if (!gssd_dentry)
+       gssd_dentry = rpc_new_dir(root, "gssd", 0555, NULL);
+       if (IS_ERR(gssd_dentry))
                return -ENOENT;
 
-       ret = rpc_populate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1, NULL);
-       if (ret) {
-               dput(gssd_dentry);
-               return ret;
-       }
-
-       clnt_dentry = try_lookup_noperm(&QSTR(gssd_dummy_clnt_dir[0].name),
-                                         gssd_dentry);
-       dput(gssd_dentry);
-       if (!clnt_dentry)
+       clnt_dentry = rpc_new_dir(gssd_dentry, "clntXX", 0555, NULL);
+       if (IS_ERR(clnt_dentry))
                return -ENOENT;
 
-       ret = rpc_populate(clnt_dentry, gssd_dummy_info_file, 0, 1, NULL);
-       if (ret) {
-               dput(clnt_dentry);
-               return ret;
-       }
-       ret = rpc_mkpipe_dentry(clnt_dentry, "gssd", NULL, pipe_data);
-       dput(clnt_dentry);
-       return ret;
+       err = rpc_new_file(clnt_dentry, "info", 0400,
+                                  &rpc_dummy_info_fops, NULL);
+       if (!err)
+               err = rpc_mkpipe_dentry(clnt_dentry, "gssd", NULL, pipe_data);
+       return err;
 }
 
 static int