/usr/include/rbd/librbd.hpp is in librbd-dev 0.41-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef __LIBRBD_HPP
#define __LIBRBD_HPP
#include <stdbool.h>
#include <string>
#include <list>
#include <map>
#include <vector>
#include "../rados/buffer.h"
#include "../rados/librados.hpp"
#include "librbd.h"
namespace librbd {
using librados::IoCtx;
class Image;
typedef void *image_ctx_t;
typedef void *completion_t;
typedef void (*callback_t)(completion_t cb, void *arg);
typedef struct {
uint64_t id;
uint64_t size;
std::string name;
} snap_info_t;
typedef rbd_image_info_t image_info_t;
class ProgressContext
{
public:
virtual ~ProgressContext();
virtual int update_progress(uint64_t offset, uint64_t total) = 0;
};
class RBD
{
public:
RBD();
~RBD();
struct AioCompletion {
void *pc;
AioCompletion(void *cb_arg, callback_t complete_cb);
int wait_for_complete();
ssize_t get_return_value();
void release();
};
void version(int *major, int *minor, int *extra);
int open(IoCtx& io_ctx, Image& image, const char *name);
int open(IoCtx& io_ctx, Image& image, const char *name, const char *snapname);
int list(IoCtx& io_ctx, std::vector<std::string>& names);
int create(IoCtx& io_ctx, const char *name, uint64_t size, int *order);
int remove(IoCtx& io_ctx, const char *name);
int remove_with_progress(IoCtx& io_ctx, const char *name, ProgressContext& pctx);
int rename(IoCtx& src_io_ctx, const char *srcname, const char *destname);
private:
/* We don't allow assignment or copying */
RBD(const RBD& rhs);
const RBD& operator=(const RBD& rhs);
};
class Image
{
public:
Image();
~Image();
int resize(uint64_t size);
int resize_with_progress(uint64_t size, ProgressContext& pctx);
int stat(image_info_t &info, size_t infosize);
int copy(IoCtx& dest_io_ctx, const char *destname);
int copy_with_progress(IoCtx& dest_io_ctx, const char *destname,
ProgressContext &prog_ctx);
/* snapshots */
int snap_list(std::vector<snap_info_t>& snaps);
int snap_create(const char *snapname);
int snap_remove(const char *snapname);
int snap_rollback(const char *snap_name);
int snap_rollback_with_progress(const char *snap_name, ProgressContext& pctx);
int snap_set(const char *snap_name);
/* I/O */
ssize_t read(uint64_t ofs, size_t len, ceph::bufferlist& bl);
int64_t read_iterate(uint64_t ofs, size_t len,
int (*cb)(uint64_t, size_t, const char *, void *), void *arg);
ssize_t write(uint64_t ofs, size_t len, ceph::bufferlist& bl);
int aio_write(uint64_t off, size_t len, ceph::bufferlist& bl, RBD::AioCompletion *c);
int aio_read(uint64_t off, size_t len, ceph::bufferlist& bl, RBD::AioCompletion *c);
int flush();
private:
friend class RBD;
Image(const Image& rhs);
const Image& operator=(const Image& rhs);
image_ctx_t ctx;
};
}
#endif
|