posix_fadvise() *returns* error codes but does not set errno
Also updates the fhandler_*::fadvise implementations to adhere to the same semantics.
This commit is contained in:
		
				
					committed by
					
						 Corinna Vinschen
						Corinna Vinschen
					
				
			
			
				
	
			
			
			
						parent
						
							076ce7098f
						
					
				
				
					commit
					8c8cdd9ad7
				
			| @@ -1075,10 +1075,7 @@ int | |||||||
| fhandler_disk_file::fadvise (off_t offset, off_t length, int advice) | fhandler_disk_file::fadvise (off_t offset, off_t length, int advice) | ||||||
| { | { | ||||||
|   if (advice < POSIX_FADV_NORMAL || advice > POSIX_FADV_NOREUSE) |   if (advice < POSIX_FADV_NORMAL || advice > POSIX_FADV_NOREUSE) | ||||||
|     { |     return EINVAL; | ||||||
|       set_errno (EINVAL); |  | ||||||
|       return -1; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|   /* Windows only supports advice flags for the whole file.  We're using |   /* Windows only supports advice flags for the whole file.  We're using | ||||||
|      a simplified test here so that we don't have to ask for the actual |      a simplified test here so that we don't have to ask for the actual | ||||||
| @@ -1097,9 +1094,7 @@ fhandler_disk_file::fadvise (off_t offset, off_t length, int advice) | |||||||
|   NTSTATUS status = NtQueryInformationFile (get_handle (), &io, |   NTSTATUS status = NtQueryInformationFile (get_handle (), &io, | ||||||
| 					    &fmi, sizeof fmi, | 					    &fmi, sizeof fmi, | ||||||
| 					    FileModeInformation); | 					    FileModeInformation); | ||||||
|   if (!NT_SUCCESS (status)) |   if (NT_SUCCESS (status)) | ||||||
|     __seterrno_from_nt_status (status); |  | ||||||
|   else |  | ||||||
|     { |     { | ||||||
|       fmi.Mode &= ~FILE_SEQUENTIAL_ONLY; |       fmi.Mode &= ~FILE_SEQUENTIAL_ONLY; | ||||||
|       if (advice == POSIX_FADV_SEQUENTIAL) |       if (advice == POSIX_FADV_SEQUENTIAL) | ||||||
| @@ -1111,7 +1106,7 @@ fhandler_disk_file::fadvise (off_t offset, off_t length, int advice) | |||||||
|       __seterrno_from_nt_status (status); |       __seterrno_from_nt_status (status); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   return -1; |   return geterrno_from_nt_status (status); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
| @@ -165,8 +165,7 @@ fhandler_pipe::lseek (off_t offset, int whence) | |||||||
| int | int | ||||||
| fhandler_pipe::fadvise (off_t offset, off_t length, int advice) | fhandler_pipe::fadvise (off_t offset, off_t length, int advice) | ||||||
| { | { | ||||||
|   set_errno (ESPIPE); |   return ESPIPE; | ||||||
|   return -1; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
|   | |||||||
| @@ -2937,7 +2937,7 @@ posix_fadvise (int fd, off_t offset, off_t len, int advice) | |||||||
|   if (cfd >= 0) |   if (cfd >= 0) | ||||||
|     res = cfd->fadvise (offset, len, advice); |     res = cfd->fadvise (offset, len, advice); | ||||||
|   else |   else | ||||||
|     set_errno (EBADF); |     res = EBADF; | ||||||
|   syscall_printf ("%R = posix_fadvice(%d, %D, %D, %d)", |   syscall_printf ("%R = posix_fadvice(%d, %D, %D, %d)", | ||||||
| 		  res, fd, offset, len, advice); | 		  res, fd, offset, len, advice); | ||||||
|   return res; |   return res; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user