Skip to content

Commit

Permalink
fsx: cleanup crypto library at exit
Browse files Browse the repository at this point in the history
Also made small tweaks so that it can be compiled under
a C++ compiler.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit c44f8e7)
  • Loading branch information
Jason Dillaman committed Jul 17, 2015
1 parent 97ff6cb commit 488578c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/test/Makefile-client.am
Expand Up @@ -333,12 +333,11 @@ ceph_test_librbd_LDADD += $(LIBRBD_TP)
endif

if LINUX
# Force use of C++ linker with dummy.cc - LIBKRBD is a C++ library
ceph_test_librbd_fsx_SOURCES = test/librbd/fsx.c common/dummy.cc
ceph_test_librbd_fsx_SOURCES = test/librbd/fsx.cc
ceph_test_librbd_fsx_LDADD = \
$(LIBKRBD) $(LIBRBD) $(LIBRADOS) \
$(CRYPTO_LIBS) $(PTHREAD_LIBS) -luuid
ceph_test_librbd_fsx_CFLAGS = ${AM_CFLAGS}
ceph_test_librbd_fsx_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_librbd_fsx
endif
endif # WITH_RBD
Expand Down
65 changes: 33 additions & 32 deletions src/test/librbd/fsx.c → src/test/librbd/fsx.cc
Expand Up @@ -42,6 +42,7 @@
#include "include/krbd.h"
#include "include/rados/librados.h"
#include "include/rbd/librbd.h"
#include "common/ceph_crypto.h"

#define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */

Expand Down Expand Up @@ -196,7 +197,7 @@ warn(const char * fmt, ...) {
#define BUF_SIZE 1024

void
prt(char *fmt, ...)
prt(const char *fmt, ...)
{
va_list args;
char buffer[BUF_SIZE];
Expand All @@ -210,13 +211,13 @@ prt(char *fmt, ...)
}

void
prterr(char *prefix)
prterr(const char *prefix)
{
prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno));
}

void
prterrcode(char *prefix, int code)
prterrcode(const char *prefix, int code)
{
prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(-code));
}
Expand Down Expand Up @@ -264,8 +265,8 @@ struct rbd_ctx {
struct rbd_operations {
int (*open)(const char *name, struct rbd_ctx *ctx);
int (*close)(struct rbd_ctx *ctx);
ssize_t (*read)(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf);
ssize_t (*write)(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf);
ssize_t (*read)(struct rbd_ctx *ctx, uint64_t off, size_t len, char *buf);
ssize_t (*write)(struct rbd_ctx *ctx, uint64_t off, size_t len, const char *buf);
int (*flush)(struct rbd_ctx *ctx);
int (*discard)(struct rbd_ctx *ctx, uint64_t off, uint64_t len);
int (*get_size)(struct rbd_ctx *ctx, uint64_t *size);
Expand Down Expand Up @@ -362,7 +363,7 @@ librbd_verify_object_map(struct rbd_ctx *ctx)
}

ssize_t
librbd_read(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf)
librbd_read(struct rbd_ctx *ctx, uint64_t off, size_t len, char *buf)
{
ssize_t n;

Expand All @@ -374,7 +375,7 @@ librbd_read(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf)
}

ssize_t
librbd_write(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf)
librbd_write(struct rbd_ctx *ctx, uint64_t off, size_t len, const char *buf)
{
ssize_t n;
int ret;
Expand Down Expand Up @@ -525,16 +526,16 @@ librbd_flatten(struct rbd_ctx *ctx)
}

const struct rbd_operations librbd_operations = {
.open = librbd_open,
.close = librbd_close,
.read = librbd_read,
.write = librbd_write,
.flush = librbd_flush,
.discard = librbd_discard,
.get_size = librbd_get_size,
.resize = librbd_resize,
.clone = librbd_clone,
.flatten = librbd_flatten,
librbd_open,
librbd_close,
librbd_read,
librbd_write,
librbd_flush,
librbd_discard,
librbd_get_size,
librbd_resize,
librbd_clone,
librbd_flatten
};

int
Expand Down Expand Up @@ -595,7 +596,7 @@ krbd_close(struct rbd_ctx *ctx)
}

ssize_t
krbd_read(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf)
krbd_read(struct rbd_ctx *ctx, uint64_t off, size_t len, char *buf)
{
ssize_t n;

Expand All @@ -610,7 +611,7 @@ krbd_read(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf)
}

ssize_t
krbd_write(struct rbd_ctx *ctx, uint64_t off, size_t len, void *buf)
krbd_write(struct rbd_ctx *ctx, uint64_t off, size_t len, const char *buf)
{
ssize_t n;

Expand Down Expand Up @@ -738,16 +739,16 @@ krbd_flatten(struct rbd_ctx *ctx)
}

const struct rbd_operations krbd_operations = {
.open = krbd_open,
.close = krbd_close,
.read = krbd_read,
.write = krbd_write,
.flush = krbd_flush,
.discard = krbd_discard,
.get_size = krbd_get_size,
.resize = krbd_resize,
.clone = krbd_clone,
.flatten = krbd_flatten,
krbd_open,
krbd_close,
krbd_read,
krbd_write,
krbd_flush,
krbd_discard,
krbd_get_size,
krbd_resize,
krbd_clone,
krbd_flatten,
};

struct rbd_ctx ctx = RBD_CTX_INIT;
Expand Down Expand Up @@ -793,7 +794,7 @@ logdump(void)
{
int i, count, down;
struct log_entry *lp;
char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};
const char *falloc_type[3] = {"PAST_EOF", "EXTENDING", "INTERIOR"};

prt("LOG DUMP (%d total operations):\n", logcount);
if (logcount < LOGSIZE) {
Expand Down Expand Up @@ -1744,8 +1745,7 @@ test(void)


void
cleanup(sig)
int sig;
cleanup(int sig)
{
if (sig)
prt("signal %d\n", sig);
Expand Down Expand Up @@ -2312,6 +2312,7 @@ main(int argc, char **argv)
krbd_destroy(krbd);
rados_shutdown(cluster);

ceph::crypto::shutdown();
free(original_buf);
free(good_buf);
free(temp_buf);
Expand Down

0 comments on commit 488578c

Please sign in to comment.