Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!notecnirp!nfs From: nfs@notecnirp.Princeton.EDU (Norbert Schlenker) Newsgroups: comp.os.minix Subject: Re: 1.5.0 upgrade: REPORT + BUGS + PATCHES Message-ID: <22990@princeton.Princeton.EDU> Date: 11 Jan 90 19:17:02 GMT References: <1990Jan7.205429.5247@chinet.chi.il.us> <363@fwi.uva.nl> Sender: news@princeton.Princeton.EDU Reply-To: nfs@notecnirp.UUCP (Norbert Schlenker) Organization: Dept. of Computer Science, Princeton University Lines: 31 In article <363@fwi.uva.nl> croes@fwi.uva.nl (Felix A. Croes) writes: |In article <1990Jan7.205429.5247@chinet.chi.il.us> bill@chinet.chi.il.us (Bill Mitchell) writes: |> [stuff deleted] |>This is apparently due to some problem below readdir(), so dp->d_name |>isn't returned as expected. Things got complicated pretty fast here. |>Knowing nothing about POSIX stuff, I didn't feel qualified pursue it. |>I did notice that /usr/include/dirent.h had struct dirent.d_name |>declared as "char d_name[1]", which looked suspicious. | |I don't know about POSIX, but it should be at least 14. It was 14 in Minix 1.3, |since file names in directories are 14 bytes long. However, using 14 will cause |problems with numerous incorrect programs which assume that file names in |directories always terminate in \0 (ever tried 1.3 tar?). | |The comment says: /* name of file plus a 0 byte */ , so perhaps 15 should be |used? Does any POSIX wizard know? | |Felix Croes (croes@fwi.uva.nl) I'm no POSIX wizard, but the declaration is reasonable. There has been a long discussion of this in comp.lang.c, the apparent conclusion of which is that this is a reasonably portable construct for a structure that is built by some trusted routine and for which a pointer is returned to a caller (like the return values from readdir()). It was pointed out that the structure definition gives the average programmer the idea that actually allocating such a beast is reasonable. Regrettably, this isn't the case here. Do NOT write programs that use this structure definition - write programs that use a pointer to it. Norbert