. added super-user check for mount

. corrected device match for unmount (otherwise unmount would
  proceed with bogus mount slot, often sending messages to 0 (PM))
. added some sanity checking to fs process number
. made fs_sendrec PRIVATE to request.c
This commit is contained in:
Ben Gras 2007-01-16 13:57:35 +00:00
parent 8412423248
commit 94b936d7c1
5 changed files with 31 additions and 15 deletions

View file

@ -222,8 +222,8 @@ PRIVATE void fs_init()
int s;
/* Clear endpoint field */
last_login_fs_e = 0;
mount_m_in.m1_p3 = 0;
last_login_fs_e = NONE;
mount_m_in.m1_p3 = (char *) NONE;
/* Initialize the process table with help of the process manager messages.
* Expect one message for each system process with its slot number and pid.
@ -313,7 +313,7 @@ PRIVATE void init_root()
panic(__FILE__, "Error receiving login request from root filesystem\n", ROOT_FS_E);
}
}
last_login_fs_e = 0;
last_login_fs_e = NONE;
/* Initialize vmnt table */
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp)

View file

@ -72,10 +72,19 @@ PUBLIC int do_mount()
{
endpoint_t fs_e;
int r;
/* Only the super-user may do MOUNT. */
if (!super_user) return(EPERM);
/* FS process' endpoint number */
fs_e = (unsigned long)m_in.m1_p3;
/* Sanity check on process number. */
if(fs_e <= 0) {
printf("vfs: warning: got process number %d for mount call.\n", fs_e);
return EINVAL;
}
/* Do the actual job */
r = mount_fs(fs_e);
@ -123,10 +132,10 @@ PRIVATE int mount_fs(endpoint_t fs_e)
/* Mount request got after FS login or
* FS login arrived after a suspended mount */
last_login_fs_e = 0;
last_login_fs_e = NONE;
/* Clear endpoint field */
mount_m_in.m1_p3 = 0;
mount_m_in.m1_p3 = (char *) NONE;
/* If 'name' is not for a block special file, return error. */
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
@ -466,18 +475,23 @@ PUBLIC int unmount(dev)
Dev_t dev;
{
struct vnode *vp;
struct vmnt *vmp;
struct vmnt *vmp_i = NULL, *vmp = NULL;
struct dmap *dp;
int count, r;
int fs_e;
/* Find vmnt */
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp) {
if (vmp->m_dev == dev) break;
else if (vmp == &vmnt[NR_MNTS])
return EINVAL;
for (vmp_i = &vmnt[0]; vmp_i < &vmnt[NR_MNTS]; ++vmp_i) {
if (vmp->m_dev == dev) {
if(vmp) panic(__FILE__, "device mounted more than once", dev);
vmp = vmp_i;
}
}
/* Device mounted? */
if(!vmp)
return EINVAL;
/* See if the mounted device is busy. Only 1 vnode using it should be
* open -- the root vnode -- and that inode only 1 time.
*/
@ -496,6 +510,8 @@ Dev_t dev;
vnode_clean_refs(vmp->m_root_node);
/* Request FS the unmount */
if(vmp->m_fs_e <= 0)
panic(__FILE__, "unmount: strange fs endpoint", vmp->m_fs_e);
if ((r = req_unmount(vmp->m_fs_e)) != OK) return r;
/* Close the device the file system lives on. */
@ -541,8 +557,8 @@ Dev_t dev;
vmp->m_root_node = NIL_VNODE;
vmp->m_mounted_on = NIL_VNODE;
vmp->m_dev = NO_DEV;
vmp->m_fs_e = 0;
vmp->m_driver_e = 0;
vmp->m_fs_e = NONE;
vmp->m_driver_e = NONE;
/* Ask RS to bring down FS */
if (-1 == fs_exit(fs_e)) {

View file

@ -150,7 +150,7 @@ PRIVATE int common_open(register int oflags, mode_t omode)
r= OK;
else
{
printf("common_open: / in pathrem");
printf("common_open: / in pathrem\n");
}
}

View file

@ -133,7 +133,6 @@ _PROTOTYPE( int do_getdents, (void) );
_PROTOTYPE( int read_write, (int rw_flag) );
/* request.c */
_PROTOTYPE( int fs_sendrec, (endpoint_t fs_e, message *reqm) );
_PROTOTYPE( int req_getnode, (node_req_t *req, node_details_t *res) );
_PROTOTYPE( int req_putnode, (int fs_e, ino_t inode_nr, int count) );
_PROTOTYPE( int req_open, (open_req_t *req, node_details_t *res) );

View file

@ -28,6 +28,7 @@
#include "vnode.h"
#include "param.h"
FORWARD _PROTOTYPE(int fs_sendrec, (endpoint_t fs_e, message *reqm));
/*===========================================================================*
* req_getnode *
@ -954,7 +955,7 @@ _t *res;
/*===========================================================================*
* fs_sendrec *
*===========================================================================*/
PUBLIC int fs_sendrec(endpoint_t fs_e, message *reqm)
PRIVATE int fs_sendrec(endpoint_t fs_e, message *reqm)
{
/* This is the low level function that sends requests to FS processes.
* It also handles driver recovery mechanism and reissuing the