Mail Archives: djgpp-workers/2001/01/06/13:40:22
> Date: Sat, 06 Jan 2001 12:43:52 +0000
> From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
>
> Please find below a diff to add the /dev/zero and /dev/full FSEXTs
> to DJGPP.
Thanks. I have a few comments.
> + /* Ensure that we only have relevant flags. */
> + data->flags &= (O_ACCMODE | O_BINARY | O_TEXT | O_NOINHERIT | O_NONBLOCK);
Why do you store O_BINARY and O_TEXT? These are internal library
flags, and since there's no hook for `setmode', if the program
switches /dev/zero to a different mode, your flags will not be
correct.
> + case __FSEXT_ready:
> + /* This must be emulated, since the FSEXT has been called. */
> + emul = 1;
> +
> + *rv = __FSEXT_ready_read | __FSEXT_ready_write;
> + break;
Shouldn't /dev/full be NOT ready for writing? What does `select'
return on Unix systems for the /dev/full device in this case?
> + case __FSEXT_close:
[snip]
> + /* Cope with dup()'d zero devices. */
> + data->dup_count--;
> +
> + if (data->dup_count <= 0) {
> + /* No longer referenced */
> + free(data);
> + _close(fd);
> + }
> + break;
This looks like a handle leak: you only close the handle when it is no
longer referenced. However, internal_dup _always_ calls
__FSEXT_alloc_fd, which always produces a new handle (connected to the
NUL device). So it looks like you don't close those additional
handles when the application closes them.
Or did I miss something?
> + case __FSEXT_lseek:
> + fd = va_arg(args, int);
> + offset = va_arg(args, off_t);
> + whence = va_arg(args, int);
> +
> + /* This must be emulated, since the FSEXT has been called. */
> + emul = 1;
> +
> + *rv = offset;
Even if `offset' and `whence' point before the beginning?
> + #include <sys/xdevices.h>
Is this header used on other platforms?
> + When read, @file{dev/full} always returns @samp{\0} characters. Writes
> + to @file{/dev/full} will fail with @var{errno} set to @code{ENOSPC}.
`errno' should have the @code markup, not @var, because it is not a
formal parameter but a specific variable name.
- Raw text -