X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=blob.c;h=adfdb1a999fa53a873959d5af6b96a15ac5f6f58;hp=373d8d005cc1ea9e232f47f76e0c3794cd018538;hb=6e0b28e02a1013c019a3225e922b71f913bfbae4;hpb=282a5e463090205ef8a12f50a9ecf6498b860e88 diff --git a/blob.c b/blob.c index 373d8d00..adfdb1a9 100644 --- a/blob.c +++ b/blob.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2013 Andre Noll + * Copyright (C) 2007 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -66,7 +66,7 @@ static struct osl_column_description blob_cols[] = { /** Define an osl table description for a blob table. */ #define DEFINE_BLOB_TABLE_DESC(table_name) \ - struct osl_table_description table_name ## _table_desc = { \ + static struct osl_table_description table_name ## _table_desc = { \ .name = #table_name, \ .num_columns = NUM_BLOB_COLUMNS, \ .flags = OSL_LARGE_TABLE, \ @@ -295,7 +295,7 @@ static void com_rmblob_callback(struct osl_table *table, int fd, ret2 = para_printf(&rmbd.pb, "no matches, nothing removed\n"); else { ret2 = para_printf(&rmbd.pb, "removed %d blobs\n", pmd.num_matches); - afs_event(BLOB_RENAME, NULL, table); + afs_event(BLOB_REMOVE, NULL, table); } out: if (ret2 >= 0 && rmbd.pb.offset) @@ -482,35 +482,51 @@ static int com_addblob(callback_function *f, struct command_context *cc) return stdin_command(cc, &arg_obj, f, afs_cb_result_handler, cc); } -/* FIXME: Print output to client, not to log file */ -static void com_mvblob_callback(struct osl_table *table, __a_unused int fd, +static void com_mvblob_callback(struct osl_table *table, int fd, const struct osl_object *query) { char *src = (char *) query->data; struct osl_object obj = {.data = src, .size = strlen(src) + 1}; char *dest = src + obj.size; struct osl_row *row; + struct para_buffer pb = { + .max_size = shm_get_shmmax(), + .private_data = &fd, + .max_size_handler = afs_max_size_handler + }; int ret = osl(osl_get_row(table, BLOBCOL_NAME, &obj, &row)); - if (ret < 0) + if (ret < 0) { + para_printf(&pb, "could not locate %s: %s\n", src, + para_strerror(-ret)); goto out; + } obj.data = dest; obj.size = strlen(dest) + 1; ret = osl(osl_update_object(table, row, BLOBCOL_NAME, &obj)); - if (ret < 0) + if (ret < 0) { + para_printf(&pb, "failed to update object %s: %s\n", dest, + para_strerror(-ret)); goto out; + } afs_event(BLOB_RENAME, NULL, table); out: - if (ret < 0) - PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); + if (pb.offset) + pass_buffer_as_shm(fd, SBD_OUTPUT, pb.buf, pb.offset); + free(pb.buf); } static int com_mvblob(callback_function *f, struct command_context *cc) { + int ret; + if (cc->argc != 3) return -E_MOOD_SYNTAX; - return send_option_arg_callback_request(NULL, cc->argc - 1, - cc->argv + 1, f, NULL, NULL); + ret = send_option_arg_callback_request(NULL, cc->argc - 1, + cc->argv + 1, f, afs_cb_result_handler, cc); + if (ret < 0) + send_strerror(cc, -ret); + return ret; } #define DEFINE_BLOB_COMMAND(cmd_name, table_name, cmd_prefix) \ @@ -629,7 +645,7 @@ static int blob_get_name_and_def_by_row(struct osl_table *table, static int table_name ## _create(const char *dir) \ { \ table_name ## _table_desc.dir = dir; \ - return osl_create_table(&table_name ## _table_desc); \ + return osl(osl_create_table(&table_name ## _table_desc)); \ } static int blob_open(struct osl_table **table,