autofs: refactor autofs_prepare_pipe()
authorIan Kent <raven@themaw.net>
Fri, 22 Sep 2023 04:12:08 +0000 (12:12 +0800)
committerChristian Brauner <brauner@kernel.org>
Fri, 22 Sep 2023 08:14:54 +0000 (10:14 +0200)
Refactor autofs_prepare_pipe() by seperating out a check function
to be used later.

Signed-off-by: Ian Kent <raven@themaw.net>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Message-Id: <20230922041215.13675-2-raven@themaw.net>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/autofs/autofs_i.h

index d5a44fa88acf9a7bdb4c8f528448be903044d15d..c24d32be7937c84ca3b0d75a8a964c9b5a6af659 100644 (file)
@@ -209,12 +209,20 @@ int autofs_fill_super(struct super_block *, void *, int);
 struct autofs_info *autofs_new_ino(struct autofs_sb_info *);
 void autofs_clean_ino(struct autofs_info *);
 
-static inline int autofs_prepare_pipe(struct file *pipe)
+static inline int autofs_check_pipe(struct file *pipe)
 {
        if (!(pipe->f_mode & FMODE_CAN_WRITE))
                return -EINVAL;
        if (!S_ISFIFO(file_inode(pipe)->i_mode))
                return -EINVAL;
+       return 0;
+}
+
+static inline int autofs_prepare_pipe(struct file *pipe)
+{
+       int ret = autofs_check_pipe(pipe);
+       if (ret < 0)
+               return ret;
        /* We want a packet pipe */
        pipe->f_flags |= O_DIRECT;
        /* We don't expect -EAGAIN */