Touch raises Input/Output error in close with libfuse

35 Views Asked by At

I am trying to create an proxy fs with additional permission checking. It will spawn dialog asking user if operation is allowed to be processed.

Sources: https://sourceforge.net/projects/secure-home/

Problem was in touch command. I read in documentation, there is only one way to respond to close request: fuse_reply_err. I set error to 0. When I remove fuse_reply_err(req, 0) line, request was never done. Documentation: https://libfuse.github.io/doxygen/structfuse__lowlevel__ops.html#a1661bb4e3a4e689ff479fdd83b59deff (see at release function's declaration) . Also, in many example on internet, authors does the same (returning 0 errno). Problem is with touch command, which will return "Unable to close file: Input/Output error". I look coreutils touch sources: https://github.com/Coreutils/Coreutils/blob/master/src/touch.c . Message was printed, when close return non-zero. I read documentation and close declaration looks that:

  int close(int fd)

So it returns int and documentation says, it should returns 0 on success. But I do not known, how to return 0 as result from

void(* fuse_lowlevel_ops::release) (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)

My code looks that:

static void sechome_close(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
{
  struct sh_inode *inode = get_real_inode(ino);

  --inode->ref_count;
  if (0 == inode->ref_count) {
    close(fi->fh);
  }
  fuse_reply_err(req, 0);
}
0

There are 0 best solutions below