]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/rados/rgw_file.h
update sources to 12.2.2
[ceph.git] / ceph / src / include / rados / rgw_file.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * convert RGW commands to file commands
5 *
6 * Copyright (C) 2015 Red Hat, Inc.
7 *
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.
12 *
13 */
14#ifndef RADOS_RGW_FILE_H
15#define RADOS_RGW_FILE_H
16
17#include <sys/stat.h>
18#include <sys/types.h>
19#include <stdint.h>
20#include <stdbool.h>
21
22#include "librgw.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#define LIBRGW_FILE_VER_MAJOR 1
29#define LIBRGW_FILE_VER_MINOR 1
3efd9988 30#define LIBRGW_FILE_VER_EXTRA 6
7c673cae
FG
31
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)
34
35/*
36 * object types
37 */
38enum rgw_fh_type {
39 RGW_FS_TYPE_NIL = 0,
40 RGW_FS_TYPE_FILE,
41 RGW_FS_TYPE_DIRECTORY,
42};
43
44/*
45 * dynamic allocated handle to support nfs handle
46 */
47
48/* content-addressable hash */
49struct rgw_fh_hk {
50 uint64_t bucket;
51 uint64_t object;
52};
53
54struct rgw_file_handle
55{
56 /* content-addressable hash */
57 struct rgw_fh_hk fh_hk;
58 void *fh_private; /* librgw private data */
59 /* object type */
60 enum rgw_fh_type fh_type;
61};
62
63struct rgw_fs
64{
65 librgw_t rgw;
66 void *fs_private;
67 struct rgw_file_handle* root_fh;
68};
69
70
71/* XXX mount info hypothetical--emulate Unix, support at least
72 * UUID-length fsid */
73struct rgw_statvfs {
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 */
85};
86
87
88void rgwfile_version(int *major, int *minor, int *extra);
89
90/*
91 lookup object by name (POSIX style)
92*/
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
98
99#define RGW_LOOKUP_TYPE_FLAGS \
100 (RGW_LOOKUP_FLAG_DIR|RGW_LOOKUP_FLAG_FILE)
101
102int 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);
105
106/*
107 lookup object by handle (NFS style)
108*/
109int rgw_lookup_handle(struct rgw_fs *rgw_fs, struct rgw_fh_hk *fh_hk,
110 struct rgw_file_handle **fh, uint32_t flags);
111
112/*
113 * release file handle
114 */
115#define RGW_FH_RELE_FLAG_NONE 0x0000
116
117int rgw_fh_rele(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
118 uint32_t flags);
119
120/*
121 attach rgw namespace
122*/
123#define RGW_MOUNT_FLAG_NONE 0x0000
124
125int rgw_mount(librgw_t rgw, const char *uid, const char *key,
126 const char *secret, struct rgw_fs **rgw_fs,
127 uint32_t flags);
128
3efd9988
FG
129int rgw_mount2(librgw_t rgw, const char *uid, const char *key,
130 const char *secret, const char *root, struct rgw_fs **rgw_fs,
131 uint32_t flags);
132
7c673cae
FG
133/*
134 register invalidate callbacks
135*/
136#define RGW_REG_INVALIDATE_FLAG_NONE 0x0000
137
138typedef void (*rgw_fh_callback_t)(void *handle, struct rgw_fh_hk fh_hk);
139
140int rgw_register_invalidate(struct rgw_fs *rgw_fs, rgw_fh_callback_t cb,
141 void *arg, uint32_t flags);
142
143/*
144 detach rgw namespace
145*/
146#define RGW_UMOUNT_FLAG_NONE 0x0000
147
148int rgw_umount(struct rgw_fs *rgw_fs, uint32_t flags);
149
150
151/*
152 get filesystem attributes
153*/
154#define RGW_STATFS_FLAG_NONE 0x0000
155
156int rgw_statfs(struct rgw_fs *rgw_fs,
157 struct rgw_file_handle *parent_fh,
158 struct rgw_statvfs *vfs_st,
159 uint32_t flags);
160
161
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
170
171/*
172 create file
173*/
174#define RGW_CREATE_FLAG_NONE 0x0000
175
176int 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,
179 uint32_t flags);
180
181/*
182 create a new directory
183*/
184#define RGW_MKDIR_FLAG_NONE 0x0000
185
186int 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);
190
191/*
192 rename object
193*/
194#define RGW_RENAME_FLAG_NONE 0x0000
195
196int 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,
199 uint32_t flags);
200
201/*
202 remove file or directory
203*/
204#define RGW_UNLINK_FLAG_NONE 0x0000
205
206int rgw_unlink(struct rgw_fs *rgw_fs,
207 struct rgw_file_handle *parent_fh, const char* path,
208 uint32_t flags);
209
210/*
211 read directory content
212*/
213typedef bool (*rgw_readdir_cb)(const char *name, void *arg, uint64_t offset,
214 uint32_t flags);
215
216#define RGW_READDIR_FLAG_NONE 0x0000
217#define RGW_READDIR_FLAG_DOTDOT 0x0001 /* send dot names */
218
219int 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,
222 uint32_t flags);
223
3efd9988
FG
224/* enumeration continuing from name */
225int 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,
228 uint32_t flags);
229
c07f9fc5
FG
230/* project offset of dirent name */
231#define RGW_DIRENT_OFFSET_FLAG_NONE 0x0000
232
233int rgw_dirent_offset(struct rgw_fs *rgw_fs,
234 struct rgw_file_handle *parent_fh,
235 const char *name, int64_t *offset,
236 uint32_t flags);
237
7c673cae
FG
238/*
239 get unix attributes for object
240*/
241#define RGW_GETATTR_FLAG_NONE 0x0000
242
243int rgw_getattr(struct rgw_fs *rgw_fs,
244 struct rgw_file_handle *fh, struct stat *st,
245 uint32_t flags);
246
247/*
248 set unix attributes for object
249*/
250#define RGW_SETATTR_FLAG_NONE 0x0000
251
252int rgw_setattr(struct rgw_fs *rgw_fs,
253 struct rgw_file_handle *fh, struct stat *st,
254 uint32_t mask, uint32_t flags);
255
256/*
257 truncate file
258*/
259#define RGW_TRUNCATE_FLAG_NONE 0x0000
260
261int rgw_truncate(struct rgw_fs *rgw_fs,
262 struct rgw_file_handle *fh, uint64_t size,
263 uint32_t flags);
264
265/*
266 open file
267*/
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 */
272
273int rgw_open(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
274 uint32_t posix_flags, uint32_t flags);
275
276/*
277 close file
278*/
279
280#define RGW_CLOSE_FLAG_NONE 0x0000
281#define RGW_CLOSE_FLAG_RELE 0x0001
282
283int rgw_close(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
284 uint32_t flags);
285
286/*
287 read data from file
288*/
289#define RGW_READ_FLAG_NONE 0x0000
290
291int 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,
294 uint32_t flags);
295
296/*
297 write data to file
298*/
299#define RGW_WRITE_FLAG_NONE 0x0000
300
301int 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,
304 uint32_t flags);
305
306#define RGW_UIO_NONE 0x0000
307#define RGW_UIO_GIFT 0x0001
308#define RGW_UIO_FREE 0x0002
309#define RGW_UIO_BUFQ 0x0004
310
311struct rgw_uio;
312typedef void (*rgw_uio_release)(struct rgw_uio *, uint32_t);
313
314/* buffer vector descriptors */
315struct rgw_vio {
316 void *vio_p1;
317 void *vio_u1;
318 void *vio_base;
319 int32_t vio_len;
320};
321
322struct rgw_uio {
323 rgw_uio_release uio_rele;
324 void *uio_p1;
325 void *uio_u1;
326 uint64_t uio_offset;
327 uint64_t uio_resid;
328 uint32_t uio_cnt;
329 uint32_t uio_flags;
330 struct rgw_vio *uio_vio; /* appended vectors */
331};
332
333typedef struct rgw_uio rgw_uio;
334
335int rgw_readv(struct rgw_fs *rgw_fs,
336 struct rgw_file_handle *fh, rgw_uio *uio, uint32_t flags);
337
338int rgw_writev(struct rgw_fs *rgw_fs,
339 struct rgw_file_handle *fh, rgw_uio *uio, uint32_t flags);
340
341/*
342 sync written data
343*/
344#define RGW_FSYNC_FLAG_NONE 0x0000
345
346int rgw_fsync(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
347 uint32_t flags);
348
349/*
350 NFS commit operation
351*/
352
353#define RGW_COMMIT_FLAG_NONE 0x0000
354
355int rgw_commit(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
356 uint64_t offset, uint64_t length, uint32_t flags);
357
358#ifdef __cplusplus
359}
360#endif
361
362#endif /* RADOS_RGW_FILE_H */