[lkml]   [2008]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Is there a "blackhole" /dev/null directory?

    On Feb 14 2008 16:19, Hans-Jürgen Koch wrote:
    >> Q: What if a program attempts to mkdir /dev/nullmnt/foo to just
    >> create a file /dev/nullmnt/foo/barfile?
    >> A: /dev/nullmnt/foo must continue to exist or be accepted for a while,
    >> or perhaps for eternity.
    >Well, the problem seems to be that a "directory" is not just data but
    >also contains metadata. While it's easy to write data to /dev/null, you
    >cannot simply discard metadata associated with a directory. So, such a
    >"/dev/null-directory" would have to remember metadata (at least all
    >created filenames including subdirectories) in the same way as other
    >filesystems do. Only file _content_ can be discarded.

    Not even that. Suppose a userspace program (whose output you'd like
    to discard) does:

    int main(void)
    int fd = open("/nullmnt/foo.txt", O_WRONLY | O_CREAT | O_EXCL);

    /* write lots of nonsensical data that we don't need anyway */
    write(fd, "Hello Wor(l)d", 13);

    if (lseek(fd, 0, SEEK_SET) < 0) {
    /* should not happen */
    fprintf(stderr, "Huh, did we write to a pipe or cdev?\n");

    /* verify */
    char buf[13];
    read(fd, buf, 13);
    if (memcmp(buf, "Hello Wor(l)d", 13) != 0)
    fprintf(stderr, "Aïe, disk corruption!\n");

    >To be honest, I still cannot see many sensible usecases for that...

    I agree.
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2008-02-14 16:27    [W:0.025 / U:1.888 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site