提交 5d6e4065 创建 作者: Austin Clements's avatar Austin Clements

Make sys_write prototype agree with user space, which takes a const void*

Most of this is propagating the const-ness through the myriad write functions.
上级 a7d4b8fe
......@@ -14,7 +14,7 @@ struct file : public referenced, public rcu_freed {
int stat(struct stat*);
int read(char *addr, int n);
ssize_t pread(char *addr, size_t n, off_t offset);
int write(char *addr, int n);
int write(const char *addr, int n);
enum { FD_NONE, FD_PIPE, FD_INODE, FD_SOCKET } type;
......@@ -75,7 +75,7 @@ struct inode : public rcu_freed {
struct devsw {
int (*read)(struct inode*, char*, u32, u32);
int (*write)(struct inode*, char*, u32, u32);
int (*write)(struct inode*, const char*, u32, u32);
void (*stat)(struct inode*, struct stat*);
};
......
......@@ -38,7 +38,7 @@ long sys_sbrk(int);
long sys_nsleep(u64);
long sys_unlink(const char*);
long sys_wait(void);
long sys_write(int, char*, int);
long sys_write(int, const void*, int);
long sys_uptime(void);
long sys_map(uptr, u64);
long sys_unmap(uptr, u64);
......
......@@ -95,7 +95,7 @@ void iupdate(struct inode*);
void iunlock(struct inode*);
int readi(struct inode*, char*, u32, u32);
void stati(struct inode*, struct stat*);
int writei(struct inode*, char*, u32, u32);
int writei(struct inode*, const char*, u32, u32);
struct inode* idup(struct inode*);
struct inode* nameiparent(inode *cwd, const char*, char*);
int dirlink(struct inode*, const char*, u32);
......@@ -160,7 +160,7 @@ void piceoi(void);
int pipealloc(struct file**, struct file**);
void pipeclose(struct pipe*, int);
int piperead(struct pipe*, char*, int);
int pipewrite(struct pipe*, char*, int);
int pipewrite(struct pipe*, const char*, int);
// proc.c
struct proc* copyproc(struct proc*);
......@@ -248,4 +248,3 @@ void trapret(void);
void threadstub(void);
void threadhelper(void (*fn)(void *), void *arg);
void trap(struct trapframe *tf);
......@@ -2,7 +2,7 @@
void netclose(int sock);
int netread(int, char *, int);
int netwrite(int, char *, int);
int netwrite(int, const char *, int);
long netsocket(int, int, int);
long netbind(int, void *, int);
long netlisten(int, int);
......
......@@ -210,7 +210,7 @@ panic(const char *fmt, ...)
}
static int
consolewrite(struct inode *ip, char *buf, u32 off, u32 n)
consolewrite(struct inode *ip, const char *buf, u32 off, u32 n)
{
int i;
......
......@@ -102,7 +102,7 @@ file::pread(char *addr, size_t n, off_t off)
}
int
file::write(char *addr, int n)
file::write(const char *addr, int n)
{
int r;
......
......@@ -569,7 +569,7 @@ readi(struct inode *ip, char *dst, u32 off, u32 n)
// PAGEBREAK!
// Write data to inode.
int
writei(struct inode *ip, char *src, u32 off, u32 n)
writei(struct inode *ip, const char *src, u32 off, u32 n)
{
u32 tot, m;
struct buf *bp;
......
......@@ -346,7 +346,7 @@ netclose(int sock)
}
int
netwrite(int sock, char *ubuf, int len)
netwrite(int sock, const char *ubuf, int len)
{
void *kbuf;
int cc;
......@@ -436,7 +436,7 @@ netclose(int sock)
}
int
netwrite(int sock, char *buf, int len)
netwrite(int sock, const char *buf, int len)
{
return -1;
}
......
......@@ -81,7 +81,7 @@ pipeclose(struct pipe *p, int writable)
//PAGEBREAK: 40
int
pipewrite(struct pipe *p, char *addr, int n)
pipewrite(struct pipe *p, const char *addr, int n)
{
int i;
......
......@@ -220,7 +220,7 @@ sampread(struct inode *ip, char *dst, u32 off, u32 n)
}
static int
sampwrite(struct inode *ip, char *buf, u32 off, u32 n)
sampwrite(struct inode *ip, const char *buf, u32 off, u32 n)
{
struct sampconf *conf;
......
......@@ -218,7 +218,7 @@ lockstat_read(struct inode *ip, char *dst, u32 off, u32 n)
}
static int
lockstat_write(struct inode *ip, char *buf, u32 off, u32 n)
lockstat_write(struct inode *ip, const char *buf, u32 off, u32 n)
{
int cmd = buf[0] - '0';
......
......@@ -71,13 +71,13 @@ sys_pread(int fd, void *ubuf, size_t count, off_t offset)
}
long
sys_write(int fd, char *p, int n)
sys_write(int fd, const void *p, int n)
{
sref<file> f;
if (!getfile(fd, &f) || argcheckptr(p, n) < 0)
return -1;
return f->write(p, n);
return f->write(static_cast<const char*>(p), n);
}
long
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论