delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/09/17/13:33:53

From: Martin Str|mberg <ams AT ludd DOT luth DOT se>
Message-Id: <200009171733.TAA19894@father.ludd.luth.se>
Subject: O_APPEND
To: djgpp-workers AT delorie DOT com (DJGPP-WORKERS)
Date: Sun, 17 Sep 2000 19:33:16 +0200 (MET DST)
X-Mailer: ELM [version 2.4ME+ PL54 (25)]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

I'm in the process of adding proper O_APPEND functionality.

One thing I'm doing is expanding the __file_handle_modes variable to
an array of unsigned shorts so it'll be able to hold the O_APPEND flag
too.

Then I'm trying to make sure the O_APPEND doesn't disappear by the
plentiful masking operations. E. g. this code in
src/libc/dos/io/setmode.c:

  newmode = (oldmode & ~(O_BINARY|O_TEXT)) | (mode & (O_BINARY|O_TEXT));

becomes:

  newmode = (oldmode & ~(O_BINARY|O_TEXT|O_APPEND)) | (mode & (O_BINARY|O_TEXT|O_APPEND));


Now, in src/libc/posix/unistd/dup2.c there is this code:

int
dup2(int fd, int newfd)
{
  __dpmi_regs r;
  if (fd == newfd)
    return newfd;
  __file_handle_set(newfd, __file_handle_modes[fd] ^ (O_BINARY|O_TEXT));
  r.h.ah = 0x46;
  r.x.bx = fd;
  r.x.cx = newfd;
  __dpmi_int(0x21, &r);
  if (r.x.flags & 1)
  {
    errno = __doserr_to_errno(r.x.ax);
    return -1;
  }
  setmode(newfd, __file_handle_modes[fd]);
  return newfd;
}

I don't understand this so I don't know if O_APPEND should go beside
O_BINARY and O_TEXT or not.

Can anyone enlighten me?


Right,

						MartinS

- Raw text -


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