From: Ian Campbell Subject: Re: [PATCH mini-os enhancements for vtpm 2/8] add posix io to blkfront Date: Tue, 18 Sep 2012 08:27:53 +0100 Message-ID: <1347953273.25803.80.camel@dagon.hellion.org.uk> References: <50579C5F.5040004@jhuapl.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <50579C5F.5040004@jhuapl.edu> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Matthew Fioravante Cc: Samuel Thibault , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org > diff --git a/extras/mini-os/include/lib.h b/extras/mini-os/include/lib.h > --- a/extras/mini-os/include/lib.h > +++ b/extras/mini-os/include/lib.h > @@ -174,6 +174,7 @@ extern struct file { > } tap; > struct { > struct blkfront_dev *dev; > + off_t offset; In indentation here and in several other places in this patch is all over the place. Please try and stick to the prevailing style (tabs vs spaces, numbers of them, brace placement etc) in the surrounding code. > } blk; > struct { > struct kbdfront_dev *dev; > diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c > --- 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 The whitespace in the rest of this hunk is particularly confused. > + 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) { > @@ -445,6 +483,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; > } > >