* fhandler.cc (fhandler_base::fork_fixup): Don't protect handle.

* dlfcn.cc: Fix to confirm to coding standards.  Reorganize includes throughout
to accomodate new cygheap.h usage.
* cygheap.h (cygheap_fdmanip): New class: simplifies locking and retrieval of
fds from cygheap->fdtab.
(cygheap_fdget): Ditto.
(cygheap_fdnew): Ditto.
* fcntl.cc (_fcntl): Use new method to lock fdtab and retrieve info.
* ioctl.cc (ioctl): Ditto.
* mmap.cc (mmap): Ditto.
* net.cc: Ditto, throughout.
* passwd.cc (getpass): Ditto.
* path.cc (fchdir): Ditto.
* pipe.cc (make_pipe): Ditto.
* sec_acl.cc (facl): Ditto.
* syscalls.cc: Ditto, throughout.
* termios.cc: Ditto, throughout.
This commit is contained in:
Christopher Faylor
2001-10-15 23:39:33 +00:00
parent fff126983e
commit df63bd490a
24 changed files with 398 additions and 396 deletions

View File

@ -30,22 +30,14 @@ tcsendbreak (int fd, int duration)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcsendbreak (duration);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcsendbreak (duration);
out:
syscall_printf ("%d = tcsendbreak (%d, %d)", res, fd, duration);
@ -60,22 +52,14 @@ tcdrain (int fd)
termios_printf ("tcdrain");
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcdrain ();
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcdrain ();
out:
syscall_printf ("%d = tcdrain (%d)", res, fd);
@ -88,22 +72,14 @@ tcflush (int fd, int queue)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcflush (queue);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcflush (queue);
out:
termios_printf ("%d = tcflush (%d, %d)", res, fd, queue);
@ -116,22 +92,14 @@ tcflow (int fd, int action)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcflow (action);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcflow (action);
out:
syscall_printf ("%d = tcflow (%d, %d)", res, fd, action);
@ -144,24 +112,16 @@ tcsetattr (int fd, int a, const struct termios *t)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
{
set_errno (EBADF);
goto out;
}
cygheap_fdget cfd (fd);
if (cfd < 0)
goto out;
t = __tonew_termios (t);
fhandler_base *fh;
fh = cygheap->fdtab[fd];
if (!fh->is_tty ())
if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = fh->bg_check (-SIGTTOU)) > bg_eof)
res = fh->tcsetattr (a, t);
}
else if ((res = cfd->bg_check (-SIGTTOU)) > bg_eof)
res = cfd->tcsetattr (a, t);
out:
termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d",
@ -178,15 +138,13 @@ tcgetattr (int fd, struct termios *in_t)
int res = -1;
struct termios *t = __makenew_termios (in_t);
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
else if (!cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0)
/* saw an error */;
else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
{
if ((res = cygheap->fdtab[fd]->tcgetattr (t)) == 0)
(void) __toapp_termios (in_t, t);
}
else if ((res = cfd->tcgetattr (t)) == 0)
(void) __toapp_termios (in_t, t);
if (res)
termios_printf ("%d = tcgetattr (%d, %p)", res, fd, in_t);
@ -204,12 +162,13 @@ tcgetpgrp (int fd)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
else if (!cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0)
/* saw an error */;
else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
res = cygheap->fdtab[fd]->tcgetpgrp ();
res = cfd->tcgetpgrp ();
termios_printf ("%d = tcgetpgrp (%d)", res, fd);
return res;
@ -221,12 +180,13 @@ tcsetpgrp (int fd, pid_t pgid)
{
int res = -1;
if (cygheap->fdtab.not_open (fd))
set_errno (EBADF);
else if (!cygheap->fdtab[fd]->is_tty ())
cygheap_fdget cfd (fd);
if (cfd < 0)
/* saw an error */;
else if (!cfd->is_tty ())
set_errno (ENOTTY);
else
res = cygheap->fdtab[fd]->tcsetpgrp (pgid);
res = cfd->tcsetpgrp (pgid);
termios_printf ("%d = tcsetpgrp (%d, %x)", res, fd, pgid);
return res;