int main(int argc, char *argv[]) { char *request; krb5_error_code retval; int sci_idx, code = 0; setlocale(LC_ALL, ""); whoami = ((whoami = strrchr(argv[0], '/')) ? whoami+1 : argv[0]); request = kadmin_startup(argc, argv); sci_idx = ss_create_invocation(whoami, "5.0", NULL, &kadmin_cmds, &retval); if (retval) { ss_perror(sci_idx, retval, _("creating invocation")); exit(1); } if (request) { code = ss_execute_line(sci_idx, request); if (code != 0) { ss_perror(sci_idx, code, request); exit_status++; } } else retval = ss_listen(sci_idx); return quit() ? 1 : exit_status; }
/* * Create subsystem */ int32_t ss_create(const char *ss_name, const char *fs_name, int32_t *ret_val) { char ss_prompt[SS_NAME_LEN_MAX + SS_PROMPT_DEFAULT_LEN + 1] = {0}; size_t ss_prompt_len = 0; if (ret_val == NULL) { error("invalid args!"); return -1; } /* * Display banner */ fprintf(stdout, "WELCOME TO YAFUSE!\n"); fprintf(stdout, "press 'help' for more info.\n"); if (ss_name == NULL) { strncpy((void *)ss_prompt, SS_PROMPT_DEFAULT, strlen(SS_PROMPT_DEFAULT)); } else { ss_prompt_len = (strlen(ss_name) >= SS_NAME_LEN_MAX) ? SS_NAME_LEN_MAX : strlen(ss_name); strncpy((void *)ss_prompt, ss_name, ss_prompt_len); strncat((void *)ss_prompt, SS_PROMPT_DEFAULT, SS_PROMPT_DEFAULT_LEN); } /* * Listener for reading line in subsystem */ ss_listen((const char *)ss_prompt, fs_name); return 0; }
int main(int argc, char **argv) { int c, code; char *request = (char *)NULL; char *cmd_file = 0; int sci_idx; int exit_status = 0; while ((c = getopt (argc, argv, "wR:f:")) != EOF) { switch (c) { case 'R': request = optarg; break; case 'f': cmd_file = optarg; break; default: com_err(argv[0], 0, "Usage: test_ss [-R request] " "[-f cmd_file]"); exit(1); } } sci_idx = ss_create_invocation(subsystem_name, version, (char *)NULL, &test_cmds, &code); if (code) { ss_perror(sci_idx, code, "creating invocation"); exit(1); } (void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &code); if (code) { ss_perror (sci_idx, code, "adding standard requests"); exit (1); } printf("test_ss %s. Type '?' for a list of commands.\n\n", version); if (request) { code = ss_execute_line(sci_idx, request); if (code) { ss_perror(sci_idx, code, request); exit_status++; } } else if (cmd_file) { exit_status = source_file(cmd_file, sci_idx); } else { ss_listen(sci_idx); } exit(exit_status); }
int __init kserver_init(void) { int r; struct sock *lsk; struct sockaddr_in saddr; r = ss_sock_create(AF_INET, SOCK_STREAM, IPPROTO_TCP, &lsk); if (r) { printk(KERN_ERR "Can't listening socket\n"); goto err_create; } inet_sk(lsk)->freebind = 1; lsk->sk_reuse = 1; /* Set TCP handlers. */ ss_proto_init((SsProto *)&my_proto, &ssocket_hooks, 0); lsk->sk_user_data = (SsProto *)&my_proto; ss_set_listen(lsk); memset(&saddr, 0, sizeof(saddr)); saddr.sin_family = AF_INET; saddr.sin_addr.s_addr = htonl(INADDR_ANY); saddr.sin_port = htons(PORT); r = ss_bind(lsk, (struct sockaddr *)&saddr, sizeof(saddr)); if (r) { printk(KERN_ERR "Can't bind listening socket\n"); goto err_call; } r = ss_listen(lsk, 1000); if (r) { printk(KERN_ERR "Can't listen on socket\n"); goto err_call; } return 0; err_call: ss_release(lsk); err_create: return r; }
int main(int argc, char **argv) { int retval; int sci_idx; int c; char *request = 0; int exit_status = 0; char *cmd_file = 0; struct ext2_super_block param; initialize_ext2_error_table(); /* * Create a sample filesystem structure */ memset(¶m, 0, sizeof(struct ext2_super_block)); ext2fs_blocks_count_set(¶m, 80000); param.s_inodes_count = 20000; retval = ext2fs_initialize("/dev/null", 0, ¶m, unix_io_manager, &test_fs); if (retval) { com_err("/dev/null", retval, "while setting up test fs"); exit(1); } while ((c = getopt (argc, argv, "wR:f:")) != EOF) { switch (c) { case 'R': request = optarg; break; case 'f': cmd_file = optarg; break; default: com_err(argv[0], 0, "Usage: test_icount " "[-R request] [-f cmd_file]"); exit(1); } } sci_idx = ss_create_invocation("test_icount", "0.0", (char *) NULL, &test_cmds, &retval); if (retval) { ss_perror(sci_idx, retval, "creating invocation"); exit(1); } (void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &retval); if (retval) { ss_perror(sci_idx, retval, "adding standard requests"); exit (1); } if (request) { retval = 0; retval = ss_execute_line(sci_idx, request); if (retval) { ss_perror(sci_idx, retval, request); exit_status++; } } else if (cmd_file) { exit_status = source_file(cmd_file, sci_idx); } else { ss_listen(sci_idx); } return(exit_status); }
int main(int argc, char **argv) { unsigned int blocks = 128; unsigned int inodes = 0; unsigned int type = EXT2FS_BMAP64_BITARRAY; int c, err, code; char *request = (char *)NULL; char *cmd_file = 0; int sci_idx; int flags = EXT2_FLAG_64BITS; add_error_table(&et_ss_error_table); add_error_table(&et_ext2_error_table); while ((c = getopt (argc, argv, "b:i:lt:R:f:")) != EOF) { switch (c) { case 'b': blocks = parse_ulong(optarg, argv[0], "number of blocks", &err); if (err) exit(1); break; case 'i': inodes = parse_ulong(optarg, argv[0], "number of blocks", &err); if (err) exit(1); break; case 'l': /* Legacy bitmaps */ flags = 0; break; case 't': type = parse_ulong(optarg, argv[0], "bitmap backend type", &err); if (err) exit(1); break; case 'R': request = optarg; break; case 'f': cmd_file = optarg; break; default: com_err(argv[0], 0, "Usage: %s [-R request] " "[-f cmd_file]", subsystem_name); exit(1); } } sci_idx = ss_create_invocation(subsystem_name, version, (char *)NULL, &tst_bitmaps_cmds, &code); if (code) { ss_perror(sci_idx, code, "creating invocation"); exit(1); } (void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &code); if (code) { ss_perror(sci_idx, code, "adding standard requests"); exit (1); } printf("%s %s. Type '?' for a list of commands.\n\n", subsystem_name, version); setup_filesystem(argv[0], blocks, inodes, type, flags); if (request) { code = ss_execute_line(sci_idx, request); if (code) { ss_perror(sci_idx, code, request); exit_status++; } } else if (cmd_file) { exit_status = source_file(cmd_file, sci_idx); } else { ss_listen(sci_idx); } exit(exit_status); }