mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 13:00:39 +03:00
[xfer] Generalise metadata "whence" field to "flags" field
iPXE has never supported SEEK_END; the usage of "whence" offers only the options of SEEK_SET and SEEK_CUR and so is effectively a boolean flag. Further flags will be required to support additional metadata required by the Fibre Channel network model, so repurpose the "whence" field as a generic "flags" field. xfer_seek() has always been used with SEEK_SET, so remove the "whence" field altogether from its argument list. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -160,7 +160,7 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
|
||||
int rc;
|
||||
|
||||
/* Calculate new buffer position */
|
||||
if ( meta->whence != SEEK_CUR )
|
||||
if ( meta->flags & XFER_FL_ABS_OFFSET )
|
||||
downloader->pos = 0;
|
||||
downloader->pos += meta->offset;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ static int posix_file_xfer_deliver ( struct posix_file *file,
|
||||
struct xfer_metadata *meta ) {
|
||||
|
||||
/* Keep track of file position solely for the filesize */
|
||||
if ( meta->whence != SEEK_CUR )
|
||||
if ( meta->flags & XFER_FL_ABS_OFFSET )
|
||||
file->pos = 0;
|
||||
file->pos += meta->offset;
|
||||
if ( file->filesize < file->pos )
|
||||
|
||||
@@ -276,18 +276,17 @@ int xfer_printf ( struct interface *intf, const char *format, ... ) {
|
||||
*
|
||||
* @v intf Data transfer interface
|
||||
* @v offset Offset to new position
|
||||
* @v whence Basis for new position
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int xfer_seek ( struct interface *intf, off_t offset, int whence ) {
|
||||
int xfer_seek ( struct interface *intf, off_t offset ) {
|
||||
struct io_buffer *iobuf;
|
||||
struct xfer_metadata meta = {
|
||||
.flags = XFER_FL_ABS_OFFSET,
|
||||
.offset = offset,
|
||||
.whence = whence,
|
||||
};
|
||||
|
||||
DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " seek %s+%ld\n",
|
||||
INTF_DBG ( intf ), whence_text ( whence ), offset );
|
||||
DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " seek to %ld\n",
|
||||
INTF_DBG ( intf ), offset );
|
||||
|
||||
/* Allocate and send a zero-length data buffer */
|
||||
iobuf = xfer_alloc_iob ( intf, 0 );
|
||||
|
||||
Reference in New Issue
Block a user