Orion
Barry Adding pipes e59e4fe (2 years, 4 months ago)diff --git a/vfs/vfs.c b/vfs/vfs.c index 68f4b34..c4784f2 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -322,7 +322,7 @@ close(int fd) } /* Read a file */ -size_t +int read(int fd, void *buf, size_t count) { if (!verify_access(buf, count, PROT_WRITE)) @@ -336,11 +336,12 @@ read(int fd, void *buf, size_t count) if (S_ISDIR(file->mode)) return -EISDIR; - return file_read(file, buf, count); + int sz = (int) file_read(file, buf, count); + return sz; } /* Write a file */ -size_t +int write(int fd, void *buf, size_t count) { if (!verify_access(buf, count, PROT_READ)) @@ -354,7 +355,8 @@ write(int fd, void *buf, size_t count) if (S_ISDIR(file->mode)) return -EISDIR; - return file_write(file, buf, count); + int sz = (int) file_write(file, buf, count); + return sz; } /* I/O Control */ @@ -414,12 +416,13 @@ stat(const char *pathname, struct stat *statbuf) if (!inode) return -ENOENT; if (statbuf) { - statbuf->inode = inode->ino; - statbuf->mode = inode->mode; - statbuf->nlink = inode->nlink; - statbuf->uid = inode->uid; - statbuf->gid = inode->gid; - statbuf->size = inode->size; + statbuf->st_dev = inode->dev; + statbuf->st_ino = inode->ino; + statbuf->st_mode = inode->mode; + statbuf->st_nlink = inode->nlink; + statbuf->st_uid = inode->uid; + statbuf->st_gid = inode->gid; + statbuf->st_size = inode->size; } inode_put(inode); return 0; @@ -437,9 +440,15 @@ fstat(int fd, struct stat *statbuf) if (!file) return -EBADF; Inode *inode = file->inode; - statbuf->inode = inode->ino; - statbuf->mode = inode->mode; - statbuf->size = inode->size; + if (statbuf) { + statbuf->st_dev = inode->dev; + statbuf->st_ino = inode->ino; + statbuf->st_mode = inode->mode; + statbuf->st_nlink = inode->nlink; + statbuf->st_uid = inode->uid; + statbuf->st_gid = inode->gid; + statbuf->st_size = inode->size; + } return 0; }