Article View: news.software.readers
Article #8108Re: trn 3.4.1 bug: lots of mkdir messages
From: Guy Harris
Date: Wed, 16 Mar 1994 21:46
Date: Wed, 16 Mar 1994 21:46
23 lines
1912 bytes
1912 bytes
>First, ensure that the MAKEDIR define is set to TRUE in common.h (it
>should be). If so, what might be happening is that the line:
>
> if (stat(dirname,&filestat) >= 0 && (filestat.st_mode & S_IFDIR)) {
S_IFDIR is *NOT* a flag bit - it's a value! One should not test whether
a file is a directory or not by testing whether the file's mode, ANDed
with S_IFDIR, is non-zero.
The correct way of checking to see whether the file in question is a
directory would be:
if (stat(dirname,&filestat) >= 0
&& (filestat.st_mode & S_IFMT) == S_IFDIR) {
even if the code, as written, happens to work in most cases. S_IFDIR
on most UNIX systems is 040000; on those systems, (st_mode & S_IFDIR)
tests whether that bit is set, and it happens to be set on block special
files and sockets, as well as on directories. It may well be that said
test doesn't cause problems, given that "stat()" should never return
S_IFLNK as a file type, and that block special files and sockets are
rare files, but it's unwise to do the test in that fashion, even if, at
least on those systems, you can usually get away with it.
Technical Details
Message-ID:
<2m7un1INN113@nova.netapp.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!ctc.com!news.mic.ucla.edu!library.ucla.edu!csulb.edu!csus.edu!netcom.com!netcomsv!netapp.netapp.com!nova.netapp.com!not-for-mailReferences:
<2lqcf8$8g8@bedap.barra.COM> <CMqCvC.35J@borland.com>Show Full Headers
Complete Article Headers
Message-ID: <2m7un1INN113@nova.netapp.com> Subject: Re: trn 3.4.1 bug: lots of mkdir messages Date: Wed, 16 Mar 1994 21:46:09 +0000 From: guy@nova.netapp.com (Guy Harris) References: <2lqcf8$8g8@bedap.barra.COM> <CMqCvC.35J@borland.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!newsserver.jvnc.net!news.cac.psu.edu!news.pop.psu.edu!ctc.com!news.mic.ucla.edu!library.ucla.edu!csulb.edu!csus.edu!netcom.com!netcomsv!netapp.netapp.com!nova.netapp.com!not-for-mail Newsgroups: news.software.readers Organization: Network Appliance Corp. Lines: 24 NNTP-Posting-Host: 192.9.200.13