delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/04/21:36:17

X-Authentication-Warning: new-smtp2.ihug.com.au: Host p58-max49.syd.ihug.com.au [203.173.144.122] claimed to be acceleron
Message-ID: <00b601c11d4e$1fb7ac30$0a02a8c0@acceleron>
From: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
To: "Charles Sandmann" <sandmann AT clio DOT rice DOT edu>, <djgpp-workers AT delorie DOT com>
Cc: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
References: <10108042310 DOT AA13147 AT clio DOT rice DOT edu>
Subject: Re: Windows 2000 /dev/null permission query
Date: Sun, 5 Aug 2001 11:29:50 +1000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
Reply-To: djgpp-workers AT delorie DOT com

> > In particular, open on /dev/null fails using O_TRUNC
>
> In this case we attempt a write to the device of 0 bytes.  This
> write fails with dos error code of 5 = Access denied.
>
> It appears to me the easiest fix for this is in open.c, which has a
> section which looks like:
>
>   if ((oflag & O_TRUNC) && !should_create)
>     if (_write(fd, 0, 0) < 0)
>       return -1;
>
> would be to ignore the return code from _write in this case:
>
>   if ((oflag & O_TRUNC) && !should_create)
>     _write(fd, 0, 0);
>
> Comments?  Can anyone think of a real case we would expect a write of 0
> bytes to fail and we would want that to be fatal to the open?  The
> handle is open and allocated...

Charles you are spot on with this one.

Tested this with a small test app that is effectively one call to
system("djecho foo >nul\0") and the patch above fixes the problem. I will
try this patch on LIBC and re-build packages again and re-test.

Andrew

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019