]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - blob.c
afs.c: Avoid noisy log message.
[paraslash.git] / blob.c
diff --git a/blob.c b/blob.c
index fa5134d7e0e066a3e8ea0627a11d1482c87b861e..20151241de438c40df87212d09c84004162be990 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -138,9 +138,10 @@ static int com_lsblob(callback_function *f, int fd, int argc, char * const * con
                return -E_BLOB_SYNTAX;
        ret = send_option_arg_callback_request(&query, argc - i,
                argv + i, f, &ls_output);
-       if (ret >= 0 && ls_output.data)
+       if (ret > 0) {
                send_buffer(fd, (char *)ls_output.data);
-       free(ls_output.data);
+               free(ls_output.data);
+       }
        return ret;
 }
 
@@ -162,6 +163,7 @@ static int com_catblob_callback(struct osl_table *table,
        memcpy(output->data, obj.data, obj.size);
        return osl_close_disk_object(&obj);
 }
+
 static int com_catblob(callback_function *f, int fd, int argc,
                char * const * const argv)
 {
@@ -173,8 +175,8 @@ static int com_catblob(callback_function *f, int fd, int argc,
        if (!*argv[1]) /* empty name is reserved of the dummy row */
                return -E_BLOB_SYNTAX;
        ret = send_standard_callback_request(1, argv + 1, f, &cat_output);
-       if (ret >= 0 && cat_output.data)
-               ret = send_buffer(fd, (char *)cat_output.data);
+       if (ret > 0)
+               ret = send_bin_buffer(fd, (char *)cat_output.data, cat_output.size);
        free(cat_output.data);
        return ret;
 
@@ -231,7 +233,7 @@ static int com_addblob_callback(struct osl_table *table,
        return osl_add_row(table, objs);
 }
 
-static int com_addblob(callback_function *f, __a_unused int fd, int argc,
+static int com_addblob(callback_function *f, int fd, int argc,
                char * const * const argv)
 {
        struct osl_object arg_obj;
@@ -243,7 +245,7 @@ static int com_addblob(callback_function *f, __a_unused int fd, int argc,
        PARA_NOTICE_LOG("argv[1]: %s\n", argv[1]);
        arg_obj.size = strlen(argv[1]) + 1;
        arg_obj.data = (char *)argv[1];
-       return stdin_command(&arg_obj, f, 10 * 1024 * 1024, NULL);
+       return stdin_command(fd, &arg_obj, f, 10 * 1024 * 1024, NULL);
 }
 
 static int com_rmblob_callback(struct osl_table *table,
@@ -336,6 +338,7 @@ static int blob_get_name_by_id(struct osl_table *table, uint32_t id,
        *name = (char *)obj.data;
        return 1;
 }
+
 /** Define the \p get_name_by_id function for this blob type. */
 #define DEFINE_GET_NAME_BY_ID(table_name, cmd_prefix) \
        int cmd_prefix ## _get_name_by_id(uint32_t id, char **name) \
@@ -352,11 +355,11 @@ static int blob_get_name_by_id(struct osl_table *table, uint32_t id,
        }
 
 static int blob_init(struct osl_table **table,
-               const struct osl_table_description *desc,
-               struct table_info *ti)
+               struct osl_table_description *desc,
+               struct table_info *ti, const char *db)
 {
        int ret;
-
+       desc->dir = db;
        ti->desc = desc;
        ret = osl_open_table(ti->desc, &ti->table);
        if (ret >= 0) {
@@ -369,10 +372,10 @@ static int blob_init(struct osl_table **table,
 
 /** Define the \p init function for this blob type. */
 #define DEFINE_BLOB_INIT(table_name) \
-       int table_name ## _init(struct table_info *ti) \
+       int table_name ## _init(struct table_info *ti, const char *db) \
        { \
                return blob_init(&table_name ## _table, \
-                       &table_name ## _table_desc, ti); \
+                       &table_name ## _table_desc, ti, db); \
        }