+ int ret;
+
+ if (argc != 3)
+ return -E_ATTR_SYNTAX;
+ ret = send_standard_callback_request(argc - 1, argv + 1, com_mvatt_callback,
+ send_result, &fd);
+ if (ret < 0)
+ send_va_buffer(fd, "%s\n", para_strerror(-ret));
+ return ret;
+}
+
+/** Data passed to the action handler of com_rmatt(). */
+struct remove_attribute_action_data {
+ /** Message buffer. */
+ struct para_buffer pb;
+ /** Numver of attributes removed. */
+ int num_removed;
+ /** Bitwise "or" of the removed attributes. */
+ uint64_t mask_of_removed_atts;
+};
+
+static int remove_attribute(struct osl_table *table, struct osl_row *row,
+ const char *name, void *data)
+{
+ struct remove_attribute_action_data *raad = data;
+ int ret;
+ struct rmatt_event_data red = {.name = name};
+
+ ret = get_attribute_bitnum_by_name(name, &red.bitnum);
+ if (ret < 0)
+ return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
+ ret = osl_del_row(table, row);
+ if (ret < 0)
+ return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
+ ret = para_printf(&raad->pb, "removed attribute %s\n", name);
+ raad->num_removed++;
+ raad->mask_of_removed_atts |= (1 << red.bitnum);
+ afs_event(ATTRIBUTE_REMOVE, &raad->pb, &red);
+ return ret;
+}
+
+static void com_rmatt_callback(int fd, const struct osl_object *query)
+{
+ struct remove_attribute_action_data raad = {
+ .num_removed = 0,
+ .pb = {
+ .max_size = SHMMAX,
+ .private_data = &fd,
+ .max_size_handler = pass_buffer_as_shm
+ }
+ };
+ int ret, ret2 = 0;
+ struct pattern_match_data pmd = {
+ .table = attribute_table,
+ .patterns = *query,
+ .loop_col_num = ATTCOL_BITNUM,
+ .match_col_num = ATTCOL_NAME,
+ .data = &raad,
+ .action = remove_attribute
+ };
+ ret = for_each_matching_row(&pmd);
+ if (ret < 0)
+ ret2 = para_printf(&raad.pb, "%s\n", para_strerror(-ret));
+ else if (!raad.num_removed)
+ ret2 = para_printf(&raad.pb, "no match -- nothing removed\n");
+ if (ret2 >= 0 && raad.pb.offset)
+ pass_buffer_as_shm(raad.pb.buf, raad.pb.offset, &fd);
+ free(raad.pb.buf);
+}
+
+int com_rmatt(int fd, int argc, char * const * const argv)
+{
+ int ret;
+