static int cephwrap_open(struct vfs_handle_struct *handle, struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode) { int result = -ENOENT; DBG_DEBUG("[CEPH] open(%p, %s, %p, %d, %d)\n", handle, smb_fname_str_dbg(smb_fname), fsp, flags, mode); if (smb_fname->stream_name) { goto out; } result = ceph_open(handle->data, smb_fname->base_name, flags, mode); out: DBG_DEBUG("[CEPH] open(...) = %d\n", result); WRAP_RETURN(result); }
/* * Bareos is calling us to do the actual I/O */ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) { plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; if (!p_ctx) { return bRC_Error; } io->io_errno = 0; io->lerror = 0; io->win32 = false; switch(io->func) { case IO_OPEN: p_ctx->cfd = ceph_open(p_ctx->cmount, io->fname, io->flags, io->mode); if (p_ctx->cfd < 0) { io->status = -1; io->io_errno = -p_ctx->cfd; goto bail_out; } io->status = 0; break; case IO_READ: if (p_ctx->cfd) { io->status = ceph_read(p_ctx->cmount, p_ctx->cfd, io->buf, io->count, -1); if (io->status < 0) { io->io_errno = -io->status; io->status = -1; goto bail_out; } } else { io->status = -1; io->io_errno = EBADF; goto bail_out; } break; case IO_WRITE: if (p_ctx->cfd) { io->status = ceph_write(p_ctx->cmount, p_ctx->cfd, io->buf, io->count, -1); if (io->status < 0) { io->io_errno = -io->status; io->status = -1; goto bail_out; } } else { io->status = -1; io->io_errno = EBADF; goto bail_out; } break; case IO_CLOSE: if (p_ctx->cfd) { io->status = ceph_close(p_ctx->cmount, p_ctx->cfd); if (io->status < 0) { io->io_errno = -io->status; io->status = -1; goto bail_out; } } else { io->status = -1; io->io_errno = EBADF; goto bail_out; } break; case IO_SEEK: if (p_ctx->cfd) { io->status = ceph_lseek(p_ctx->cmount, p_ctx->cfd, io->offset, io->whence); if (io->status < 0) { io->io_errno = -io->status; io->status = -1; goto bail_out; } } else { io->status = -1; io->io_errno = EBADF; goto bail_out; } break; } return bRC_OK; bail_out: return bRC_Error; }