From 488578c1d557ebec7e50d53e45ed46f42984f4f8 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 28 Apr 2015 10:54:47 -0400 Subject: [PATCH] fsx: cleanup crypto library at exit Also made small tweaks so that it can be compiled under a C++ compiler. Signed-off-by: Jason Dillaman (cherry picked from commit c44f8e7fbc19924a9453d8c032c624ebb6c0296f) --- src/test/Makefile-client.am | 5 +-- src/test/librbd/{fsx.c => fsx.cc} | 65 ++++++++++++++++--------------- 2 files changed, 35 insertions(+), 35 deletions(-) rename src/test/librbd/{fsx.c => fsx.cc} (98%) diff --git a/src/test/Makefile-client.am b/src/test/Makefile-client.am index e83a13107b996..ca5ce803ea679 100644 --- a/src/test/Makefile-client.am +++ b/src/test/Makefile-client.am @@ -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 diff --git a/src/test/librbd/fsx.c b/src/test/librbd/fsx.cc similarity index 98% rename from src/test/librbd/fsx.c rename to src/test/librbd/fsx.cc index e2ad45c4bb3f6..c5ed1e60a8ca9 100644 --- a/src/test/librbd/fsx.c +++ b/src/test/librbd/fsx.cc @@ -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 */ @@ -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]; @@ -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)); } @@ -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); @@ -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; @@ -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; @@ -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 @@ -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; @@ -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; @@ -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; @@ -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) { @@ -1744,8 +1745,7 @@ test(void) void -cleanup(sig) - int sig; +cleanup(int sig) { if (sig) prt("signal %d\n", sig); @@ -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);