810 /* -------------------------- VFS_IO functions -------------------------- */ |
810 /* -------------------------- VFS_IO functions -------------------------- */ |
811 |
811 |
812 ssize_t pg_vfs_io_read(SYS_FILE fd, void *buf, size_t nbyte) { |
812 ssize_t pg_vfs_io_read(SYS_FILE fd, void *buf, size_t nbyte) { |
813 PgVFS *pgvfs = fd->ctx->vfs->instance; |
813 PgVFS *pgvfs = fd->ctx->vfs->instance; |
814 PgFile *pg = fd->data; |
814 PgFile *pg = fd->data; |
|
815 if(pg->fd < 0) return-1; |
815 return lo_read(pgvfs->connection, pg->fd, buf, nbyte); |
816 return lo_read(pgvfs->connection, pg->fd, buf, nbyte); |
816 } |
817 } |
817 |
818 |
818 ssize_t pg_vfs_io_write(SYS_FILE fd, const void *buf, size_t nbyte) { |
819 ssize_t pg_vfs_io_write(SYS_FILE fd, const void *buf, size_t nbyte) { |
819 PgVFS *pgvfs = fd->ctx->vfs->instance; |
820 PgVFS *pgvfs = fd->ctx->vfs->instance; |
820 PgFile *pg = fd->data; |
821 PgFile *pg = fd->data; |
|
822 if(pg->fd < 0) return-1; |
821 return lo_write(pgvfs->connection, pg->fd, buf, nbyte); |
823 return lo_write(pgvfs->connection, pg->fd, buf, nbyte); |
822 } |
824 } |
823 |
825 |
824 ssize_t pg_vfs_io_pread(SYS_FILE fd, void *buf, size_t nbyte, off_t offset) { |
826 ssize_t pg_vfs_io_pread(SYS_FILE fd, void *buf, size_t nbyte, off_t offset) { |
825 PgVFS *pgvfs = fd->ctx->vfs->instance; |
827 PgVFS *pgvfs = fd->ctx->vfs->instance; |
826 PgFile *pg = fd->data; |
828 PgFile *pg = fd->data; |
|
829 if(pg->fd < 0) return-1; |
827 if(lo_lseek64(pgvfs->connection, pg->fd, offset, SEEK_SET) == -1) { |
830 if(lo_lseek64(pgvfs->connection, pg->fd, offset, SEEK_SET) == -1) { |
828 return -1; |
831 return -1; |
829 } |
832 } |
830 return lo_read(pgvfs->connection, pg->fd, buf, nbyte); |
833 return lo_read(pgvfs->connection, pg->fd, buf, nbyte); |
831 } |
834 } |
832 |
835 |
833 ssize_t pg_vfs_io_pwrite(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset) { |
836 ssize_t pg_vfs_io_pwrite(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset) { |
834 PgVFS *pgvfs = fd->ctx->vfs->instance; |
837 PgVFS *pgvfs = fd->ctx->vfs->instance; |
835 PgFile *pg = fd->data; |
838 PgFile *pg = fd->data; |
|
839 if(pg->fd < 0) return-1; |
836 if(lo_lseek64(pgvfs->connection, pg->fd, offset, SEEK_SET) == -1) { |
840 if(lo_lseek64(pgvfs->connection, pg->fd, offset, SEEK_SET) == -1) { |
837 return -1; |
841 return -1; |
838 } |
842 } |
839 return lo_write(pgvfs->connection, pg->fd, buf, nbyte); |
843 return lo_write(pgvfs->connection, pg->fd, buf, nbyte); |
840 } |
844 } |
841 |
845 |
842 off_t pg_vfs_io_seek(SYS_FILE fd, off_t offset, int whence) { |
846 off_t pg_vfs_io_seek(SYS_FILE fd, off_t offset, int whence) { |
843 PgVFS *pgvfs = fd->ctx->vfs->instance; |
847 PgVFS *pgvfs = fd->ctx->vfs->instance; |
844 PgFile *pg = fd->data; |
848 PgFile *pg = fd->data; |
|
849 if(pg->fd < 0) return-1; |
845 return lo_lseek64(pgvfs->connection, pg->fd, offset, whence); |
850 return lo_lseek64(pgvfs->connection, pg->fd, offset, whence); |
846 } |
851 } |
847 |
852 |
848 off_t pg_vfs_io_tell(SYS_FILE fd) { |
853 off_t pg_vfs_io_tell(SYS_FILE fd) { |
849 PgVFS *pgvfs = fd->ctx->vfs->instance; |
854 PgVFS *pgvfs = fd->ctx->vfs->instance; |
850 PgFile *pg = fd->data; |
855 PgFile *pg = fd->data; |
|
856 if(pg->fd < 0) return-1; |
851 return lo_tell64(pgvfs->connection, pg->fd); |
857 return lo_tell64(pgvfs->connection, pg->fd); |
852 } |
858 } |
853 |
859 |
854 void pg_vfs_io_close(SYS_FILE fd) { |
860 void pg_vfs_io_close(SYS_FILE fd) { |
855 pool_handle_t *pool = fd->ctx->pool; |
861 pool_handle_t *pool = fd->ctx->pool; |