From owner-freebsd-current@FreeBSD.ORG Tue Jun 9 09:03:38 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 02C58106566B for ; Tue, 9 Jun 2009 09:03:38 +0000 (UTC) (envelope-from freebsd-current@m.gmane.org) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id B1F928FC1A for ; Tue, 9 Jun 2009 09:03:37 +0000 (UTC) (envelope-from freebsd-current@m.gmane.org) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MDxF0-0003Ba-Cw for freebsd-current@freebsd.org; Tue, 09 Jun 2009 09:03:34 +0000 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Jun 2009 09:03:34 +0000 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 09 Jun 2009 09:03:34 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-current@freebsd.org From: Ivan Voras Date: Tue, 09 Jun 2009 11:03:49 +0200 Lines: 30 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Thunderbird 2.0.0.21 (X11/20090409) In-Reply-To: Sender: news Subject: Re: FS utils treates directories as files? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2009 09:03:38 -0000 Thomas Backman wrote: > FreeBSD 8.0-CURRENT r193521 (Jun 5), bash: > [root@chaos /usr/ports]# file / > /: directory > [root@chaos /usr/ports]# cat / > =EF=BF=BDg=EF=BF=BD=EF=BF=BD=3D[root@chaos /usr/ports]# > [root@chaos /usr/ports]# cat /usr/ports/mail > =EF=BF=BD This is the traditional behaviour because yes, directories are just simply ordinary files with a special bit set to distinguish them. Other systems might have modified "cat" to check if directories are files but it's not standard. You can easily check this yourself. The following small program should work on every unix-ish system: #include #include #include int main() { int fd, i; char buf[512]; =09 fd =3D open(".", O_RDONLY); read(fd, buf, 512); for (i =3D 0; i < 512; i++) printf("%4d ", buf[i]); }