cURL / Mailing Lists / curl-users / Single Mail


Re: curl and fallocate

From: Manfred Schwarb <>
Date: Thu, 22 Jan 2015 11:59:52 +0100


follow-up to thread at

Besides the fact that curl does not pre-allocate disk space (which is debatable),
the issue is that it is not possible at the moment to
externally pre-allocate disk space for files when doing downloads using curl.

Curl does unconditionally truncate zero-sized files even in resume mode,
which seems illogical to me.
May I suggest to not truncate output files in resume mode, in any case?

I.e. something like

--- tool_operate.c.orig 2015-01-22 11:01:39.891897312 +0100
+++ tool_operate.c 2015-01-22 11:12:08.800263622 +0100
@@ -602,15 +602,15 @@ static CURLcode operate_do(struct Global
                config->resume_from = 0;

- if(config->resume_from) {
+ if(config->resume_from || config->resume_from_current) {
  #ifdef __VMS
              /* open file for output, forcing VMS output format into stream
                 mode which is needed for stat() call above to always work. */
- FILE *file = fopen(outfile, config->resume_from?"ab":"wb",
+ FILE *file = fopen(outfile, "ab",
                                 "ctx=stm", "rfm=stmlf", "rat=cr", "mrs=0");
              /* open file for output: */
- FILE *file = fopen(outfile, config->resume_from?"ab":"wb");
+ FILE *file = fopen(outfile, "ab");
              if(!file) {
                helpf(global->errors, "Can't open '%s'!\n", outfile);

Then a work flow like the following would become possible:
   rm -f index.html
   fallocate -n -l 500000 index.html
   ~/software/curl-7.39.0.modified/src/curl -C - -o index.html http://localhost/index.html
   ls -l index.html
   du --block-size=1 index.html
   truncate -rindex.htmlindex.html
   du --block-size=1 index.html

What do you think?

List admin:
Received on 2015-01-22