Example #1
0
int
main(int argc, char *argv[])
{
    START(argc, argv, "util_poolset");

    common_init(LOG_PREFIX, LOG_LEVEL_VAR, LOG_FILE_VAR,
                MAJOR_VERSION, MINOR_VERSION);

    if (argc < 5)
        UT_FATAL("usage: %s cmd minlen hdrsize [mockopts] setfile ...",
                 argv[0]);

    char *fname;
    struct pool_set *set;
    int ret;

    size_t minsize = strtoul(argv[2], &fname, 0);

    for (int arg = 3; arg < argc; arg++) {
        arg += mock_options(argv[arg]);
        fname = argv[arg];

        switch (argv[1][0]) {
        case 'c':
            ret = util_pool_create(&set, fname, 0, minsize,
                                   SIG, 1, 0, 0, 0, NULL, REPLICAS_ENABLED);
            if (ret == -1)
                UT_OUT("!%s: util_pool_create", fname);
            else {
                /*
                 * XXX: On Windows pool files are created with
                 * R/W permissions, so no need for chmod().
                 */
#ifndef _WIN32
                util_poolset_chmod(set, S_IWUSR | S_IRUSR);
#endif
                poolset_info(fname, set, 0);
                util_poolset_close(set, 0); /* do not delete */
            }
            break;
        case 'o':
            ret = util_pool_open(&set, fname, 0 /* rdonly */,
                                 minsize, SIG, 1, 0, 0, 0, NULL);
            if (ret == -1)
                UT_OUT("!%s: util_pool_open", fname);
            else {
                poolset_info(fname, set, 1);
                util_poolset_close(set, 0); /* do not delete */
            }
            break;
        }
    }

    common_fini();

    DONE(NULL);
}
Example #2
0
int
main(int argc, char *argv[])
{
	START(argc, argv, "util_poolset");

	out_init(LOG_PREFIX, LOG_LEVEL_VAR, LOG_FILE_VAR,
			MAJOR_VERSION, MINOR_VERSION);
	util_init();

	if (argc < 5)
		UT_FATAL("usage: %s cmd minlen hdrsize [mockopts] setfile ...",
			argv[0]);

	char *fname;
	struct pool_set *set;
	int ret;

	size_t minsize = strtoul(argv[2], &fname, 0);

	for (int arg = 3; arg < argc; arg++) {
		arg += mock_options(argv[arg]);
		fname = argv[arg];

		switch (argv[1][0]) {
		case 'c':
			ret = util_pool_create(&set, fname, 0, minsize,
				SIG, 1, 0, 0, 0);
			if (ret == -1)
				UT_OUT("!%s: util_pool_create", fname);
			else {
				util_poolset_chmod(set, S_IWUSR | S_IRUSR);
				poolset_info(fname, set, 0);
				util_poolset_close(set, 0); /* do not delete */
			}
			break;
		case 'o':
			ret = util_pool_open(&set, fname, 0 /* rdonly */,
				minsize, SIG, 1, 0, 0, 0);
			if (ret == -1)
				UT_OUT("!%s: util_pool_open", fname);
			else {
				poolset_info(fname, set, 1);
				util_poolset_close(set, 0); /* do not delete */
			}
			break;
		}
	}

	out_fini();

	DONE(NULL);
}
Example #3
0
int
main(int argc, char *argv[])
{
	START(argc, argv, "util_poolset");

	common_init(LOG_PREFIX, LOG_LEVEL_VAR, LOG_FILE_VAR,
			MAJOR_VERSION, MINOR_VERSION);

	if (argc < 3)
		UT_FATAL("usage: %s cmd minsize [mockopts] "
			"setfile ...", argv[0]);

	char *fname;
	struct pool_set *set;
	int ret;

	size_t minsize = strtoul(argv[2], &fname, 0);

	for (int arg = 3; arg < argc; arg++) {
		arg += mock_options(argv[arg]);
		fname = argv[arg];
		struct pool_attr attr;
		memset(&attr, 0, sizeof(attr));
		memcpy(attr.signature, SIG, sizeof(SIG));
		attr.major = 1;

		switch (argv[1][0]) {
		case 'c':
			ret = util_pool_create(&set, fname, 0, minsize,
				MIN_PART, &attr, NULL, REPLICAS_ENABLED);
			if (ret == -1)
				UT_OUT("!%s: util_pool_create", fname);
			else {
				/*
				 * XXX: On Windows pool files are created with
				 * R/W permissions, so no need for chmod().
				 */
#ifndef _WIN32
				util_poolset_chmod(set, S_IWUSR | S_IRUSR);
#endif
				poolset_info(fname, set, 0);
				util_poolset_close(set, DO_NOT_DELETE_PARTS);
			}
			break;
		case 'o':
			attr.incompat_features = TEST_FORMAT_INCOMPAT_CHECK;
			ret = util_pool_open(&set, fname, 0 /* rdonly */,
				MIN_PART, &attr, NULL, false, NULL);
			if (ret == -1)
				UT_OUT("!%s: util_pool_open", fname);
			else {
				poolset_info(fname, set, 1);
				util_poolset_close(set, DO_NOT_DELETE_PARTS);
			}
			break;
		case 'e':
			attr.incompat_features = TEST_FORMAT_INCOMPAT_CHECK;
			ret = util_pool_open(&set, fname, 0 /* rdonly */,
				MIN_PART, &attr, NULL, false, NULL);
			UT_ASSERTeq(ret, 0);
			void *nptr = util_pool_extend(set, Extend_size);
			if (nptr == NULL)
				UT_OUT("!%s: util_pool_extend", fname);
			else {
				poolset_info(fname, set, 1);
			}
			util_poolset_close(set, DO_NOT_DELETE_PARTS);
			break;
		}
	}

	common_fini();

	DONE(NULL);
}