Kahli R. Burke wrote:

> SO...how much are those 8TB drives running these days?  Could you spare 
> me a couple?

I wondered who'd call me on that first.  The size of the file is 8 TB.
But it's a sparse file.  It only has 44 nonzero bytes in it, and it
only uses 488 Kb of disk space.

Here's the program that created it.  To use on Linux, compile like
this.

        cc -o bigfile bigfile.c -D_FILE_OFFSET_BITS=64

-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     [EMAIL PROTECTED]
#include <stdio.h>
#include <unistd.h>

#define OFFSET 0x10000000LL

const char filename[] = "a-big-file";

 typedef enum { false = 0, true = 1 } bool;

/* write one byte of "k" just before the specified offset. */

bool writeabyte(int fd, off_t offset)
{
    if (offset <= 0) {
        fprintf(stderr, "writeabyte: invalid argument %lld\n", offset);
        exit(1);
    }
    if (lseek(fd, offset - 1, SEEK_SET) != offset - 1)
        return false;
    if (write(fd, "k", 1) != 1)
        return false;
    printf("Wrote to %lld (0x%llx)\n", offset, offset);
    return true;
}

main()
{
    off_t offset, bump;
    int fd;

    (void) unlink(filename);
    fd = creat(filename, 0666);
    if (fd < 0) {
        perror("creat");
        exit(1);
    }
    for (offset = 1; offset != 0; offset <<= 1)
        if (!writeabyte(fd, offset))
            break;
    for (bump = offset; bump != 0; bump >>= 1) {
        if (writeabyte(fd, offset + bump))
            offset += bump;
    }
    execl("/bin/ls", "ls", "-sl", filename, NULL);
    perror("execl");
    return 1;
}

Reply via email to