From: Ben Gras Date: Mon, 21 Sep 2009 14:49:26 +0000 (+0000) Subject: - some exec debugging prints when errors happen X-Git-Tag: v3.1.5~118 X-Git-Url: http://zhaoyanbai.com/repos/nsupdate.html?a=commitdiff_plain;h=f5459e38db44f5528f21a6421ce31424ddbaa386;p=minix.git - some exec debugging prints when errors happen - lookup mounted_on check to avoid NULL dereference - some errors in exec() shouldn't be fatal --- diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index e55da6bbd..cde7151c7 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -104,8 +104,6 @@ printf("return at %s, %d\n", __FILE__, __LINE__); /* Fetch the stack from the user before destroying the old core image. */ if (frame_len > ARG_MAX) { - printf("pm_exec: bad frame_len\n"); -printf("return at %s, %d\n", __FILE__, __LINE__); return(ENOMEM); /* stack too big */ } r = sys_datacopy(proc_e, (vir_bytes) frame, @@ -210,7 +208,7 @@ printf("return at %s, %d\n", __FILE__, __LINE__); progname, new_uid, new_gid, &stack_top, &load_text, &allow_setuid); if (r != OK) { - printf("pm_exec: exec_newmap failed: %d\n", r); + printf("VFS: pm_exec: exec_newmem failed: %d\n", r); put_vnode(vp); return r; } @@ -223,7 +221,7 @@ printf("return at %s, %d\n", __FILE__, __LINE__); proc_e, (vir_bytes) vsp, (phys_bytes)frame_len); if (r != OK) { printf("vfs: datacopy returns %d trying to copy to %p\n", r, vsp); - panic(__FILE__,"pm_exec stack copy err on", proc_e); + return r; } off = hdrlen; @@ -591,7 +589,11 @@ phys_bytes seg_bytes; /* how much is to be transferred? */ char buf[1024]; /* Make sure that the file is big enough */ - if (vp->v_size < off+seg_bytes) return EIO; + if (vp->v_size < off+seg_bytes) { + printf("VFS: read_seg: file isn't big enough (size %ld, need %ld)\n", + vp->v_size, off+seg_bytes); + return EIO; + } if (seg != D) { @@ -612,7 +614,10 @@ printf("read_seg for user %d, seg %d: buf 0x%x, size %d, pos %d\n", r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, vp->v_index, cvul64(off+o), READING, FS_PROC_NR, buf, n, &new_pos, &cum_io_incr); - if (r != OK) return r; + if (r != OK) { + printf("VFS: read_seg: req_readwrite failed (text)\n"); + return r; + } if (cum_io_incr != n) { @@ -623,8 +628,10 @@ printf("read_seg for user %d, seg %d: buf 0x%x, size %d, pos %d\n", r= sys_vircopy(FS_PROC_NR, D, (vir_bytes)buf, proc_e, seg, o, n); - if (r != OK) + if (r != OK) { + printf("VFS: read_seg: copy failed (text)\n"); return r; + } o += n; } @@ -639,7 +646,10 @@ printf("read_seg for user %d, seg %d: buf 0x%x, size %d, pos %d\n", /* Issue request */ r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, vp->v_index, cvul64(off), READING, proc_e, 0, seg_bytes, &new_pos, &cum_io_incr); - if (r != OK) return r; + if (r != OK) { + printf("VFS: read_seg: req_readwrite failed (data)\n"); + return r; + } if (r == OK && cum_io_incr != seg_bytes) printf("VFSread_seg segment has not been read properly by exec() \n"); diff --git a/servers/vfs/main.c b/servers/vfs/main.c index 49bb67408..ff875d298 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "file.h" #include "fproc.h" #include "param.h" @@ -59,6 +60,10 @@ PUBLIC int main() SANITYCHECK; +#if DO_SANITYCHECKS + FIXME("VFS: DO_SANITYCHECKS is on"); +#endif + /* This is the main loop that gets work, processes it, and sends replies. */ while (TRUE) { SANITYCHECK; @@ -285,9 +290,14 @@ PRIVATE void get_work() continue; } if(who_p >= 0 && fproc[who_p].fp_endpoint != who_e) { - printf("FS: receive endpoint inconsistent (%d, %d, %d).\n", - who_e, fproc[who_p].fp_endpoint, who_e); + if(fproc[who_p].fp_endpoint == NONE) { + printf("slot unknown even\n"); + } + printf("FS: receive endpoint inconsistent (source %d, who_p %d, stored ep %d, who_e %d).\n", + m_in.m_source, who_p, fproc[who_p].fp_endpoint, who_e); +#if 0 panic(__FILE__, "FS: inconsistent endpoint ", NO_NUM); +#endif continue; } call_nr = m_in.m_type; diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 3258d182a..e19f98a58 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -241,7 +241,7 @@ node_details_t *node; struct vnode *dir_vp; struct vmnt *vmp; struct lookup_res res; - + /* Empty (start) path? */ if (user_fullpath[0] == '\0') { node->inode_nr = 0; @@ -308,10 +308,18 @@ node_details_t *node; dir_vp = 0; /* Start node is now the mounted partition's root node */ for (vmp = &vmnt[0]; vmp != &vmnt[NR_MNTS]; ++vmp) { - if (vmp->m_mounted_on->v_inode_nr == res.inode_nr && - vmp->m_mounted_on->v_fs_e == res.fs_e) { + if (vmp->m_dev != NO_DEV) { + if(vmp->m_mounted_on && + vmp->m_mounted_on->v_inode_nr == + res.inode_nr && + vmp->m_mounted_on->v_fs_e == res.fs_e) { dir_vp = vmp->m_root_node; + if(!dir_vp) { + panic(__FILE__, + "vfs: root_node NULL", NO_NUM); + } break; + } } } if (!dir_vp) { diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 0db338bcf..8649a5949 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -126,7 +126,11 @@ mode_t *new_modep; m.REQ_INODE_NR = inode_nr; m.REQ_UID = fp->fp_effuid; m.REQ_GID = fp->fp_effgid; + if (newuid == -1) + newuid = fp->fp_effuid; m.REQ_NEW_UID = newuid; + if (newgid == -1) + newgid = fp->fp_effgid; m.REQ_NEW_GID = newgid; /* Send/rec request */