changeset 289:244f08f58e51

fc-fsio: error decoding implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 28 Feb 2014 23:12:52 +0000
parents e33d71e9033f
children 76228aecf0d9
files rvinterf/etmsync/Makefile rvinterf/etmsync/fileio.c rvinterf/etmsync/fsbasics.c rvinterf/etmsync/fserr.c rvinterf/include/ffserr.h
diffstat 5 files changed, 125 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile	Fri Feb 28 08:46:14 2014 +0000
+++ b/rvinterf/etmsync/Makefile	Fri Feb 28 23:12:52 2014 +0000
@@ -4,7 +4,7 @@
 INSTBIN=/usr/local/bin
 
 FSIO_OBJS=	connect.o dispatch.o fdcmd.o fileio.o fsbasics.o fscmdtab.o \
-		fsiomain.o fsread.o interf.o launchrvif.o
+		fserr.o fsiomain.o fsread.o interf.o launchrvif.o
 
 all:	${PROGS}
 
--- a/rvinterf/etmsync/fileio.c	Fri Feb 28 08:46:14 2014 +0000
+++ b/rvinterf/etmsync/fileio.c	Fri Feb 28 23:12:52 2014 +0000
@@ -41,7 +41,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("open fd: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("open fd", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len != 6) {
@@ -72,7 +72,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("read fd: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("read fd", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len < 6) {
@@ -101,7 +101,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("close fd: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("close fd", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len != 5) {
@@ -140,7 +140,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("read file: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("read file", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len < 6) {
--- a/rvinterf/etmsync/fsbasics.c	Fri Feb 28 08:46:14 2014 +0000
+++ b/rvinterf/etmsync/fsbasics.c	Fri Feb 28 23:12:52 2014 +0000
@@ -63,7 +63,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("opendir: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("opendir", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len != 11 || rvi_msg[5] != 4) {
@@ -91,7 +91,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("readdir: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("readdir", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len < 14) {
@@ -155,7 +155,7 @@
 	if (rc)
 		return(rc);
 	if (rvi_msg[3]) {
-		printf("xlstat: FFS error %d\n", rvi_msg[3]);
+		report_ffs_err("xlstat", rvi_msg[3]);
 		return(ERROR_TARGET);
 	}
 	if (rvi_msg_len != 30 || rvi_msg[4] != 24) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/fserr.c	Fri Feb 28 23:12:52 2014 +0000
@@ -0,0 +1,69 @@
+/*
+ * FFS error decoding
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include "etm.h"
+#include "ffs.h"
+#include "ffserr.h"
+
+static struct errtab {
+	int	errcode;
+	char	*desc;
+} errtab[] = {
+	{TMFFS_ERR_NODEVICE, "EFFS_NODEVICE: flash device unknown"},
+	{TMFFS_ERR_CORRUPTED, "EFFS_CORRUPTED: filesystem corrupted"},
+	{TMFFS_ERR_NOPREFORMAT, "EFFS_NOPREFORMAT: ffs not preformatted"},
+	{TMFFS_ERR_NOFORMAT, "EFFS_NOFORMAT: ffs not formatted"},
+	{TMFFS_ERR_BADFORMAT,
+		"EFFS_BADFORMAT: incompatible ffs version, reformat needed"},
+	{TMFFS_ERR_MAGIC, "EFFS_MAGIC: bad magic"},
+	{TMFFS_ERR_AGAIN, "EFFS_AGAIN: not ready, try again later"},
+	{TMFFS_ERR_NOSYS, "EFFS_NOSYS: function not implemented"},
+	{TMFFS_ERR_DRIVER, "EFFS_DRIVER: ffs device driver error"},
+	{TMFFS_ERR_NOSPACE, "EFFS_NOSPACE: out of data space"},
+	{TMFFS_ERR_FSFULL, "EFFS_FSFULL: file system full, no free inodes"},
+	{TMFFS_ERR_BADNAME, "EFFS_BADNAME: bad filename"},
+	{TMFFS_ERR_NOTFOUND, "EFFS_NOTFOUND: object not found"},
+	{TMFFS_ERR_EXISTS, "EFFS_EXISTS: object exists"},
+	{TMFFS_ERR_ACCESS, "EFFS_ACCESS: access permission violation"},
+	{TMFFS_ERR_NAMETOOLONG, "EFFS_NAMETOOLONG"},
+	{TMFFS_ERR_INVALID, "EFFS_INVALID"},
+	{TMFFS_ERR_DIRNOTEMPTY, "EFFS_DIRNOTEMPTY"},
+	{TMFFS_ERR_NOTADIR, "EFFS_NOTADIR"},
+	{TMFFS_ERR_SPARE, "EFFS_SPARE"},
+	{TMFFS_ERR_FILETOOBIG, "EFFS_FILETOOBIG"},
+	{TMFFS_ERR_NOTAFILE, "EFFS_NOTAFILE"},
+	{TMFFS_ERR_PATHTOODEEP, "EFFS_PATHTOODEEP"},
+	{TMFFS_ERR_NUMFD, "EFFS_NUMFD: max number of open files reached"},
+	{TMFFS_ERR_BADFD, "EFFS_BADFD: bad file descriptor"},
+	{TMFFS_ERR_BADOP, "EFFS_BADOP: bad operation"},
+	{TMFFS_ERR_LOCKED, "EFFS_LOCKED: the file is locked"},
+	{TMFFS_ERR_TOOBIG, "EFFS_TOOBIG: tmffs buffer overflow"},
+	{TMFFS_ERR_MEMORY, "EFFS_MEMORY: out of memory"},
+	{TMFFS_ERR_MSGSEND, "EFFS_MSGSEND: message send failed"},
+	{TMFFS_ERR_SIBLINGLOOP, "EFFS_SIBLINGLOOP: directory sibling loop"},
+	{TMFFS_ERR_NOBLOCKS, "EFFS_NOBLOCKS: debug error?"},
+	{TMFFS_ERR_DBR, "EFFS_DBR: debug error?"},
+	{TMFFS_ERR_RECLAIMLOOP, "EFFS_RECLAIMLOOP: debug error?"},
+	{0, 0}
+};
+
+report_ffs_err(oper, errcode)
+	char *oper;
+{
+	struct errtab *tp;
+	char *errdesc;
+
+	for (tp = errtab; tp->errcode; tp++)
+		if (tp->errcode == errcode)
+			break;
+	errdesc = tp->desc;
+	if (!errdesc)
+		errdesc = "unknown";
+	printf("%s: FFS error %d (%s)\n", oper, errcode, errdesc);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/include/ffserr.h	Fri Feb 28 23:12:52 2014 +0000
@@ -0,0 +1,48 @@
+/*
+ * FFS error codes as returned in TMFFS2 response byte packets:
+ * these are positive, whereas the ones in the gsm-fw code
+ * are negative.
+ */
+
+enum TMFFS_ERRORS {
+    TMFFS_ERR_NODEVICE    = 1,  /* flash device unknown */
+    TMFFS_ERR_CORRUPTED   = 2,  /* filesystem corrupted!? */
+    TMFFS_ERR_NOPREFORMAT = 3,  /* ffs not preformatted */
+    TMFFS_ERR_NOFORMAT    = 4,  /* ffs not formatted */
+    TMFFS_ERR_BADFORMAT   = 5,  /* incompatible ffs version, re-format needed */
+    TMFFS_ERR_MAGIC       = 6,  /* bad magic */
+    TMFFS_ERR_AGAIN       = 7,  /* not ready, try again later */
+    TMFFS_ERR_NOSYS       = 8,  /* function not implemented */
+    TMFFS_ERR_DRIVER      = 9,  /* ffs device driver error */
+
+    TMFFS_ERR_NOSPACE     = 10, /* out of data space */
+    TMFFS_ERR_FSFULL      = 11, /* file system full, no free inodes */
+    TMFFS_ERR_BADNAME     = 12, /* bad filename */
+    TMFFS_ERR_NOTFOUND    = 13, /* object not found */
+    TMFFS_ERR_EXISTS      = 14, /* object exists */
+    TMFFS_ERR_ACCESS      = 15, /* access permission violation */
+    TMFFS_ERR_NAMETOOLONG = 16, /* filename too long */
+    TMFFS_ERR_INVALID     = 17, /* invalid argument */
+    TMFFS_ERR_DIRNOTEMPTY = 18, /* directory not empty */
+    TMFFS_ERR_NOTADIR     = 19, /* object is not a directory */
+    TMFFS_ERR_SPARE       = 20, /* SPARE */
+    TMFFS_ERR_FILETOOBIG  = 21, /* file too big */
+    TMFFS_ERR_NOTAFILE    = 22, /* object is not a file */
+    TMFFS_ERR_PATHTOODEEP = 23, /* path too deep */
+
+    TMFFS_ERR_NUMFD       = 24, /* Max number of open files reached */
+    TMFFS_ERR_BADFD       = 25, /* Bad file descriptor */
+    TMFFS_ERR_BADOP       = 26, /* Bad operation */
+    TMFFS_ERR_LOCKED      = 27, /* The file is locked */
+
+    TMFFS_ERR_TOOBIG      = 30, /* too big (tmffs buffer overflow) */
+    TMFFS_ERR_MEMORY      = 31, /* out of memory */
+    TMFFS_ERR_MSGSEND     = 32, /* message send failed */
+
+    /* debug errors - ??? */
+
+    TMFFS_ERR_SIBLINGLOOP = 40, /* directory sibling loop */
+    TMFFS_ERR_NOBLOCKS    = 41, /* No more blocks!? */
+    TMFFS_ERR_DBR         = 42, /* Data reclaim did not finish!? */
+    TMFFS_ERR_RECLAIMLOOP = 43  /* Data reclaim loop */
+};