mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	switch /dev/kmsg to ->write_iter()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									cd678fce42
								
							
						
					
					
						commit
						849f3127bb
					
				
					 1 changed files with 7 additions and 13 deletions
				
			
		| 
						 | 
					@ -519,14 +519,13 @@ struct devkmsg_user {
 | 
				
			||||||
	char buf[8192];
 | 
						char buf[8192];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
 | 
					static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 | 
				
			||||||
			      unsigned long count, loff_t pos)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char *buf, *line;
 | 
						char *buf, *line;
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	int level = default_message_loglevel;
 | 
						int level = default_message_loglevel;
 | 
				
			||||||
	int facility = 1;	/* LOG_USER */
 | 
						int facility = 1;	/* LOG_USER */
 | 
				
			||||||
	size_t len = iov_length(iv, count);
 | 
						size_t len = iocb->ki_nbytes;
 | 
				
			||||||
	ssize_t ret = len;
 | 
						ssize_t ret = len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len > LOG_LINE_MAX)
 | 
						if (len > LOG_LINE_MAX)
 | 
				
			||||||
| 
						 | 
					@ -535,13 +534,10 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
 | 
				
			||||||
	if (buf == NULL)
 | 
						if (buf == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	line = buf;
 | 
						buf[len] = '\0';
 | 
				
			||||||
	for (i = 0; i < count; i++) {
 | 
						if (copy_from_iter(buf, len, from) != len) {
 | 
				
			||||||
		if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) {
 | 
							kfree(buf);
 | 
				
			||||||
			ret = -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
			goto out;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		line += iv[i].iov_len;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -567,10 +563,8 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
 | 
				
			||||||
			line = endp;
 | 
								line = endp;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	line[len] = '\0';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	printk_emit(facility, level, NULL, 0, "%s", line);
 | 
						printk_emit(facility, level, NULL, 0, "%s", line);
 | 
				
			||||||
out:
 | 
					 | 
				
			||||||
	kfree(buf);
 | 
						kfree(buf);
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -802,7 +796,7 @@ static int devkmsg_release(struct inode *inode, struct file *file)
 | 
				
			||||||
const struct file_operations kmsg_fops = {
 | 
					const struct file_operations kmsg_fops = {
 | 
				
			||||||
	.open = devkmsg_open,
 | 
						.open = devkmsg_open,
 | 
				
			||||||
	.read = devkmsg_read,
 | 
						.read = devkmsg_read,
 | 
				
			||||||
	.aio_write = devkmsg_writev,
 | 
						.write_iter = devkmsg_write,
 | 
				
			||||||
	.llseek = devkmsg_llseek,
 | 
						.llseek = devkmsg_llseek,
 | 
				
			||||||
	.poll = devkmsg_poll,
 | 
						.poll = devkmsg_poll,
 | 
				
			||||||
	.release = devkmsg_release,
 | 
						.release = devkmsg_release,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue