static ssize_t dasd_stats_proc_write(struct file *file,
		const char __user *user_buf, size_t user_len, loff_t *pos)
{
#ifdef CONFIG_DASD_PROFILE
	char *buffer, *str;
	int rc;

	if (user_len > 65536)
		user_len = 65536;
	buffer = dasd_get_user_string(user_buf, user_len);
	if (IS_ERR(buffer))
		return PTR_ERR(buffer);

	/*                       */
	str = skip_spaces(buffer);
	if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
		/*                     */
		str = skip_spaces(str + 4);
		if (strcmp(str, "on") == 0) {
			/*                                */
			rc = dasd_stats_all_block_on();
			if (rc) {
				dasd_stats_all_block_off();
				goto out_error;
			}
			dasd_global_profile_reset();
			dasd_global_profile_level = DASD_PROFILE_ON;
			pr_info("The statistics feature has been switched "
				"on\n");
		} else if (strcmp(str, "off") == 0) {
			/*                                           */
			dasd_global_profile_level = DASD_PROFILE_OFF;
			dasd_global_profile_reset();
			dasd_stats_all_block_off();
			pr_info("The statistics feature has been switched "
				"off\n");
		} else
			goto out_parse_error;
	} else if (strncmp(str, "reset", 5) == 0) {
		/*                      */
		dasd_global_profile_reset();
		dasd_stats_all_block_reset();
		pr_info("The statistics have been reset\n");
	} else
		goto out_parse_error;
	vfree(buffer);
	return user_len;
out_parse_error:
	rc = -EINVAL;
	pr_warning("%s is not a supported value for /proc/dasd/statistics\n",
		str);
out_error:
	vfree(buffer);
	return rc;
#else
	pr_warning("/proc/dasd/statistics: is not activated in this kernel\n");
	return user_len;
#endif				/*                     */
}
static ssize_t dasd_stats_proc_write(struct file *file,
		const char __user *user_buf, size_t user_len, loff_t *pos)
{
#ifdef CONFIG_DASD_PROFILE
	char *buffer, *str;

	if (user_len > 65536)
		user_len = 65536;
	buffer = dasd_get_user_string(user_buf, user_len);
	if (IS_ERR(buffer))
		return PTR_ERR(buffer);
<<<<<<< HEAD
Example #3
0
static int
dasd_statistics_write(struct file *file, const char __user *user_buf,
                      unsigned long user_len, void *data)
{
#ifdef CONFIG_DASD_PROFILE
    char *buffer, *str;

    if (user_len > 65536)
        user_len = 65536;
    buffer = dasd_get_user_string(user_buf, user_len);
    if (IS_ERR(buffer))
        return PTR_ERR(buffer);
    MESSAGE_LOG(KERN_INFO, "/proc/dasd/statictics: '%s'", buffer);

    /* check for valid verbs */
    for (str = buffer; isspace(*str); str++);
    if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
        /* 'set xxx' was given */
        for (str = str + 4; isspace(*str); str++);
        if (strcmp(str, "on") == 0) {
            /* switch on statistics profiling */
            dasd_profile_level = DASD_PROFILE_ON;
            MESSAGE(KERN_INFO, "%s", "Statistics switched on");
        } else if (strcmp(str, "off") == 0) {
            /* switch off and reset statistics profiling */
            memset(&dasd_global_profile,
                   0, sizeof (struct dasd_profile_info_t));
            dasd_profile_level = DASD_PROFILE_OFF;
            MESSAGE(KERN_INFO, "%s", "Statistics switched off");
        } else
            goto out_error;
    } else if (strncmp(str, "reset", 5) == 0) {
        /* reset the statistics */
        memset(&dasd_global_profile, 0,
               sizeof (struct dasd_profile_info_t));
        MESSAGE(KERN_INFO, "%s", "Statistics reset");
    } else
        goto out_error;
    kfree(buffer);
    return user_len;
out_error:
    MESSAGE(KERN_WARNING, "%s",
            "/proc/dasd/statistics: only 'set on', 'set off' "
            "and 'reset' are supported verbs");
    kfree(buffer);
    return -EINVAL;
#else
    MESSAGE(KERN_WARNING, "%s",
            "/proc/dasd/statistics: is not activated in this kernel");
    return user_len;
#endif				/* CONFIG_DASD_PROFILE */
}
Example #4
0
static int
dasd_statistics_write(struct file *file, const char __user *user_buf,
		      unsigned long user_len, void *data)
{
#ifdef CONFIG_DASD_PROFILE
	char *buffer, *str;

	if (user_len > 65536)
		user_len = 65536;
	buffer = dasd_get_user_string(user_buf, user_len);
	if (IS_ERR(buffer))
		return PTR_ERR(buffer);
	DBF_EVENT(DBF_DEBUG, "/proc/dasd/statictics: '%s'\n", buffer);

	/* check for valid verbs */
	for (str = buffer; isspace(*str); str++);
	if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
		/* 'set xxx' was given */
		for (str = str + 4; isspace(*str); str++);
		if (strcmp(str, "on") == 0) {
			/* switch on statistics profiling */
			dasd_profile_level = DASD_PROFILE_ON;
			pr_info("The statistics feature has been switched "
				"on\n");
		} else if (strcmp(str, "off") == 0) {
			/* switch off and reset statistics profiling */
			memset(&dasd_global_profile,
			       0, sizeof (struct dasd_profile_info_t));
			dasd_profile_level = DASD_PROFILE_OFF;
			pr_info("The statistics feature has been switched "
				"off\n");
		} else
			goto out_error;
	} else if (strncmp(str, "reset", 5) == 0) {
		/* reset the statistics */
		memset(&dasd_global_profile, 0,
		       sizeof (struct dasd_profile_info_t));
		pr_info("The statistics have been reset\n");
	} else
		goto out_error;
	kfree(buffer);
	return user_len;
out_error:
	pr_warning("%s is not a supported value for /proc/dasd/statistics\n",
		str);
	kfree(buffer);
	return -EINVAL;
#else
	pr_warning("/proc/dasd/statistics: is not activated in this kernel\n");
	return user_len;
#endif				/* CONFIG_DASD_PROFILE */
}