vfs/mount/rs/service changes:

. changed umount() and mount() to call 'service', so that it can include
   a custom label, so that umount() works again (RS slot gets freed now).
   merged umount() and mount() into one file to encode keep this label
   knowledge in one file.
 . removed obsolete RS_PID field and RS_RESCUE rescue command
 . added label to RS_START struct
 . vfs no longer does kill of fs process on unmount (which was failing
   due to RS_PID request not working)
 . don't assume that if error wasn't one of three errors, that no error
   occured in vfs/request.c
mfs changes:
 . added checks to copy statements to truncate copies at buffer sizes
   (left in debug code for now)
 . added checks for null-terminatedness, if less than NAME_MAX was copied
 . added checks for copy function success
is changes: 
 . dump rs label
drivers.conf changes:
 . added acl for mfs so that mfs can be started with 'service start',
   so that a custom label can be provided
This commit is contained in:
Ben Gras
2007-01-22 15:25:41 +00:00
parent d954a122f7
commit 2194bc0310
23 changed files with 300 additions and 222 deletions
-1
View File
@@ -92,7 +92,6 @@ libc_FILES=" \
_times.c \
_truncate.c \
_umask.c \
_umount.c \
_uname.c \
_unlink.c \
_utime.c \
+99 -25
View File
@@ -1,49 +1,123 @@
#include <lib.h>
#define mount _mount
#define umount _umount
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <minix/syslib.h>
#include <minix/rs.h>
#include <minix/paths.h>
#define OK 0
#define MFSNAME "mfs"
#define MFSPATH "/sbin/"
PRIVATE int rs_down(char *label)
{
char cmd[200];
message m;
if(strlen(_PATH_SERVICE)+strlen(label)+50 >= sizeof(cmd))
return -1;
sprintf(cmd, _PATH_SERVICE " down %s", label);
return system(cmd);
}
PRIVATE char *makelabel(_CONST char *special)
{
static char label[40];
_CONST char *dev;
/* Make label name. */
dev = strrchr(special, '/');
if(dev) dev++;
else dev = special;
if(strlen(dev)+strlen(MFSNAME)+3 >= sizeof(label))
return NULL;
sprintf(label, MFSNAME "_%s", dev);
return label;
}
PUBLIC int mount(special, name, rwflag)
char *name, *special;
int rwflag;
{
int r;
struct stat stat_buf;
message m;
m.RS_CMD_ADDR = "/sbin/mfs";
if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) {
/* /sbin/mfs does not exist, try /bin/mfs as well */
m.RS_CMD_ADDR = "/bin/mfs";
if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) {
/* /bin/mfs does not exist either, give up */
return -1;
}
}
if (m.RS_CMD_ADDR) {
m.RS_CMD_LEN = strlen(m.RS_CMD_ADDR);
m.RS_DEV_MAJOR = 0;
m.RS_PERIOD = 0;
r= _taskcall(RS_PROC_NR, RS_UP, &m);
if (r != OK) {
errno= -r;
return -1;
}
/* copy endpointnumber */
m.m1_p3 = (char*)(unsigned long)m.RS_ENDPOINT;
struct rs_start rs_start;
char *label;
char cmd[200];
FILE *pipe;
int ep;
/* Make MFS process label for RS from special name. */
if(!(label=makelabel(special))) {
errno = E2BIG;
return -1;
}
if(strlen(_PATH_SERVICE)+strlen(MFSPATH)+strlen(MFSNAME)+
strlen(label)+50 >= sizeof(cmd)) {
errno = E2BIG;
return -1;
}
sprintf(cmd, _PATH_SERVICE " up " MFSPATH MFSNAME
" -label \"%s\" -config " _PATH_DRIVERS_CONF " -printep yes",
label);
if(!(pipe = popen(cmd, "r"))) {
fprintf(stderr, "mount: couldn't run %s\n", cmd);
return -1;
}
if(fscanf(pipe, "%d", &ep) != 1 || ep <= 0) {
fprintf(stderr, "mount: couldn't parse endpoint from %s\n", cmd);
errno = EINVAL;
pclose(pipe);
return -1;
}
pclose(pipe);
/* Now perform mount(). */
m.m1_i1 = strlen(special) + 1;
m.m1_i2 = strlen(name) + 1;
m.m1_i3 = rwflag;
m.m1_p1 = special;
m.m1_p2 = name;
return(_syscall(FS, MOUNT, &m));
m.m1_p3 = (char*) ep;
r = _syscall(FS, MOUNT, &m);
if(r != OK) {
/* If mount() failed, tell RS to shutdown MFS process.
* No error check - won't do anything with this error anyway.
*/
rs_down(label);
}
return r;
}
PUBLIC int umount(name)
_CONST char *name;
{
message m;
char *label;
int r;
/* Make MFS process label for RS from special name. */
if(!(label=makelabel(name))) {
errno = E2BIG;
return -1;
}
_loadname(name, &m);
r = _syscall(FS, UMOUNT, &m);
if(r == OK) {
rs_down(label);
}
return r;
}
-12
View File
@@ -1,12 +0,0 @@
#include <lib.h>
#define umount _umount
#include <unistd.h>
PUBLIC int umount(name)
_CONST char *name;
{
message m;
_loadname(name, &m);
return(_syscall(FS, UMOUNT, &m));
}