From d84dd06b3f1c76774dc87b4cf1818d0ae2a729fe Mon Sep 17 00:00:00 2001 From: Philip Homburg Date: Fri, 24 Nov 2006 14:01:14 +0000 Subject: [PATCH] Better error handling in _mount.c --- lib/posix/_mount.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/posix/_mount.c b/lib/posix/_mount.c index 7130d450d..e7dc63134 100755 --- a/lib/posix/_mount.c +++ b/lib/posix/_mount.c @@ -13,37 +13,31 @@ 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) { - 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; + /* /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) { - 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; - } + 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; } m.m1_i1 = strlen(special) + 1; -- 2.44.0