Esempio n. 1
0
ssize_t nvramdrv_ioctl(struct inode * inode, struct file * file,
	unsigned int cmd, unsigned long buf)
#endif
{
	int index, len;
	const char *p;
	nvram_ioctl_t *nvr;
	char *value;


	switch (cmd) {
		case NVRAM_IOCTL_GET:
			nvr = (nvram_ioctl_t __user *)buf;
			p = nvram_get(nvr->index, nvr->name);
			if (p == NULL)
				p = "";

			if (copy_to_user(nvr->value, p, strlen(p) + 1))
				return -EFAULT;
			break;

		case NVRAM_IOCTL_GETALL:
			nvr = (nvram_ioctl_t __user *)buf;
			//index = nvr->index;
			index = 0;
			len = fb[index].flash_max_len - sizeof(fb[index].env.crc);

			if (nvram_getall(index, fb[index].env.data) == 0) {
				if (copy_to_user(nvr->value, fb[index].env.data, len))
					return -EFAULT;
			}
			break;
		case NVRAM_IOCTL_SET:
			nvr = (nvram_ioctl_t *)buf;		
			value = (char *)kmalloc(MAX_VALUE_LEN, GFP_KERNEL);
			if (!value)
				return -ENOMEM;

			if (copy_from_user(value, nvr->value, strlen(nvr->value) + 1)) {
				kfree(value);
				return -EFAULT;
			}

			nvram_set(nvr->index, nvr->name, value);
			kfree(value);
			break;

		case NVRAM_IOCTL_COMMIT:
			nvr = (nvram_ioctl_t __user *)buf;
			nvr->useFile = nvram_commit(nvr->index);
			break;
		case NVRAM_IOCTL_CLEAR:
			nvr = (nvram_ioctl_t __user *)buf;
			nvram_clear(nvr->index);
		default:
			printk(KERN_CRIT "Unsupported ioctl(%d) on nvram\n", cmd);
			break;
	}
	return 0;
}
Esempio n. 2
0
static int
nvram_restore_defaults(void)
{
	struct nvram_pair *np;
	int restore_defaults;

	/* Restore defaults if told to or OS has changed */
	restore_defaults = !nvram_match("restore_defaults", "0");

	/* check asus-wrt NVRAM content (sorry, but many params is incompatible) */
	if (!restore_defaults) {
		if (nvram_get("buildno") && nvram_get("buildinfo") && nvram_get("extendno"))
			restore_defaults = 1;
	}

	if (restore_defaults)
		nvram_clear();

	/* Restore defaults */
	for (np = router_defaults; np->name; np++) {
		if (restore_defaults || !nvram_get(np->name)) {
			nvram_set(np->name, np->value);
		}
	}

	klogctl(8, NULL, nvram_get_int("console_loglevel"));

	/* load static values */
	nvram_modem_type = nvram_get_int("modem_type");
	nvram_modem_rule = nvram_get_int("modem_rule");
	nvram_nf_nat_type = nvram_get_int("nf_nat_type");
	nvram_ipv6_type = get_ipv6_type();

	return restore_defaults;
}
Esempio n. 3
0
int ralink_nvram_ioctl(struct inode *inode, struct file *file, unsigned int req,
		unsigned long arg)
