diff options
author | Matthew Fioravante <matthew.fioravante@jhuapl.edu> | 2012-10-09 10:39:08 +0100 |
---|---|---|
committer | Matthew Fioravante <matthew.fioravante@jhuapl.edu> | 2012-10-09 10:39:08 +0100 |
commit | 78ef2bb502c15bd7ef117a365e6afc7dee4ad71b (patch) | |
tree | 8c1bccdac8f713ad0a78567a4f5aa657aaae6c55 /extras/mini-os/lib | |
parent | 8e19000995c69250aa60bf40bfd7f158a4894d44 (diff) | |
download | xen-78ef2bb502c15bd7ef117a365e6afc7dee4ad71b.tar.gz xen-78ef2bb502c15bd7ef117a365e6afc7dee4ad71b.tar.bz2 xen-78ef2bb502c15bd7ef117a365e6afc7dee4ad71b.zip |
minios: add posix io for blkfront
This patch adds posix io support (read,write,lseek) to block devices
using blkfront.
Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'extras/mini-os/lib')
-rw-r--r-- | extras/mini-os/lib/sys.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c index 3172d2a60f..6cb97b1932 100644 --- a/extras/mini-os/lib/sys.c +++ b/extras/mini-os/lib/sys.c @@ -289,6 +289,11 @@ int read(int fd, void *buf, size_t nbytes) return ret * sizeof(union xenfb_in_event); } #endif +#ifdef CONFIG_BLKFRONT + case FTYPE_BLK: { + return blkfront_posix_read(fd, buf, nbytes); + } +#endif default: break; } @@ -321,6 +326,10 @@ int write(int fd, const void *buf, size_t nbytes) netfront_xmit(files[fd].tap.dev, (void*) buf, nbytes); return nbytes; #endif +#ifdef CONFIG_BLKFRONT + case FTYPE_BLK: + return blkfront_posix_write(fd, buf, nbytes); +#endif default: break; } @@ -331,8 +340,37 @@ int write(int fd, const void *buf, size_t nbytes) off_t lseek(int fd, off_t offset, int whence) { - errno = ESPIPE; - return (off_t) -1; + switch(files[fd].type) { +#ifdef CONFIG_BLKFRONT + case FTYPE_BLK: + switch (whence) { + case SEEK_SET: + files[fd].file.offset = offset; + break; + case SEEK_CUR: + files[fd].file.offset += offset; + break; + case SEEK_END: + { + struct stat st; + int ret; + ret = fstat(fd, &st); + if (ret) + return -1; + files[fd].file.offset = st.st_size + offset; + break; + } + default: + errno = EINVAL; + return -1; + } + return files[fd].file.offset; + break; +#endif + default: /* Not implemented on this FTYPE */ + errno = ESPIPE; + return (off_t) -1; + } } int fsync(int fd) { @@ -447,6 +485,10 @@ int fstat(int fd, struct stat *buf) buf->st_ctime = time(NULL); return 0; } +#ifdef CONFIG_BLKFRONT + case FTYPE_BLK: + return blkfront_posix_fstat(fd, buf); +#endif default: break; } |