예제 #1
0
static ssize_t validate_flash_read(struct file *file, char __user *buf,
			       size_t count, loff_t *ppos)
{
	struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
	struct rtas_validate_flash_t *args_buf;
	char msg[RTAS_MSG_MAXLEN];
	int msglen;

	args_buf = (struct rtas_validate_flash_t *) dp->data;

	if (ppos && *ppos != 0)
		return 0;	/* be cheap */
	
	msglen = get_validate_flash_msg(args_buf, msg);
	if (msglen > count)
		msglen = count;

	if (!access_ok(VERIFY_WRITE, buf, msglen))
		return -EINVAL;

	if (copy_to_user(buf, msg, msglen))
		return -EFAULT;

	if (ppos)
		*ppos = msglen;
	return msglen;
}
예제 #2
0
파일: rtas_flash.c 프로젝트: AllenDou/linux
static ssize_t validate_flash_read(struct file *file, char __user *buf,
			       size_t count, loff_t *ppos)
{
	struct proc_dir_entry *dp = PDE(file->f_path.dentry->d_inode);
	struct rtas_validate_flash_t *args_buf;
	char msg[RTAS_MSG_MAXLEN];
	int msglen;

	args_buf = dp->data;

	msglen = get_validate_flash_msg(args_buf, msg);

	return simple_read_from_buffer(buf, count, ppos, msg, msglen);
}
static ssize_t validate_flash_read(struct file *file, char __user *buf,
			       size_t count, loff_t *ppos)
{
	struct rtas_validate_flash_t *const args_buf =
		&rtas_validate_flash_data;
	char msg[VALIDATE_MSG_LEN];
	int msglen;

	mutex_lock(&rtas_validate_flash_mutex);
	msglen = get_validate_flash_msg(args_buf, msg, VALIDATE_MSG_LEN);
	mutex_unlock(&rtas_validate_flash_mutex);

	return simple_read_from_buffer(buf, count, ppos, msg, msglen);
}