#endif
{
	int index, len;
	const char *p;
	nvram_ioctl_t *nvr;
	char *value;


	switch (req) {
	case RALINK_NVRAM_IOCTL_GET:
		nvr = (nvram_ioctl_t __user *)arg;
		p = nvram_get(nvr->index, nvr->name);
		if (p == NULL)
			p = "";

		if (copy_to_user(nvr->value, p, strlen(p) + 1))
			return -EFAULT;
		break;
	case RALINK_NVRAM_IOCTL_GETALL:
		nvr = (nvram_ioctl_t __user *)arg;
		index = nvr->index;
		len = fb[index].flash_max_len - sizeof(fb[index].env.crc);
			
		if (nvram_getall(index, fb[index].env.data) == 0) {
			if (copy_to_user(nvr->value, fb[index].env.data, len))
				return -EFAULT;
		}
		break;
	case RALINK_NVRAM_IOCTL_SET:
		nvr = (nvram_ioctl_t *)arg;		
		value = (char *)kmalloc(MAX_VALUE_LEN, GFP_KERNEL);
		if (!value)
			return -ENOMEM;

		if (copy_from_user(value, nvr->value, strlen(nvr->value) + 1)) {
			kfree(value);
			return -EFAULT;
		}

		nvram_set(nvr->index, nvr->name, value);
		kfree(value);
		break;

	case RALINK_NVRAM_IOCTL_COMMIT:
		nvr = (nvram_ioctl_t __user *)arg;
		nvram_commit(nvr->index);
		break;
	case RALINK_NVRAM_IOCTL_CLEAR:
		nvr = (nvram_ioctl_t __user *)arg;
		nvram_clear(nvr->index);
	default:
		break;
	}

	return 0;
}
Esempio n. 4
0
/* NVRAM utility */
int
main(int argc, char **argv)
{
	char *name, *value;

	/* Skip program name */
	--argc;
	++argv;

	if (!*argv) 
		usage();

	/* Process the remaining arguments. */
	for (; *argv; argv++) {
		if (!strncmp(*argv, "get", 3)) {
			if (*++argv) {
				if ((value = nvram_get(*argv)))
					puts(value);
			}
		}
		else if (!strncmp(*argv, "set", 3)) {
			if (*++argv) {
				char buf[1024];
				strncpy(value = buf, *argv, sizeof(buf)-1);
				name = strsep(&value, "=");
				nvram_set(name, value);
			}
		}
		else if (!strncmp(*argv, "unset", 5)) {
			if (*++argv)
				nvram_unset(*argv);
		}
		else if (!strncmp(*argv, "commit", 6)) {
			nvram_commit();
		}
		else if (!strncmp(*argv, "clear", 5)) {
			nvram_clear();
		}
		else if (!strncmp(*argv, "save", 4)) 
		{
			if (*++argv) 
				nvram_save_new(*argv);
		}
		else if (!strncmp(*argv, "restore", 7)) 
		{
			if (*++argv) 
				nvram_restore_new(*argv);
		}
		else if (!strncmp(*argv, "show", 4) || !strncmp(*argv, "getall", 6)) {
			nvram_show_new();
		}
		if (!*argv)
			break;
	}

	return 0;
}
Esempio n. 5
0
static long dev_nvram_ioctl(struct file *file, unsigned int req, unsigned long arg)
{
	switch(req)
	{
	case NVRAM_IOCTL_COMMIT:
		return nvram_commit();
	case NVRAM_IOCTL_CLEAR:
		return nvram_clear();
	case NVRAM_IOCTL_SET:
		return user_nvram_set((anvram_ioctl_t __user *)arg);
	case NVRAM_IOCTL_GET:
		return user_nvram_get((anvram_ioctl_t __user *)arg);
	}
	
	return -EINVAL;
}
Esempio n. 6
0
int nvram_restore_new(char *file)
{
	FILE *fp;
	char header[8], *p, *v, *buf;
	unsigned long count, filelen, *filelenptr, i;
	unsigned char rand, *randptr;

	if ((fp = fopen(file, "r+")) == NULL) return -1;

	buf = malloc(NVRAM_SPACE);
	if (!buf) {
		fclose(fp);
		perror ("Out of memory!\n");
		return -1;
	}

	buf[0] = 0;

	count = fread(header, 1, 8, fp);
	if (count>=8 && strncmp(header, PROFILE_HEADER, 4) == 0)
	{
		filelenptr = (unsigned long *)(header + 4);
		fread(buf, 1, *filelenptr, fp);
	}
	else if (count>=8 && strncmp(header, PROFILE_HEADER_NEW, 4) == 0)
	{
		filelenptr = (unsigned long *)(header + 4);
		filelen = *filelenptr & 0xffffff;
		randptr = (unsigned char *)(header + 7);
		rand = *randptr;
		if (filelen > NVRAM_SPACE)
			filelen = NVRAM_SPACE;
		count = fread(buf, 1, filelen, fp);
		for (i = 0; i < count; i++)
		{
			if ((unsigned char) buf[i] > ( 0xfd - 0x1))
				buf[i] = 0x0;
			else
				buf[i] = 0xff + rand - buf[i];
		}
	}
	else
	{
		fclose(fp);
		return 0;
	}
	fclose(fp);

	nvram_clear();

	p = buf;

	while (*p)
	{
		v = strchr(p, '=');
		if (v != NULL)
		{
			*v++ = 0;
			if (is_sys_param(p))
				nvram_set(p, v);
			p = v + strlen(v) + 1;
		}
		else
		{
			nvram_unset(p);
			p = p + 1;
		}
	}

	free(buf);

	nvram_set("x_Setting", "1");
	nvram_set("w_Setting", "1");
	return 0;
}
Esempio n. 7
0
int32_t main(int32_t argc, char ** argv)
{
    int32_t i = 0;

    for(i=0; i<argc; i++)
        DEBUG("argv[%d]:%s\n", i, argv[i]);


    if (argc < 2)
        return usage(OK);

    nvram_mtd_size = mtd_size(NVRAM_MTD_NAME);
    DEBUG("nvram_mtd_size = %u\n", nvram_mtd_size);
    if (nvram_mtd_size <= 0)
        return NG;

    if (nvram_filecache(NVRAM_CACHE_FILE) != OK)
        return NG;

    if (nvram_parse(NULL, NVRAM_CACHE_FILE) != OK)
        return NG;

    if (0 == strcasecmp(argv[1], "commit"))
    {
        return nvram_commit(1);
    }
    else if (0 == strcasecmp(argv[1], "set"))
    {
        if (argc == 5)
            return nvram_set(argv[2], argv[3], argv[4]);
        else
            return usage(NG);
    }
    else if (0 == strcasecmp(argv[1], "get"))
    {
        if (argc < 4)
            return usage(NG);
        else
            nvram_get(argv[2], argv[3]);
    }
    else if (0 == strcasecmp(argv[1], "del"))
    {
        if (argc < 4)
            return usage(NG);
        else
            nvram_del(argv[2], argv[3]);
    }
    else if (0 == strcasecmp(argv[1], "show"))
    {
        if (argc < 3)
            return nvram_show(NULL);
        else
            return nvram_show(argv[2]);
    }
    else if (0 == strcasecmp(argv[1], "clear"))
    {
        return nvram_clear(argv[2]);
    }
    else if (0 == strcasecmp(argv[1], "reset"))
    {
        if (argc < 4)
            return usage(NG);
        else
            return nvram_reset(argv[2], argv[3]);
    }
    else
        return usage(NG);

    return OK;
}
Esempio n. 8
0
int32_t main(int32_t argc, char ** argv)
{
#if 0
    int32_t i = 0;

    for(i=0; i<argc; i++)
        DEBUG("argv[%d]:%s\n", i, argv[i]);
#endif

    if (argc < 2)
        return usage(OK);

    if (nvram_filecache(NVRAM_CACHE_FILE) != OK)
        return NG;

    if (nvram_parse(NULL, NVRAM_CACHE_FILE) != OK)
        return NG;

    if (0 == strcasecmp(argv[1], "commit"))
    {
        return nvram_commit(1);
    }
    else if (0 == strcasecmp(argv[1], "set"))
    {
        if (argc == 5)
            return nvram_set(argv[2], argv[3], argv[4]);
        else
            return usage(NG);
    }
    else if (0 == strcasecmp(argv[1], "get"))
    {
        if (argc < 4)
            return usage(NG);
        else
            nvram_get(argv[2], argv[3]);
    }
    else if (0 == strcasecmp(argv[1], "del"))
    {
        if (argc < 4)
            return usage(NG);
        else
            nvram_del(argv[2], argv[3]);
    }
    else if (0 == strcasecmp(argv[1], "show"))
    {
        if (argc < 3)
            return nvram_show(NULL);
        else
            return nvram_show(argv[2]);
    }
    else if (0 == strcasecmp(argv[1], "clear"))
    {
        return nvram_clear(argv[2]);
    }
    else if (0 == strcasecmp(argv[1], "layout"))
    {
        return nvram_layout();
    }
    else if (0 == strcasecmp(argv[1], "loadfile"))
    {
        if (argc < 4)
            return usage(NG);
        else
            return nvram_loadfile(argv[2], argv[3]);
    }
    else
        return usage(NG);

    return OK;
}
Esempio n. 9
0
/* NVRAM utility */
int
main(int argc, char **argv)
{
	char *name, *value;
	int ret = 0;

	/* Skip program name */
	--argc;
	++argv;

	if (!*argv)
		usage();

	/* Process the remaining arguments. */
	for (; *argv; argv++) {
		if (!strcmp(*argv, "get")) {
			if (*++argv) {
				if ((value = nvram_get(*argv)))
					puts(value);
			}
		}
		else if (!strcmp(*argv, "settmp")) {
			if (*++argv) {
				char buf[1024];
				strncpy(value = buf, *argv, sizeof(buf)-1);
				name = strsep(&value, "=");
				nvram_set_temp(name, value);
			}
		}
		else if (!strcmp(*argv, "set")) {
			if (*++argv) {
				char buf[1024];
				strncpy(value = buf, *argv, sizeof(buf)-1);
				name = strsep(&value, "=");
				nvram_set(name, value);
			}
		}
		else if (!strcmp(*argv, "unset")) {
			if (*++argv)
				nvram_unset(*argv);
		}
		else if (!strcmp(*argv, "clear")) {
			nvram_clear();
		}
		else if (!strcmp(*argv, "commit")) {
			nvram_commit();
			break;
		}
		else if (!strcmp(*argv, "save")) {
			if (*++argv)
				ret |= nvram_save(*argv);
			break;
		}
		else if (!strcmp(*argv, "restore")) {
			if (*++argv)
				ret |= nvram_restore(*argv);
			break;
		}
		else if (!strcmp(*argv, "show")) {
			ret |= nvram_show(0);
			break;
		}
		else if (!strcmp(*argv, "showall")) {
			ret |= nvram_show(1);
			break;
		}
		if (!*argv)
			break;
	}

	return ret;
}
Esempio n. 10
0
int main(int argc, char *argv[])
{
	char *cmd;

	if (argc < 2)
		usage(argv[0]);

	//call nvram_get or nvram_set
	if ((cmd = strrchr(argv[0], '/')) != NULL)
		cmd++;
	else
		cmd = argv[0];
	if (!strncmp(cmd, "nvram_get", 10))
		return ra_nv_get(argc, argv);
	else if (!strncmp(cmd, "nvram_set", 10))
		return ra_nv_set(argc, argv);

	if (argc == 2) {
		if (!strncmp(argv[1], "rt2860_nvram_show", 18))
			nvram_show(RT2860_NVRAM);
#if defined (CONFIG_RTDEV_MII) || defined (CONFIG_RTDEV_USB) || defined (CONFIG_RTDEV_PCI)|| \
	defined (CONFIG_RT2561_AP) || defined (CONFIG_RT2561_AP_MODULE)
		else if (!strncmp(argv[1], "rtdev_nvram_show", 17))
			nvram_show(RTDEV_NVRAM);
#endif
#ifdef CONFIG_DUAL_IMAGE
		else if (!strncmp(argv[1], "uboot_nvram_show", 17))
			nvram_show(UBOOT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_STA_WPA_SUPPLICANT
		else if (!strncmp(argv[1], "cert_nvram_show", 16))
			nvram_show(CERT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_AP_WAPI
		else if (!strncmp(argv[1], "wapi_nvram_show", 16))
			nvram_show(WAPI_NVRAM);
#endif
		else
			usage(argv[0]);
	} else if (argc == 3) {
		/* TODO: <cmd> gen 2860ap */
		if (!strncasecmp(argv[1], "gen", 4) ||
		    !strncasecmp(argv[1], "make_wireless_config", 21)) {
			if (!strncmp(argv[2], "2860", 5) ||
			    !strncasecmp(argv[2], "rt2860", 7)) //b-compatible
				gen_config(RT2860_NVRAM);
#if defined (CONFIG_RTDEV_MII) || defined (CONFIG_RTDEV_USB) || defined (CONFIG_RTDEV_PCI) || \
	defined (CONFIG_RT2561_AP) || defined (CONFIG_RT2561_AP_MODULE)
			else if (!strncasecmp(argv[2], "rtdev", 6))
				gen_config(RTDEV_NVRAM);
#endif
#ifdef CONFIG_DUAL_IMAGE
			else if (!strncasecmp(argv[2], "uboot", 6))
				printf("No support of gen command of uboot parameter.\n");
#endif
#ifdef CONFIG_RT2860V2_STA_WPA_SUPPLICANT
			else if (!strncmp(argv[2], "cert", 5))
				gen_cert(CERT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_AP_WAPI
			else if (!strncmp(argv[2], "wapi", 5))
				gen_cert(WAPI_NVRAM);
#endif
			else
				usage(argv[0]);
		} else if (!strncasecmp(argv[1], "show", 5)) {
			if (!strncmp(argv[2], "2860", 5) ||
			    !strncasecmp(argv[2], "rt2860", 7)) //b-compatible
				nvram_show(RT2860_NVRAM);
#if defined (CONFIG_RTDEV_MII) || defined (CONFIG_RTDEV_USB) || defined (CONFIG_RTDEV_PCI) || \
	defined (CONFIG_RT2561_AP) || defined (CONFIG_RT2561_AP_MODULE)
			else if (!strncasecmp(argv[2], "rtdev", 6))
				nvram_show(RTDEV_NVRAM);
#endif
#ifdef CONFIG_DUAL_IMAGE
			else if (!strncasecmp(argv[2], "uboot", 6))
				nvram_show(UBOOT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_STA_WPA_SUPPLICANT
			else if (!strncasecmp(argv[2], "cert", 5))
				nvram_show(CERT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_AP_WAPI
			else if (!strncasecmp(argv[2], "wapi", 5))
				nvram_show(WAPI_NVRAM);
#endif
			else
				usage(argv[0]);
		} else if(!strncasecmp(argv[1], "clear", 6)) {
			if (!strncmp(argv[2], "2860", 5) || 
			    !strncasecmp(argv[2], "rt2860", 7)) //b-compatible
				nvram_clear(RT2860_NVRAM);
#if defined (CONFIG_RTDEV_MII) || defined (CONFIG_RTDEV_USB) || defined (CONFIG_RTDEV_PCI) || \
	defined (CONFIG_RT2561_AP) || defined (CONFIG_RT2561_AP_MODULE)
			else if (!strncasecmp(argv[2], "rtdev", 6))
				nvram_clear(RTDEV_NVRAM);
#endif
#ifdef CONFIG_DUAL_IMAGE
			else if (!strncasecmp(argv[2], "uboot", 6))
				nvram_clear(UBOOT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_STA_WPA_SUPPLICANT
			else if (!strncasecmp(argv[2], "cert", 5))
				nvram_clear(CERT_NVRAM);
#endif
#ifdef CONFIG_RT2860V2_AP_WAPI
			else if (!strncasecmp(argv[2], "wapi", 5))
				nvram_clear(WAPI_NVRAM);
#endif
			else
				usage(argv[0]);
		} else
			usage(argv[0]);
	} else if (argc == 4) {
		if (!strncasecmp(argv[1], "renew", 6)) {
			if (!strncmp(argv[2], "2860", 5) ||
			    !strncasecmp(argv[2], "rt2860", 7)) //b-compatible
				renew_nvram(RT2860_NVRAM, argv[3]);
#if defined (CONFIG_RTDEV_MII) || defined (CONFIG_RTDEV_USB) || defined (CONFIG_RTDEV_PCI) || \
	defined (CONFIG_RT2561_AP) || defined (CONFIG_RT2561_AP_MODULE)
			else if (!strncasecmp(argv[2], "rtdev", 6))
				renew_nvram(RTDEV_NVRAM, argv[3]);
#endif
#ifdef CONFIG_DUAL_IMAGE
			else if (!strncasecmp(argv[2], "uboot", 6))
				printf("No support of renew command of uboot parameter.\n");
#endif
		} else
			usage(argv[0]);
	} else
		usage(argv[0]);
	return 0;
}
Esempio n. 11
0
static int init_nvram_block(int index)
{
	unsigned long from;
	int i, j, len;
	char *p, *q;

	i = index;

	RANV_PRINT("--> nvram_init %d\n", index);
	RANV_CHECK_INDEX(-1);

	if (fb[index].valid)
		return -EINVAL;

		//read crc from flash
		from = fb[i].flash_offset;
		len = sizeof(fb[i].env.crc);
		ra_mtd_read_nm(RALINK_NVRAM_MTDNAME, from, len, (unsigned char *)&fb[i].env.crc);

		//read data from flash
		from = from + len;
		len = fb[i].flash_max_len - len;
		fb[i].env.data = (char *)kzalloc(len, GFP_KERNEL);
		if (!fb[i].env.data)
			return -ENOMEM;

		ra_mtd_read_nm(RALINK_NVRAM_MTDNAME, from, len, (unsigned char *)fb[i].env.data);

		//check crc
		if (nv_crc32(0, fb[i].env.data, len) != fb[i].env.crc) {
			printk("NVRAM: Particion %x Bad CRC %x, start cleanup.\n", i, (unsigned int)fb[i].env.crc);
			memset(fb[index].env.data, 0, len);
			fb[i].valid = 0;
			fb[i].dirty = 1;
#ifdef AUTO_REBUILD_NVRAM
			up(&nvram_sem); /* unlock before clear */
			nvram_clear(i);
			printk("NVRAM: Particion %x cleanup OK. Reinit.\n", i);
			return NEED_REINIT;
#else
			return -1;
#endif
		}

		//parse env to cache
		p = fb[i].env.data;
		for (j = 0; j < MAX_CACHE_ENTRY; j++) {
			if (NULL == (q = strchr(p, '='))) {
				RANV_PRINT("NVRAM: Parsed failed - cannot find '='\n");
				break;
			}
			*q = '\0'; //strip '='
			fb[i].cache[j].name = kstrdup(p, GFP_KERNEL);
			//printk("  %d '%s'->", i, p);

			p = q + 1; //value
			if (NULL == (q = strchr(p, '\0'))) {
				RANV_PRINT("NVRAM: Parsed failed - cannot find '\\0'\n");
				break;
			}
			fb[i].cache[j].value = kstrdup(p, GFP_KERNEL);
			//printk("'%s'\n", p);

			p = q + 1; //next entry
			if (p - fb[i].env.data + 1 >= len) {
				//end of block
				break;
			}
			if (*p == '\0') {
				//end of env
				break;
			}
		}
		if (j == MAX_CACHE_ENTRY)
			RANV_PRINT("NVRAM: Run out of env cache, please increase MAX_CACHE_ENTRY\n");

		printk("NVRAM: Particion %x CRC %x OK.\n", i, (unsigned int)fb[i].env.crc);
		fb[i].valid = 1;
		fb[i].dirty = 0;

	return 0;
}
Esempio n. 12
0
int ralink_nvram_ioctl(struct inode *inode, struct file *file, unsigned int req,
		unsigned long arg)
#endif
{
	int index, len;
	const char *p;
	nvram_ioctl_t *nvr;
	char *value;

	switch (req) {
	case RALINK_NVRAM_IOCTL_GET:
		nvr = (nvram_ioctl_t __user *)arg;
		p = nvram_get(nvr->index, nvr->name);
		if (p == NULL)
			p = "";

		len = strlen(p) + 1;
		if (nvr->size < len) {
			nvr->size = len;
			return -EOVERFLOW;
		}

		if (copy_to_user(nvr->value, p, strlen(p) + 1))
			return -EFAULT;
		break;
	case RALINK_NVRAM_IOCTL_GETALL:
		nvr = (nvram_ioctl_t __user *)arg;
		index = nvr->index;
		len = fb[index].flash_max_len - sizeof(fb[index].env.crc);

		if (nvram_getall(index, fb[index].env.data) == 0) {
			if (copy_to_user(nvr->value, fb[index].env.data, len))
				return -EFAULT;
		}
		break;
	case RALINK_NVRAM_IOCTL_SET:
		nvr = (nvram_ioctl_t *)arg;
		len = ((nvr->size + MAX_VALUE_LEN) / MAX_VALUE_LEN) * MAX_VALUE_LEN; // Align size+1 bytes to MAX_VALUE_LEN boundary
		if ((len > MAX_PERMITTED_VALUE_LEN) || (len < 0))
			return -EOVERFLOW;
		
		value = (char *)kzalloc(len, GFP_KERNEL);
		if (!value)
			return -ENOMEM;
		
		if (copy_from_user(value, nvr->value, nvr->size)) {
			KFREE(value);
			return -EFAULT;
		}

		nvram_set(nvr->index, nvr->name, value);
		KFREE(value);
		break;
	case RALINK_NVRAM_IOCTL_COMMIT:
		nvr = (nvram_ioctl_t __user *)arg;
		nvram_commit(nvr->index);
		break;
	case RALINK_NVRAM_IOCTL_CLEAR:
		nvr = (nvram_ioctl_t __user *)arg;
		nvram_clear(nvr->index);
	default:
		break;
	}

	return 0;
}