本文档主要为您说明在通过SDK方式接入DBFS服务时所需要遵循的接口使用规范。

DBFS的SDK头文件位于“/usr/local/include/dbfs.h” 。以下为DBFS服务目前支持的接口,具体语义可参考Linux MAN手册。
  int dbfs_mount(const char *conf_file);
  int dbfs_umount();
  int dbfs_open(const char *pathname, int flags, ...);
  int dbfs_close(int fd);
  int dbfs_fcntl(int fd, int cmd, ...);
  off_t dbfs_lseek(int fd, off_t offset, int whence);
  int dbfs_fallocate(int fd, int mode, off_t offset, off_t len);
  int dbfs_posix_fallocate(int fd, off_t offset, off_t len);
  int dbfs_truncate(const char *path, off_t length);
  int dbfs_ftruncate(int fd, off_t length);
  int dbfs_fsync(int fd);
  int dbfs_fdatasync(int fildes);
  int dbfs_sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags);
  int dbfs_rename(const char *oldname, const char *newname);
  int dbfs_link(const char *oldpath, const char *newpath);
  int dbfs_unlink(const char *filepath);
  int dbfs_symlink(const char *oldpath, const char *newpath);
  ssize_t dbfs_readlink(const char *path, char *buf, size_t bufsiz);
  int dbfs_lstat(const char *path, struct stat *buf);
  int dbfs_stat(const char *path, struct stat *buf);
  int dbfs_fstat(int fd, struct stat *buf);
  int dbfs_statvfs(const char *path, struct statvfs *buf);
  int dbfs_chdir(const char *path);
  char *dbfs_getcwd(char *buf, size_t size);
  int dbfs_mkdir(const char *dirname, mode_t mode);
  int dbfs_rmdir(const char *dirname);
  int dbfs_access(const char *path, int mode);
  int dbfs_flock(int fd, int operation);
  int dbfs_mkstemp(char *tmpl);
  int dbfs_dup2(int oldfd, int newfd);
  int dbfs_chown(const char *path, uid_t owner, gid_t group);
  int dbfs_chmod(const char *path, mode_t mode);
  int dbfs_fchmod(int fd, mode_t mode);
  char *dbfs_realpath(const char *path, char *resolved_path);
  ssize_t dbfs_read(int fd, void *buf, size_t size);
  ssize_t dbfs_write(int fd, const void *buf, size_t size);
  ssize_t dbfs_pread(int fd, void *buf, size_t size, off_t offset);
  ssize_t dbfs_pwrite(int fd, const void *buf, size_t size, off_t offset);
  DIR *dbfs_opendir(const char *name);
  int dbfs_closedir(DIR *dirp);
  struct dirent *dbfs_readdir(DIR *dirp);
  int dbfs_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
  FILE *dbfs_fopen(const char *path, const char *mode);
  FILE *dbfs_fdopen(int fildes, const char *mode);
  size_t dbfs_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
  size_t dbfs_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
  int dbfs_fflush(FILE *stream);
  int dbfs_fclose(FILE *stream);
  int dbfs_fileno(FILE *stream);
  int dbfs_feof(FILE *stream);
  int dbfs_ferror(FILE *stream);
  void dbfs_clearerr(FILE *stream);
  int dbfs_fseeko(FILE *stream, off_t offset, int whence);
  int dbfs_fseek(FILE *stream, long offset, int whence);
  off_t dbfs_ftello(FILE *stream);
  long dbfs_ftell(FILE *stream);
  void dbfs_rewind(FILE *stream);
  int dbfs_fputs(const char *s, FILE *stream);
  int dbfs_fputc(int c, FILE *stream);
  int dbfs_putc(int c, FILE *stream);
  char *dbfs_fgets(char *s, int size, FILE *stream);
  int dbfs_fgetc(FILE *stream);
  int dbfs_getc(FILE *stream);
  int dbfs_fprintf(FILE *stream, const char *format, ...);
  int dbfs_fscanf(FILE *stream, const char *format, ...);
  int dbfs_vfscanf(FILE *stream, const char *format, va_list args);
  // POSIX async io interface
  void dbfs_io_prep_pread(struct iocb *iocb, int fd, void *buf, size_t count, long long offset);
  void dbfs_io_prep_pwrite(struct iocb *iocb, int fd, void *buf, size_t count, long long offset);
  int  dbfs_io_setup(int maxevents, io_context_t *ctxp);
  int  dbfs_io_destroy(io_context_t ctx);
  int  dbfs_io_submit(io_context_t ctx, long nr, struct iocb *ios[]);
  int  dbfs_io_cancel(io_context_t ctx, struct iocb *iocb, struct io_event *evt);
  int  dbfs_io_getevents(io_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout);