示例#1
0
static int
fg_write (const char *path, const char *buf, size_t size,
          off_t offset, struct fuse_file_info *fi)
{
  TRACE_CALL ("%s, %p, %zu, %ld", path, buf, size, (long) offset);

  if (read_only) return -EROFS;

  dir_cache_invalidate (path);

  /* See fg_read. */
  const size_t limit = 2 * 1024 * 1024;
  if (size > limit)
    size = limit;

  int r;
  r = guestfs_pwrite (g, path, buf, size, offset);
  if (r == -1)
    return error ();

  return r;
}
示例#2
0
static int
mount_local_write (const char *path, const char *buf, size_t size,
                   off_t offset, struct fuse_file_info *fi)
{
  const size_t limit = 2 * 1024 * 1024;
  int r;
  DECL_G ();
  DEBUG_CALL ("%s, %p, %zu, %ld", path, buf, size, (long) offset);

  if (g->ml_read_only) return -EROFS;

  dir_cache_invalidate (g, path);

  /* See mount_local_read. */
  if (size > limit)
    size = limit;

  r = guestfs_pwrite (g, path, buf, size, offset);
  if (r == -1)
    RETURN_ERRNO;

  return r;
}