Basic VM and other minor improvements.
Not complete, probably not fully debugged or optimized.
This commit is contained in:
@@ -11,13 +11,13 @@ h = $i/minix
|
||||
CC = exec cc
|
||||
CFLAGS = -I$i $(EXTRA_OPTS) $(CPROFILE)
|
||||
LDFLAGS = -i
|
||||
LIBS = -lsysutil -lsys -ltimers
|
||||
LIBS = -lsys -ltimers
|
||||
|
||||
OBJ = main.o open.o read.o write.o pipe.o dmap.o \
|
||||
path.o device.o mount.o link.o exec.o \
|
||||
filedes.o stadir.o protect.o time.o \
|
||||
lock.o misc.o utility.o select.o timers.o table.o \
|
||||
vnode.o vmnt.o request.o kputc.o
|
||||
vnode.o vmnt.o request.o kputc.o mmap.o
|
||||
|
||||
# build local binary
|
||||
install all build: $(SERVER)
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/* Buffer (block) cache. To acquire a block, a routine calls get_block(),
|
||||
* telling which block it wants. The block is then regarded as "in use"
|
||||
* and has its 'b_count' field incremented. All the blocks that are not
|
||||
* in use are chained together in an LRU list, with 'front' pointing
|
||||
* to the least recently used block, and 'rear' to the most recently used
|
||||
* block. A reverse chain, using the field b_prev is also maintained.
|
||||
* Usage for LRU is measured by the time the put_block() is done. The second
|
||||
* parameter to put_block() can violate the LRU order and put a block on the
|
||||
* front of the list, if it will probably not be needed soon. If a block
|
||||
* is modified, the modifying routine must set b_dirt to DIRTY, so the block
|
||||
* will eventually be rewritten to the disk.
|
||||
*/
|
||||
|
||||
#include <sys/dir.h> /* need struct direct */
|
||||
#include <dirent.h>
|
||||
|
||||
EXTERN struct buf {
|
||||
/* Data portion of the buffer. */
|
||||
union {
|
||||
char b__data[_MAX_BLOCK_SIZE]; /* ordinary user data */
|
||||
/* directory block */
|
||||
struct direct b__dir[NR_DIR_ENTRIES(_MAX_BLOCK_SIZE)];
|
||||
/* V1 indirect block */
|
||||
zone1_t b__v1_ind[V1_INDIRECTS];
|
||||
/* V2 indirect block */
|
||||
zone_t b__v2_ind[V2_INDIRECTS(_MAX_BLOCK_SIZE)];
|
||||
/* V1 inode block */
|
||||
d1_inode b__v1_ino[V1_INODES_PER_BLOCK];
|
||||
/* V2 inode block */
|
||||
d2_inode b__v2_ino[V2_INODES_PER_BLOCK(_MAX_BLOCK_SIZE)];
|
||||
/* bit map block */
|
||||
bitchunk_t b__bitmap[FS_BITMAP_CHUNKS(_MAX_BLOCK_SIZE)];
|
||||
} b;
|
||||
|
||||
/* Header portion of the buffer. */
|
||||
struct buf *b_next; /* used to link all free bufs in a chain */
|
||||
struct buf *b_prev; /* used to link all free bufs the other way */
|
||||
struct buf *b_hash; /* used to link bufs on hash chains */
|
||||
block_t b_blocknr; /* block number of its (minor) device */
|
||||
dev_t b_dev; /* major | minor device where block resides */
|
||||
char b_dirt; /* CLEAN or DIRTY */
|
||||
char b_count; /* number of users of this buffer */
|
||||
} buf[NR_BUFS];
|
||||
|
||||
/* A block is free if b_dev == NO_DEV. */
|
||||
|
||||
#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */
|
||||
|
||||
/* These defs make it possible to use to bp->b_data instead of bp->b.b__data */
|
||||
#define b_data b.b__data
|
||||
#define b_dir b.b__dir
|
||||
#define b_v1_ind b.b__v1_ind
|
||||
#define b_v2_ind b.b__v2_ind
|
||||
#define b_v1_ino b.b__v1_ino
|
||||
#define b_v2_ino b.b__v2_ino
|
||||
#define b_bitmap b.b__bitmap
|
||||
|
||||
EXTERN struct buf *buf_hash[NR_BUF_HASH]; /* the buffer hash table */
|
||||
|
||||
EXTERN struct buf *front; /* points to least recently used free block */
|
||||
EXTERN struct buf *rear; /* points to most recently used free block */
|
||||
EXTERN int bufs_in_use; /* # bufs currently in use (not on free list)*/
|
||||
|
||||
/* When a block is released, the type of usage is passed to put_block(). */
|
||||
#define WRITE_IMMED 0100 /* block should be written to disk now */
|
||||
#define ONE_SHOT 0200 /* set if block not likely to be needed soon */
|
||||
|
||||
#define INODE_BLOCK 0 /* inode block */
|
||||
#define DIRECTORY_BLOCK 1 /* directory block */
|
||||
#define INDIRECT_BLOCK 2 /* pointer block */
|
||||
#define MAP_BLOCK 3 /* bit map */
|
||||
#define FULL_DATA_BLOCK 5 /* data, fully used */
|
||||
#define PARTIAL_DATA_BLOCK 6 /* data, partly used*/
|
||||
|
||||
#define HASH_MASK (NR_BUF_HASH - 1) /* mask for hashing block numbers */
|
||||
@@ -633,6 +633,10 @@ message *mess_ptr; /* pointer to message for task */
|
||||
|
||||
int r, proc_e;
|
||||
|
||||
if(task_nr == SYSTEM) {
|
||||
printf("VFS: sending %d to SYSTEM\n", mess_ptr->m_type);
|
||||
}
|
||||
|
||||
proc_e = mess_ptr->IO_ENDPT;
|
||||
|
||||
r = sendrec(task_nr, mess_ptr);
|
||||
@@ -1117,6 +1121,7 @@ PUBLIC void reopen_reply()
|
||||
restart_reopen(maj);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define ASYN_NR 100
|
||||
PRIVATE asynmsg_t msgtable[ASYN_NR];
|
||||
PRIVATE int first_slot= 0, next_slot= 0;
|
||||
@@ -1203,4 +1208,5 @@ message *mp;
|
||||
/* Tell the kernel to rescan the table */
|
||||
return senda(msgtable+first_slot, next_slot-first_slot);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -221,7 +221,10 @@ printf("return at %s, %d\n", __FILE__, __LINE__);
|
||||
patch_ptr(mbuf, vsp);
|
||||
r = sys_datacopy(SELF, (vir_bytes) mbuf,
|
||||
proc_e, (vir_bytes) vsp, (phys_bytes)frame_len);
|
||||
if (r != OK) panic(__FILE__,"pm_exec stack copy err on", proc_e);
|
||||
if (r != OK) {
|
||||
printf("vfs: datacopy returns %d trying to copy to %p\n", r, vsp);
|
||||
panic(__FILE__,"pm_exec stack copy err on", proc_e);
|
||||
}
|
||||
|
||||
off = hdrlen;
|
||||
|
||||
@@ -255,7 +258,6 @@ printf("return at %s, %d\n", __FILE__, __LINE__);
|
||||
/* Check if this is a driver that can now be useful. */
|
||||
dmap_endpt_up(rfp->fp_endpoint);
|
||||
|
||||
/*printf("VFSpm_exec: %s OK\n", user_fullpath);*/
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -432,7 +434,7 @@ vir_bytes *stk_bytes; /* size of initial stack */
|
||||
unsigned int cum_io_incr;
|
||||
char buf[_MAX_BLOCK_SIZE];
|
||||
|
||||
/* Make user_path the new argv[0]. */
|
||||
/* Make user_fullpath the new argv[0]. */
|
||||
if (!insert_arg(stack, stk_bytes, user_fullpath, REPLACE)) return(ENOMEM);
|
||||
|
||||
pos = 0; /* Read from the start of the file */
|
||||
@@ -451,7 +453,7 @@ vir_bytes *stk_bytes; /* size of initial stack */
|
||||
n -= 2;
|
||||
if (n > PATH_MAX) n = PATH_MAX;
|
||||
|
||||
/* Use the user_path variable for temporary storage */
|
||||
/* Use the user_fullpath variable for temporary storage */
|
||||
memcpy(user_fullpath, sp, n);
|
||||
|
||||
if ((sp = memchr(user_fullpath, '\n', n)) == NULL) /* must be a proper line */
|
||||
|
||||
@@ -261,10 +261,13 @@ PUBLIC int do_truncate()
|
||||
PUBLIC int do_ftruncate()
|
||||
{
|
||||
/* As with do_truncate(), truncate_inode() does the actual work. */
|
||||
int r;
|
||||
struct filp *rfilp;
|
||||
|
||||
if ( (rfilp = get_filp(m_in.m2_i1)) == NIL_FILP)
|
||||
return err_code;
|
||||
if ( (r = forbidden(rfilp->filp_vno, W_BIT, 0 /*!use_realuid*/)) != OK)
|
||||
return r;
|
||||
return truncate_vn(rfilp->filp_vno, m_in.m2_l1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* This file contains the main program of the File System. It consists of
|
||||
/*
|
||||
* a loop that gets messages requesting work, carries out the work, and sends
|
||||
* replies.
|
||||
*
|
||||
@@ -60,8 +60,6 @@ PUBLIC int main()
|
||||
/* This is the main loop that gets work, processes it, and sends replies. */
|
||||
while (TRUE) {
|
||||
get_work(); /* sets who and call_nr */
|
||||
fp = &fproc[who_p]; /* pointer to proc table struct */
|
||||
super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */
|
||||
|
||||
if (who_e == PM_PROC_NR && call_nr != PROC_EVENT)
|
||||
printf("FS: strange, got message %d from PM\n", call_nr);
|
||||
@@ -143,24 +141,60 @@ PUBLIC int main()
|
||||
continue;
|
||||
}
|
||||
|
||||
switch(call_nr)
|
||||
{
|
||||
case DEVCTL:
|
||||
/* We only expect notify()s from tasks. */
|
||||
if(who_p < 0) {
|
||||
printf("FS: ignoring message from %d (%d)\n",
|
||||
who_e, m_in.m_type);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Now it's safe to set and check fp. */
|
||||
fp = &fproc[who_p]; /* pointer to proc table struct */
|
||||
super_user = (fp->fp_effuid == SU_UID ? TRUE : FALSE); /* su? */
|
||||
|
||||
/* Calls from VM. */
|
||||
if(who_e == VM_PROC_NR) {
|
||||
int caught = 1;
|
||||
switch(call_nr)
|
||||
{
|
||||
case VM_VFS_OPEN:
|
||||
error = do_vm_open();
|
||||
break;
|
||||
case VM_VFS_CLOSE:
|
||||
error = do_vm_close();
|
||||
break;
|
||||
case VM_VFS_MMAP:
|
||||
error = do_vm_mmap();
|
||||
break;
|
||||
default:
|
||||
caught = 0;
|
||||
break;
|
||||
}
|
||||
if(caught) {
|
||||
reply(who_e, error);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Other calls. */
|
||||
switch(call_nr)
|
||||
{
|
||||
case DEVCTL:
|
||||
error= do_devctl();
|
||||
if (error != SUSPEND) reply(who_e, error);
|
||||
break;
|
||||
|
||||
case MAPDRIVER:
|
||||
case MAPDRIVER:
|
||||
error= do_mapdriver();
|
||||
if (error != SUSPEND) reply(who_e, error);
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
/* Call the internal function that does the work. */
|
||||
if (call_nr < 0 || call_nr >= NCALLS) {
|
||||
error = SUSPEND;
|
||||
/* Not supposed to happen. */
|
||||
printf("FS, warning illegal %d system call by %d\n",
|
||||
printf("VFS: illegal %d system call by %d\n",
|
||||
call_nr, who_e);
|
||||
} else if (fp->fp_pid == PID_FREE) {
|
||||
error = ENOSYS;
|
||||
@@ -176,7 +210,6 @@ PUBLIC int main()
|
||||
|
||||
/* Copy the results back to the user and send reply. */
|
||||
if (error != SUSPEND) { reply(who_e, error); }
|
||||
|
||||
}
|
||||
#if 0
|
||||
if (!check_vrefs())
|
||||
@@ -336,13 +369,6 @@ PRIVATE void fs_init()
|
||||
* extra block_size requirements are checked at super-block-read-in time.
|
||||
*/
|
||||
if (OPEN_MAX > 127) panic(__FILE__,"OPEN_MAX > 127", NO_NUM);
|
||||
/*
|
||||
if (NR_BUFS < 6) panic(__FILE__,"NR_BUFS < 6", NO_NUM);
|
||||
if (V1_INODE_SIZE != 32) panic(__FILE__,"V1 inode size != 32", NO_NUM);
|
||||
if (V2_INODE_SIZE != 64) panic(__FILE__,"V2 inode size != 64", NO_NUM);
|
||||
if (OPEN_MAX > 8 * sizeof(long))
|
||||
panic(__FILE__,"Too few bits in fp_cloexec", NO_NUM);
|
||||
*/
|
||||
|
||||
/* The following initializations are needed to let dev_opcl succeed .*/
|
||||
fp = (struct fproc *) NULL;
|
||||
|
||||
@@ -219,6 +219,9 @@ PUBLIC int do_fcntl()
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if ( (r = forbidden(f->filp_vno, W_BIT, 0 /*!use_realuid*/)) != OK)
|
||||
return r;
|
||||
|
||||
/* Copy flock data from userspace. */
|
||||
if((r = sys_datacopy(who_e, (vir_bytes) m_in.name1,
|
||||
SELF, (vir_bytes) &flock_arg,
|
||||
@@ -369,6 +372,7 @@ int cpid; /* Child process id */
|
||||
|
||||
/* Increase the counters in the 'filp' table. */
|
||||
cp = &fproc[childno];
|
||||
fp = &fproc[parentno];
|
||||
for (i = 0; i < OPEN_MAX; i++)
|
||||
if (cp->fp_filp[i] != NIL_FILP) cp->fp_filp[i]->filp_count++;
|
||||
|
||||
@@ -379,8 +383,14 @@ int cpid; /* Child process id */
|
||||
/* A forking process never has an outstanding grant,
|
||||
* as it isn't blocking on i/o.
|
||||
*/
|
||||
assert(!GRANT_VALID(fp->fp_grant));
|
||||
assert(!GRANT_VALID(cp->fp_grant));
|
||||
if(GRANT_VALID(fp->fp_grant)) {
|
||||
printf("vfs: fork: fp (endpoint %d) has grant %d\n", fp->fp_endpoint, fp->fp_grant);
|
||||
panic(__FILE__, "fp contains valid grant", NO_NUM);
|
||||
}
|
||||
if(GRANT_VALID(cp->fp_grant)) {
|
||||
printf("vfs: fork: cp (endpoint %d) has grant %d\n", cp->fp_endpoint, cp->fp_grant);
|
||||
panic(__FILE__, "cp contains valid grant", NO_NUM);
|
||||
}
|
||||
|
||||
/* A child is not a process leader. */
|
||||
cp->fp_sesldr = 0;
|
||||
@@ -554,7 +564,9 @@ PUBLIC int do_svrctl()
|
||||
*/
|
||||
if(fproc[proc_nr_n].fp_execced) {
|
||||
/* Reply before calling dev_up */
|
||||
#if 0
|
||||
printf("do_svrctl: replying before dev_up\n");
|
||||
#endif
|
||||
reply(who_e, r);
|
||||
dev_up(major);
|
||||
r= SUSPEND;
|
||||
|
||||
32
servers/vfs/mmap.c
Normal file
32
servers/vfs/mmap.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* mmap implementation in VFS
|
||||
*
|
||||
* The entry points into this file are
|
||||
* do_vm_mmap: VM calls VM_VFS_MMAP
|
||||
*/
|
||||
|
||||
#include "fs.h"
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <minix/callnr.h>
|
||||
#include <minix/com.h>
|
||||
#include <minix/u64.h>
|
||||
#include "file.h"
|
||||
#include "fproc.h"
|
||||
#include "lock.h"
|
||||
#include "param.h"
|
||||
#include <dirent.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <minix/vfsif.h>
|
||||
#include "vnode.h"
|
||||
#include "vmnt.h"
|
||||
|
||||
/*===========================================================================*
|
||||
* do_vm_mmap *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_vm_mmap()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -311,8 +311,6 @@ PRIVATE int mount_fs(endpoint_t fs_e)
|
||||
root_node->v_dev = vmp->m_dev;
|
||||
|
||||
if (replace_root) {
|
||||
printf("Replacing root\n");
|
||||
|
||||
/* Superblock and root node already read.
|
||||
* Nothing else can go wrong. Perform the mount. */
|
||||
vmp->m_root_node = root_node;
|
||||
|
||||
@@ -795,3 +795,77 @@ PUBLIC void close_reply()
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* do_vm_open *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_vm_open()
|
||||
{
|
||||
int len, r, n;
|
||||
endpoint_t ep;
|
||||
|
||||
len = m_in.VMVO_NAME_LENGTH;
|
||||
m_out.VMV_ENDPOINT = ep = m_in.VMVO_ENDPOINT;
|
||||
|
||||
/* Do open() call on behalf of any process, performed by VM. */
|
||||
if(len < 2 || len > sizeof(user_fullpath)) {
|
||||
printf("do_vm_open: strange length %d\n", len);
|
||||
m_out.VMVRO_FD = EINVAL;
|
||||
return VM_VFS_REPLY_OPEN;
|
||||
}
|
||||
|
||||
/* Do open on behalf of which process? */
|
||||
if(isokendpt(ep, &n) != OK) {
|
||||
printf("do_vm_open: strange endpoint %d\n", ep);
|
||||
m_out.VMVRO_FD = EINVAL;
|
||||
return VM_VFS_REPLY_OPEN;
|
||||
}
|
||||
|
||||
/* XXX - do open on behalf of this process */
|
||||
fp = &fproc[n];
|
||||
|
||||
/* Get path name from VM address space. */
|
||||
if((r=sys_safecopyfrom(VM_PROC_NR, m_in.VMVO_NAME_GRANT, 0,
|
||||
(vir_bytes) user_fullpath, len, D)) != OK) {
|
||||
printf("do_vm_open: sys_safecopyfrom failed: %d\n", r);
|
||||
m_out.VMVRO_FD = EPERM;
|
||||
return VM_VFS_REPLY_OPEN;
|
||||
}
|
||||
|
||||
/* Check if path is null-terminated. */
|
||||
if(user_fullpath[len-1] != '\0') {
|
||||
printf("do_vm_open: name (len %d) not 0-terminated\n", len);
|
||||
m_out.VMVRO_FD = EINVAL;
|
||||
return VM_VFS_REPLY_OPEN;
|
||||
}
|
||||
|
||||
/* Perform open(). */
|
||||
m_out.VMVRO_FD = common_open(m_in.VMVO_FLAGS, m_in.VMVO_MODE);
|
||||
m_out.VMV_ENDPOINT = ep;
|
||||
|
||||
/* Send open() reply. */
|
||||
return VM_VFS_REPLY_OPEN;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_vm_close *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_vm_close()
|
||||
{
|
||||
int len, r, n;
|
||||
endpoint_t ep;
|
||||
|
||||
len = m_in.VMVO_NAME_LENGTH;
|
||||
|
||||
/* Do close() call on behalf of any process, performed by VM. */
|
||||
m_out.VMV_ENDPOINT = ep = m_in.VMVC_ENDPOINT;
|
||||
if(isokendpt(ep, &n) != OK) {
|
||||
printf("do_vm_close: strange endpoint %d\n", ep);
|
||||
return VM_VFS_REPLY_CLOSE;
|
||||
}
|
||||
|
||||
/* Perform close(). */
|
||||
r = close_fd(&fproc[n], m_in.VMVC_FD);
|
||||
|
||||
return VM_VFS_REPLY_CLOSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -462,7 +462,11 @@ int proc_nr_e;
|
||||
dev_t dev;
|
||||
message mess;
|
||||
|
||||
okendpt(proc_nr_e, &proc_nr_p);
|
||||
if(isokendpt(proc_nr_e, &proc_nr_p) != OK) {
|
||||
printf("VFS: ignoring unpause for bogus endpoint %d\n", proc_nr_e);
|
||||
return;
|
||||
}
|
||||
|
||||
rfp = &fproc[proc_nr_p];
|
||||
if (rfp->fp_suspended == NOT_SUSPENDED)
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,6 @@ _PROTOTYPE( void dev_up, (int major) );
|
||||
_PROTOTYPE( endpoint_t suspended_ep, (endpoint_t driver,
|
||||
cp_grant_id_t g) );
|
||||
_PROTOTYPE( void reopen_reply, (void) );
|
||||
_PROTOTYPE( int asynsend, (endpoint_t dst, message *mp) );
|
||||
|
||||
/* dmap.c */
|
||||
_PROTOTYPE( int do_devctl, (void) );
|
||||
@@ -52,7 +51,7 @@ _PROTOTYPE( int pm_exec, (int proc_e, char *path, vir_bytes path_len,
|
||||
/* filedes.c */
|
||||
_PROTOTYPE( struct filp *find_filp, (struct vnode *vp, mode_t bits) );
|
||||
_PROTOTYPE( int get_fd, (int start, mode_t bits, int *k,
|
||||
struct filp **fpt) );
|
||||
struct filp **fpt) );
|
||||
_PROTOTYPE( struct filp *get_filp, (int fild) );
|
||||
_PROTOTYPE( struct filp *get_filp2, (struct fproc *rfp, int fild) );
|
||||
_PROTOTYPE( int inval_filp, (struct filp *) );
|
||||
@@ -90,6 +89,9 @@ _PROTOTYPE( int do_svrctl, (void) );
|
||||
_PROTOTYPE( int do_getsysinfo, (void) );
|
||||
_PROTOTYPE( int pm_dumpcore, (int proc_e, struct mem_map *seg_ptr) );
|
||||
|
||||
/* mmap.c */
|
||||
_PROTOTYPE( int do_vm_mmap, (void) );
|
||||
|
||||
/* mount.c */
|
||||
_PROTOTYPE( int do_fslogin, (void) );
|
||||
_PROTOTYPE( int do_mount, (void) );
|
||||
@@ -108,14 +110,16 @@ _PROTOTYPE( int do_mknod, (void) );
|
||||
_PROTOTYPE( int do_mkdir, (void) );
|
||||
_PROTOTYPE( int do_open, (void) );
|
||||
_PROTOTYPE( int do_slink, (void) );
|
||||
_PROTOTYPE( int do_vm_open, (void) );
|
||||
_PROTOTYPE( int do_vm_close, (void) );
|
||||
|
||||
/* path.c */
|
||||
_PROTOTYPE( int lookup_rel_vp, (struct vnode *start_node, int flags,
|
||||
int use_realuid, struct vnode **vpp) );
|
||||
int use_realuid, struct vnode **vpp) );
|
||||
_PROTOTYPE( int lookup_vp, (int flags, int use_realuid,
|
||||
struct vnode **vpp) );
|
||||
struct vnode **vpp) );
|
||||
_PROTOTYPE( int lookup_lastdir_rel, (struct vnode *start_node,
|
||||
int use_realuid, struct vnode **vpp) );
|
||||
int use_realuid, struct vnode **vpp) );
|
||||
_PROTOTYPE( int lookup_lastdir, (int use_realuid, struct vnode **vpp) );
|
||||
|
||||
/* pipe.c */
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
#include <minix/endpoint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "file.h"
|
||||
#include "fproc.h"
|
||||
#include "param.h"
|
||||
#include "vmnt.h"
|
||||
|
||||
PRIVATE int panicking; /* inhibits recursive panics during sync */
|
||||
|
||||
/*===========================================================================*
|
||||
* fetch_name *
|
||||
*===========================================================================*/
|
||||
@@ -30,7 +29,7 @@ char *path; /* pointer to the path in user space */
|
||||
int len; /* path length, including 0 byte */
|
||||
int flag; /* M3 means path may be in message */
|
||||
{
|
||||
/* Go get path and put it in 'user_path'.
|
||||
/* Go get path and put it in 'user_fullpath'.
|
||||
* If 'flag' = M3 and 'len' <= M3_STRING, the path is present in 'message'.
|
||||
* If it is not, go copy it from user space.
|
||||
*/
|
||||
@@ -38,6 +37,8 @@ int flag; /* M3 means path may be in message */
|
||||
int r;
|
||||
|
||||
if (len > PATH_MAX) {
|
||||
printf("VFS: fetch_name: len (%d) > %d\n", len, PATH_MAX);
|
||||
util_stacktrace();
|
||||
err_code = ENAMETOOLONG;
|
||||
return(EGENERIC);
|
||||
}
|
||||
@@ -50,11 +51,12 @@ int flag; /* M3 means path may be in message */
|
||||
if (len <= 0) {
|
||||
err_code = EINVAL;
|
||||
printf("vfs: fetch_name: len %d?\n", len);
|
||||
util_stacktrace();
|
||||
return(EGENERIC);
|
||||
}
|
||||
|
||||
if (flag == M3 && len <= M3_STRING) {
|
||||
/* Just copy the path from the message to 'user_path'. */
|
||||
/* Just copy the path from the message to 'user_fullpath'. */
|
||||
rpu = &user_fullpath[0];
|
||||
rpm = m_in.pathname; /* contained in input message */
|
||||
do { *rpu++ = *rpm++; } while (--len);
|
||||
@@ -88,40 +90,32 @@ PUBLIC int no_sys()
|
||||
return(SUSPEND);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* panic *
|
||||
*===========================================================================*/
|
||||
PUBLIC void panic(who, mess, num)
|
||||
char *who; /* who caused the panic */
|
||||
char *mess; /* panic message string */
|
||||
int num; /* number to go with it */
|
||||
{
|
||||
if (!panicking) { /* do not panic during a sync */
|
||||
panicking = TRUE; /* prevent another panic during the sync */
|
||||
|
||||
printf("VFS panic (%s): %s ", who, mess);
|
||||
if (num != NO_NUM) printf("%d",num);
|
||||
printf("\n");
|
||||
(void) do_sync(); /* flush everything to the disk */
|
||||
} else printf("VFS re-panic\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* isokendpt_f *
|
||||
*===========================================================================*/
|
||||
PUBLIC int isokendpt_f(char *file, int line, int endpoint, int *proc, int fatal)
|
||||
{
|
||||
int failed = 0;
|
||||
endpoint_t ke;
|
||||
*proc = _ENDPOINT_P(endpoint);
|
||||
if(*proc < 0 || *proc >= NR_PROCS) {
|
||||
if(endpoint == NONE) {
|
||||
printf("vfs:%s: endpoint is NONE\n", file, line, endpoint);
|
||||
failed = 1;
|
||||
} else if(*proc < 0 || *proc >= NR_PROCS) {
|
||||
printf("vfs:%s:%d: proc (%d) from endpoint (%d) out of range\n",
|
||||
file, line, *proc, endpoint);
|
||||
failed = 1;
|
||||
} else if(fproc[*proc].fp_endpoint != endpoint) {
|
||||
printf("vfs:%s:%d: proc (%d) from endpoint (%d) doesn't match "
|
||||
"known endpoint (%d)\n",
|
||||
file, line, *proc, endpoint, fproc[*proc].fp_endpoint);
|
||||
} else if((ke=fproc[*proc].fp_endpoint) != endpoint) {
|
||||
if(ke == NONE) {
|
||||
printf("vfs:%s:%d: endpoint (%d) points to NONE slot (%d)\n",
|
||||
file, line, endpoint, *proc);
|
||||
assert(fproc[*proc].fp_pid == PID_FREE);
|
||||
} else {
|
||||
printf("vfs:%s:%d: proc (%d) from endpoint (%d) doesn't match "
|
||||
"known endpoint (%d)\n",
|
||||
file, line, *proc, endpoint, fproc[*proc].fp_endpoint);
|
||||
assert(fproc[*proc].fp_pid != PID_FREE);
|
||||
}
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user