static int cephwrap_statvfs(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, vfs_statvfs_struct *statbuf) { struct statvfs statvfs_buf; int ret; ret = ceph_statfs(handle->data, smb_fname->base_name, &statvfs_buf); if (ret < 0) { WRAP_RETURN(ret); } else { statbuf->OptimalTransferSize = statvfs_buf.f_frsize; statbuf->BlockSize = statvfs_buf.f_bsize; statbuf->TotalBlocks = statvfs_buf.f_blocks; statbuf->BlocksAvail = statvfs_buf.f_bfree; statbuf->UserBlocksAvail = statvfs_buf.f_bavail; statbuf->TotalFileNodes = statvfs_buf.f_files; statbuf->FreeFileNodes = statvfs_buf.f_ffree; statbuf->FsIdentifier = statvfs_buf.f_fsid; DBG_DEBUG("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, f_bavail: %ld\n", (long int)statvfs_buf.f_bsize, (long int)statvfs_buf.f_blocks, (long int)statvfs_buf.f_bfree, (long int)statvfs_buf.f_bavail); } return ret; }
static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize) { struct statvfs statvfs_buf; int ret; if (!(ret = ceph_statfs(handle->data, smb_fname->base_name, &statvfs_buf))) { /* * Provide all the correct values. */ *bsize = statvfs_buf.f_bsize; *dfree = statvfs_buf.f_bavail; *dsize = statvfs_buf.f_blocks; DBG_DEBUG("[CEPH] bsize: %llu, dfree: %llu, dsize: %llu\n", llu(*bsize), llu(*dfree), llu(*dsize)); return *dfree; } else { DBG_DEBUG("[CEPH] ceph_statfs returned %d\n", ret); WRAP_RETURN(ret); } }
static long cephwrap_telldir(struct vfs_handle_struct *handle, DIR *dirp) { long ret; DBG_DEBUG("[CEPH] telldir(%p, %p)\n", handle, dirp); ret = ceph_telldir(handle->data, (struct ceph_dir_result *) dirp); DBG_DEBUG("[CEPH] telldir(...) = %ld\n", ret); WRAP_RETURN(ret); }
static int cephwrap_closedir(struct vfs_handle_struct *handle, DIR *dirp) { int result; DBG_DEBUG("[CEPH] closedir(%p, %p)\n", handle, dirp); result = ceph_closedir(handle->data, (struct ceph_dir_result *) dirp); DBG_DEBUG("[CEPH] closedir(...) = %d\n", result); WRAP_RETURN(result); }
static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp) { int result; DBG_DEBUG("[CEPH] close(%p, %p)\n", handle, fsp); result = ceph_close(handle->data, fsp->fh->fd); DBG_DEBUG("[CEPH] close(...) = %d\n", result); WRAP_RETURN(result); }
static int cephwrap_rmdir(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname) { int result; DBG_DEBUG("[CEPH] rmdir(%p, %s)\n", handle, smb_fname->base_name); result = ceph_rmdir(handle->data, smb_fname->base_name); DBG_DEBUG("[CEPH] rmdir(...) = %d\n", result); WRAP_RETURN(result); }
static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n, off_t offset) { ssize_t result; DBG_DEBUG("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)); result = ceph_read(handle->data, fsp->fh->fd, data, n, offset); DBG_DEBUG("[CEPH] pread(...) = %llu\n", llu(result)); WRAP_RETURN(result); }
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); }
static int cephwrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt) { /* libceph: Ceph does not implement this */ #if 0 /* was ifdef HAVE_SYS_QUOTAS */ int ret; ret = ceph_set_quota(handle->conn->connectpath, qtype, id, qt); if (ret) { errno = -ret; ret = -1; } return ret; #else WRAP_RETURN(-ENOSYS); #endif }
static int cephwrap_mkdir(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) { int result; char *parent = NULL; const char *path = smb_fname->base_name; DBG_DEBUG("[CEPH] mkdir(%p, %s)\n", handle, path); if (lp_inherit_acls(SNUM(handle->conn)) && parent_dirname(talloc_tos(), path, &parent, NULL) && directory_has_default_acl(handle->conn, parent)) { mode = 0777; } TALLOC_FREE(parent); result = ceph_mkdir(handle->data, path, mode); return WRAP_RETURN(result); }
static int cephwrap_connect(struct vfs_handle_struct *handle, const char *service, const char *user) { int ret; char buf[256]; int snum = SNUM(handle->conn); const char *conf_file; const char *user_id; if (cmount) { handle->data = cmount; /* We have been here before */ cmount_cnt++; return 0; } /* if config_file and/or user_id are NULL, ceph will use defaults */ conf_file = lp_parm_const_string(snum, "ceph", "config_file", NULL); user_id = lp_parm_const_string(snum, "ceph", "user_id", NULL); DBG_DEBUG("[CEPH] calling: ceph_create\n"); ret = ceph_create(&cmount, user_id); if (ret) { goto err_out; } DBG_DEBUG("[CEPH] calling: ceph_conf_read_file with %s\n", (conf_file == NULL ? "default path" : conf_file)); ret = ceph_conf_read_file(cmount, conf_file); if (ret) { goto err_cm_release; } DBG_DEBUG("[CEPH] calling: ceph_conf_get\n"); ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf)); if (ret < 0) { goto err_cm_release; } DBG_DEBUG("[CEPH] calling: ceph_mount\n"); ret = ceph_mount(cmount, NULL); if (ret < 0) { goto err_cm_release; } /* * encode mount context/state into our vfs/connection holding structure * cmount is a ceph_mount_t* */ handle->data = cmount; cmount_cnt++; return 0; err_cm_release: ceph_release(cmount); cmount = NULL; err_out: /* * Handle the error correctly. Ceph returns -errno. */ DBG_DEBUG("[CEPH] Error return: %s\n", strerror(-ret)); WRAP_RETURN(ret); }
PyObject * PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { STACKLESS_GETARG(); PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); Py_ssize_t size; #ifdef STACKLESS switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS)) { #else switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) { #endif case METH_VARARGS: if (kw == NULL || PyDict_Size(kw) == 0) WRAP_RETURN( (*meth)(self, arg) ) break; case METH_VARARGS | METH_KEYWORDS: case METH_OLDARGS | METH_KEYWORDS: WRAP_RETURN( (*(PyCFunctionWithKeywords)meth)(self, arg, kw) ) case METH_NOARGS: if (kw == NULL || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg); if (size == 0) WRAP_RETURN( (*meth)(self, NULL) ) PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%zd given)", f->m_ml->ml_name, size); return NULL; } break; case METH_O: if (kw == NULL || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg); if (size == 1) WRAP_RETURN( (*meth)(self, PyTuple_GET_ITEM(arg, 0)) ) PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%zd given)", f->m_ml->ml_name, size); return NULL; } break; case METH_OLDARGS: /* the really old style */ if (kw == NULL || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg); if (size == 1) arg = PyTuple_GET_ITEM(arg, 0); else if (size == 0) arg = NULL; WRAP_RETURN( (*meth)(self, arg) ) } break; default: PyErr_BadInternalCall(); return NULL; } PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; }
PyObject * PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { STACKLESS_GETARG(); PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func); Py_ssize_t size; #ifdef STACKLESS switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS)) { #else switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) { #endif case METH_VARARGS: if (kw == NULL || PyDict_Size(kw) == 0) WRAP_RETURN( (*meth)(self, arg) ) break; case METH_VARARGS | METH_KEYWORDS: WRAP_RETURN( (*(PyCFunctionWithKeywords)meth)(self, arg, kw) ) case METH_NOARGS: if (kw == NULL || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg); if (size == 0) WRAP_RETURN( (*meth)(self, NULL) ) PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%zd given)", f->m_ml->ml_name, size); return NULL; } break; case METH_O: if (kw == NULL || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg); if (size == 1) WRAP_RETURN( (*meth)(self, PyTuple_GET_ITEM(arg, 0)) ) PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%zd given)", f->m_ml->ml_name, size); return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags in " "PyCFunction_Call. METH_OLDARGS is no " "longer supported!"); return NULL; } PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; } /* Methods (the standard built-in methods, that is) */ static void meth_dealloc(PyCFunctionObject *m) { _PyObject_GC_UNTRACK(m); Py_XDECREF(m->m_self); Py_XDECREF(m->m_module); if (numfree < PyCFunction_MAXFREELIST) { m->m_self = (PyObject *)free_list; free_list = m; numfree++; } else { PyObject_GC_Del(m); } }