1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * convert RGW commands to file commands
6 * Copyright (C) 2015 Red Hat, Inc.
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
14 #ifndef RADOS_RGW_FILE_H
15 #define RADOS_RGW_FILE_H
18 #include <sys/types.h>
28 #define LIBRGW_FILE_VER_MAJOR 1
29 #define LIBRGW_FILE_VER_MINOR 1
30 #define LIBRGW_FILE_VER_EXTRA 6
32 #define LIBRGW_FILE_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
33 #define LIBRGW_FILE_VERSION_CODE LIBRGW_FILE_VERSION(LIBRGW_FILE_VER_MAJOR, LIBRGW_FILE_VER_MINOR, LIBRGW_FILE_VER_EXTRA)
41 RGW_FS_TYPE_DIRECTORY,
45 * dynamic allocated handle to support nfs handle
48 /* content-addressable hash */
54 struct rgw_file_handle
56 /* content-addressable hash */
57 struct rgw_fh_hk fh_hk;
58 void *fh_private; /* librgw private data */
60 enum rgw_fh_type fh_type;
67 struct rgw_file_handle* root_fh;
71 /* XXX mount info hypothetical--emulate Unix, support at least
74 uint64_t f_bsize; /* file system block size */
75 uint64_t f_frsize; /* fragment size */
76 uint64_t f_blocks; /* size of fs in f_frsize units */
77 uint64_t f_bfree; /* # free blocks */
78 uint64_t f_bavail; /* # free blocks for unprivileged users */
79 uint64_t f_files; /* # inodes */
80 uint64_t f_ffree; /* # free inodes */
81 uint64_t f_favail; /* # free inodes for unprivileged users */
82 uint64_t f_fsid[2]; /* file system ID */
83 uint64_t f_flag; /* mount flags */
84 uint64_t f_namemax; /* maximum filename length */
88 void rgwfile_version(int *major, int *minor, int *extra);
91 lookup object by name (POSIX style)
93 #define RGW_LOOKUP_FLAG_NONE 0x0000
94 #define RGW_LOOKUP_FLAG_CREATE 0x0001
95 #define RGW_LOOKUP_FLAG_RCB 0x0002 /* readdir callback hint */
96 #define RGW_LOOKUP_FLAG_DIR 0x0004
97 #define RGW_LOOKUP_FLAG_FILE 0x0008
99 #define RGW_LOOKUP_TYPE_FLAGS \
100 (RGW_LOOKUP_FLAG_DIR|RGW_LOOKUP_FLAG_FILE)
102 int rgw_lookup(struct rgw_fs *rgw_fs,
103 struct rgw_file_handle *parent_fh, const char *path,
104 struct rgw_file_handle **fh, uint32_t flags);
107 lookup object by handle (NFS style)
109 int rgw_lookup_handle(struct rgw_fs *rgw_fs, struct rgw_fh_hk *fh_hk,
110 struct rgw_file_handle **fh, uint32_t flags);
113 * release file handle
115 #define RGW_FH_RELE_FLAG_NONE 0x0000
117 int rgw_fh_rele(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
123 #define RGW_MOUNT_FLAG_NONE 0x0000
125 int rgw_mount(librgw_t rgw, const char *uid, const char *key,
126 const char *secret, struct rgw_fs **rgw_fs,
129 int rgw_mount2(librgw_t rgw, const char *uid, const char *key,
130 const char *secret, const char *root, struct rgw_fs **rgw_fs,
134 register invalidate callbacks
136 #define RGW_REG_INVALIDATE_FLAG_NONE 0x0000
138 typedef void (*rgw_fh_callback_t)(void *handle, struct rgw_fh_hk fh_hk);
140 int rgw_register_invalidate(struct rgw_fs *rgw_fs, rgw_fh_callback_t cb,
141 void *arg, uint32_t flags);
146 #define RGW_UMOUNT_FLAG_NONE 0x0000
148 int rgw_umount(struct rgw_fs *rgw_fs, uint32_t flags);
152 get filesystem attributes
154 #define RGW_STATFS_FLAG_NONE 0x0000
156 int rgw_statfs(struct rgw_fs *rgw_fs,
157 struct rgw_file_handle *parent_fh,
158 struct rgw_statvfs *vfs_st,
162 /* XXX (get|set)attr mask bits */
163 #define RGW_SETATTR_MODE 1
164 #define RGW_SETATTR_UID 2
165 #define RGW_SETATTR_GID 4
166 #define RGW_SETATTR_MTIME 8
167 #define RGW_SETATTR_ATIME 16
168 #define RGW_SETATTR_SIZE 32
169 #define RGW_SETATTR_CTIME 64
174 #define RGW_CREATE_FLAG_NONE 0x0000
176 int rgw_create(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
177 const char *name, struct stat *st, uint32_t mask,
178 struct rgw_file_handle **fh, uint32_t posix_flags,
182 create a new directory
184 #define RGW_MKDIR_FLAG_NONE 0x0000
186 int rgw_mkdir(struct rgw_fs *rgw_fs,
187 struct rgw_file_handle *parent_fh,
188 const char *name, struct stat *st, uint32_t mask,
189 struct rgw_file_handle **fh, uint32_t flags);
194 #define RGW_RENAME_FLAG_NONE 0x0000
196 int rgw_rename(struct rgw_fs *rgw_fs,
197 struct rgw_file_handle *olddir, const char* old_name,
198 struct rgw_file_handle *newdir, const char* new_name,
202 remove file or directory
204 #define RGW_UNLINK_FLAG_NONE 0x0000
206 int rgw_unlink(struct rgw_fs *rgw_fs,
207 struct rgw_file_handle *parent_fh, const char* path,
211 read directory content
213 typedef bool (*rgw_readdir_cb)(const char *name, void *arg, uint64_t offset,
216 #define RGW_READDIR_FLAG_NONE 0x0000
217 #define RGW_READDIR_FLAG_DOTDOT 0x0001 /* send dot names */
219 int rgw_readdir(struct rgw_fs *rgw_fs,
220 struct rgw_file_handle *parent_fh, uint64_t *offset,
221 rgw_readdir_cb rcb, void *cb_arg, bool *eof,
224 /* enumeration continuing from name */
225 int rgw_readdir2(struct rgw_fs *rgw_fs,
226 struct rgw_file_handle *parent_fh, const char *name,
227 rgw_readdir_cb rcb, void *cb_arg, bool *eof,
230 /* project offset of dirent name */
231 #define RGW_DIRENT_OFFSET_FLAG_NONE 0x0000
233 int rgw_dirent_offset(struct rgw_fs *rgw_fs,
234 struct rgw_file_handle *parent_fh,
235 const char *name, int64_t *offset,
239 get unix attributes for object
241 #define RGW_GETATTR_FLAG_NONE 0x0000
243 int rgw_getattr(struct rgw_fs *rgw_fs,
244 struct rgw_file_handle *fh, struct stat *st,
248 set unix attributes for object
250 #define RGW_SETATTR_FLAG_NONE 0x0000
252 int rgw_setattr(struct rgw_fs *rgw_fs,
253 struct rgw_file_handle *fh, struct stat *st,
254 uint32_t mask, uint32_t flags);
259 #define RGW_TRUNCATE_FLAG_NONE 0x0000
261 int rgw_truncate(struct rgw_fs *rgw_fs,
262 struct rgw_file_handle *fh, uint64_t size,
268 #define RGW_OPEN_FLAG_NONE 0x0000
269 #define RGW_OPEN_FLAG_CREATE 0x0001
270 #define RGW_OPEN_FLAG_V3 0x0002 /* ops have v3 semantics */
271 #define RGW_OPEN_FLAG_STATELESS 0x0002 /* alias it */
273 int rgw_open(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
274 uint32_t posix_flags, uint32_t flags);
280 #define RGW_CLOSE_FLAG_NONE 0x0000
281 #define RGW_CLOSE_FLAG_RELE 0x0001
283 int rgw_close(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
289 #define RGW_READ_FLAG_NONE 0x0000
291 int rgw_read(struct rgw_fs *rgw_fs,
292 struct rgw_file_handle *fh, uint64_t offset,
293 size_t length, size_t *bytes_read, void *buffer,
299 #define RGW_WRITE_FLAG_NONE 0x0000
301 int rgw_write(struct rgw_fs *rgw_fs,
302 struct rgw_file_handle *fh, uint64_t offset,
303 size_t length, size_t *bytes_written, void *buffer,
306 #define RGW_UIO_NONE 0x0000
307 #define RGW_UIO_GIFT 0x0001
308 #define RGW_UIO_FREE 0x0002
309 #define RGW_UIO_BUFQ 0x0004
312 typedef void (*rgw_uio_release)(struct rgw_uio *, uint32_t);
314 /* buffer vector descriptors */
323 rgw_uio_release uio_rele;
330 struct rgw_vio *uio_vio; /* appended vectors */
333 typedef struct rgw_uio rgw_uio;
335 int rgw_readv(struct rgw_fs *rgw_fs,
336 struct rgw_file_handle *fh, rgw_uio *uio, uint32_t flags);
338 int rgw_writev(struct rgw_fs *rgw_fs,
339 struct rgw_file_handle *fh, rgw_uio *uio, uint32_t flags);
344 #define RGW_FSYNC_FLAG_NONE 0x0000
346 int rgw_fsync(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
353 #define RGW_COMMIT_FLAG_NONE 0x0000
355 int rgw_commit(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
356 uint64_t offset, uint64_t length, uint32_t flags);
362 #endif /* RADOS_RGW_FILE_H */