home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
archives
/
utils.tar.gz
/
utils.tar
/
bigfile.c
< prev
next >
Wrap
C/C++ Source or Header
|
2009-12-17
|
1KB
|
42 lines
/*
bigfile.c - Make a big file that doesn't actually take up any disk space.
To build on 64-bit Linux: "make bigfile"
To build on 32-bit Linux:
make bigfile "CFLAGS=-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
To build on Solaris: "make bigfile CFLAGS=-xarch=generic64"
F. da Cruz, Columbia University, 24 Dec 2005
*/
#include <stdio.h>
#include <sys/types.h>
main() {
FILE * fp;
off_t offset;
offset = 3000000000LL; /* > 2^31 */
offset = 4300000000LL; /* > 2^32 */
if ((int)(sizeof(off_t)) < 8) {
printf("sizeof off_t is %d - can't make big files\n",
(int)(sizeof(off_t))
);
}
printf("sizeof off_t: %d\n", (int)(sizeof(off_t)));
/* Create the file */
if (!(fp = fopen("BIGFILE","w"))) {
perror("fopen BIGFILE\n");
exit(1);
}
/* Seek to a spot at the desired offset */
/* (This gets EINVAL errors on old Linux versions like RH6.1 */
/* even though off_t is 64 bits). */
if (fseeko(fp,offset,SEEK_SET) < 0) {
perror("fseeko");
exit(1);
}
/* Write one byte at the far end */
if (fputc('x',fp) == EOF) {
perror("fputc");
exit(1);
}
fclose(fp);
exit(0);
}