replace posix_fallocate with fallocate

posix_fallocate does not return -1 for an error case.

Replace posix_fallocate for fallocate which does return -1 when
something goes wrong. See fallocate(2):

 On success, fallocate() returns zero.
 On error, -1 is returned and errno is set to indicate the error.
master
Jose M. Guisado 2022-09-27 17:56:19 +02:00
parent 9bfb511749
commit 67d9fde94c
1 changed files with 2 additions and 1 deletions

View File

@ -7,6 +7,7 @@
* (at your option) any later version.
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <ev.h>
@ -273,7 +274,7 @@ static int tip_client_head_hdr(struct tip_client *cli)
return -1;
}
if (posix_fallocate(cli->fd, 0, cli->content_len) < 0) {
if (fallocate(cli->fd, 0, 0, cli->content_len) < 0) {
syslog(LOG_ERR, "failed to allocate room for file %s: %s",
filename, strerror(errno));
return -1;