summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-09-27 17:56:19 +0200
committerJose M. Guisado <jguisado@soleta.eu>2022-09-27 17:56:19 +0200
commit67d9fde94c88d188b5873d9eab0cadcb2cc2e35c (patch)
tree22eecf8718754e1d0954181d255b843708cbebdd /src
parent9bfb511749f4d8488ca6673514a1cccd9a62ce79 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 969e287..298112d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;