Message type and related cleanup
- Intorduce and use a message type for VFS_GETDENTS, VFS_READ, VFS_WRITE. - Some cleanup to related functions where vir_bytes are replaced (and casted to/from, in parameter definition and local variables as well. This allow to see more clearly which function receives unsafe (pointer) values, or at least values which are not supposed to be valid in the address space of VFS. The current patch does so only for the minimal amount of functions which are concerned with the introduction of the new message type. Change-Id: I0cdca97409c4016d02fae067b48bf55d37572c5c
This commit is contained in:
@@ -10,9 +10,9 @@ ssize_t getdents(int fd, char *buffer, size_t nbytes)
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VFS_READWRITE_FD = fd;
|
||||
m.VFS_READWRITE_LEN = nbytes;
|
||||
m.VFS_READWRITE_BUF = (char *) buffer;
|
||||
m.m_lc_vfs_readwrite.fd = fd;
|
||||
m.m_lc_vfs_readwrite.len = nbytes;
|
||||
m.m_lc_vfs_readwrite.buf = (vir_bytes)buffer;
|
||||
return _syscall(VFS_PROC_NR, VFS_GETDENTS, &m);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ int ioctl(int fd, unsigned long request, ...)
|
||||
{
|
||||
int r, request_save;
|
||||
message m;
|
||||
void *addr;
|
||||
vir_bytes addr;
|
||||
void *data;
|
||||
va_list ap;
|
||||
|
||||
@@ -66,12 +66,12 @@ int ioctl(int fd, unsigned long request, ...)
|
||||
switch (request) {
|
||||
case I2C_IOCTL_EXEC:
|
||||
rewrite_i2c_netbsd_to_minix(&i2c, data);
|
||||
addr = (void *) &i2c;
|
||||
addr = (vir_bytes) &i2c;
|
||||
request = MINIX_I2C_IOCTL_EXEC;
|
||||
break;
|
||||
default:
|
||||
/* Keep original as-is */
|
||||
addr = (void *) data;
|
||||
addr = data;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ ssize_t read(int fd, void *buffer, size_t nbytes)
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VFS_READWRITE_FD = fd;
|
||||
m.VFS_READWRITE_LEN = nbytes;
|
||||
m.VFS_READWRITE_BUF = (char *) buffer;
|
||||
m.m_lc_vfs_readwrite.fd = fd;
|
||||
m.m_lc_vfs_readwrite.len = nbytes;
|
||||
m.m_lc_vfs_readwrite.buf = (vir_bytes)buffer;
|
||||
return(_syscall(VFS_PROC_NR, VFS_READ, &m));
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ ssize_t write(int fd, const void *buffer, size_t nbytes)
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VFS_READWRITE_FD = fd;
|
||||
m.VFS_READWRITE_LEN = nbytes;
|
||||
m.VFS_READWRITE_BUF = (char *) __UNCONST(buffer);
|
||||
m.m_lc_vfs_readwrite.fd = fd;
|
||||
m.m_lc_vfs_readwrite.len = nbytes;
|
||||
m.m_lc_vfs_readwrite.buf = (vir_bytes)buffer;
|
||||
return(_syscall(VFS_PROC_NR, VFS_WRITE, &m));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user