lkml.org 
[lkml]   [2004]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: file as a directory
    From
    Date
    On Tue, 2004-12-14 at 17:21, Jan Engelhardt wrote:
    > Recently I discovered that calling "joe /etc" on FreeBSD opens the directory
    > itself (rather than erroring out with EISDIR). The byte string looked like a
    > number of "struct dirent"s. Did it break apps in BSD? I donot think so.

    I don't imagine anyone would miss that behaviour, we can probably have
    something more useful than a
    cat: /etc: Is a directory
    message.

    > >(I am not sure whether the access method, e.g. read() vs. readdir() is
    > >sufficient to distinguish the meaning. Another way may be putting a "/"
    > >after the objectname to indicate that you want it as a directory.)
    >
    > I would not rely on that. Many apps strip a trailing slash (just to add it
    > later again) or vice versa!

    ok, I don't really care about the trailing slash. The reading method
    (read() vs. readdir()) may be enough to distinguish the uses. The
    trailing / is still a useful (and logical) visual notation though for
    the different meanings, so something like ls could give both versions.

    > What will ls do?

    list both /etc/passwd and /etc/passwd/ perhaps?

    > Consider this on a "normal" filesystem:
    >
    > ls -l /etc/passwd
    > -rw-r--r-- 1 root root 1614 Dec 12 23:57 /etc/passwd
    > ls -l /etc
    > [lots of files]
    >
    >
    > What will happen on v4 then?
    > ls -l /etc
    > -rw-r--r-- 1 root root 123456 Dec 01 23:45 /etc
    > ls -l /etc/passwd
    > -rw-r--r-- 1 root root 1234 Dec 01 23:45 root
    > -rw-r--r-- 1 root root 1234 Dec 01 23:45 jengelh
    > -rw-r--r-- 1 root root 1234 Dec 01 23:45 daemon
    > -rw-r--r-- 1 root root 1234 Dec 01 23:45 sys
    > -rw-r--r-- 1 root root 1234 Dec 01 23:45 stduser
    >
    > It's because "ls" checks the type of the argument to decide what to do (unless
    > you add -d).
    >
    >
    > Jan Engelhardt

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

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