Exemplo n.º 1
0
Arquivo: main.c Projeto: erikb85/HidaV
static void _set( struct bootconfig * bc, const char * desc, 
                 const char * part_string, int part_mod, enum bt_ll_parttype what )
{

    unsigned int part;

    if( 1 != sscanf( part_string, "mtd%u", &part) ) {
        bc_log( LOG_ERR, "Unable to parse partition string %s.\n", part_string );
        exit(1);
    }

    part  = part + part_mod;

    if (part > 1) {
        printf("Illegal partition %s. Valid: mtd%d, mtd%d.\n", 
                part_string, 0 - part_mod, 0 - part_mod + 1);
        exit(1);
    }
    printf("   Setting current %s to %s (%s partition #%u).\n", 
                desc, part_string, desc, part);
    printf("   Writing to NAND...\n");

    bc_ll_set_partition( bc, what, part ); 
    bc_ll_reread( bc );
    _print_config( bc );

    exit(0);
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: erikb85/HidaV
int main(int argc, char ** argv)
{
    struct bootconfig bc;
    int ret = -1;

    bc_ll_init( &bc, "/dev/mtd1" );

    if ( argc < 2 ) {
        _print_config( &bc );
        exit(0);
    }

    if ( 0 == strcmp( argv[1], "info" ) ) {
        _print_info( &bc );
        exit(0);
    }

    if ( 0 == strcmp( argv[1], "help" ) ) {
        ret = 0;
    }

    if ( 0 == strcmp( argv[1], "set-kernel-healthy" ) ) {
	_set_kernel_healthy( &bc );
	_print_config( &bc );
        exit(0);
    }
    if ( 0 == strcmp( argv[1], "set-rootfs-healthy" ) ) {
        _set_rootfs_healthy( &bc );
        _print_config( &bc );
        exit(0);
    }

    if ( argc == 3 ) {
        /* TFM TODO / FIXME: this needs refactoring. */
        if ( 0 == strcmp( argv[1], "set-kernel" ) ) {
            _set( &bc, "kernel", argv[2], -2, kernel );
        }

        if ( 0 == strcmp( argv[1], "set-rootfs" ) ) {
            _set( &bc, "rootfs", argv[2], -4, rootfs );
        }
    }

    _print_help();

    return ret;
}
Exemplo n.º 3
0
/* Load configuration file contents into global variables.
 * Call nonstop_free_config to free memory. */
extern void nonstop_read_config(void)
{
	char *nonstop_file = NULL;
	s_p_hashtbl_t *tbl = NULL;
	struct stat config_stat;

	nonstop_file = get_extra_conf_path("nonstop.conf");
	if (stat(nonstop_file, &config_stat) < 0)
		fatal("Can't stat nonstop.conf %s: %m", nonstop_file);
	tbl = s_p_hashtbl_create(nonstop_options);
	if (s_p_parse_file(tbl, NULL, nonstop_file, false) == SLURM_ERROR)
		fatal("Can't parse nonstop.conf %s: %m", nonstop_file);

	s_p_get_string(&nonstop_backup_addr, "BackupAddr", tbl);
	if (!s_p_get_string(&nonstop_control_addr, "ControlAddr", tbl))
		fatal("No ControlAddr in nonstop.conf %s", nonstop_file);
	s_p_get_uint16(&nonstop_debug, "Debug", tbl);
	s_p_get_string(&hot_spare_count_str, "HotSpareCount", tbl);
	s_p_get_uint32(&max_spare_node_count, "MaxSpareNodeCount", tbl);
	if (!s_p_get_uint16(&nonstop_comm_port, "Port", tbl))
		nonstop_comm_port = DEFAULT_NONSTOP_PORT;
	s_p_get_uint16(&time_limit_delay, "TimeLimitDelay", tbl);
	s_p_get_uint16(&time_limit_drop, "TimeLimitDrop", tbl);
	s_p_get_uint16(&time_limit_extend, "TimeLimitExtend", tbl);
	s_p_get_string(&user_drain_allow_str, "UserDrainAllow", tbl);
	s_p_get_string(&user_drain_deny_str, "UserDrainDeny", tbl);
	s_p_get_uint32(&read_timeout, "ReadTimeout", tbl);
	s_p_get_uint32(&write_timeout, "WriteTimeout", tbl);

	_validate_config();
	if (nonstop_debug > 0)
		_print_config();

	s_p_hashtbl_destroy(tbl);
	xfree(nonstop_file);
}
Exemplo n.º 4
0
static void
_process_cmdline(int ac, char **av)
{
	int c;
	char *tmp_char;

	conf->prog = xbasename(av[0]);

	while ((c = getopt(ac, av, GETOPT_ARGS)) > 0) {
		switch (c) {
		case 'c':
			conf->cleanstart = 1;
			break;
		case 'C':
			_print_config();
			exit(0);
			break;
		case 'd':
			conf->stepd_loc = xstrdup(optarg);
			break;
		case 'D':
			conf->daemonize = 0;
			break;
		case 'f':
			conf->conffile = xstrdup(optarg);
			break;
		case 'h':
			_usage();
			exit(0);
			break;
		case 'L':
			conf->logfile = xstrdup(optarg);
			break;
		case 'M':
			conf->mlock_pages = 1;
			break;
		case 'n':
			conf->nice = strtol(optarg, &tmp_char, 10);
			if (tmp_char[0] != '\0') {
				error("Invalid option for -n option (nice "
				      "value), ignored");
				conf->nice = 0;
			}
			break;
		case 'N':
			conf->node_name = xstrdup(optarg);
			break;
		case 'v':
			conf->debug_level++;
			conf->debug_level_set = 1;
			break;
		case 'V':
			print_slurm_version();
			exit(0);
			break;
		default:
			_usage();
			exit(1);
			break;
		}
	}

	/*
	 *  If slurmstepd path wasn't overridden by command line, set
	 *   it to the default here:
	 */
	if (!conf->stepd_loc)
		conf->stepd_loc =
			xstrdup_printf("%s/sbin/slurmstepd", SLURM_PREFIX);
}