kern_exec.c (ed6aff7387a072271291a3c7d9930312d44a5eaa) | kern_exec.c (d323ddf3171ff6652c94cb9f79105f48f5ea8819) |
---|---|
1/* 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 92 unchanged lines hidden (view full) --- 101 struct proc *p; 102 register struct execve_args *uap; 103{ 104 struct nameidata nd, *ndp; 105 register_t *stack_base; 106 int error, len, i; 107 struct image_params image_params, *imgp; 108 struct vattr attr; | 1/* 2 * Copyright (c) 1993, David Greenman 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 92 unchanged lines hidden (view full) --- 101 struct proc *p; 102 register struct execve_args *uap; 103{ 104 struct nameidata nd, *ndp; 105 register_t *stack_base; 106 int error, len, i; 107 struct image_params image_params, *imgp; 108 struct vattr attr; |
109 int (*img_first) __P((struct image_params *)); |
|
109 110 imgp = &image_params; 111 112 /* 113 * Initialize part of the common data 114 */ 115 imgp->proc = p; 116 imgp->uap = uap; --- 52 unchanged lines hidden (view full) --- 169 } 170 171 error = exec_map_first_page(imgp); 172 VOP_UNLOCK(imgp->vp, 0, p); 173 if (error) 174 goto exec_fail_dealloc; 175 176 /* | 110 111 imgp = &image_params; 112 113 /* 114 * Initialize part of the common data 115 */ 116 imgp->proc = p; 117 imgp->uap = uap; --- 52 unchanged lines hidden (view full) --- 170 } 171 172 error = exec_map_first_page(imgp); 173 VOP_UNLOCK(imgp->vp, 0, p); 174 if (error) 175 goto exec_fail_dealloc; 176 177 /* |
177 * Loop through list of image activators, calling each one. 178 * If there is no match, the activator returns -1. If there 179 * is a match, but there was an error during the activation, 180 * the error is returned. Otherwise 0 means success. If the 181 * image is interpreted, loop back up and try activating 182 * the interpreter. | 178 * If the current process has a special image activator it 179 * wants to try first, call it. For example, emulating shell 180 * scripts differently. |
183 */ | 181 */ |
184 for (i = 0; execsw[i]; ++i) { 185 if (execsw[i]->ex_imgact) 186 error = (*execsw[i]->ex_imgact)(imgp); 187 else | 182 error = -1; 183 if ((img_first = imgp->proc->p_sysent->sv_imgact_try) != NULL) 184 error = img_first(imgp); 185 186 /* 187 * Loop through the list of image activators, calling each one. 188 * An activator returns -1 if there is no match, 0 on success, 189 * and an error otherwise. 190 */ 191 for (i = 0; error == -1 && execsw[i]; ++i) { 192 if (execsw[i]->ex_imgact == NULL || 193 execsw[i]->ex_imgact == img_first) { |
188 continue; | 194 continue; |
189 if (error == -1) 190 continue; 191 if (error) 192 goto exec_fail_dealloc; 193 if (imgp->interpreted) { 194 exec_unmap_first_page(imgp); 195 /* free name buffer and old vnode */ 196 NDFREE(ndp, NDF_ONLY_PNBUF); 197 vrele(ndp->ni_vp); 198 /* set new name to that of the interpreter */ 199 NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, 200 UIO_SYSSPACE, imgp->interpreter_name, p); 201 goto interpret; | |
202 } | 195 } |
203 break; | 196 error = (*execsw[i]->ex_imgact)(imgp); |
204 } | 197 } |
205 /* If we made it through all the activators and none matched, exit. */ 206 if (error == -1) { 207 error = ENOEXEC; | 198 199 if (error) { 200 if (error == -1) 201 error = ENOEXEC; |
208 goto exec_fail_dealloc; 209 } 210 211 /* | 202 goto exec_fail_dealloc; 203 } 204 205 /* |
206 * Special interpreter operation, cleanup and loop up to try to 207 * activate the interpreter. 208 */ 209 if (imgp->interpreted) { 210 exec_unmap_first_page(imgp); 211 /* free name buffer and old vnode */ 212 NDFREE(ndp, NDF_ONLY_PNBUF); 213 vrele(ndp->ni_vp); 214 /* set new name to that of the interpreter */ 215 NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, 216 UIO_SYSSPACE, imgp->interpreter_name, p); 217 goto interpret; 218 } 219 220 /* |
|
212 * Copy out strings (args and env) and initialize stack base 213 */ 214 stack_base = exec_copyout_strings(imgp); 215 p->p_vmspace->vm_minsaddr = (char *)stack_base; 216 217 /* 218 * If custom stack fixup routine present for this process 219 * let it do the stack setup. --- 577 unchanged lines hidden --- | 221 * Copy out strings (args and env) and initialize stack base 222 */ 223 stack_base = exec_copyout_strings(imgp); 224 p->p_vmspace->vm_minsaddr = (char *)stack_base; 225 226 /* 227 * If custom stack fixup routine present for this process 228 * let it do the stack setup. --- 577 unchanged lines hidden --- |