X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=attribute.c;h=edf3baf51fa376708785eaa014f321eaff827aa4;hp=d94589871562038a7ba96aad85c741de0db05b65;hb=4744d937c4160898d1fe151257606430750e580c;hpb=eecc102ad0abeb0335fe994bb72031a15b9090d7 diff --git a/attribute.c b/attribute.c index d9458987..edf3baf5 100644 --- a/attribute.c +++ b/attribute.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2009 Andre Noll + * Copyright (C) 1997-2012 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -7,7 +7,6 @@ /** \file attribute.c Attribute handling functions. */ #include -#include #include #include "para.h" @@ -16,8 +15,9 @@ #include "string.h" #include "afh.h" #include "afs.h" -#include "net.h" #include "ipc.h" +#include "sideband.h" +#include "command.h" static struct osl_table *attribute_table; static int greatest_att_bitnum; @@ -151,9 +151,11 @@ static void com_lsatt_callback(int fd, const struct osl_object *query) struct lsatt_action_data laad = { .flags = *(unsigned *) query->data, .pb = { - .max_size = SHMMAX, - .private_data = &fd, - .max_size_handler = pass_buffer_as_shm + .max_size = shm_get_shmmax(), + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + }, + .max_size_handler = afs_max_size_handler } }; @@ -177,14 +179,14 @@ static void com_lsatt_callback(int fd, const struct osl_object *query) free(laad.pb.buf); } -int com_lsatt(struct rc4_context *rc4c, int argc, char * const * const argv) +int com_lsatt(struct command_context *cc) { unsigned flags = 0; struct osl_object options = {.data = &flags, .size = sizeof(flags)}; int ret, i; - for (i = 1; i < argc; i++) { - const char *arg = argv[i]; + for (i = 1; i < cc->argc; i++) { + const char *arg = cc->argv[i]; if (arg[0] != '-') break; if (!strcmp(arg, "--")) { @@ -204,13 +206,13 @@ int com_lsatt(struct rc4_context *rc4c, int argc, char * const * const argv) continue; } } - ret = send_option_arg_callback_request(&options, argc - i, argv + i, - com_lsatt_callback, rc4_send_result, rc4c); + ret = send_option_arg_callback_request(&options, cc->argc - i, cc->argv + i, + com_lsatt_callback, afs_cb_result_handler, cc); if (!ret) { - if (argc > 1) - ret = rc4_send_va_buffer(rc4c, "no matches\n"); + if (cc->argc > 1) + ret = sc_send_va_buffer(&cc->scc, "no matches\n"); } else if (ret < 0) - rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret)); + sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); return ret; } @@ -278,12 +280,12 @@ out: PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); } -int com_setatt(__a_unused struct rc4_context *rc4c, int argc, char * const * const argv) +int com_setatt(struct command_context *cc) { - if (argc < 3) + if (cc->argc < 3) return -E_ATTR_SYNTAX; - return send_standard_callback_request(argc - 1, argv + 1, com_setatt_callback, - NULL, NULL); + return send_standard_callback_request(cc->argc - 1, cc->argv + 1, + com_setatt_callback, NULL, NULL); } struct addatt_event_data { @@ -297,9 +299,11 @@ static void com_addatt_callback(int fd, const struct osl_object *query) char *p; int ret = 1, ret2 = 0; struct para_buffer pb = { - .max_size = SHMMAX, - .private_data = &fd, - .max_size_handler = pass_buffer_as_shm + .max_size = shm_get_shmmax(), + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + }, + .max_size_handler = afs_max_size_handler }; size_t len; @@ -359,16 +363,16 @@ out: free(pb.buf); } -int com_addatt(struct rc4_context *rc4c, int argc, char * const * const argv) +int com_addatt(struct command_context *cc) { int ret; - if (argc < 2) + if (cc->argc < 2) return -E_ATTR_SYNTAX; - ret = send_standard_callback_request(argc - 1, argv + 1, com_addatt_callback, - rc4_send_result, rc4c); + ret = send_standard_callback_request(cc->argc - 1, cc->argv + 1, + com_addatt_callback, afs_cb_result_handler, cc); if (ret < 0) - rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret)); + sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); return ret; } @@ -380,9 +384,11 @@ static void com_mvatt_callback(int fd, const struct osl_object *query) struct osl_object obj = {.data = old, .size = size}; struct osl_row *row; struct para_buffer pb = { - .max_size = SHMMAX, - .private_data = &fd, - .max_size_handler = pass_buffer_as_shm + .max_size = shm_get_shmmax(), + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + }, + .max_size_handler = afs_max_size_handler, }; int ret; @@ -402,16 +408,16 @@ out: free(pb.buf); } -int com_mvatt(struct rc4_context *rc4c, int argc, char * const * const argv) +int com_mvatt(struct command_context *cc) { int ret; - if (argc != 3) + if (cc->argc != 3) return -E_ATTR_SYNTAX; - ret = send_standard_callback_request(argc - 1, argv + 1, com_mvatt_callback, - rc4_send_result, rc4c); + ret = send_standard_callback_request(cc->argc - 1, cc->argv + 1, + com_mvatt_callback, afs_cb_result_handler, cc); if (ret < 0) - rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret)); + sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); return ret; } @@ -450,9 +456,11 @@ 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 + .max_size = shm_get_shmmax(), + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + }, + .max_size_handler = afs_max_size_handler, } }; int ret, ret2 = 0; @@ -474,16 +482,16 @@ static void com_rmatt_callback(int fd, const struct osl_object *query) free(raad.pb.buf); } -int com_rmatt(struct rc4_context *rc4c, int argc, char * const * const argv) +int com_rmatt(struct command_context *cc) { int ret; - if (argc < 2) + if (cc->argc < 2) return -E_ATTR_SYNTAX; - ret = send_standard_callback_request(argc - 1, argv + 1, com_rmatt_callback, - rc4_send_result, rc4c); + ret = send_standard_callback_request(cc->argc - 1, cc->argv + 1, + com_rmatt_callback, afs_cb_result_handler, cc); if (ret < 0) - rc4_send_va_buffer(rc4c, "%s\n", para_strerror(-ret)); + sc_send_va_buffer(&cc->scc, "%s\n", para_strerror(-ret)); return ret; }