cbfstool: Don't use fileno() to get file size
fileno() is a mess on some operating systems. Don't deliberately convert between FILE * and file handles. Change-Id: I5be62a731f928333ea2e5843d81f541453fdb396 Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-on: http://review.coreboot.org/11636 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 Stefan Reinauer
						Stefan Reinauer
					
				
			
			
				
	
			
			
			
						parent
						
							d66f1da846
						
					
				
				
					commit
					1bb487c474
				
			| @@ -46,14 +46,14 @@ int is_big_endian(void) | |||||||
|  |  | ||||||
| static off_t get_file_size(FILE *f) | static off_t get_file_size(FILE *f) | ||||||
| { | { | ||||||
| 	struct stat s; | 	off_t fsize; | ||||||
| 	int fd = fileno(f); | 	fseek(f, 0, SEEK_END); | ||||||
| 	if (fd == -1) return -1; | 	fsize = ftell(f); | ||||||
| 	if (fstat(fd, &s) == -1) return -1; | 	fseek(f, 0, SEEK_SET); | ||||||
| 	return s.st_size; | 	return fsize; | ||||||
| } | } | ||||||
| /* Buffer and file I/O */ |  | ||||||
|  |  | ||||||
|  | /* Buffer and file I/O */ | ||||||
| int buffer_create(struct buffer *buffer, size_t size, const char *name) | int buffer_create(struct buffer *buffer, size_t size, const char *name) | ||||||
| { | { | ||||||
| 	buffer->name = strdup(name); | 	buffer->name = strdup(name); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user