diff options
author | Roland McGrath <roland@gnu.org> | 2000-02-28 04:51:50 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2000-02-28 04:51:50 +0000 |
commit | 655c61ce801fe319aea386ed96e2cb5587200051 (patch) | |
tree | bfbc1cdffbcd24b60c6a30413063e2145c46afae | |
parent | 768aa93a6ffbe038ddae2e46e37c02d4cd54312d (diff) |
2000-02-27 Roland McGrath <roland@baalperazim.frob.com>
* hashexec.c (check_hashbang: user_fd): Add a user ref to DTABLE[FD]
send right, because caller (hurd_file_name_lookup internals) will
consume one.
* hashexec.c (check_hashbang): When dealloc'ing DTABLE ports,
optimize out syscall for null ports.
-rw-r--r-- | exec/hashexec.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/exec/hashexec.c b/exec/hashexec.c index 03981da4..15d67f51 100644 --- a/exec/hashexec.c +++ b/exec/hashexec.c @@ -1,5 +1,5 @@ /* GNU Hurd standard exec server, #! script execution support. - Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc. Written by Roland McGrath. This file is part of the GNU Hurd. @@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License along with the GNU Hurd; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "priv.h" #include <hurd/sigpreempt.h> #include <unistd.h> @@ -57,12 +56,18 @@ check_hashbang (struct execdata *e, file_t user_fd (int fd) { - if (fd < 0 || fd >= dtablesize || dtable[fd] == MACH_PORT_NULL) + if (fd >= 0 && fd < dtablesize) { - errno = EBADF; - return MACH_PORT_NULL; + const file_t dport = dtable[fd]; + if (dport != MACH_PORT_NULL) + { + mach_port_mod_refs (mach_task_self (), dport, + MACH_PORT_RIGHT_SEND, +1); + return dport; + } } - return dtable[fd]; + errno = EBADF; + return MACH_PORT_NULL; } file_t user_crdir, user_cwdir; error_t user_port (int which, error_t (*operate) (mach_port_t)) @@ -318,7 +323,7 @@ check_hashbang (struct execdata *e, = (argvlen - strlen (argv) - 1) /* existing args - old argv[0] */ + interp_len + len + namelen; /* New args */ - new_argv = mmap (0, new_argvlen, PROT_READ|PROT_WRITE, + new_argv = mmap (0, new_argvlen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); if (new_argv == (caddr_t) -1) { @@ -416,7 +421,8 @@ check_hashbang (struct execdata *e, if (! envp_copy) munmap (envp, envplen); for (i = 0; i < dtablesize; ++i) - mach_port_deallocate (mach_task_self (), dtable[i]); + if (MACH_PORT_VALID (dtable[i])) + mach_port_deallocate (mach_task_self (), dtable[i]); if (! dtable_copy) munmap (dtable, dtablesize * sizeof *dtable); for (i = 0; i < nports; ++i) |