made a bit more robust
This commit is contained in:
		
							parent
							
								
									7d131a2cd5
								
							
						
					
					
						commit
						46b57440a0
					
				
					 4 changed files with 8 additions and 3 deletions
				
			
		|  | @ -9,7 +9,9 @@ | |||
| sys_close(fp) | ||||
| 	register File *fp; | ||||
| { | ||||
| 	fp->o_flags = 0; | ||||
| 	close(fp->o_fd); | ||||
| 	fp->o_fd = -1; | ||||
| 	if (fp) { | ||||
| 		fp->o_flags = 0; | ||||
| 		close(fp->o_fd); | ||||
| 		fp->o_fd = -1; | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -12,5 +12,6 @@ sys_read(fp, bufptr, bufsiz, pnbytes) | |||
| 	char *bufptr; | ||||
| 	int bufsiz, *pnbytes; | ||||
| { | ||||
| 	if (! fp) return 0; | ||||
| 	return (*pnbytes = read(fp->o_fd, bufptr, bufsiz)) >= 0; | ||||
| } | ||||
|  |  | |||
|  | @ -14,5 +14,6 @@ sys_seek(fp, off, whence, poff) | |||
| 	long off; | ||||
| 	long *poff; | ||||
| { | ||||
| 	if (! fp) return 0; | ||||
| 	return (*poff = lseek(fp->o_fd, off, whence)) >= 0; | ||||
| } | ||||
|  |  | |||
|  | @ -12,5 +12,6 @@ sys_write(fp, bufptr, nbytes) | |||
| 	char *bufptr; | ||||
| 	int nbytes; | ||||
| { | ||||
| 	if (! fp) return 0; | ||||
| 	return write(fp->o_fd, bufptr, nbytes) == nbytes; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue