lkml.org 
[lkml]   [1999]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectUndefined behavior? Or just a feature?
Date
I seem to be able to create files in linux that are 2+ gigs when there is
only 100 MB free...infact I can create dozens of them without problem, and
the disk usage shown by "df" is unaffected, and "du" reports only 4 blocks
on the files. Heres the code that does it :

#include <stdio.h>
#include <stdlib.h>

#define FILESIZE 2000000000

int main(int argc, char **argv) {
FILE *bf;
if (argc != 2) {
fprintf(stderr, "Syntax: %s filename\n", *argv);
return 1;
}
bf = fopen(argv[1], "w+");
if (!bf) {
perror("fopen");
return 2;
}

fseek(bf, FILESIZE, SEEK_SET);
fputc('?', bf);
fclose(bf);
printf("Done\n");
return 0;
}

(there may be errors, I just typed in this in the message and didn't compile
it, but you get the idea)

Regards,
Dave (paradox@maine.rr.com)



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.024 / U:1.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site