Date: Tue, 09 Jun 2009 11:03:49 +0200 From: Ivan Voras <ivoras@freebsd.org> To: freebsd-current@freebsd.org Subject: Re: FS utils treates directories as files? Message-ID: <h0l8gb$57r$1@ger.gmane.org> In-Reply-To: <B7437F9F-A8BF-4F49-AAE4-9B93B62B6223@exscape.org> References: <B7437F9F-A8BF-4F49-AAE4-9B93B62B6223@exscape.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdio.h> #include <stdlib.h> #include <sys/fcntl.h> 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]); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?h0l8gb$57r$1>