Ejemplo n.º 1
0
// fixme
static inline void conf_check_add(const char *attr, const char *val)
{
	char str[CONF_VAL_LEN];

	if (conf_get_attr(attr, str) < 0)
		conf_add_attr(attr, val);
}
Ejemplo n.º 2
0
Archivo: cd.c Proyecto: JansZeng/g-bios
int main(int argc, char *argv[])
{
	int ret; // index;
	const char *path;
	char str[CONF_VAL_LEN];

	switch (argc) {
	case 1:
		ret = conf_get_attr(HOME, str);
		assert(ret >= 0); // should never fail!
		path = str;
		goto L1;

	case 2:
		path = argv[1];
		break;

	default:
		usage();
		return -EINVAL;
	}

#if 0
	ret = dec_str_to_int(path, &index);
	if (ret >= 0) {
		if (index >= 0) {
			ret = get_bdev_by_index(index, str, sizeof(str));
			if (!ret) {
				path = str;
				goto L1;
			}
		}

		usage();
		return -ENOENT;
	}
#endif

L1:
	if (!strcmp(path, get_current_dir_name()))
		return 0;

	ret = chdir(path);
	if (ret < 0) {
		printf("cd failed, errno = %d!\n", ret);
		return ret;
	}

	return ret;
}
Ejemplo n.º 3
0
static inline int shell_init(void)
{
	int i;
	char home[CONF_VAL_LEN];

	for (i = 0; i < APP_HIST_DEPTH; i++)
		g_cmd_stack.stack[i] = NULL;
	g_cmd_stack.hist = 0;

	// always check the HOME
	if (conf_get_attr("HOME", home) < 0) {
		strcpy(home, "/");
		conf_add_attr("HOME", home);
	}

	// and set CWD
	return chdir(home);
}
Ejemplo n.º 4
0
static int __INIT__ flash_scan_part(struct flash_chip *host,
						struct part_attr part[])
{
	int ret;
	char part_def[CONF_VAL_LEN];
	char conf_val[CONF_VAL_LEN];
	const char *match_parts;

	ret = conf_get_attr("flash.parts", conf_val);
	if (ret < 0) {
		return ret;
	}

	match_parts = strstr(conf_val, host->name);
	if (!match_parts) {
		// TODO: add hint here
		return -ENOENT;
	}

	remove_blank_space(match_parts, part_def, sizeof(part_def));

	return flash_parse_part(host, part, part_def);
}