]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/rados/rgw_file.h
bump version to 12.1.1-pve1 while rebasing patches
[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
30#define LIBRGW_FILE_VER_EXTRA 3
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
129/*
130 register invalidate callbacks
131*/
132#define RGW_REG_INVALIDATE_FLAG_NONE 0x0000
133
134typedef void (*rgw_fh_callback_t)(void *handle, struct rgw_fh_hk fh_hk);
135
136int rgw_register_invalidate(struct rgw_fs *rgw_fs, rgw_fh_callback_t cb,
137 void *arg, uint32_t flags);
138
139/*
140 detach rgw namespace
141*/
142#define RGW_UMOUNT_FLAG_NONE 0x0000
143
144int rgw_umount(struct rgw_fs *rgw_fs, uint32_t flags);
145
146
147/*
148 get filesystem attributes
149*/
150#define RGW_STATFS_FLAG_NONE 0x0000
151
152int rgw_statfs(struct rgw_fs *rgw_fs,
153 struct rgw_file_handle *parent_fh,
154 struct rgw_statvfs *vfs_st,
155 uint32_t flags);
156
157
158/* XXX (get|set)attr mask bits */
159#define RGW_SETATTR_MODE 1
160#define RGW_SETATTR_UID 2
161#define RGW_SETATTR_GID 4
162#define RGW_SETATTR_MTIME 8
163#define RGW_SETATTR_ATIME 16
164#define RGW_SETATTR_SIZE 32
165#define RGW_SETATTR_CTIME 64
166
167/*
168 create file
169*/
170#define RGW_CREATE_FLAG_NONE 0x0000
171
172int rgw_create(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
173 const char *name, struct stat *st, uint32_t mask,
174 struct rgw_file_handle **fh, uint32_t posix_flags,
175 uint32_t flags);
176
177/*
178 create a new directory
179*/
180#define RGW_MKDIR_FLAG_NONE 0x0000
181
182int rgw_mkdir(struct rgw_fs *rgw_fs,
183 struct rgw_file_handle *parent_fh,
184 const char *name, struct stat *st, uint32_t mask,
185 struct rgw_file_handle **fh, uint32_t flags);
186
187/*
188 rename object
189*/
190#define RGW_RENAME_FLAG_NONE 0x0000
191
192int rgw_rename(struct rgw_fs *rgw_fs,
193 struct rgw_file_handle *olddir, const char* old_name,
194 struct rgw_file_handle *newdir, const char* new_name,
195 uint32_t flags);
196
197/*
198 remove file or directory
199*/
200#define RGW_UNLINK_FLAG_NONE 0x0000
201
202int rgw_unlink(struct rgw_fs *rgw_fs,
203 struct rgw_file_handle *parent_fh, const char* path,
204 uint32_t flags);
205
206/*
207 read directory content
208*/
209typedef bool (*rgw_readdir_cb)(const char *name, void *arg, uint64_t offset,
210 uint32_t flags);
211
212#define RGW_READDIR_FLAG_NONE 0x0000
213#define RGW_READDIR_FLAG_DOTDOT 0x0001 /* send dot names */
214
215int rgw_readdir(struct rgw_fs *rgw_fs,
216 struct rgw_file_handle *parent_fh, uint64_t *offset,
217 rgw_readdir_cb rcb, void *cb_arg, bool *eof,
218 uint32_t flags);
219
220/*
221 get unix attributes for object
222*/
223#define RGW_GETATTR_FLAG_NONE 0x0000
224
225int rgw_getattr(struct rgw_fs *rgw_fs,
226 struct rgw_file_handle *fh, struct stat *st,
227 uint32_t flags);
228
229/*
230 set unix attributes for object
231*/
232#define RGW_SETATTR_FLAG_NONE 0x0000
233
234int rgw_setattr(struct rgw_fs *rgw_fs,
235 struct rgw_file_handle *fh, struct stat *st,
236 uint32_t mask, uint32_t flags);
237
238/*
239 truncate file
240*/
241#define RGW_TRUNCATE_FLAG_NONE 0x0000
242
243int rgw_truncate(struct rgw_fs *rgw_fs,
244 struct rgw_file_handle *fh, uint64_t size,
245 uint32_t flags);
246
247/*
248 open file
249*/
250#define RGW_OPEN_FLAG_NONE 0x0000
251#define RGW_OPEN_FLAG_CREATE 0x0001
252#define RGW_OPEN_FLAG_V3 0x0002 /* ops have v3 semantics */
253#define RGW_OPEN_FLAG_STATELESS 0x0002 /* alias it */
254
255int rgw_open(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
256 uint32_t posix_flags, uint32_t flags);
257
258/*
259 close file
260*/
261
262#define RGW_CLOSE_FLAG_NONE 0x0000
263#define RGW_CLOSE_FLAG_RELE 0x0001
264
265int rgw_close(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
266 uint32_t flags);
267
268/*
269 read data from file
270*/
271#define RGW_READ_FLAG_NONE 0x0000
272
273int rgw_read(struct rgw_fs *rgw_fs,
274 struct rgw_file_handle *fh, uint64_t offset,
275 size_t length, size_t *bytes_read, void *buffer,
276 uint32_t flags);
277
278/*
279 write data to file
280*/
281#define RGW_WRITE_FLAG_NONE 0x0000
282
283int rgw_write(struct rgw_fs *rgw_fs,
284 struct rgw_file_handle *fh, uint64_t offset,
285 size_t length, size_t *bytes_written, void *buffer,
286 uint32_t flags);
287
288#define RGW_UIO_NONE 0x0000
289#define RGW_UIO_GIFT 0x0001
290#define RGW_UIO_FREE 0x0002
291#define RGW_UIO_BUFQ 0x0004
292
293struct rgw_uio;
294typedef void (*rgw_uio_release)(struct rgw_uio *, uint32_t);
295
296/* buffer vector descriptors */
297struct rgw_vio {
298 void *vio_p1;
299 void *vio_u1;
300 void *vio_base;
301 int32_t vio_len;
302};
303
304struct rgw_uio {
305 rgw_uio_release uio_rele;
306 void *uio_p1;
307 void *uio_u1;
308 uint64_t uio_offset;
309 uint64_t uio_resid;
310 uint32_t uio_cnt;
311 uint32_t uio_flags;
312 struct rgw_vio *uio_vio; /* appended vectors */
313};
314
315typedef struct rgw_uio rgw_uio;
316
317int rgw_readv(struct rgw_fs *rgw_fs,
318 struct rgw_file_handle *fh, rgw_uio *uio, uint32_t flags);
319
320int rgw_writev(struct rgw_fs *rgw_fs,
321 struct rgw_file_handle *fh, rgw_uio *uio, uint32_t flags);
322
323/*
324 sync written data
325*/
326#define RGW_FSYNC_FLAG_NONE 0x0000
327
328int rgw_fsync(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
329 uint32_t flags);
330
331/*
332 NFS commit operation
333*/
334
335#define RGW_COMMIT_FLAG_NONE 0x0000
336
337int rgw_commit(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
338 uint64_t offset, uint64_t length, uint32_t flags);
339
340#ifdef __cplusplus
341}
342#endif
343
344#endif /* RADOS_RGW_FILE_H */