2006-05-11 16:57:23 +02:00
|
|
|
/* This file handles the EXEC system call. It performs the work as follows:
|
|
|
|
* - see if the permissions allow the file to be executed
|
|
|
|
* - read the header and extract the sizes
|
|
|
|
* - fetch the initial args and environment from the user space
|
|
|
|
* - allocate the memory for the new process
|
|
|
|
* - copy the initial stack from PM to the process
|
|
|
|
* - read in the text and data segments and copy to the process
|
|
|
|
* - take care of setuid and setgid bits
|
|
|
|
* - fix up 'mproc' table
|
|
|
|
* - tell kernel about EXEC
|
|
|
|
* - save offset to initial argc (for ps)
|
|
|
|
*
|
|
|
|
* The entry points into this file are:
|
|
|
|
* pm_exec: perform the EXEC system call
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/endpoint.h>
|
|
|
|
#include <minix/com.h>
|
2006-11-27 15:21:43 +01:00
|
|
|
#include <minix/u64.h>
|
2006-05-11 16:57:23 +02:00
|
|
|
#include <a.out.h>
|
|
|
|
#include <signal.h>
|
2010-12-10 10:27:56 +01:00
|
|
|
#include <stdlib.h>
|
2006-05-11 16:57:23 +02:00
|
|
|
#include <string.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <dirent.h>
|
2010-12-10 10:27:56 +01:00
|
|
|
#include <sys/param.h>
|
2006-05-11 16:57:23 +02:00
|
|
|
#include "fproc.h"
|
2012-02-13 16:28:04 +01:00
|
|
|
#include "path.h"
|
2006-05-11 16:57:23 +02:00
|
|
|
#include "param.h"
|
2006-10-25 15:40:36 +02:00
|
|
|
#include "vnode.h"
|
|
|
|
#include <minix/vfsif.h>
|
2010-12-10 10:27:56 +01:00
|
|
|
#include <assert.h>
|
|
|
|
#include <libexec.h>
|
|
|
|
#include "exec.h"
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static void lock_exec(void);
|
|
|
|
static void unlock_exec(void);
|
|
|
|
static int exec_newmem(int proc_e, vir_bytes text_addr, vir_bytes
|
2012-03-24 16:16:34 +01:00
|
|
|
text_bytes, vir_bytes data_addr, vir_bytes data_bytes, vir_bytes
|
|
|
|
tot_bytes, vir_bytes frame_len, int sep_id, int is_elf, dev_t st_dev,
|
|
|
|
ino_t st_ino, time_t ctime, char *progname, int new_uid, int new_gid,
|
|
|
|
vir_bytes *stack_topp, int *load_textp, int *setugidp);
|
2012-03-25 20:25:53 +02:00
|
|
|
static int is_script(const char *exec_hdr, size_t exec_len);
|
|
|
|
static int patch_stack(struct vnode *vp, char stack[ARG_MAX], vir_bytes
|
2012-03-24 16:16:34 +01:00
|
|
|
*stk_bytes, char path[PATH_MAX]);
|
2012-03-25 20:25:53 +02:00
|
|
|
static int insert_arg(char stack[ARG_MAX], vir_bytes *stk_bytes, char
|
2012-03-24 16:16:34 +01:00
|
|
|
*arg, int replace);
|
2012-03-25 20:25:53 +02:00
|
|
|
static void patch_ptr(char stack[ARG_MAX], vir_bytes base);
|
|
|
|
static void clo_exec(struct fproc *rfp);
|
|
|
|
static int read_seg(struct vnode *vp, off_t off, int proc_e, int seg,
|
2012-03-24 16:16:34 +01:00
|
|
|
vir_bytes seg_addr, phys_bytes seg_bytes);
|
2012-03-25 20:25:53 +02:00
|
|
|
static int load_aout(struct exec_info *execi);
|
|
|
|
static int load_elf(struct exec_info *execi);
|
|
|
|
static int map_header(char **exec_hdr, const struct vnode *vp);
|
2006-05-11 16:57:23 +02:00
|
|
|
|
|
|
|
#define PTRSIZE sizeof(char *) /* Size of pointers in argv[] and envp[]. */
|
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
/* Array of loaders for different object file formats */
|
|
|
|
struct exec_loaders {
|
|
|
|
int (*load_object)(struct exec_info *);
|
2012-02-13 16:28:04 +01:00
|
|
|
};
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static const struct exec_loaders exec_loaders[] = {
|
2010-12-10 10:27:56 +01:00
|
|
|
{ load_aout },
|
|
|
|
{ load_elf },
|
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
2012-03-25 20:25:53 +02:00
|
|
|
static char hdr[PAGE_SIZE]; /* Assume that header is not larger than a page */
|
2012-02-13 16:28:04 +01:00
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* lock_exec *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void lock_exec(void)
|
2012-02-13 16:28:04 +01:00
|
|
|
{
|
|
|
|
message org_m_in;
|
|
|
|
struct fproc *org_fp;
|
|
|
|
struct worker_thread *org_self;
|
|
|
|
|
|
|
|
/* First try to get it right off the bat */
|
|
|
|
if (mutex_trylock(&exec_lock) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
org_m_in = m_in;
|
|
|
|
org_fp = fp;
|
|
|
|
org_self = self;
|
|
|
|
|
|
|
|
if (mutex_lock(&exec_lock) != 0)
|
|
|
|
panic("Could not obtain lock on exec");
|
|
|
|
|
|
|
|
m_in = org_m_in;
|
|
|
|
fp = org_fp;
|
|
|
|
self = org_self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* unlock_exec *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void unlock_exec(void)
|
2012-02-13 16:28:04 +01:00
|
|
|
{
|
|
|
|
if (mutex_unlock(&exec_lock) != 0)
|
|
|
|
panic("Could not release lock on exec");
|
|
|
|
}
|
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* pm_exec *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int pm_exec(int proc_e, char *path, vir_bytes path_len, char *frame,
|
2010-12-10 10:27:56 +01:00
|
|
|
vir_bytes frame_len, vir_bytes *pc)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
|
|
|
/* Perform the execve(name, argv, envp) call. The user library builds a
|
|
|
|
* complete stack image, including pointers, args, environ, etc. The stack
|
2010-06-10 16:04:46 +02:00
|
|
|
* is copied to a buffer inside VFS, and then to the new core image.
|
2006-05-11 16:57:23 +02:00
|
|
|
*/
|
2012-02-13 16:28:04 +01:00
|
|
|
int r, r1, round, slot;
|
2010-12-10 10:27:56 +01:00
|
|
|
vir_bytes vsp;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
struct fproc *rfp;
|
|
|
|
struct vnode *vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vmnt *vmp;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
char *cp;
|
|
|
|
static char mbuf[ARG_MAX]; /* buffer for stack and zeroes */
|
2010-12-10 10:27:56 +01:00
|
|
|
struct exec_info execi;
|
|
|
|
int i;
|
2012-02-13 16:28:04 +01:00
|
|
|
char fullpath[PATH_MAX];
|
|
|
|
struct lookup resolve;
|
|
|
|
|
|
|
|
lock_exec();
|
|
|
|
|
|
|
|
okendpt(proc_e, &slot);
|
|
|
|
rfp = fp = &fproc[slot];
|
|
|
|
vp = NULL;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
lookup_init(&resolve, fullpath, PATH_NOFLAGS, &vmp, &vp);
|
|
|
|
resolve.l_vmnt_lock = VMNT_READ;
|
|
|
|
resolve.l_vnode_lock = VNODE_READ;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
|
|
|
/* Get the exec file name. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((r = fetch_name(path, path_len, 0, fullpath)) != OK)
|
|
|
|
goto pm_execfinal;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
|
|
|
/* Fetch the stack from the user before destroying the old core image. */
|
2010-12-15 15:43:59 +01:00
|
|
|
if (frame_len > ARG_MAX) {
|
2012-02-13 16:28:04 +01:00
|
|
|
r = ENOMEM; /* stack too big */
|
|
|
|
goto pm_execfinal;
|
|
|
|
}
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = sys_datacopy(proc_e, (vir_bytes) frame, SELF, (vir_bytes) mbuf,
|
2012-02-13 16:28:04 +01:00
|
|
|
(phys_bytes) frame_len);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (r != OK) { /* can't fetch stack (e.g. bad virtual addr) */
|
2012-02-13 16:28:04 +01:00
|
|
|
printf("VFS: pm_exec: sys_datacopy failed\n");
|
|
|
|
goto pm_execfinal;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* The default is to keep the original user and group IDs */
|
2010-12-10 10:27:56 +01:00
|
|
|
execi.new_uid = rfp->fp_effuid;
|
|
|
|
execi.new_gid = rfp->fp_effgid;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
for (round = 0; round < 2; round++) {
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* round = 0 (first attempt), or 1 (interpreted script) */
|
|
|
|
/* Save the name of the program */
|
2012-02-13 16:28:04 +01:00
|
|
|
(cp = strrchr(fullpath, '/')) ? cp++ : (cp = fullpath);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
strncpy(execi.progname, cp, PROC_NAME_LEN-1);
|
|
|
|
execi.progname[PROC_NAME_LEN-1] = '\0';
|
2011-11-28 11:03:43 +01:00
|
|
|
execi.setugid = 0;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Open executable */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp = eat_path(&resolve, fp)) == NULL) {
|
|
|
|
r = err_code;
|
|
|
|
goto pm_execfinal;
|
|
|
|
}
|
2010-12-10 10:27:56 +01:00
|
|
|
execi.vp = vp;
|
2012-02-13 16:28:04 +01:00
|
|
|
unlock_vmnt(vmp);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((vp->v_mode & I_TYPE) != I_REGULAR)
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = ENOEXEC;
|
2012-01-27 17:06:43 +01:00
|
|
|
else if ((r1 = forbidden(fp, vp, X_BIT)) != OK)
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = r1;
|
|
|
|
else
|
2010-06-08 15:58:01 +02:00
|
|
|
r = req_stat(vp->v_fs_e, vp->v_inode_nr, VFS_PROC_NR,
|
2011-07-01 21:35:54 +02:00
|
|
|
(char *) &(execi.sb), 0, 0);
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r != OK) goto pm_execfinal;
|
2006-05-11 16:57:23 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (round == 0) {
|
2011-11-28 11:03:43 +01:00
|
|
|
/* Deal with setuid/setgid executables */
|
|
|
|
if (vp->v_mode & I_SET_UID_BIT) {
|
|
|
|
execi.new_uid = vp->v_uid;
|
|
|
|
execi.setugid = 1;
|
|
|
|
}
|
|
|
|
if (vp->v_mode & I_SET_GID_BIT) {
|
|
|
|
execi.new_gid = vp->v_gid;
|
|
|
|
execi.setugid = 1;
|
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
}
|
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
r = map_header(&execi.hdr, execi.vp);
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r != OK) goto pm_execfinal;
|
2010-12-10 10:27:56 +01:00
|
|
|
|
|
|
|
if (!is_script(execi.hdr, execi.vp->v_size) || round != 0)
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Get fresh copy of the file name. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((r = fetch_name(path, path_len, 0, fullpath)) != OK)
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
printf("VFS pm_exec: 2nd fetch_name failed\n");
|
2012-02-13 16:28:04 +01:00
|
|
|
else
|
|
|
|
r = patch_stack(vp, mbuf, &frame_len, fullpath);
|
|
|
|
|
|
|
|
unlock_vnode(vp);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
put_vnode(vp);
|
2012-02-13 16:28:04 +01:00
|
|
|
vp = NULL;
|
|
|
|
if (r != OK) goto pm_execfinal;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
execi.proc_e = proc_e;
|
|
|
|
execi.frame_len = frame_len;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
for (i = 0; exec_loaders[i].load_object != NULL; i++) {
|
2010-12-10 10:27:56 +01:00
|
|
|
r = (*exec_loaders[i].load_object)(&execi);
|
|
|
|
/* Loaded successfully, so no need to try other loaders */
|
|
|
|
if (r == OK) break;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r != OK) { /* No exec loader could load the object */
|
|
|
|
r = ENOEXEC;
|
|
|
|
goto pm_execfinal;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
/* Save off PC */
|
|
|
|
*pc = execi.pc;
|
|
|
|
|
2010-06-10 16:04:46 +02:00
|
|
|
/* Patch up stack and copy it from VFS to new core image. */
|
2010-12-10 10:27:56 +01:00
|
|
|
vsp = execi.stack_top;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
vsp -= frame_len;
|
|
|
|
patch_ptr(mbuf, vsp);
|
|
|
|
if ((r = sys_datacopy(SELF, (vir_bytes) mbuf, proc_e, (vir_bytes) vsp,
|
|
|
|
(phys_bytes)frame_len)) != OK) {
|
2010-07-02 14:41:19 +02:00
|
|
|
printf("VFS: datacopy failed (%d) trying to copy to %lu\n", r, vsp);
|
2012-02-13 16:28:04 +01:00
|
|
|
goto pm_execfinal;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r != OK) goto pm_execfinal;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
clo_exec(rfp);
|
|
|
|
|
2011-11-28 11:03:43 +01:00
|
|
|
if (execi.setugid) {
|
|
|
|
/* If after loading the image we're still allowed to run with
|
2012-02-13 16:28:04 +01:00
|
|
|
* setuid or setgid, change credentials now */
|
2010-12-10 10:27:56 +01:00
|
|
|
rfp->fp_effuid = execi.new_uid;
|
|
|
|
rfp->fp_effgid = execi.new_gid;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
pm_execfinal:
|
|
|
|
if (vp != NULL) {
|
|
|
|
unlock_vnode(vp);
|
|
|
|
put_vnode(vp);
|
|
|
|
}
|
|
|
|
unlock_exec();
|
|
|
|
return(r);
|
2006-05-11 16:57:23 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* load_aout *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int load_aout(struct exec_info *execi)
|
2010-12-10 10:27:56 +01:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct vnode *vp;
|
|
|
|
int proc_e;
|
|
|
|
off_t off;
|
|
|
|
int hdrlen;
|
|
|
|
int sep_id;
|
|
|
|
vir_bytes text_bytes, data_bytes, bss_bytes;
|
|
|
|
phys_bytes tot_bytes; /* total space for program, including gap */
|
|
|
|
|
|
|
|
assert(execi != NULL);
|
|
|
|
assert(execi->hdr != NULL);
|
|
|
|
assert(execi->vp != NULL);
|
|
|
|
|
|
|
|
proc_e = execi->proc_e;
|
|
|
|
vp = execi->vp;
|
|
|
|
|
|
|
|
/* Read the file header and extract the segment sizes. */
|
|
|
|
r = read_header_aout(execi->hdr, execi->vp->v_size, &sep_id,
|
|
|
|
&text_bytes, &data_bytes, &bss_bytes,
|
|
|
|
&tot_bytes, &execi->pc, &hdrlen);
|
|
|
|
if (r != OK) return(r);
|
|
|
|
|
|
|
|
r = exec_newmem(proc_e, 0 /* text_addr */, text_bytes,
|
|
|
|
0 /* data_addr */, data_bytes + bss_bytes, tot_bytes,
|
|
|
|
execi->frame_len, sep_id, 0 /* is_elf */, vp->v_dev, vp->v_inode_nr,
|
|
|
|
execi->sb.st_ctime,
|
|
|
|
execi->progname, execi->new_uid, execi->new_gid,
|
2011-11-28 11:03:43 +01:00
|
|
|
&execi->stack_top, &execi->load_text, &execi->setugid);
|
2010-12-10 10:27:56 +01:00
|
|
|
|
|
|
|
if (r != OK) {
|
|
|
|
printf("VFS: load_aout: exec_newmem failed: %d\n", r);
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
off = hdrlen;
|
|
|
|
|
|
|
|
/* Read in text and data segments. */
|
2012-02-13 16:28:04 +01:00
|
|
|
if (execi->load_text)
|
|
|
|
r = read_seg(vp, off, proc_e, T, 0, text_bytes);
|
2010-12-10 10:27:56 +01:00
|
|
|
off += text_bytes;
|
2012-02-13 16:28:04 +01:00
|
|
|
if (r == OK)
|
|
|
|
r = read_seg(vp, off, proc_e, D, 0, data_bytes);
|
2010-12-10 10:27:56 +01:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
return(r);
|
2010-12-10 10:27:56 +01:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* load_elf *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int load_elf(struct exec_info *execi)
|
2010-12-10 10:27:56 +01:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
struct vnode *vp;
|
|
|
|
int proc_e;
|
|
|
|
phys_bytes tot_bytes; /* total space for program, including gap */
|
2011-04-07 14:22:36 +02:00
|
|
|
vir_bytes text_vaddr, text_paddr, text_filebytes, text_membytes;
|
|
|
|
vir_bytes data_vaddr, data_paddr, data_filebytes, data_membytes;
|
2010-12-10 10:27:56 +01:00
|
|
|
off_t text_offset, data_offset;
|
|
|
|
int sep_id, is_elf;
|
|
|
|
|
|
|
|
assert(execi != NULL);
|
|
|
|
assert(execi->hdr != NULL);
|
|
|
|
assert(execi->vp != NULL);
|
|
|
|
|
|
|
|
proc_e = execi->proc_e;
|
|
|
|
vp = execi->vp;
|
|
|
|
|
|
|
|
/* Read the file header and extract the segment sizes. */
|
2011-04-07 14:22:36 +02:00
|
|
|
r = read_header_elf(execi->hdr, &text_vaddr, &text_paddr,
|
|
|
|
&text_filebytes, &text_membytes,
|
|
|
|
&data_vaddr, &data_paddr,
|
|
|
|
&data_filebytes, &data_membytes,
|
|
|
|
&execi->pc, &text_offset, &data_offset);
|
2010-12-10 10:27:56 +01:00
|
|
|
if (r != OK) return(r);
|
|
|
|
|
2011-07-26 15:21:07 +02:00
|
|
|
sep_id = 0;
|
2010-12-10 10:27:56 +01:00
|
|
|
is_elf = 1;
|
2011-04-07 14:22:36 +02:00
|
|
|
tot_bytes = 0; /* Use default stack size */
|
2010-12-10 10:27:56 +01:00
|
|
|
r = exec_newmem(proc_e,
|
2011-04-07 14:22:36 +02:00
|
|
|
trunc_page(text_vaddr), text_membytes,
|
|
|
|
trunc_page(data_vaddr), data_membytes,
|
2010-12-10 10:27:56 +01:00
|
|
|
tot_bytes, execi->frame_len, sep_id, is_elf,
|
|
|
|
vp->v_dev, vp->v_inode_nr, execi->sb.st_ctime,
|
|
|
|
execi->progname, execi->new_uid, execi->new_gid,
|
2011-11-28 11:03:43 +01:00
|
|
|
&execi->stack_top, &execi->load_text, &execi->setugid);
|
2010-12-10 10:27:56 +01:00
|
|
|
|
|
|
|
if (r != OK) {
|
|
|
|
printf("VFS: load_elf: exec_newmem failed: %d\n", r);
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read in text and data segments. */
|
|
|
|
if (execi->load_text)
|
2011-04-07 14:22:36 +02:00
|
|
|
r = read_seg(vp, text_offset, proc_e, T, text_vaddr, text_filebytes);
|
2010-12-10 10:27:56 +01:00
|
|
|
|
|
|
|
if (r == OK)
|
2011-04-07 14:22:36 +02:00
|
|
|
r = read_seg(vp, data_offset, proc_e, D, data_vaddr, data_filebytes);
|
2010-12-10 10:27:56 +01:00
|
|
|
|
2011-04-12 15:09:19 +02:00
|
|
|
return(r);
|
2010-12-10 10:27:56 +01:00
|
|
|
}
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* exec_newmem *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int exec_newmem(
|
2010-04-13 12:58:41 +02:00
|
|
|
int proc_e,
|
2010-12-10 10:27:56 +01:00
|
|
|
vir_bytes text_addr,
|
2010-04-13 12:58:41 +02:00
|
|
|
vir_bytes text_bytes,
|
2010-12-10 10:27:56 +01:00
|
|
|
vir_bytes data_addr,
|
2010-04-13 12:58:41 +02:00
|
|
|
vir_bytes data_bytes,
|
|
|
|
vir_bytes tot_bytes,
|
|
|
|
vir_bytes frame_len,
|
|
|
|
int sep_id,
|
2010-12-10 10:27:56 +01:00
|
|
|
int is_elf,
|
2010-04-13 12:58:41 +02:00
|
|
|
dev_t st_dev,
|
|
|
|
ino_t st_ino,
|
2011-07-01 21:35:54 +02:00
|
|
|
time_t ctime,
|
2010-04-13 12:58:41 +02:00
|
|
|
char *progname,
|
|
|
|
int new_uid,
|
|
|
|
int new_gid,
|
|
|
|
vir_bytes *stack_topp,
|
|
|
|
int *load_textp,
|
2011-11-28 11:03:43 +01:00
|
|
|
int *setugidp
|
2010-04-13 12:58:41 +02:00
|
|
|
)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Allocate a new memory map for a process that tries to exec */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
int r;
|
|
|
|
struct exec_newmem e;
|
|
|
|
message m;
|
|
|
|
|
2011-11-28 11:03:43 +01:00
|
|
|
assert(setugidp != NULL);
|
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
e.text_addr = text_addr;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
e.text_bytes = text_bytes;
|
2010-12-10 10:27:56 +01:00
|
|
|
e.data_addr = data_addr;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
e.data_bytes = data_bytes;
|
|
|
|
e.tot_bytes = tot_bytes;
|
|
|
|
e.args_bytes = frame_len;
|
|
|
|
e.sep_id = sep_id;
|
2010-12-10 10:27:56 +01:00
|
|
|
e.is_elf = is_elf;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
e.st_dev = st_dev;
|
|
|
|
e.st_ino = st_ino;
|
2011-07-01 21:35:54 +02:00
|
|
|
e.enst_ctime = ctime;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
e.new_uid = new_uid;
|
|
|
|
e.new_gid = new_gid;
|
2011-11-28 11:03:43 +01:00
|
|
|
e.setugid = *setugidp;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
strncpy(e.progname, progname, sizeof(e.progname)-1);
|
|
|
|
e.progname[sizeof(e.progname)-1] = '\0';
|
|
|
|
|
|
|
|
m.m_type = EXEC_NEWMEM;
|
|
|
|
m.EXC_NM_PROC = proc_e;
|
|
|
|
m.EXC_NM_PTR = (char *)&e;
|
|
|
|
if ((r = sendrec(PM_PROC_NR, &m)) != OK) return(r);
|
|
|
|
|
|
|
|
*stack_topp = m.m1_i1;
|
|
|
|
*load_textp = !!(m.m1_i2 & EXC_NM_RF_LOAD_TEXT);
|
2011-11-28 11:03:43 +01:00
|
|
|
*setugidp = !!(m.m1_i2 & EXC_NM_RF_ALLOW_SETUID);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
|
|
|
return(m.m_type);
|
2006-05-11 16:57:23 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* is_script *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int is_script(const char *exec_hdr, size_t exec_len)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Is Interpreted script? */
|
2010-12-10 10:27:56 +01:00
|
|
|
assert(exec_hdr != NULL);
|
2006-05-11 16:57:23 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
return(exec_hdr[0] == '#' && exec_hdr[1] == '!' && exec_len >= 2);
|
2006-05-11 16:57:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* patch_stack *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int patch_stack(vp, stack, stk_bytes, path)
|
2012-02-13 16:28:04 +01:00
|
|
|
struct vnode *vp; /* pointer for open script file */
|
|
|
|
char stack[ARG_MAX]; /* pointer to stack image within VFS */
|
|
|
|
vir_bytes *stk_bytes; /* size of initial stack */
|
|
|
|
char path[PATH_MAX]; /* path to script file */
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
|
|
|
/* Patch the argument vector to include the path name of the script to be
|
|
|
|
* interpreted, and all strings on the #! line. Returns the path name of
|
|
|
|
* the interpreter.
|
|
|
|
*/
|
|
|
|
enum { INSERT=FALSE, REPLACE=TRUE };
|
2006-10-25 15:40:36 +02:00
|
|
|
int n, r;
|
2006-05-11 16:57:23 +02:00
|
|
|
off_t pos;
|
|
|
|
char *sp, *interp = NULL;
|
2007-08-07 14:52:47 +02:00
|
|
|
u64_t new_pos;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
unsigned int cum_io;
|
2006-10-25 15:40:36 +02:00
|
|
|
char buf[_MAX_BLOCK_SIZE];
|
2006-05-11 16:57:23 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Make 'path' the new argv[0]. */
|
|
|
|
if (!insert_arg(stack, stk_bytes, path, REPLACE)) return(ENOMEM);
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
pos = 0; /* Read from the start of the file */
|
|
|
|
|
|
|
|
/* Issue request */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(pos), READING,
|
2012-02-13 16:28:04 +01:00
|
|
|
VFS_PROC_NR, buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io);
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (r != OK) return(r);
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
n = vp->v_size;
|
2007-08-07 14:52:47 +02:00
|
|
|
if (n > _MAX_BLOCK_SIZE)
|
|
|
|
n = _MAX_BLOCK_SIZE;
|
2006-10-25 15:40:36 +02:00
|
|
|
if (n < 2) return ENOEXEC;
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
sp = &(buf[2]); /* just behind the #! */
|
2006-05-11 16:57:23 +02:00
|
|
|
n -= 2;
|
2006-10-25 15:40:36 +02:00
|
|
|
if (n > PATH_MAX) n = PATH_MAX;
|
2006-05-11 16:57:23 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Use the 'path' variable for temporary storage */
|
|
|
|
memcpy(path, sp, n);
|
2006-05-11 16:57:23 +02:00
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if ((sp = memchr(path, '\n', n)) == NULL) /* must be a proper line */
|
2006-05-11 16:57:23 +02:00
|
|
|
return(ENOEXEC);
|
|
|
|
|
|
|
|
/* Move sp backwards through script[], prepending each string to stack. */
|
|
|
|
for (;;) {
|
|
|
|
/* skip spaces behind argument. */
|
2012-02-13 16:28:04 +01:00
|
|
|
while (sp > path && (*--sp == ' ' || *sp == '\t')) {}
|
|
|
|
if (sp == path) break;
|
2006-05-11 16:57:23 +02:00
|
|
|
|
|
|
|
sp[1] = 0;
|
|
|
|
/* Move to the start of the argument. */
|
2012-02-13 16:28:04 +01:00
|
|
|
while (sp > path && sp[-1] != ' ' && sp[-1] != '\t') --sp;
|
2006-05-11 16:57:23 +02:00
|
|
|
|
|
|
|
interp = sp;
|
2010-12-15 15:43:59 +01:00
|
|
|
if (!insert_arg(stack, stk_bytes, sp, INSERT)) {
|
|
|
|
printf("VFS: patch_stack: insert_arg failed\n");
|
|
|
|
return(ENOMEM);
|
|
|
|
}
|
2006-05-11 16:57:23 +02:00
|
|
|
}
|
|
|
|
|
2011-12-20 16:20:32 +01:00
|
|
|
if(!interp)
|
|
|
|
return ENOEXEC;
|
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
/* Round *stk_bytes up to the size of a pointer for alignment contraints. */
|
|
|
|
*stk_bytes= ((*stk_bytes + PTRSIZE - 1) / PTRSIZE) * PTRSIZE;
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
if (interp != path)
|
|
|
|
memmove(path, interp, strlen(interp)+1);
|
2006-05-11 16:57:23 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* insert_arg *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int insert_arg(
|
2010-12-10 10:27:56 +01:00
|
|
|
char stack[ARG_MAX], /* pointer to stack image within PM */
|
|
|
|
vir_bytes *stk_bytes, /* size of initial stack */
|
|
|
|
char *arg, /* argument to prepend/replace as new argv[0] */
|
|
|
|
int replace
|
|
|
|
)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
|
|
|
/* Patch the stack so that arg will become argv[0]. Be careful, the stack may
|
|
|
|
* be filled with garbage, although it normally looks like this:
|
|
|
|
* nargs argv[0] ... argv[nargs-1] NULL envp[0] ... NULL
|
|
|
|
* followed by the strings "pointed" to by the argv[i] and the envp[i]. The
|
|
|
|
* pointers are really offsets from the start of stack.
|
|
|
|
* Return true iff the operation succeeded.
|
|
|
|
*/
|
|
|
|
int offset, a0, a1, old_bytes = *stk_bytes;
|
|
|
|
|
|
|
|
/* Prepending arg adds at least one string and a zero byte. */
|
|
|
|
offset = strlen(arg) + 1;
|
|
|
|
|
|
|
|
a0 = (int) ((char **) stack)[1]; /* argv[0] */
|
|
|
|
if (a0 < 4 * PTRSIZE || a0 >= old_bytes) return(FALSE);
|
|
|
|
|
|
|
|
a1 = a0; /* a1 will point to the strings to be moved */
|
|
|
|
if (replace) {
|
|
|
|
/* Move a1 to the end of argv[0][] (argv[1] if nargs > 1). */
|
|
|
|
do {
|
|
|
|
if (a1 == old_bytes) return(FALSE);
|
|
|
|
--offset;
|
|
|
|
} while (stack[a1++] != 0);
|
|
|
|
} else {
|
|
|
|
offset += PTRSIZE; /* new argv[0] needs new pointer in argv[] */
|
|
|
|
a0 += PTRSIZE; /* location of new argv[0][]. */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stack will grow by offset bytes (or shrink by -offset bytes) */
|
|
|
|
if ((*stk_bytes += offset) > ARG_MAX) return(FALSE);
|
|
|
|
|
|
|
|
/* Reposition the strings by offset bytes */
|
|
|
|
memmove(stack + a1 + offset, stack + a1, old_bytes - a1);
|
|
|
|
|
|
|
|
strcpy(stack + a0, arg); /* Put arg in the new space. */
|
|
|
|
|
|
|
|
if (!replace) {
|
|
|
|
/* Make space for a new argv[0]. */
|
|
|
|
memmove(stack + 2 * PTRSIZE, stack + 1 * PTRSIZE, a0 - 2 * PTRSIZE);
|
|
|
|
|
|
|
|
((char **) stack)[0]++; /* nargs++; */
|
|
|
|
}
|
|
|
|
/* Now patch up argv[] and envp[] by offset. */
|
|
|
|
patch_ptr(stack, (vir_bytes) offset);
|
|
|
|
((char **) stack)[1] = (char *) a0; /* set argv[0] correctly */
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* patch_ptr *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void patch_ptr(
|
2010-12-10 10:27:56 +01:00
|
|
|
char stack[ARG_MAX], /* pointer to stack image within PM */
|
|
|
|
vir_bytes base /* virtual address of stack base inside user */
|
|
|
|
)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
|
|
|
/* When doing an exec(name, argv, envp) call, the user builds up a stack
|
|
|
|
* image with arg and env pointers relative to the start of the stack. Now
|
|
|
|
* these pointers must be relocated, since the stack is not positioned at
|
|
|
|
* address 0 in the user's address space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char **ap, flag;
|
|
|
|
vir_bytes v;
|
|
|
|
|
|
|
|
flag = 0; /* counts number of 0-pointers seen */
|
|
|
|
ap = (char **) stack; /* points initially to 'nargs' */
|
|
|
|
ap++; /* now points to argv[0] */
|
|
|
|
while (flag < 2) {
|
|
|
|
if (ap >= (char **) &stack[ARG_MAX]) return; /* too bad */
|
|
|
|
if (*ap != NULL) {
|
|
|
|
v = (vir_bytes) *ap; /* v is relative pointer */
|
|
|
|
v += base; /* relocate it */
|
|
|
|
*ap = (char *) v; /* put it back */
|
|
|
|
} else {
|
|
|
|
flag++;
|
|
|
|
}
|
|
|
|
ap++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* read_seg *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int read_seg(
|
2010-12-10 10:27:56 +01:00
|
|
|
struct vnode *vp, /* inode descriptor to read from */
|
|
|
|
off_t off, /* offset in file */
|
|
|
|
int proc_e, /* process number (endpoint) */
|
|
|
|
int seg, /* T, D, or S */
|
|
|
|
vir_bytes seg_addr, /* address to load segment */
|
|
|
|
phys_bytes seg_bytes /* how much is to be transferred? */
|
|
|
|
)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* The byte count on read is usually smaller than the segment count, because
|
|
|
|
* a segment is padded out to a click multiple, and the data segment is only
|
|
|
|
* partially initialized.
|
|
|
|
*/
|
2006-10-25 15:40:36 +02:00
|
|
|
int r;
|
2007-08-07 14:52:47 +02:00
|
|
|
unsigned n, o;
|
|
|
|
u64_t new_pos;
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
unsigned int cum_io;
|
2011-05-12 19:04:55 +02:00
|
|
|
static char buf[128 * 1024];
|
2006-05-11 16:57:23 +02:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
assert((seg == T)||(seg == D));
|
|
|
|
|
2006-05-11 16:57:23 +02:00
|
|
|
/* Make sure that the file is big enough */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (vp->v_size < off+seg_bytes) return(EIO);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
if (seg == T) {
|
2007-08-07 14:52:47 +02:00
|
|
|
/* We have to use a copy loop until safecopies support segments */
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
o = 0;
|
|
|
|
while (o < seg_bytes) {
|
|
|
|
n = seg_bytes - o;
|
2007-08-07 14:52:47 +02:00
|
|
|
if (n > sizeof(buf))
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
n = sizeof(buf);
|
2007-08-07 14:52:47 +02:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
if ((r = req_readwrite(vp->v_fs_e,vp->v_inode_nr,cvul64(off+o),
|
|
|
|
READING, VFS_PROC_NR, buf,
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
n, &new_pos, &cum_io)) != OK) {
|
2009-09-21 16:49:26 +02:00
|
|
|
printf("VFS: read_seg: req_readwrite failed (text)\n");
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2009-09-21 16:49:26 +02:00
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
if (cum_io != n) {
|
2007-08-07 14:52:47 +02:00
|
|
|
printf(
|
|
|
|
"VFSread_seg segment has not been read properly by exec() \n");
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(EIO);
|
2007-08-07 14:52:47 +02:00
|
|
|
}
|
|
|
|
|
2010-06-08 15:58:01 +02:00
|
|
|
if ((r = sys_vircopy(VFS_PROC_NR, D, (vir_bytes)buf, proc_e,
|
2010-12-10 10:27:56 +01:00
|
|
|
seg, seg_addr + o, n)) != OK) {
|
2009-09-21 16:49:26 +02:00
|
|
|
printf("VFS: read_seg: copy failed (text)\n");
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2009-09-21 16:49:26 +02:00
|
|
|
}
|
2007-08-07 14:52:47 +02:00
|
|
|
|
|
|
|
o += n;
|
|
|
|
}
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(OK);
|
2010-12-10 10:27:56 +01:00
|
|
|
} else if (seg == D) {
|
|
|
|
|
|
|
|
if ((r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(off), READING,
|
|
|
|
proc_e, (char*)seg_addr, seg_bytes,
|
|
|
|
&new_pos, &cum_io)) != OK) {
|
|
|
|
printf("VFS: read_seg: req_readwrite failed (data)\n");
|
|
|
|
return(r);
|
|
|
|
}
|
2012-02-13 16:28:04 +01:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
if (r == OK && cum_io != seg_bytes)
|
|
|
|
printf("VFS: read_seg segment has not been read properly by exec()\n");
|
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
return(r);
|
2009-09-21 16:49:26 +02:00
|
|
|
}
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2010-12-10 10:27:56 +01:00
|
|
|
return(OK);
|
2006-05-11 16:57:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* clo_exec *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void clo_exec(struct fproc *rfp)
|
2006-05-11 16:57:23 +02:00
|
|
|
{
|
2012-02-13 16:28:04 +01:00
|
|
|
/* Files can be marked with the FD_CLOEXEC bit (in fp->fp_cloexec).
|
2006-05-11 16:57:23 +02:00
|
|
|
*/
|
2006-06-27 18:47:35 +02:00
|
|
|
int i;
|
2006-05-11 16:57:23 +02:00
|
|
|
|
- Introduce support for sticky bit.
- Revise VFS-FS protocol and update VFS/MFS/ISOFS accordingly.
- Clean up MFS by removing old, dead code (backwards compatibility is broken by
the new VFS-FS protocol, anyway) and rewrite other parts. Also, make sure all
functions have proper banners and prototypes.
- VFS should always provide a (syntactically) valid path to the FS; no need for
the FS to do sanity checks when leaving/entering mount points.
- Fix several bugs in MFS:
- Several path lookup bugs in MFS.
- A link can be too big for the path buffer.
- A mountpoint can become inaccessible when the creation of a new inode
fails, because the inode already exists and is a mountpoint.
- Introduce support for supplemental groups.
- Add test 46 to test supplemental group functionality (and removed obsolete
suppl. tests from test 2).
- Clean up VFS (not everything is done yet).
- ISOFS now opens device read-only. This makes the -r flag in the mount command
unnecessary (but will still report to be mounted read-write).
- Introduce PipeFS. PipeFS is a new FS that handles all anonymous and
named pipes. However, named pipes still reside on the (M)FS, as they are part
of the file system on disk. To make this work VFS now has a concept of
'mapped' inodes, which causes read, write, truncate and stat requests to be
redirected to the mapped FS, and all other requests to the original FS.
2009-12-20 21:27:14 +01:00
|
|
|
/* Check the file desriptors one by one for presence of FD_CLOEXEC. */
|
|
|
|
for (i = 0; i < OPEN_MAX; i++)
|
|
|
|
if ( FD_ISSET(i, &rfp->fp_cloexec_set))
|
2006-06-27 18:47:35 +02:00
|
|
|
(void) close_fd(rfp, i);
|
2006-05-11 16:57:23 +02:00
|
|
|
}
|
|
|
|
|
2012-02-13 16:28:04 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* map_header *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static int map_header(char **exec_hdr, const struct vnode *vp)
|
2010-12-10 10:27:56 +01:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
u64_t new_pos;
|
|
|
|
unsigned int cum_io;
|
|
|
|
off_t pos;
|
|
|
|
|
|
|
|
pos = 0; /* Read from the start of the file */
|
|
|
|
|
|
|
|
r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(pos), READING,
|
|
|
|
VFS_PROC_NR, hdr, MIN(vp->v_size, PAGE_SIZE),
|
|
|
|
&new_pos, &cum_io);
|
2010-12-15 15:43:59 +01:00
|
|
|
if (r != OK) {
|
|
|
|
printf("VFS: exec: map_header: req_readwrite failed\n");
|
|
|
|
return(r);
|
|
|
|
}
|
2010-12-10 10:27:56 +01:00
|
|
|
|
|
|
|
*exec_hdr = hdr;
|
|
|
|
return(OK);
|
|
|
|
}
|