Browse Source

ioctl: don't set outbufsz when not needed

pull/593/head
Antonio SJ Musumeci 6 years ago
parent
commit
b69819e4b2
  1. 4
      libfuse/include/fuse_lowlevel.h
  2. 4
      libfuse/lib/fuse.c
  3. 27
      libfuse/lib/fuse_lowlevel.c
  4. 3
      src/fuse_ioctl.cpp

4
libfuse/include/fuse_lowlevel.h

@ -888,7 +888,7 @@ struct fuse_lowlevel_ops {
*/ */
void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, void (*ioctl) (fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
struct fuse_file_info *fi, unsigned flags, struct fuse_file_info *fi, unsigned flags,
const void *in_buf, size_t in_bufsz, size_t out_bufsz);
const void *in_buf, uint32_t in_bufsz, uint32_t out_bufsz);
/** /**
* Poll for IO readiness * Poll for IO readiness
@ -1286,7 +1286,7 @@ int fuse_reply_ioctl_retry(fuse_req_t req,
* @param buf buffer containing output data * @param buf buffer containing output data
* @param size length of output data * @param size length of output data
*/ */
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size);
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, uint32_t size);
/** /**
* Reply to finish ioctl with iov buffer * Reply to finish ioctl with iov buffer

4
libfuse/lib/fuse.c

@ -3896,8 +3896,8 @@ static void fuse_lib_bmap(fuse_req_t req, fuse_ino_t ino, size_t blocksize,
static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, static void fuse_lib_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg,
struct fuse_file_info *llfi, unsigned int flags, struct fuse_file_info *llfi, unsigned int flags,
const void *in_buf, size_t in_bufsz,
size_t out_bufsz_)
const void *in_buf, uint32_t in_bufsz,
uint32_t out_bufsz_)
{ {
struct fuse *f = req_fuse_prepare(req); struct fuse *f = req_fuse_prepare(req);
struct fuse_intr_data d; struct fuse_intr_data d;

27
libfuse/lib/fuse_lowlevel.c

@ -916,23 +916,28 @@ enomem:
goto out; goto out;
} }
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, size_t size)
int fuse_reply_ioctl(fuse_req_t req, int result, const void *buf, uint32_t size)
{ {
struct fuse_ioctl_out arg;
int count;
struct iovec iov[3]; struct iovec iov[3];
size_t count = 1;
struct fuse_ioctl_out arg;
memset(&arg, 0, sizeof(arg));
arg.result = result;
arg.result = result;
arg.flags = 0;
arg.in_iovs = 0;
arg.out_iovs = 0;
count = 1;
iov[count].iov_base = &arg; iov[count].iov_base = &arg;
iov[count].iov_len = sizeof(arg);
iov[count].iov_len = sizeof(arg);
count++; count++;
if (size) {
iov[count].iov_base = (char *) buf;
iov[count].iov_len = size;
count++;
}
if(size)
{
iov[count].iov_base = (char*)buf;
iov[count].iov_len = size;
count++;
}
return send_reply_iov(req, 0, iov, count); return send_reply_iov(req, 0, iov, count);
} }

3
src/fuse_ioctl.cpp

@ -90,7 +90,8 @@ namespace l
case FS_IOC_SETVERSION: case FS_IOC_SETVERSION:
if(endian::is_big() && (sizeof(long) != sizeof(int))) if(endian::is_big() && (sizeof(long) != sizeof(int)))
return -ENOTTY; return -ENOTTY;
*out_bufsz_ = 4;
if((data_ != NULL) && (*out_bufsz_ > 4))
*out_bufsz_ = 4;
break; break;
} }

Loading…
Cancel
Save