Charlie Gordon wrote:
> "Tor Rustad" <> a écrit dans le message de
[...]
>> # touch /big
>> # time ./a.out
>>
>> real 0m0.002s
>> user 0m0.000s
>> sys 0m0.004s
>>
>>
>> so ISO C, is clearly not the best tool around for this job. 
>
> This solution for POSIX systems has been mentioned already.
So? I timed it.
> Your program does not make a 2+GB file, but a small 2.2 megabyte one.
Ooops, that number was a copy-paste from another post, I didn't pay
attention to it! However, creating a 2 Mb or a 2 Gb file with this
method, shouldn't make much of a time difference:
# time ./mr_big
File '/big' of 4Gb has been created
real 0m0.002s
user 0m0.000s
sys 0m0.000s
# ls -l /big
-rw-r--r-- 1 root root 4294967295 2007-09-17 20:04 /big
right?
> Changing the number to the requested size will not work on most 32 bit
> systems.
On a 32-bit system, I used
gcc -D_FILE_OFFSET_BITS=64 mr_big.c -o mr_big
of course, you need file system support for >2 Gb files too.
> Most unix users cannot create files in the root directory either, and don't
> program as root.
Most UNIX users... isn't a Norse God.
--
Tor <torust [at] online [dot] no>