]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - blob.c
Merge branch 't/mvblob_improvement'
[paraslash.git] / blob.c
diff --git a/blob.c b/blob.c
index 37f5404890d94b89589be8121a1c04af50c89061..bdff90613817a56d14c6b9622ae5e068a496efcf 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -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) \