Пример #1
0
int
bos_stop(int argc, char **argv)
{
    int optind = 0;
    
    if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) {
	usage ();
	return 0;
    }
    
    if (helpflag) {
	usage ();
	return 0;
    }
    
    argc -= optind;
    argv += optind;
    
    if (server == NULL) {
	printf ("bos stop: missing -server\n");
	return 0;
    }
    
    if (cell == NULL)
	cell = cell_getcellbyhost (server);

    stop (cell, server, instance, noauth, localauth, verbose);
    return 0;
}
Пример #2
0
int
mkmount_cmd (int argc, char **argv)
{
    char  buf[MAXSIZE];
    char prefix;
    char *dirname = NULL;
    char *volname = NULL;
    char *cell = NULL;
    int rwflag = 0;
    int helpflag = 0;
    int optind = 0;

    struct agetargs mkmargs[] = {
	{"dir",     0, aarg_string, NULL, "mount point directory name",
	 "directory", aarg_mandatory},
	{"vol",     0, aarg_string, NULL, "volume to mount",
	 "volume",    aarg_mandatory},
	{"cell",    0, aarg_string, NULL, "cell of volume",
	 "cell",      aarg_optional_swless},
	{"rw",      0, aarg_flag, NULL, "mount read-write", NULL},
	{"help",    0, aarg_flag, NULL, NULL, NULL},
	{NULL,      0, aarg_end,  NULL}}, *arg;
    
    arg = mkmargs;
    arg->value = &dirname; arg++;
    arg->value = &volname; arg++;
    arg->value = &cell; arg++;
    arg->value = &rwflag; arg++;
    arg->value = &helpflag; arg++;

    if (agetarg (mkmargs, argc, argv, &optind, AARG_AFSSTYLE)) {
	aarg_printusage(mkmargs, "fs mkmount", "", AARG_AFSSTYLE);
 	return 0;
    }

    argc -= optind;
    argv += optind;

    if (argc) {
	printf("unknown option %s\n", *argv);
	return 0;
    }

    if (rwflag)
	prefix = '%';
    else
	prefix = '#';
    if (cell)
	snprintf(buf, sizeof(buf), "%c%s:%s.", prefix, cell, volname);
    else
	snprintf(buf, sizeof(buf), "%c%s.", prefix, volname);

    if (symlink (buf, dirname) == -1) {
	perror ("fs");
	return 0;
    }

    return 0;
}
Пример #3
0
static void
test_simple_string(void)
{
    char *string;
    int i, optind;
    ga_tests tests[] = {
	{AARG_GNUSTYLE, 2, {"string", "--string=foo", NULL}},
	{AARG_GNUSTYLE, 3, {"string", "-s", "foo", NULL}},
	{AARG_AFSSTYLE, 3, {"string", "-string", "foo", NULL}},
	{AARG_AFSSTYLE, 3, {"string", "-strin", "foo", NULL}},
	{AARG_AFSSTYLE, 3, {"string", "-st", "foo", NULL}, GA_FAILURE},
	{AARG_AFSSTYLE, 2, {"string", "--flag"}, GA_FAILURE},
	{AARG_AFSSTYLE, 2, {"string", "foo", NULL}}
    };

    struct agetargs args[] = {
	{"string", 's', aarg_string, NULL,
	 "string test", "stringfoo", aarg_mandatory},
	{"strip", 0, aarg_string, NULL,
	 "strip test", "stripfoo", aarg_optional},
	{NULL, 0, aarg_end, NULL, NULL}
    }, *a = args;

    a->value = &string;

    for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) {
	string = NULL;
	optind = 0;

	if (agetarg
	    (args, tests[i].argc, tests[i].argv, &optind, tests[i].style)) {
	    if (tests[i].retval == GA_FAILURE)
		continue;
	    warnx("test_string: %s failed for test %d", tests[i].argv[1], i);
	    continue;
	} else {
	    if (tests[i].retval != GA_SUCCESS) {
		warnx("test_string: %s failed to fail for test %d",
		      tests[i].argv[1], i);
		continue;
	    }
	}

	if (optind != tests[i].argc) {
	    warnx("argc != optind for test %s, %d", tests[i].argv[1], i);
	    continue;
	}

	if (string == NULL || strcmp(string, "foo") != 0) {
	    warnx("error parsing for test %d: string", i);
	    continue;
	}
    }
}
Пример #4
0
int main(int argc, char **argv)
{
    int optind = 0;
    while(agetarg(args, 5, argc, argv, &optind))
	printf("Bad arg: %s\n", argv[optind]);
    printf("flag1 = %d\n", flag1);  
    printf("flag2 = %d\n", flag2);  
    printf("foo_flag = %d\n", foo_flag);  
    printf("bar_int = %d\n", bar_int);
    printf("baz_flag = %s\n", baz_string);
    aarg_printusage (args, 5, argv[0], "nothing here");
}
Пример #5
0
int
main(int argc, char **argv)
{
    int optind = 0;
    int i;
    struct fhb_handle *handles;


    if (agetarg(args, argc, argv, &optind, AARG_GNUSTYLE))
	usage(1);

    if (help_flag)
	usage(0);

    if (num_files <= 0)
	usage(1);

    if (write_file < 0)
	usage(1);

#ifdef KERBEROS
    if (!k_hasafs())
#endif
	errx(1, "no afs kernel module");

    handles = emalloc(num_files * sizeof(*handles));

    starttesting("creating files");
    for (i = 0; i < num_files; i++)
	create_file(i, &handles[i]);
    endtesting();

    for (i = 0; i < num_runs; i++)
	open_bench(i, handles);

    printf("==================\n");
    starttesting("unlink files");
    for (i = 0; i < num_files; i++)
	unlink_file(i);
    endtesting();

    printf("==================\n");
    starttesting("nop call");
    for (i = 0; i < num_files; i++)
	nop_call();
    endtesting();

    return 0;
}
Пример #6
0
int
main(int argc, char **argv)
{
    int ret = 0;
    int optind = 0;

    set_progname (argv[0]);

    verbose_flag = getenv ("VERBOSE") != NULL;

    if (agetarg (args, argc, argv, &optind, AARG_GNUSTYLE))
	usage (1);

    argc -= optind;
    argv += optind;

    if (argc != 0)
	usage (1);
    if (help_flag)
	usage (0);

    verbose_fp = fdopen (4, "w");
    if (verbose_fp == NULL) {
	verbose_fp = fopen ("/dev/null", "w");
	if (verbose_fp == NULL)
	    err (1, "fopen");
    }

    ret += test_it (getcwd, "getcwd", 3);
#ifdef __NR_getcwd
    ret += test_it (getcwd_syscall, "getcwd_syscall", 3);
#endif
    ret += test_it (getcwd_classic, "getcwd_classic", 0);
#if linux
    ret += test_it (getcwd_proc, "getcwd_proc", 0);
#endif
    return ret;
}