Thread: File pre-allocation in NTFS

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    77

    File pre-allocation in NTFS

    I'm trying to do a disk file pre-allocation under XP and Vista programmatically. I'm using just an fseek() positionning on the desired max space at creation time since I've read that if it goes beyond the EOF it automaticcaly fills the empty space with zeroes.
    Well, it doesn't allocate (size 0k under Explorer) if I do just the fseek(). But as soon as I do a write somewhere, righte after it fills-in with spaces.
    Is there any other technique, more reliable, to do file disk pre-allocation?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Try having a look at this:
    http://support.microsoft.com/default...b;EN-US;841551

    The System Call "SetEndOfFile" is supposed to do that.

    How you go about doing that from the C runtime is a more interesting question.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    77
    Thanks Mats, I'll look at. I can do in run time writing a dummy character at the last position of fseek(). I this case I need to keep in mind that dummy. As I'm working with a bunch of files in all kinds of I/O operations I would have liked a "one shot" module at the beginning of the app - C run time of course - to perform the necessary allocations and don't bother after that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 12:13 AM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM