提交 e89a9667 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Add an offset argument to device read and write functions

上级 2022c007
...@@ -170,7 +170,7 @@ panic(const char *s) ...@@ -170,7 +170,7 @@ panic(const char *s)
} }
static int static int
consolewrite(struct inode *ip, char *buf, int n) consolewrite(struct inode *ip, char *buf, u32 off, u32 n)
{ {
int i; int i;
...@@ -252,7 +252,7 @@ consoleintr(int (*getc)(void)) ...@@ -252,7 +252,7 @@ consoleintr(int (*getc)(void))
} }
static int static int
consoleread(struct inode *ip, char *dst, int n) consoleread(struct inode *ip, char *dst, u32 off, u32 n)
{ {
int target; int target;
int c; int c;
......
...@@ -42,10 +42,11 @@ struct inode { ...@@ -42,10 +42,11 @@ struct inode {
// device implementations // device implementations
struct devsw { struct devsw {
int (*read)(struct inode*, char*, int); int (*read)(struct inode*, char*, u32, u32);
int (*write)(struct inode*, char*, int); int (*write)(struct inode*, char*, u32, u32);
}; };
extern struct devsw devsw[]; extern struct devsw devsw[];
#define CONSOLE 1 #define CONSOLE 1
#define NETIF 2
...@@ -516,7 +516,7 @@ readi(struct inode *ip, char *dst, u32 off, u32 n) ...@@ -516,7 +516,7 @@ readi(struct inode *ip, char *dst, u32 off, u32 n)
if(ip->type == T_DEV){ if(ip->type == T_DEV){
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
return -1; return -1;
return devsw[ip->major].read(ip, dst, n); return devsw[ip->major].read(ip, dst, off, n);
} }
if(off > ip->size || off + n < off) if(off > ip->size || off + n < off)
...@@ -544,7 +544,7 @@ writei(struct inode *ip, char *src, u32 off, u32 n) ...@@ -544,7 +544,7 @@ writei(struct inode *ip, char *src, u32 off, u32 n)
if(ip->type == T_DEV){ if(ip->type == T_DEV){
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
return -1; return -1;
return devsw[ip->major].write(ip, src, n); return devsw[ip->major].write(ip, src, off, n);
} }
if(off > ip->size || off + n < off) if(off > ip->size || off + n < off)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论