Better error handling in _mount.c

This commit is contained in:
Philip Homburg 2006-11-24 14:01:14 +00:00
parent 2032e23e8c
commit d84dd06b3f

View File

@ -13,37 +13,31 @@ PUBLIC int mount(special, name, rwflag)
char *name, *special; char *name, *special;
int rwflag; int rwflag;
{ {
int r;
struct stat stat_buf; struct stat stat_buf;
message m; message m;
m.RS_CMD_ADDR = "/sbin/mfs"; m.RS_CMD_ADDR = "/sbin/mfs";
if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) { if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) {
printf("MOUNT: /sbin/mfs doesn't exist\n"); /* /sbin/mfs does not exist, try /bin/mfs as well */
m.RS_CMD_ADDR = 0; m.RS_CMD_ADDR = "/bin/mfs";
} if (stat(m.RS_CMD_ADDR, &stat_buf) == -1) {
/* /bin/mfs does not exist either, give up */
if (!m.RS_CMD_ADDR) { return -1;
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 (m.RS_CMD_ADDR) {
if (!(stat_buf.st_mode & S_IFREG)) { m.RS_CMD_LEN = strlen(m.RS_CMD_ADDR);
printf("MOUNT: FS binary is not a regular file\n"); m.RS_DEV_MAJOR = 0;
} m.RS_PERIOD = 0;
m.RS_CMD_LEN = strlen(m.RS_CMD_ADDR); r= _taskcall(RS_PROC_NR, RS_UP, &m);
m.RS_DEV_MAJOR = 0; if (r != OK) {
m.RS_PERIOD = 0; errno= -r;
if (OK != _taskcall(RS_PROC_NR, RS_UP, &m)) { return -1;
printf("MOUNT: error sending request to RS\n"); }
} /* copy endpointnumber */
else { m.m1_p3 = (char*)(unsigned long)m.RS_ENDPOINT;
/* copy endpointnumber */
m.m1_p3 = (char*)(unsigned long)m.RS_ENDPOINT;
}
} }
m.m1_i1 = strlen(special) + 1; m.m1_i1 = strlen(special) + 1;