- if (argc == 1)
- return create_all_tables();
- for (i = 1; i < argc; i++) {
- for (j = 0; j < NUM_AFS_TABLES; j++) {
- struct table_info *ti = afs_tables + j;
-
- if (ti->flags & TBLFLAG_SKIP_CREATE)
- continue;
- if (strcmp(argv[i], ti->desc->name))
- continue;
- PARA_NOTICE_LOG("creating table %s\n", argv[i]);
- ret = osl_create_table(ti->desc);
- if (ret < 0)
- return ret;
- break;
- }
- if (j == NUM_AFS_TABLES)
- return -E_BAD_TABLE_NAME;
- }
- return 1;
-}
-
-#if 0
-/** Describes a command of para_server. */
-struct command {
- /** The name of the command. */
- const char *name;
- /** The handler function. */
- int (*handler)(int fd, int argc, const char **argv);
-};
-
-static struct command afs_cmds[] = {
-{
- .name = "add",
- .handler = com_add,
-},
-{
- .name = "addlyr",
- .handler = com_addlyr,
-},
-{
- .name = "addimg",
- .handler = com_addimg,
-},
-{
- .name = "addmood",
- .handler = com_addmood,
-},
-{
- .name = "addpl",
- .handler = com_addpl,
-},
-{
- .name = "catlyr",
- .handler = com_catlyr,
-},
-{
- .name = "catimg",
- .handler = com_catimg,
-},
-{
- .name = "mvimg",
- .handler = com_mvimg,
-},
-{
- .name = "mvlyr",
- .handler = com_mvlyr,
-},
-{
- .name = "mvmood",
- .handler = com_mvmood,
-},
-{
- .name = "mvpl",
- .handler = com_mvpl,
-},
-{
- .name = "catmood",
- .handler = com_catmood,
-},
-{
- .name = "catpl",
- .handler = com_catpl,
-},
-{
- .name = "rmatt",
- .handler = com_rmatt,
-},
-{
- .name = "init",
- .handler = com_init,
-},
-{
- .name = "lsatt",
- .handler = com_lsatt,
-},
-{
- .name = "ls",
- .handler = com_afs_ls,
-},
-{
- .name = "lslyr",
- .handler = com_lslyr,
-},
-{
- .name = "lsimg",
- .handler = com_lsimg,
-},
-{
- .name = "lsmood",
- .handler = com_lsmood,
-},
-{
- .name = "lspl",
- .handler = com_lspl,
-},
-{
- .name = "setatt",
- .handler = com_setatt,
-},
-{
- .name = "addatt",
- .handler = com_addatt,
-},
-{
- .name = "rm",
- .handler = com_afs_rm,
-},
-{
- .name = "rmlyr",
- .handler = com_rmlyr,
-},
-{
- .name = "rmimg",
- .handler = com_rmimg,
-},
-{
- .name = "rmmood",
- .handler = com_rmmood,
-},
-{
- .name = "rmpl",
- .handler = com_rmpl,
-},
-{
- .name = "touch",
- .handler = com_touch,
-},
-{
- .name = NULL,
-}
-};
-
-static void call_callback(void)
-{
- struct osl_object query, result = {.data = NULL};
- int ret, ret2;
-
- shm_callback_data->result_shmid = -1; /* no result */
- ret = shm_attach(shm_callback_data->query_shmid, ATTACH_RW,
- &query.data);
- if (ret < 0)
- goto out;
- query.size = shm_callback_data->query_size;
- shm_callback_data->callback_ret = shm_callback_data->handler(&query,
- &result);
- if (result.data && result.size) {
- void *sma;
- ret = shm_new(result.size);
- if (ret < 0)
- goto detach_query;
- shm_callback_data->result_shmid = ret;
- shm_callback_data->result_size = result.size;
- ret = shm_attach(shm_callback_data->result_shmid, ATTACH_RW, &sma);
- if (ret < 0)
- goto destroy_result;
- memcpy(sma, result.data, result.size);
- ret = shm_detach(sma);
- if (ret < 0) {
- PARA_ERROR_LOG("detach result failed\n");
- goto destroy_result;
+ uint32_t table_mask = (1 << (NUM_AFS_TABLES + 1)) - 1;
+ struct osl_object query = {.data = &table_mask,
+ .size = sizeof(table_mask)};
+
+ if (argc != 1) {
+ table_mask = 0;
+ for (i = 1; i < argc; i++) {
+ for (j = 0; j < NUM_AFS_TABLES; j++) {
+ struct table_info *ti = afs_tables + j;
+
+ if (ti->flags & TBLFLAG_SKIP_CREATE)
+ continue;
+ if (strcmp(argv[i], ti->desc->name))
+ continue;
+ table_mask |= (1 << j);
+ break;
+ }
+ if (j == NUM_AFS_TABLES)
+ return -E_BAD_TABLE_NAME;