Blame 0022-virtiofsd-Trim-out-compatibility-code.patch

1d442b
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
1d442b
Date: Mon, 27 Jan 2020 19:00:51 +0000
1d442b
Subject: [PATCH] virtiofsd: Trim out compatibility code
1d442b
MIME-Version: 1.0
1d442b
Content-Type: text/plain; charset=UTF-8
1d442b
Content-Transfer-Encoding: 8bit
1d442b
1d442b
virtiofsd only supports major=7, minor>=31; trim out a lot of
1d442b
old compatibility code.
1d442b
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit 72c42e2d65510e073cf78fdc924d121c77fa0080)
1d442b
---
1d442b
 tools/virtiofsd/fuse_lowlevel.c | 330 ++++++++++++--------------------
1d442b
 1 file changed, 119 insertions(+), 211 deletions(-)
1d442b
1d442b
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
1d442b
index 07fb8a6095..514d79cb24 100644
1d442b
--- a/tools/virtiofsd/fuse_lowlevel.c
1d442b
+++ b/tools/virtiofsd/fuse_lowlevel.c
1d442b
@@ -387,16 +387,7 @@ static void fill_open(struct fuse_open_out *arg, const struct fuse_file_info *f)
1d442b
 int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
1d442b
 {
1d442b
     struct fuse_entry_out arg;
1d442b
-    size_t size = req->se->conn.proto_minor < 9 ? FUSE_COMPAT_ENTRY_OUT_SIZE :
1d442b
-                                                  sizeof(arg);
1d442b
-
1d442b
-    /*
1d442b
-     * before ABI 7.4 e->ino == 0 was invalid, only ENOENT meant
1d442b
-     * negative entry
1d442b
-     */
1d442b
-    if (!e->ino && req->se->conn.proto_minor < 4) {
1d442b
-        return fuse_reply_err(req, ENOENT);
1d442b
-    }
1d442b
+    size_t size = sizeof(arg);
1d442b
 
1d442b
     memset(&arg, 0, sizeof(arg));
1d442b
     fill_entry(&arg, e);
1d442b
@@ -407,9 +398,7 @@ int fuse_reply_create(fuse_req_t req, const struct fuse_entry_param *e,
1d442b
                       const struct fuse_file_info *f)
1d442b
 {
1d442b
     char buf[sizeof(struct fuse_entry_out) + sizeof(struct fuse_open_out)];
1d442b
-    size_t entrysize = req->se->conn.proto_minor < 9 ?
1d442b
-                           FUSE_COMPAT_ENTRY_OUT_SIZE :
1d442b
-                           sizeof(struct fuse_entry_out);
1d442b
+    size_t entrysize = sizeof(struct fuse_entry_out);
1d442b
     struct fuse_entry_out *earg = (struct fuse_entry_out *)buf;
1d442b
     struct fuse_open_out *oarg = (struct fuse_open_out *)(buf + entrysize);
1d442b
 
1d442b
@@ -423,8 +412,7 @@ int fuse_reply_attr(fuse_req_t req, const struct stat *attr,
1d442b
                     double attr_timeout)
1d442b
 {
1d442b
     struct fuse_attr_out arg;
1d442b
-    size_t size =
1d442b
-        req->se->conn.proto_minor < 9 ? FUSE_COMPAT_ATTR_OUT_SIZE : sizeof(arg);
1d442b
+    size_t size = sizeof(arg);
1d442b
 
1d442b
     memset(&arg, 0, sizeof(arg));
1d442b
     arg.attr_valid = calc_timeout_sec(attr_timeout);
1d442b
@@ -519,8 +507,7 @@ int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv)
1d442b
 int fuse_reply_statfs(fuse_req_t req, const struct statvfs *stbuf)
1d442b
 {
1d442b
     struct fuse_statfs_out arg;
1d442b
-    size_t size =
1d442b
-        req->se->conn.proto_minor < 4 ? FUSE_COMPAT_STATFS_SIZE : sizeof(arg);
1d442b
+    size_t size = sizeof(arg);
1d442b
 
1d442b
     memset(&arg, 0, sizeof(arg));
1d442b
     convert_statfs(stbuf, &arg.st);
1d442b
@@ -604,45 +591,31 @@ int fuse_reply_ioctl_retry(fuse_req_t req, const struct iovec *in_iov,
1d442b
     iov[count].iov_len = sizeof(arg);
1d442b
     count++;
1d442b
 
1d442b
-    if (req->se->conn.proto_minor < 16) {
1d442b
-        if (in_count) {
1d442b
-            iov[count].iov_base = (void *)in_iov;
1d442b
-            iov[count].iov_len = sizeof(in_iov[0]) * in_count;
1d442b
-            count++;
1d442b
-        }
1d442b
+    /* Can't handle non-compat 64bit ioctls on 32bit */
1d442b
+    if (sizeof(void *) == 4 && req->ioctl_64bit) {
1d442b
+        res = fuse_reply_err(req, EINVAL);
1d442b
+        goto out;
1d442b
+    }
1d442b
 
1d442b
-        if (out_count) {
1d442b
-            iov[count].iov_base = (void *)out_iov;
1d442b
-            iov[count].iov_len = sizeof(out_iov[0]) * out_count;
1d442b
-            count++;
1d442b
+    if (in_count) {
1d442b
+        in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
1d442b
+        if (!in_fiov) {
1d442b
+            goto enomem;
1d442b
         }
1d442b
-    } else {
1d442b
-        /* Can't handle non-compat 64bit ioctls on 32bit */
1d442b
-        if (sizeof(void *) == 4 && req->ioctl_64bit) {
1d442b
-            res = fuse_reply_err(req, EINVAL);
1d442b
-            goto out;
1d442b
-        }
1d442b
-
1d442b
-        if (in_count) {
1d442b
-            in_fiov = fuse_ioctl_iovec_copy(in_iov, in_count);
1d442b
-            if (!in_fiov) {
1d442b
-                goto enomem;
1d442b
-            }
1d442b
 
1d442b
-            iov[count].iov_base = (void *)in_fiov;
1d442b
-            iov[count].iov_len = sizeof(in_fiov[0]) * in_count;
1d442b
-            count++;
1d442b
+        iov[count].iov_base = (void *)in_fiov;
1d442b
+        iov[count].iov_len = sizeof(in_fiov[0]) * in_count;
1d442b
+        count++;
1d442b
+    }
1d442b
+    if (out_count) {
1d442b
+        out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
1d442b
+        if (!out_fiov) {
1d442b
+            goto enomem;
1d442b
         }
1d442b
-        if (out_count) {
1d442b
-            out_fiov = fuse_ioctl_iovec_copy(out_iov, out_count);
1d442b
-            if (!out_fiov) {
1d442b
-                goto enomem;
1d442b
-            }
1d442b
 
1d442b
-            iov[count].iov_base = (void *)out_fiov;
1d442b
-            iov[count].iov_len = sizeof(out_fiov[0]) * out_count;
1d442b
-            count++;
1d442b
-        }
1d442b
+        iov[count].iov_base = (void *)out_fiov;
1d442b
+        iov[count].iov_len = sizeof(out_fiov[0]) * out_count;
1d442b
+        count++;
1d442b
     }
1d442b
 
1d442b
     res = send_reply_iov(req, 0, iov, count);
1d442b
@@ -784,14 +757,12 @@ static void do_getattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     struct fuse_file_info *fip = NULL;
1d442b
     struct fuse_file_info fi;
1d442b
 
1d442b
-    if (req->se->conn.proto_minor >= 9) {
1d442b
-        struct fuse_getattr_in *arg = (struct fuse_getattr_in *)inarg;
1d442b
+    struct fuse_getattr_in *arg = (struct fuse_getattr_in *)inarg;
1d442b
 
1d442b
-        if (arg->getattr_flags & FUSE_GETATTR_FH) {
1d442b
-            memset(&fi, 0, sizeof(fi));
1d442b
-            fi.fh = arg->fh;
1d442b
-            fip = &fi;
1d442b
-        }
1d442b
+    if (arg->getattr_flags & FUSE_GETATTR_FH) {
1d442b
+        memset(&fi, 0, sizeof(fi));
1d442b
+        fi.fh = arg->fh;
1d442b
+        fip = &fi;
1d442b
     }
1d442b
 
1d442b
     if (req->se->op.getattr) {
1d442b
@@ -856,11 +827,7 @@ static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     struct fuse_mknod_in *arg = (struct fuse_mknod_in *)inarg;
1d442b
     char *name = PARAM(arg);
1d442b
 
1d442b
-    if (req->se->conn.proto_minor >= 12) {
1d442b
-        req->ctx.umask = arg->umask;
1d442b
-    } else {
1d442b
-        name = (char *)inarg + FUSE_COMPAT_MKNOD_IN_SIZE;
1d442b
-    }
1d442b
+    req->ctx.umask = arg->umask;
1d442b
 
1d442b
     if (req->se->op.mknod) {
1d442b
         req->se->op.mknod(req, nodeid, name, arg->mode, arg->rdev);
1d442b
@@ -873,9 +840,7 @@ static void do_mkdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
 {
1d442b
     struct fuse_mkdir_in *arg = (struct fuse_mkdir_in *)inarg;
1d442b
 
1d442b
-    if (req->se->conn.proto_minor >= 12) {
1d442b
-        req->ctx.umask = arg->umask;
1d442b
-    }
1d442b
+    req->ctx.umask = arg->umask;
1d442b
 
1d442b
     if (req->se->op.mkdir) {
1d442b
         req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
1d442b
@@ -967,11 +932,7 @@ static void do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
         memset(&fi, 0, sizeof(fi));
1d442b
         fi.flags = arg->flags;
1d442b
 
1d442b
-        if (req->se->conn.proto_minor >= 12) {
1d442b
-            req->ctx.umask = arg->umask;
1d442b
-        } else {
1d442b
-            name = (char *)inarg + sizeof(struct fuse_open_in);
1d442b
-        }
1d442b
+        req->ctx.umask = arg->umask;
1d442b
 
1d442b
         req->se->op.create(req, nodeid, name, arg->mode, &fi);
1d442b
     } else {
1d442b
@@ -1003,10 +964,8 @@ static void do_read(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
 
1d442b
         memset(&fi, 0, sizeof(fi));
1d442b
         fi.fh = arg->fh;
1d442b
-        if (req->se->conn.proto_minor >= 9) {
1d442b
-            fi.lock_owner = arg->lock_owner;
1d442b
-            fi.flags = arg->flags;
1d442b
-        }
1d442b
+        fi.lock_owner = arg->lock_owner;
1d442b
+        fi.flags = arg->flags;
1d442b
         req->se->op.read(req, nodeid, arg->size, arg->offset, &fi);
1d442b
     } else {
1d442b
         fuse_reply_err(req, ENOSYS);
1d442b
@@ -1023,13 +982,9 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     fi.fh = arg->fh;
1d442b
     fi.writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1d442b
 
1d442b
-    if (req->se->conn.proto_minor < 9) {
1d442b
-        param = ((char *)arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1d442b
-    } else {
1d442b
-        fi.lock_owner = arg->lock_owner;
1d442b
-        fi.flags = arg->flags;
1d442b
-        param = PARAM(arg);
1d442b
-    }
1d442b
+    fi.lock_owner = arg->lock_owner;
1d442b
+    fi.flags = arg->flags;
1d442b
+    param = PARAM(arg);
1d442b
 
1d442b
     if (req->se->op.write) {
1d442b
         req->se->op.write(req, nodeid, param, arg->size, arg->offset, &fi);
1d442b
@@ -1053,21 +1008,14 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
1d442b
     fi.fh = arg->fh;
1d442b
     fi.writepage = arg->write_flags & FUSE_WRITE_CACHE;
1d442b
 
1d442b
-    if (se->conn.proto_minor < 9) {
1d442b
-        bufv.buf[0].mem = ((char *)arg) + FUSE_COMPAT_WRITE_IN_SIZE;
1d442b
-        bufv.buf[0].size -=
1d442b
-            sizeof(struct fuse_in_header) + FUSE_COMPAT_WRITE_IN_SIZE;
1d442b
-        assert(!(bufv.buf[0].flags & FUSE_BUF_IS_FD));
1d442b
-    } else {
1d442b
-        fi.lock_owner = arg->lock_owner;
1d442b
-        fi.flags = arg->flags;
1d442b
-        if (!(bufv.buf[0].flags & FUSE_BUF_IS_FD)) {
1d442b
-            bufv.buf[0].mem = PARAM(arg);
1d442b
-        }
1d442b
-
1d442b
-        bufv.buf[0].size -=
1d442b
-            sizeof(struct fuse_in_header) + sizeof(struct fuse_write_in);
1d442b
+    fi.lock_owner = arg->lock_owner;
1d442b
+    fi.flags = arg->flags;
1d442b
+    if (!(bufv.buf[0].flags & FUSE_BUF_IS_FD)) {
1d442b
+        bufv.buf[0].mem = PARAM(arg);
1d442b
     }
1d442b
+
1d442b
+    bufv.buf[0].size -=
1d442b
+        sizeof(struct fuse_in_header) + sizeof(struct fuse_write_in);
1d442b
     if (bufv.buf[0].size < arg->size) {
1d442b
         fuse_log(FUSE_LOG_ERR, "fuse: do_write_buf: buffer size too small\n");
1d442b
         fuse_reply_err(req, EIO);
1d442b
@@ -1086,9 +1034,7 @@ static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     memset(&fi, 0, sizeof(fi));
1d442b
     fi.fh = arg->fh;
1d442b
     fi.flush = 1;
1d442b
-    if (req->se->conn.proto_minor >= 7) {
1d442b
-        fi.lock_owner = arg->lock_owner;
1d442b
-    }
1d442b
+    fi.lock_owner = arg->lock_owner;
1d442b
 
1d442b
     if (req->se->op.flush) {
1d442b
         req->se->op.flush(req, nodeid, &fi);
1d442b
@@ -1105,10 +1051,8 @@ static void do_release(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     memset(&fi, 0, sizeof(fi));
1d442b
     fi.flags = arg->flags;
1d442b
     fi.fh = arg->fh;
1d442b
-    if (req->se->conn.proto_minor >= 8) {
1d442b
-        fi.flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1d442b
-        fi.lock_owner = arg->lock_owner;
1d442b
-    }
1d442b
+    fi.flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
1d442b
+    fi.lock_owner = arg->lock_owner;
1d442b
     if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
1d442b
         fi.flock_release = 1;
1d442b
         fi.lock_owner = arg->lock_owner;
1d442b
@@ -1477,8 +1421,7 @@ static void do_ioctl(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     memset(&fi, 0, sizeof(fi));
1d442b
     fi.fh = arg->fh;
1d442b
 
1d442b
-    if (sizeof(void *) == 4 && req->se->conn.proto_minor >= 16 &&
1d442b
-        !(flags & FUSE_IOCTL_32BIT)) {
1d442b
+    if (sizeof(void *) == 4 && !(flags & FUSE_IOCTL_32BIT)) {
1d442b
         req->ioctl_64bit = 1;
1d442b
     }
1d442b
 
1d442b
@@ -1603,7 +1546,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     outarg.major = FUSE_KERNEL_VERSION;
1d442b
     outarg.minor = FUSE_KERNEL_MINOR_VERSION;
1d442b
 
1d442b
-    if (arg->major < 7) {
1d442b
+    if (arg->major < 7 || (arg->major == 7 && arg->minor < 31)) {
1d442b
         fuse_log(FUSE_LOG_ERR, "fuse: unsupported protocol version: %u.%u\n",
1d442b
                  arg->major, arg->minor);
1d442b
         fuse_reply_err(req, EPROTO);
1d442b
@@ -1616,81 +1559,71 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
         return;
1d442b
     }
1d442b
 
1d442b
-    if (arg->minor >= 6) {
1d442b
-        if (arg->max_readahead < se->conn.max_readahead) {
1d442b
-            se->conn.max_readahead = arg->max_readahead;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_ASYNC_READ) {
1d442b
-            se->conn.capable |= FUSE_CAP_ASYNC_READ;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_POSIX_LOCKS) {
1d442b
-            se->conn.capable |= FUSE_CAP_POSIX_LOCKS;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_ATOMIC_O_TRUNC) {
1d442b
-            se->conn.capable |= FUSE_CAP_ATOMIC_O_TRUNC;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_EXPORT_SUPPORT) {
1d442b
-            se->conn.capable |= FUSE_CAP_EXPORT_SUPPORT;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_DONT_MASK) {
1d442b
-            se->conn.capable |= FUSE_CAP_DONT_MASK;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_FLOCK_LOCKS) {
1d442b
-            se->conn.capable |= FUSE_CAP_FLOCK_LOCKS;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_AUTO_INVAL_DATA) {
1d442b
-            se->conn.capable |= FUSE_CAP_AUTO_INVAL_DATA;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_DO_READDIRPLUS) {
1d442b
-            se->conn.capable |= FUSE_CAP_READDIRPLUS;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_READDIRPLUS_AUTO) {
1d442b
-            se->conn.capable |= FUSE_CAP_READDIRPLUS_AUTO;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_ASYNC_DIO) {
1d442b
-            se->conn.capable |= FUSE_CAP_ASYNC_DIO;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_WRITEBACK_CACHE) {
1d442b
-            se->conn.capable |= FUSE_CAP_WRITEBACK_CACHE;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_NO_OPEN_SUPPORT) {
1d442b
-            se->conn.capable |= FUSE_CAP_NO_OPEN_SUPPORT;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_PARALLEL_DIROPS) {
1d442b
-            se->conn.capable |= FUSE_CAP_PARALLEL_DIROPS;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_POSIX_ACL) {
1d442b
-            se->conn.capable |= FUSE_CAP_POSIX_ACL;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_HANDLE_KILLPRIV) {
1d442b
-            se->conn.capable |= FUSE_CAP_HANDLE_KILLPRIV;
1d442b
-        }
1d442b
-        if (arg->flags & FUSE_NO_OPENDIR_SUPPORT) {
1d442b
-            se->conn.capable |= FUSE_CAP_NO_OPENDIR_SUPPORT;
1d442b
-        }
1d442b
-        if (!(arg->flags & FUSE_MAX_PAGES)) {
1d442b
-            size_t max_bufsize =
1d442b
-                FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize() +
1d442b
-                FUSE_BUFFER_HEADER_SIZE;
1d442b
-            if (bufsize > max_bufsize) {
1d442b
-                bufsize = max_bufsize;
1d442b
-            }
1d442b
+    if (arg->max_readahead < se->conn.max_readahead) {
1d442b
+        se->conn.max_readahead = arg->max_readahead;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_ASYNC_READ) {
1d442b
+        se->conn.capable |= FUSE_CAP_ASYNC_READ;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_POSIX_LOCKS) {
1d442b
+        se->conn.capable |= FUSE_CAP_POSIX_LOCKS;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_ATOMIC_O_TRUNC) {
1d442b
+        se->conn.capable |= FUSE_CAP_ATOMIC_O_TRUNC;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_EXPORT_SUPPORT) {
1d442b
+        se->conn.capable |= FUSE_CAP_EXPORT_SUPPORT;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_DONT_MASK) {
1d442b
+        se->conn.capable |= FUSE_CAP_DONT_MASK;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_FLOCK_LOCKS) {
1d442b
+        se->conn.capable |= FUSE_CAP_FLOCK_LOCKS;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_AUTO_INVAL_DATA) {
1d442b
+        se->conn.capable |= FUSE_CAP_AUTO_INVAL_DATA;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_DO_READDIRPLUS) {
1d442b
+        se->conn.capable |= FUSE_CAP_READDIRPLUS;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_READDIRPLUS_AUTO) {
1d442b
+        se->conn.capable |= FUSE_CAP_READDIRPLUS_AUTO;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_ASYNC_DIO) {
1d442b
+        se->conn.capable |= FUSE_CAP_ASYNC_DIO;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_WRITEBACK_CACHE) {
1d442b
+        se->conn.capable |= FUSE_CAP_WRITEBACK_CACHE;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_NO_OPEN_SUPPORT) {
1d442b
+        se->conn.capable |= FUSE_CAP_NO_OPEN_SUPPORT;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_PARALLEL_DIROPS) {
1d442b
+        se->conn.capable |= FUSE_CAP_PARALLEL_DIROPS;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_POSIX_ACL) {
1d442b
+        se->conn.capable |= FUSE_CAP_POSIX_ACL;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_HANDLE_KILLPRIV) {
1d442b
+        se->conn.capable |= FUSE_CAP_HANDLE_KILLPRIV;
1d442b
+    }
1d442b
+    if (arg->flags & FUSE_NO_OPENDIR_SUPPORT) {
1d442b
+        se->conn.capable |= FUSE_CAP_NO_OPENDIR_SUPPORT;
1d442b
+    }
1d442b
+    if (!(arg->flags & FUSE_MAX_PAGES)) {
1d442b
+        size_t max_bufsize = FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize() +
1d442b
+                             FUSE_BUFFER_HEADER_SIZE;
1d442b
+        if (bufsize > max_bufsize) {
1d442b
+            bufsize = max_bufsize;
1d442b
         }
1d442b
-    } else {
1d442b
-        se->conn.max_readahead = 0;
1d442b
     }
1d442b
-
1d442b
-    if (se->conn.proto_minor >= 14) {
1d442b
 #ifdef HAVE_SPLICE
1d442b
 #ifdef HAVE_VMSPLICE
1d442b
-        se->conn.capable |= FUSE_CAP_SPLICE_WRITE | FUSE_CAP_SPLICE_MOVE;
1d442b
+    se->conn.capable |= FUSE_CAP_SPLICE_WRITE | FUSE_CAP_SPLICE_MOVE;
1d442b
 #endif
1d442b
-        se->conn.capable |= FUSE_CAP_SPLICE_READ;
1d442b
+    se->conn.capable |= FUSE_CAP_SPLICE_READ;
1d442b
 #endif
1d442b
-    }
1d442b
-    if (se->conn.proto_minor >= 18) {
1d442b
-        se->conn.capable |= FUSE_CAP_IOCTL_DIR;
1d442b
-    }
1d442b
+    se->conn.capable |= FUSE_CAP_IOCTL_DIR;
1d442b
 
1d442b
     /*
1d442b
      * Default settings for modern filesystems.
1d442b
@@ -1797,24 +1730,20 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
     }
1d442b
     outarg.max_readahead = se->conn.max_readahead;
1d442b
     outarg.max_write = se->conn.max_write;
1d442b
-    if (se->conn.proto_minor >= 13) {
1d442b
-        if (se->conn.max_background >= (1 << 16)) {
1d442b
-            se->conn.max_background = (1 << 16) - 1;
1d442b
-        }
1d442b
-        if (se->conn.congestion_threshold > se->conn.max_background) {
1d442b
-            se->conn.congestion_threshold = se->conn.max_background;
1d442b
-        }
1d442b
-        if (!se->conn.congestion_threshold) {
1d442b
-            se->conn.congestion_threshold = se->conn.max_background * 3 / 4;
1d442b
-        }
1d442b
-
1d442b
-        outarg.max_background = se->conn.max_background;
1d442b
-        outarg.congestion_threshold = se->conn.congestion_threshold;
1d442b
+    if (se->conn.max_background >= (1 << 16)) {
1d442b
+        se->conn.max_background = (1 << 16) - 1;
1d442b
+    }
1d442b
+    if (se->conn.congestion_threshold > se->conn.max_background) {
1d442b
+        se->conn.congestion_threshold = se->conn.max_background;
1d442b
     }
1d442b
-    if (se->conn.proto_minor >= 23) {
1d442b
-        outarg.time_gran = se->conn.time_gran;
1d442b
+    if (!se->conn.congestion_threshold) {
1d442b
+        se->conn.congestion_threshold = se->conn.max_background * 3 / 4;
1d442b
     }
1d442b
 
1d442b
+    outarg.max_background = se->conn.max_background;
1d442b
+    outarg.congestion_threshold = se->conn.congestion_threshold;
1d442b
+    outarg.time_gran = se->conn.time_gran;
1d442b
+
1d442b
     if (se->debug) {
1d442b
         fuse_log(FUSE_LOG_DEBUG, "   INIT: %u.%u\n", outarg.major,
1d442b
                  outarg.minor);
1d442b
@@ -1828,11 +1757,6 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
1d442b
                  outarg.congestion_threshold);
1d442b
         fuse_log(FUSE_LOG_DEBUG, "   time_gran=%u\n", outarg.time_gran);
1d442b
     }
1d442b
-    if (arg->minor < 5) {
1d442b
-        outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
1d442b
-    } else if (arg->minor < 23) {
1d442b
-        outargsize = FUSE_COMPAT_22_INIT_OUT_SIZE;
1d442b
-    }
1d442b
 
1d442b
     send_reply_ok(req, &outarg, outargsize);
1d442b
 }
1d442b
@@ -1896,10 +1820,6 @@ int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino,
1d442b
         return -EINVAL;
1d442b
     }
1d442b
 
1d442b
-    if (se->conn.proto_major < 6 || se->conn.proto_minor < 12) {
1d442b
-        return -ENOSYS;
1d442b
-    }
1d442b
-
1d442b
     outarg.ino = ino;
1d442b
     outarg.off = off;
1d442b
     outarg.len = len;
1d442b
@@ -1920,10 +1840,6 @@ int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent,
1d442b
         return -EINVAL;
1d442b
     }
1d442b
 
1d442b
-    if (se->conn.proto_major < 6 || se->conn.proto_minor < 12) {
1d442b
-        return -ENOSYS;
1d442b
-    }
1d442b
-
1d442b
     outarg.parent = parent;
1d442b
     outarg.namelen = namelen;
1d442b
     outarg.padding = 0;
1d442b
@@ -1947,10 +1863,6 @@ int fuse_lowlevel_notify_delete(struct fuse_session *se, fuse_ino_t parent,
1d442b
         return -EINVAL;
1d442b
     }
1d442b
 
1d442b
-    if (se->conn.proto_major < 6 || se->conn.proto_minor < 18) {
1d442b
-        return -ENOSYS;
1d442b
-    }
1d442b
-
1d442b
     outarg.parent = parent;
1d442b
     outarg.child = child;
1d442b
     outarg.namelen = namelen;
1d442b
@@ -1977,10 +1889,6 @@ int fuse_lowlevel_notify_store(struct fuse_session *se, fuse_ino_t ino,
1d442b
         return -EINVAL;
1d442b
     }
1d442b
 
1d442b
-    if (se->conn.proto_major < 6 || se->conn.proto_minor < 15) {
1d442b
-        return -ENOSYS;
1d442b
-    }
1d442b
-
1d442b
     out.unique = 0;
1d442b
     out.error = FUSE_NOTIFY_STORE;
1d442b