示例#1
0
int LL_PROC_PROTO(proc_pages_max)
{
        char buf[22];
        int len;

        if (!*lenp || (*ppos && !write)) {
                *lenp = 0;
                return 0;
        }
        if (write)
                return -EINVAL;

        len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_max());
        if (len > *lenp)
                len = *lenp;
        buf[len] = '\0';
	if (copy_to_user(buffer, buf, len))
                return -EFAULT;
        *lenp = len;
        *ppos += *lenp;
        return 0;
}
示例#2
0
static int proc_pages_max(struct ctl_table *table, int write,
			void __user *buffer, size_t *lenp, loff_t *ppos)
{
	char buf[22];
	int len;

	if (!*lenp || (*ppos && !write)) {
		*lenp = 0;
		return 0;
	}
	if (write)
		return -EINVAL;

	len = snprintf(buf, sizeof(buf), "%llu\n", obd_pages_max());
	if (len > *lenp)
		len = *lenp;
	buf[len] = '\0';
	if (copy_to_user(buffer, buf, len))
		return -EFAULT;
	*lenp = len;
	*ppos += *lenp;
	return 0;
}