wok rev 1005

gpxe: fix pxenv_file_read
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jul 07 15:18:59 2008 +0000 (2008-07-07)
parents ff6fa8104a8c
children 71aeaedf0b9b
files gpxe/stuff/default_boot.u
line diff
     1.1 --- a/gpxe/stuff/default_boot.u	Sun Jul 06 21:04:02 2008 +0000
     1.2 +++ b/gpxe/stuff/default_boot.u	Mon Jul 07 15:18:59 2008 +0000
     1.3 @@ -172,7 +172,24 @@
     1.4   
     1.5   /**
     1.6    * FILE OPEN
     1.7 -@@ -189,3 +189,76 @@
     1.8 +@@ -148,12 +148,14 @@
     1.9 + 
    1.10 + 	buffer = real_to_user ( file_read->Buffer.segment,
    1.11 + 				file_read->Buffer.offset );
    1.12 +-	if ( ( len = read_user ( file_read->FileHandle, buffer, 0,
    1.13 ++	while ( ( len = read_user ( file_read->FileHandle, buffer, 0,
    1.14 + 				file_read->BufferSize ) ) < 0 ) {
    1.15 + 		file_read->Status = PXENV_STATUS ( len );
    1.16 ++		if (len == (ssize_t) -1309286401 /* -EWOULDBLOCK */ ) {
    1.17 ++			continue;
    1.18 ++		}
    1.19 + 		return PXENV_EXIT_FAILURE;
    1.20 + 	}
    1.21 +-
    1.22 + 	DBG ( " read %04zx", ( ( size_t ) len ) );
    1.23 + 
    1.24 + 	file_read->BufferSize = len;
    1.25 +@@ -189,3 +191,76 @@
    1.26   	get_file_size->Status = PXENV_STATUS_SUCCESS;
    1.27   	return PXENV_EXIT_SUCCESS;
    1.28   }
    1.29 @@ -249,7 +266,6 @@
    1.30  +		return PXENV_EXIT_SUCCESS;
    1.31  +	}
    1.32  +}
    1.33 -
    1.34  --- gpxe-0.9.3/src/usr/autoboot.c
    1.35  +++ gpxe-0.9.3/src/usr/autoboot.c
    1.36  @@ -120,6 +120,28 @@
    1.37 @@ -304,3 +320,57 @@
    1.38   }
    1.39   
    1.40   /**
    1.41 +
    1.42 +--- gpxe-0.9.3/src/interface/pxe/pxe_tftp.c
    1.43 ++++ gpxe-0.9.3/src/interface/pxe/pxe_tftp.c
    1.44 +@@ -189,7 +189,7 @@
    1.45 + 	if ( blksize < TFTP_DEFAULT_BLKSIZE )
    1.46 + 		blksize = TFTP_DEFAULT_BLKSIZE;
    1.47 + 	snprintf ( uri_string, sizeof ( uri_string ),
    1.48 +-		   "tftp://%s:%d%s%s?blksize=%d",
    1.49 ++		   "tftp://%s:%d%s%s?blksize=%zd",
    1.50 + 		   inet_ntoa ( address ), ntohs ( port ),
    1.51 + 		   ( ( filename[0] == '/' ) ? "" : "/" ), filename, blksize );
    1.52 + 	DBG ( " %s", uri_string );
    1.53 +--- gpxe-0.9.3/src/core/posix_io.c
    1.54 ++++ gpxe-0.9.3/src/core/posix_io.c
    1.55 +@@ -114,7 +114,7 @@
    1.56 + static int
    1.57 + posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
    1.58 + 			      struct io_buffer *iobuf,
    1.59 +-			      struct xfer_metadata *meta __unused ) {
    1.60 ++			      struct xfer_metadata *meta ) {
    1.61 + 	struct posix_file *file =
    1.62 + 		container_of ( xfer, struct posix_file, xfer );
    1.63 + 
    1.64 +@@ -125,7 +125,12 @@
    1.65 + 	if ( file->filesize < file->pos )
    1.66 + 		file->filesize = file->pos;
    1.67 + 
    1.68 +-	list_add_tail ( &iobuf->list, &file->data );
    1.69 ++	if ( iob_len ( iobuf ) ) {
    1.70 ++		list_add_tail ( &iobuf->list, &file->data );
    1.71 ++	} else {
    1.72 ++		free_iob ( iobuf );
    1.73 ++	}
    1.74 ++
    1.75 + 	return 0;
    1.76 + }
    1.77 + 
    1.78 +@@ -293,12 +298,15 @@
    1.79 + 			free_iob ( iobuf );
    1.80 + 		}
    1.81 + 		file->pos += len;
    1.82 ++		assert ( len != 0 );
    1.83 + 		return len;
    1.84 + 	}
    1.85 + 
    1.86 + 	/* If file has completed, return (after returning all data) */
    1.87 +-	if ( file->rc != -EINPROGRESS )
    1.88 ++	if ( file->rc != -EINPROGRESS ) {
    1.89 ++		assert ( list_empty ( &file->data ) );
    1.90 + 		return file->rc;
    1.91 ++	}
    1.92 + 
    1.93 + 	/* No data ready and file still in progress; return -WOULDBLOCK */
    1.94 + 	return -EWOULDBLOCK;