. 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:
parent
8412423248
commit
94b936d7c1
@ -222,8 +222,8 @@ PRIVATE void fs_init()
|
|||||||
int s;
|
int s;
|
||||||
|
|
||||||
/* Clear endpoint field */
|
/* Clear endpoint field */
|
||||||
last_login_fs_e = 0;
|
last_login_fs_e = NONE;
|
||||||
mount_m_in.m1_p3 = 0;
|
mount_m_in.m1_p3 = (char *) NONE;
|
||||||
|
|
||||||
/* Initialize the process table with help of the process manager messages.
|
/* Initialize the process table with help of the process manager messages.
|
||||||
* Expect one message for each system process with its slot number and pid.
|
* 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);
|
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 */
|
/* Initialize vmnt table */
|
||||||
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp)
|
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp)
|
||||||
|
|||||||
@ -73,9 +73,18 @@ PUBLIC int do_mount()
|
|||||||
endpoint_t fs_e;
|
endpoint_t fs_e;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
/* Only the super-user may do MOUNT. */
|
||||||
|
if (!super_user) return(EPERM);
|
||||||
|
|
||||||
/* FS process' endpoint number */
|
/* FS process' endpoint number */
|
||||||
fs_e = (unsigned long)m_in.m1_p3;
|
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 */
|
/* Do the actual job */
|
||||||
r = mount_fs(fs_e);
|
r = mount_fs(fs_e);
|
||||||
|
|
||||||
@ -123,10 +132,10 @@ PRIVATE int mount_fs(endpoint_t fs_e)
|
|||||||
|
|
||||||
/* Mount request got after FS login or
|
/* Mount request got after FS login or
|
||||||
* FS login arrived after a suspended mount */
|
* FS login arrived after a suspended mount */
|
||||||
last_login_fs_e = 0;
|
last_login_fs_e = NONE;
|
||||||
|
|
||||||
/* Clear endpoint field */
|
/* 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 '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);
|
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
|
||||||
@ -466,17 +475,22 @@ PUBLIC int unmount(dev)
|
|||||||
Dev_t dev;
|
Dev_t dev;
|
||||||
{
|
{
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
struct vmnt *vmp;
|
struct vmnt *vmp_i = NULL, *vmp = NULL;
|
||||||
struct dmap *dp;
|
struct dmap *dp;
|
||||||
int count, r;
|
int count, r;
|
||||||
int fs_e;
|
int fs_e;
|
||||||
|
|
||||||
/* Find vmnt */
|
/* Find vmnt */
|
||||||
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp) {
|
for (vmp_i = &vmnt[0]; vmp_i < &vmnt[NR_MNTS]; ++vmp_i) {
|
||||||
if (vmp->m_dev == dev) break;
|
if (vmp->m_dev == dev) {
|
||||||
else if (vmp == &vmnt[NR_MNTS])
|
if(vmp) panic(__FILE__, "device mounted more than once", dev);
|
||||||
return EINVAL;
|
vmp = vmp_i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Device mounted? */
|
||||||
|
if(!vmp)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
/* See if the mounted device is busy. Only 1 vnode using it should be
|
/* See if the mounted device is busy. Only 1 vnode using it should be
|
||||||
* open -- the root vnode -- and that inode only 1 time.
|
* open -- the root vnode -- and that inode only 1 time.
|
||||||
@ -496,6 +510,8 @@ Dev_t dev;
|
|||||||
vnode_clean_refs(vmp->m_root_node);
|
vnode_clean_refs(vmp->m_root_node);
|
||||||
|
|
||||||
/* Request FS the unmount */
|
/* 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;
|
if ((r = req_unmount(vmp->m_fs_e)) != OK) return r;
|
||||||
|
|
||||||
/* Close the device the file system lives on. */
|
/* Close the device the file system lives on. */
|
||||||
@ -541,8 +557,8 @@ Dev_t dev;
|
|||||||
vmp->m_root_node = NIL_VNODE;
|
vmp->m_root_node = NIL_VNODE;
|
||||||
vmp->m_mounted_on = NIL_VNODE;
|
vmp->m_mounted_on = NIL_VNODE;
|
||||||
vmp->m_dev = NO_DEV;
|
vmp->m_dev = NO_DEV;
|
||||||
vmp->m_fs_e = 0;
|
vmp->m_fs_e = NONE;
|
||||||
vmp->m_driver_e = 0;
|
vmp->m_driver_e = NONE;
|
||||||
|
|
||||||
/* Ask RS to bring down FS */
|
/* Ask RS to bring down FS */
|
||||||
if (-1 == fs_exit(fs_e)) {
|
if (-1 == fs_exit(fs_e)) {
|
||||||
|
|||||||
@ -150,7 +150,7 @@ PRIVATE int common_open(register int oflags, mode_t omode)
|
|||||||
r= OK;
|
r= OK;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("common_open: / in pathrem");
|
printf("common_open: / in pathrem\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -133,7 +133,6 @@ _PROTOTYPE( int do_getdents, (void) );
|
|||||||
_PROTOTYPE( int read_write, (int rw_flag) );
|
_PROTOTYPE( int read_write, (int rw_flag) );
|
||||||
|
|
||||||
/* request.c */
|
/* 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_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_putnode, (int fs_e, ino_t inode_nr, int count) );
|
||||||
_PROTOTYPE( int req_open, (open_req_t *req, node_details_t *res) );
|
_PROTOTYPE( int req_open, (open_req_t *req, node_details_t *res) );
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
|
||||||
|
FORWARD _PROTOTYPE(int fs_sendrec, (endpoint_t fs_e, message *reqm));
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* req_getnode *
|
* req_getnode *
|
||||||
@ -954,7 +955,7 @@ _t *res;
|
|||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* fs_sendrec *
|
* 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.
|
/* This is the low level function that sends requests to FS processes.
|
||||||
* It also handles driver recovery mechanism and reissuing the
|
* It also handles driver recovery mechanism and reissuing the
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user