Ejemplo n.º 1
0
static int set_timeout(struct cfgdata_t *cfgdata, char *value)
{
	cfgdata->timeout = get_nni(value, NULL);
	if (cfgdata->timeout < 0) {
		log_msg(lg, "Can't convert '%s' to integer", value);
		cfgdata->timeout = 0;
		return -1;
	}
	return 0;
}
Ejemplo n.º 2
0
static int set_priority(struct cfgdata_t *cfgdata, char *value)
{
	kx_cfg_section *sc;

	sc = cfgdata->current;
	if (!sc) return -1;

	sc->priority = get_nni(value, NULL);
	if (sc->priority < 0) {
		log_msg(lg, "Can't convert '%s' to integer", value);
		sc->priority = 0;
		return -1;
	}
	return 0;
}
Ejemplo n.º 3
0
static int set_fbcon(struct cfgdata_t *cfgdata, char *value)
{
	const char *str_rotate = "rotate:";
	char *c;
	int i;

	/* Value should be 'rotate:<n>' */
	if (0 != strncmp(str_rotate, value, strlen(str_rotate))) {
		/* This is not 'rotate' parameter. Skip it */
		return 0;
	}

	c = strchr(value, ':');
	if (NULL == c) {
		log_msg(lg, "Wrong 'rotate' value: %s", value);
		return -1;
	}

	dispose(cfgdata->fbcon);
	cfgdata->fbcon = strdup(value);

	++c;	/* Skip ':' */
	i = get_nni(c, NULL);
	if (i < 0) {
		log_msg(lg, "Can't convert '%s' to integer", c);
		return -1;
	}

	switch(i) {
	case 3:
		//cfgdata->angle = 270;
		cfgdata->angle = 90;
		break;
	case 2:
		cfgdata->angle = 180;
		break;
	case 1:
		//cfgdata->angle = 90;
		cfgdata->angle = 270;
		break;
	case 0:
	default:
		cfgdata->angle = 0;
	}

	return 0;
}
Ejemplo n.º 4
0
int devscan_next(FILE *fp, struct charlist *fslist, struct device_t *dev)
{
	int major, minor, len;
	unsigned long long blocks;
	char *tmp, *p;
	char *device;
	char line[80];

	if (NULL == fgets(line, sizeof(line), fp)) {
		return 0;
	}

	/* Get major, minor, blocks and device name */
	len = 0;
	major = get_nni(line, &p);
	minor = get_nni(p, &p);
	blocks = get_nnll(p, &p, &len);	/* len is used as temp variable */
	tmp = get_word(p, &p);

	if (major < 0 || minor < 0 || NULL == tmp) {
		log_msg(lg, "Can't parse partition string: '%s'", line);
		return -1;
	}

	/* FIXME: 200k is hardcoded below */
	if ((0 == len) && (blocks < 200)) {
		log_msg(lg, "+ device (%d, %d) is too small (%dk < 200k), skipped", major, minor, blocks);
		return -1;
	}

	/* Format device name */
	len = p - tmp;
	device = malloc(len + 5 + 1); /* 5 = strlen("/dev/") */
	if (NULL == device) {
		DPRINTF("Can't allocate memory for device name '%s'", tmp);
		return -1;
	}
	strcpy(device, "/dev/");
	strncat(device, tmp, len);

	log_msg(lg, "Found device '%s' (%d, %d) of size %lluMb",
			device, major, minor, blocks>>10);

#ifdef USE_DEVICES_RECREATING
	/* Remove old device node. We don't care about unlink() result. */
	unlink(device);

	/* Re-create device node */
	log_msg(lg, "+ creating device node");
	if ( -1 == mknod( device,
			(S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH),
			makedev(major, minor) ) )
	{
		log_msg(lg, "+ mknod failed: %s", ERRMSG);
	}
#endif

	dev->fstype = detect_fstype(device, fslist);
	if (NULL == dev->fstype) {
		free(device);
		return -1;
	}

	dev->device = device;
	dev->blocks = blocks;

	return 1;
}