From: Kefu Chai Date: Thu, 3 Dec 2020 07:23:35 +0000 (+0800) Subject: pybind/rgw: extract non-shared interface definitions into c_rgw.pxd X-Git-Tag: v16.1.0~324^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea80b9b40e13ffd2c47a62a2dadc9bbd4df83f9d;p=ceph.git pybind/rgw: extract non-shared interface definitions into c_rgw.pxd so it'd be simpler if we want to parse and generate the stub for these declarations when building document where where the annotations are used. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/rgw/c_rgw.pxd b/src/pybind/rgw/c_rgw.pxd new file mode 100644 index 000000000000..988b67b0ef91 --- /dev/null +++ b/src/pybind/rgw/c_rgw.pxd @@ -0,0 +1,137 @@ +# cython: embedsignature=True + +from libc.stdint cimport * +from libcpp cimport bool +from cstat cimport stat + + +cdef extern from "rados/librgw.h" nogil: + ctypedef void* librgw_t + + int librgw_create(librgw_t *rgw, int argc, char **argv) + void librgw_shutdown(librgw_t rgw) + + +cdef extern from "rados/rgw_file.h" nogil: + enum: + RGW_FS_TYPE_FILE + RGW_FS_TYPE_DIRECTORY + + RGW_LOOKUP_FLAG_CREATE + + RGW_SETATTR_MODE + RGW_SETATTR_UID + RGW_SETATTR_GID + RGW_SETATTR_MTIME + RGW_SETATTR_ATIME + RGW_SETATTR_SIZE + RGW_SETATTR_CTIME + + RGW_READDIR_FLAG_NONE + RGW_READDIR_FLAG_DOTDOT + + RGW_OPEN_FLAG_CREATE + RGW_OPEN_FLAG_V3 # ops have v3 semantics + RGW_OPEN_FLAG_STATELESS # alias it + + RGW_CLOSE_FLAG_RELE + + + ctypedef void *rgw_fh_hk + cdef struct rgw_file_handle: + pass + + cdef struct rgw_fs: + librgw_t rgw + void *fs_private + void *root_fh + + # mount info hypothetical--emulate Unix, support at least UUID-length fsid + cdef struct rgw_statvfs: + uint64_t f_bsize # file system block size + uint64_t f_frsize # fragment size + uint64_t f_blocks # size of fs in f_frsize units + uint64_t f_bfree # free blocks + uint64_t f_bavail # free blocks for unprivileged users + uint64_t f_files # inodes + uint64_t f_ffree # free inodes + uint64_t f_favail # free inodes for unprivileged users + uint64_t f_fsid[2] # /* file system ID + uint64_t f_flag # mount flags + uint64_t f_namemax # maximum filename length + + void rgwfile_version(int *major, int *minor, int *extra) + + int rgw_lookup(rgw_fs *fs, + rgw_file_handle *parent_fh, const char *path, + rgw_file_handle **fh, stat* st, uint32_t st_mask, + uint32_t flags) + + int rgw_lookup_handle(rgw_fs *fs, rgw_fh_hk *fh_hk, + rgw_file_handle **fh, uint32_t flags) + + int rgw_fh_rele(rgw_fs *fs, rgw_file_handle *fh, + uint32_t flags) + + int rgw_mount(librgw_t rgw, const char *uid, const char *key, + const char *secret, rgw_fs **fs, uint32_t flags) + + int rgw_umount(rgw_fs *fs, uint32_t flags) + + int rgw_statfs(rgw_fs *fs, rgw_file_handle *parent_fh, + rgw_statvfs *vfs_st, uint32_t flags) + + int rgw_create(rgw_fs *fs, rgw_file_handle *parent_fh, + const char *name, stat *st, uint32_t mask, + rgw_file_handle **fh, uint32_t posix_flags, + uint32_t flags) + + int rgw_mkdir(rgw_fs *fs, + rgw_file_handle *parent_fh, + const char *name, stat *st, uint32_t mask, + rgw_file_handle **fh, uint32_t flags) + + int rgw_rename(rgw_fs *fs, + rgw_file_handle *olddir, const char* old_name, + rgw_file_handle *newdir, const char* new_name, + uint32_t flags) + + int rgw_unlink(rgw_fs *fs, + rgw_file_handle *parent_fh, const char* path, + uint32_t flags) + + int rgw_readdir(rgw_fs *fs, + rgw_file_handle *parent_fh, uint64_t *offset, + bool (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000, + void *cb_arg, bool *eof, uint32_t flags) except? -9000 + + int rgw_getattr(rgw_fs *fs, + rgw_file_handle *fh, stat *st, + uint32_t flags) + + int rgw_setattr(rgw_fs *fs, rgw_file_handle *fh, stat *st, + uint32_t mask, uint32_t flags) + + int rgw_truncate(rgw_fs *fs, rgw_file_handle *fh, uint64_t size, uint32_t flags) + + int rgw_open(rgw_fs *fs, rgw_file_handle *parent_fh, + uint32_t posix_flags, uint32_t flags) + + int rgw_close(rgw_fs *fs, rgw_file_handle *fh, + uint32_t flags) + + int rgw_read(rgw_fs *fs, + rgw_file_handle *fh, uint64_t offset, + size_t length, size_t *bytes_read, void *buffer, + uint32_t flags) + + int rgw_write(rgw_fs *fs, + rgw_file_handle *fh, uint64_t offset, + size_t length, size_t *bytes_written, void *buffer, + uint32_t flags) + + int rgw_fsync(rgw_fs *fs, rgw_file_handle *fh, + uint32_t flags) + + int rgw_commit(rgw_fs *fs, rgw_file_handle *fh, + uint64_t offset, uint64_t length, uint32_t flags) diff --git a/src/pybind/rgw/cstat.pxd b/src/pybind/rgw/cstat.pxd new file mode 100644 index 000000000000..f7da7c6def2d --- /dev/null +++ b/src/pybind/rgw/cstat.pxd @@ -0,0 +1,20 @@ +cdef extern from "time.h": + ctypedef long int time_t + + +cdef extern from "sys/stat.h": + cdef struct stat: + unsigned long st_dev + unsigned long st_ino + unsigned long st_nlink + unsigned int st_mode + unsigned int st_uid + unsigned int st_gid + int __pad0 + unsigned long st_rdev + long int st_size + long int st_blksize + long int st_blocks + time_t st_atime + time_t st_mtime + time_t st_ctime diff --git a/src/pybind/rgw/rgw.pyx b/src/pybind/rgw/rgw.pyx index 6e85dd718f54..3385d063e810 100644 --- a/src/pybind/rgw/rgw.pyx +++ b/src/pybind/rgw/rgw.pyx @@ -7,7 +7,9 @@ from cpython cimport PyObject, ref, exc, array from libc.stdint cimport * from libcpp cimport bool from libc.stdlib cimport malloc, realloc, free +from cstat cimport stat +from c_rgw cimport * cimport rados from collections import namedtuple @@ -26,160 +28,6 @@ cdef extern from "Python.h": void PyEval_InitThreads() -cdef extern from "time.h": - ctypedef long int time_t - - -cdef extern from "sys/stat.h": - cdef struct stat: - unsigned long st_dev - unsigned long st_ino - unsigned long st_nlink - unsigned int st_mode - unsigned int st_uid - unsigned int st_gid - int __pad0 - unsigned long st_rdev - long int st_size - long int st_blksize - long int st_blocks - time_t st_atime - time_t st_mtime - time_t st_ctime - - -cdef extern from "rados/librgw.h" nogil: - ctypedef void* librgw_t - - int librgw_create(librgw_t *rgw, int argc, char **argv) - void librgw_shutdown(librgw_t rgw) - - -cdef extern from "rados/rgw_file.h" nogil: - enum: - RGW_FS_TYPE_FILE - RGW_FS_TYPE_DIRECTORY - - RGW_LOOKUP_FLAG_CREATE - - RGW_SETATTR_MODE - RGW_SETATTR_UID - RGW_SETATTR_GID - RGW_SETATTR_MTIME - RGW_SETATTR_ATIME - RGW_SETATTR_SIZE - RGW_SETATTR_CTIME - - RGW_READDIR_FLAG_NONE - RGW_READDIR_FLAG_DOTDOT - - RGW_OPEN_FLAG_CREATE - RGW_OPEN_FLAG_V3 # ops have v3 semantics - RGW_OPEN_FLAG_STATELESS # alias it - - RGW_CLOSE_FLAG_RELE - - - ctypedef void *rgw_fh_hk - cdef struct rgw_file_handle: - pass - - cdef struct rgw_fs: - librgw_t rgw - void *fs_private - void *root_fh - - # mount info hypothetical--emulate Unix, support at least UUID-length fsid - cdef struct rgw_statvfs: - uint64_t f_bsize # file system block size - uint64_t f_frsize # fragment size - uint64_t f_blocks # size of fs in f_frsize units - uint64_t f_bfree # free blocks - uint64_t f_bavail # free blocks for unprivileged users - uint64_t f_files # inodes - uint64_t f_ffree # free inodes - uint64_t f_favail # free inodes for unprivileged users - uint64_t f_fsid[2] # /* file system ID - uint64_t f_flag # mount flags - uint64_t f_namemax # maximum filename length - - void rgwfile_version(int *major, int *minor, int *extra) - - int rgw_lookup(rgw_fs *fs, - rgw_file_handle *parent_fh, const char *path, - rgw_file_handle **fh, stat* st, uint32_t st_mask, - uint32_t flags) - - int rgw_lookup_handle(rgw_fs *fs, rgw_fh_hk *fh_hk, - rgw_file_handle **fh, uint32_t flags) - - int rgw_fh_rele(rgw_fs *fs, rgw_file_handle *fh, - uint32_t flags) - - int rgw_mount(librgw_t rgw, const char *uid, const char *key, - const char *secret, rgw_fs **fs, uint32_t flags) - - int rgw_umount(rgw_fs *fs, uint32_t flags) - - int rgw_statfs(rgw_fs *fs, rgw_file_handle *parent_fh, - rgw_statvfs *vfs_st, uint32_t flags) - - int rgw_create(rgw_fs *fs, rgw_file_handle *parent_fh, - const char *name, stat *st, uint32_t mask, - rgw_file_handle **fh, uint32_t posix_flags, - uint32_t flags) - - int rgw_mkdir(rgw_fs *fs, - rgw_file_handle *parent_fh, - const char *name, stat *st, uint32_t mask, - rgw_file_handle **fh, uint32_t flags) - - int rgw_rename(rgw_fs *fs, - rgw_file_handle *olddir, const char* old_name, - rgw_file_handle *newdir, const char* new_name, - uint32_t flags) - - int rgw_unlink(rgw_fs *fs, - rgw_file_handle *parent_fh, const char* path, - uint32_t flags) - - int rgw_readdir(rgw_fs *fs, - rgw_file_handle *parent_fh, uint64_t *offset, - bool (*cb)(const char *name, void *arg, uint64_t offset, stat *st, uint32_t st_mask, uint32_t flags) nogil except? -9000, - void *cb_arg, bool *eof, uint32_t flags) except? -9000 - - int rgw_getattr(rgw_fs *fs, - rgw_file_handle *fh, stat *st, - uint32_t flags) - - int rgw_setattr(rgw_fs *fs, rgw_file_handle *fh, stat *st, - uint32_t mask, uint32_t flags) - - int rgw_truncate(rgw_fs *fs, rgw_file_handle *fh, uint64_t size, uint32_t flags) - - int rgw_open(rgw_fs *fs, rgw_file_handle *parent_fh, - uint32_t posix_flags, uint32_t flags) - - int rgw_close(rgw_fs *fs, rgw_file_handle *fh, - uint32_t flags) - - int rgw_read(rgw_fs *fs, - rgw_file_handle *fh, uint64_t offset, - size_t length, size_t *bytes_read, void *buffer, - uint32_t flags) - - int rgw_write(rgw_fs *fs, - rgw_file_handle *fh, uint64_t offset, - size_t length, size_t *bytes_written, void *buffer, - uint32_t flags) - - int rgw_fsync(rgw_fs *fs, rgw_file_handle *fh, - uint32_t flags) - - int rgw_commit(rgw_fs *fs, rgw_file_handle *fh, - uint64_t offset, uint64_t length, uint32_t flags) - - class Error(Exception): pass