public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
From: Mensch <bausparkasse@gmx.de>
To: linux-newbie list <linux-newbie@vger.kernel.org>
Subject: Re: allocating disk space the fast way
Date: Sat, 05 Aug 2006 18:06:51 +0000	[thread overview]
Message-ID: <1154801212.1885.16.camel@Marvin> (raw)
In-Reply-To: <1154799802.1885.9.camel@Marvin>

it's me again.
i'm sorry, but i found a way myself.

written in c:

/*** START OF filesize_alloc.c ***/

#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <linux/unistd.h>
#include <errno.h>

int main(int argc, char **argv) {
	FILE *newfile;
	char *filename = "blub.img";
	int size_in_bytes = 2000*(1024*1024); /* 2000 MB */

	 /* create a new file char *filename or overwrite it */
	newfile = fopen(filename, "w");
	 /* now jump to byte int size_in_bytes from start... */
	fseek(newfile, size_in_bytes, SEEK_SET);
	 /* ... and write a final zero at this position */
	fwrite("\0", 1, 1, newfile); 
	fclose(newfile);
}

/*** END OF filesize_alloc.c ***/

Am Samstag, den 05.08.2006, 17:43 +0000 schrieb Mensch:
> hello list.
> i want to allocate some space for a harddisk image file.
> for now, i do it like
> $ dd if=/dev/zero of=blub.img bs=1M count=2000
> which takes some time. is there a faster way to create a huge file? it
> don't have to be zeroed.
> i've seen that e.g. azureus allocates filesize in no time. how does this
> work?
> 
> thanks in advance,
> josef gosch

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

  reply	other threads:[~2006-08-05 18:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-05 17:43 allocating disk space the fast way Mensch
2006-08-05 18:06 ` Mensch [this message]
2006-10-14 17:35 ` Eric Bambach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1154801212.1885.16.camel@Marvin \
    --to=bausparkasse@gmx.de \
    --cc=linux-newbie@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox