+ return send_standard_callback_request(argc - 1, argv + 1, f, send_result, &fd);
+}
+
+/** Used for removing rows from a blob table. */
+struct rmblob_data {
+ /** Message buffer. */
+ struct para_buffer pb;
+ /** Number of removed blobs. */
+ unsigned num_removed;
+};
+
+static int remove_blob(struct osl_table *table, struct osl_row *row,
+ const char *name, void *data)
+{
+ struct rmblob_data *rmbd = data;
+ int ret = osl_del_row(table, row);
+ if (ret < 0) {
+ para_printf(&rmbd->pb, "%s: %s\n", name, para_strerror(-ret));
+ return ret;
+ }
+ rmbd->num_removed++;
+ return 1;
+}
+
+static void com_rmblob_callback(struct osl_table *table, int fd,
+ const struct osl_object *query)
+{
+ int ret, ret2 = 0;
+ struct rmblob_data rmbd = {
+ .num_removed = 0,
+ .pb = {
+ .max_size = SHMMAX,
+ .private_data = &fd,
+ .max_size_handler = pass_buffer_as_shm
+ }
+ };
+ struct pattern_match_data pmd = {
+ .table = table,
+ .patterns = *query,
+ .loop_col_num = BLOBCOL_NAME,
+ .match_col_num = BLOBCOL_NAME,
+ .pm_flags = PM_SKIP_EMPTY_NAME,
+ .data = &rmbd,
+ .action = remove_blob
+ };
+ ret = for_each_matching_row(&pmd);
+ if (ret < 0) {
+ ret2 = para_printf(&rmbd.pb, "%s\n", para_strerror(-ret));
+ if (ret2 < 0)
+ goto out;
+ }
+ if (!rmbd.num_removed)
+ ret2 = para_printf(&rmbd.pb, "no matches, nothing removed\n");
+ else {
+ ret2 = para_printf(&rmbd.pb, "removed %d blobs\n", rmbd.num_removed);
+ afs_event(BLOB_RENAME, NULL, table);
+ }
+out:
+ if (ret2 >= 0 && rmbd.pb.offset)
+ pass_buffer_as_shm(rmbd.pb.buf, rmbd.pb.offset, &fd);
+ free(rmbd.pb.buf);
+}