]>
git.proxmox.com Git - ceph.git/blob - ceph/src/include/rados/rgw_file.h
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 4
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
,
130 register invalidate callbacks
132 #define RGW_REG_INVALIDATE_FLAG_NONE 0x0000
134 typedef void (*rgw_fh_callback_t
)(void *handle
, struct rgw_fh_hk fh_hk
);
136 int rgw_register_invalidate(struct rgw_fs
*rgw_fs
, rgw_fh_callback_t cb
,
137 void *arg
, uint32_t flags
);
142 #define RGW_UMOUNT_FLAG_NONE 0x0000
144 int rgw_umount(struct rgw_fs
*rgw_fs
, uint32_t flags
);
148 get filesystem attributes
150 #define RGW_STATFS_FLAG_NONE 0x0000
152 int rgw_statfs(struct rgw_fs
*rgw_fs
,
153 struct rgw_file_handle
*parent_fh
,
154 struct rgw_statvfs
*vfs_st
,
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
170 #define RGW_CREATE_FLAG_NONE 0x0000
172 int 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
,
178 create a new directory
180 #define RGW_MKDIR_FLAG_NONE 0x0000
182 int 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
);
190 #define RGW_RENAME_FLAG_NONE 0x0000
192 int 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
,
198 remove file or directory
200 #define RGW_UNLINK_FLAG_NONE 0x0000
202 int rgw_unlink(struct rgw_fs
*rgw_fs
,
203 struct rgw_file_handle
*parent_fh
, const char* path
,
207 read directory content
209 typedef bool (*rgw_readdir_cb
)(const char *name
, void *arg
, uint64_t offset
,
212 #define RGW_READDIR_FLAG_NONE 0x0000
213 #define RGW_READDIR_FLAG_DOTDOT 0x0001 /* send dot names */
215 int 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
,
220 /* project offset of dirent name */
221 #define RGW_DIRENT_OFFSET_FLAG_NONE 0x0000
223 int rgw_dirent_offset(struct rgw_fs
*rgw_fs
,
224 struct rgw_file_handle
*parent_fh
,
225 const char *name
, int64_t *offset
,
229 get unix attributes for object
231 #define RGW_GETATTR_FLAG_NONE 0x0000
233 int rgw_getattr(struct rgw_fs
*rgw_fs
,
234 struct rgw_file_handle
*fh
, struct stat
*st
,
238 set unix attributes for object
240 #define RGW_SETATTR_FLAG_NONE 0x0000
242 int rgw_setattr(struct rgw_fs
*rgw_fs
,
243 struct rgw_file_handle
*fh
, struct stat
*st
,
244 uint32_t mask
, uint32_t flags
);
249 #define RGW_TRUNCATE_FLAG_NONE 0x0000
251 int rgw_truncate(struct rgw_fs
*rgw_fs
,
252 struct rgw_file_handle
*fh
, uint64_t size
,
258 #define RGW_OPEN_FLAG_NONE 0x0000
259 #define RGW_OPEN_FLAG_CREATE 0x0001
260 #define RGW_OPEN_FLAG_V3 0x0002 /* ops have v3 semantics */
261 #define RGW_OPEN_FLAG_STATELESS 0x0002 /* alias it */
263 int rgw_open(struct rgw_fs
*rgw_fs
, struct rgw_file_handle
*parent_fh
,
264 uint32_t posix_flags
, uint32_t flags
);
270 #define RGW_CLOSE_FLAG_NONE 0x0000
271 #define RGW_CLOSE_FLAG_RELE 0x0001
273 int rgw_close(struct rgw_fs
*rgw_fs
, struct rgw_file_handle
*fh
,
279 #define RGW_READ_FLAG_NONE 0x0000
281 int rgw_read(struct rgw_fs
*rgw_fs
,
282 struct rgw_file_handle
*fh
, uint64_t offset
,
283 size_t length
, size_t *bytes_read
, void *buffer
,
289 #define RGW_WRITE_FLAG_NONE 0x0000
291 int rgw_write(struct rgw_fs
*rgw_fs
,
292 struct rgw_file_handle
*fh
, uint64_t offset
,
293 size_t length
, size_t *bytes_written
, void *buffer
,
296 #define RGW_UIO_NONE 0x0000
297 #define RGW_UIO_GIFT 0x0001
298 #define RGW_UIO_FREE 0x0002
299 #define RGW_UIO_BUFQ 0x0004
302 typedef void (*rgw_uio_release
)(struct rgw_uio
*, uint32_t);
304 /* buffer vector descriptors */
313 rgw_uio_release uio_rele
;
320 struct rgw_vio
*uio_vio
; /* appended vectors */
323 typedef struct rgw_uio rgw_uio
;
325 int rgw_readv(struct rgw_fs
*rgw_fs
,
326 struct rgw_file_handle
*fh
, rgw_uio
*uio
, uint32_t flags
);
328 int rgw_writev(struct rgw_fs
*rgw_fs
,
329 struct rgw_file_handle
*fh
, rgw_uio
*uio
, uint32_t flags
);
334 #define RGW_FSYNC_FLAG_NONE 0x0000
336 int rgw_fsync(struct rgw_fs
*rgw_fs
, struct rgw_file_handle
*fh
,
343 #define RGW_COMMIT_FLAG_NONE 0x0000
345 int rgw_commit(struct rgw_fs
*rgw_fs
, struct rgw_file_handle
*fh
,
346 uint64_t offset
, uint64_t length
, uint32_t flags
);
352 #endif /* RADOS_RGW_FILE_H */