2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <lib.h>
|
|
|
|
#define mount _mount
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <minix/syslib.h>
|
|
|
|
|
|
|
|
#define OK 0
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
PUBLIC int mount(special, name, rwflag)
|
|
|
|
char *name, *special;
|
|
|
|
int rwflag;
|
|
|
|
{
|
2006-10-25 15:40:36 +02:00
|
|
|
struct stat stat_buf;
|
2005-04-21 16:53:53 +02:00
|
|
|
message m;
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
m.RS_CMD_ADDR = "/sbin/mfs";
|
|
|
|
if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) {
|
|
|
|
printf("MOUNT: /sbin/mfs doesn't exist\n");
|
|
|
|
m.RS_CMD_ADDR = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!m.RS_CMD_ADDR) {
|
|
|
|
m.RS_CMD_ADDR = "/bin/mfs";
|
|
|
|
if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) {
|
|
|
|
printf("MOUNT: /bin/mfs doesn't exist\n");
|
|
|
|
m.RS_CMD_ADDR = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m.RS_CMD_ADDR) {
|
|
|
|
if (!(stat_buf.st_mode & S_IFREG)) {
|
|
|
|
printf("MOUNT: FS binary is not a regular file\n");
|
|
|
|
}
|
|
|
|
m.RS_CMD_LEN = strlen(m.RS_CMD_ADDR);
|
|
|
|
m.RS_DEV_MAJOR = 0;
|
|
|
|
m.RS_PERIOD = 0;
|
|
|
|
if (OK != _taskcall(RS_PROC_NR, RS_UP, &m)) {
|
|
|
|
printf("MOUNT: error sending request to RS\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* copy endpointnumber */
|
|
|
|
m.m1_p3 = (char*)(unsigned long)m.RS_ENDPOINT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
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));
|
|
|
|
}
|