summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHorms <horms@verge.net.au>2006-12-11 14:25:56 +0900
committerSimon Horman <horms@verge.net.au>2006-12-12 17:55:49 +0900
commit1fd7cb01165e301789566e6a19344972e0595457 (patch)
treed23e59e16669aa210c47ad92998a9461806075f6
parent713fa5718a9f75c32e39efa2026c2d33c39ea353 (diff)
kexec-tools: Use die() instead of err()
Instead of defining a specialised err() function to exit with non-standard error codes, just use the global die() function. Signed-off-by: Simon Horman <horms@verge.net.au> Makes sense. Tested and working fine. Ack. Acked-by: Sachin P. Sant <sachinp@linux.vnet.ibm.com>
-rw-r--r--kexec/arch/ppc64/fs2dt.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/kexec/arch/ppc64/fs2dt.c b/kexec/arch/ppc64/fs2dt.c
index 7f7f972..9518e73 100644
--- a/kexec/arch/ppc64/fs2dt.c
+++ b/kexec/arch/ppc64/fs2dt.c
@@ -37,26 +37,6 @@
#define TREEWORDS 65536 /* max 32 bit words for property values */
#define MEMRESERVE 256 /* max number of reserved memory blocks */
-enum {
- ERR_NONE,
- ERR_USAGE,
- ERR_OPENDIR,
- ERR_READDIR,
- ERR_STAT,
- ERR_OPEN,
- ERR_READ,
- ERR_RESERVE,
-};
-
-static void err(const char *str, int rc)
-{
- if (errno)
- perror(str);
- else
- fprintf(stderr, "%s: unrecoverable error\n", str);
- exit(rc);
-}
-
static char pathname[MAXPATH], *pathstart;
static char propnames[NAMESPACE] = { 0 };
static unsigned dtstruct[TREEWORDS], *dt;
@@ -78,7 +58,7 @@ void reserve(unsigned long long where, unsigned long long length)
;
if (offset + 4 >= 2 * MEMRESERVE)
- err("exhasuted reservation meta data", ERR_RESERVE);
+ die("unrecoverable error: exhasuted reservation meta data\n");
mem_rsrv[offset] = where;
mem_rsrv[offset + 1] = length;
@@ -91,7 +71,7 @@ static void checkprop(char *name, unsigned *data)
static unsigned long long base, size;
if ((data == NULL) && (base || size))
- err((void *)data, ERR_RESERVE);
+ die("unrecoverable error: no property data");
else if (!strcmp(name, "linux,rtas-base"))
base = *data;
else if (!strcmp(name, "linux,tce-base"))
@@ -145,7 +125,8 @@ static void add_usable_mem_property(int fd, int len)
lseek(fd, 0, SEEK_SET);
if (read(fd, buf, len) != len)
- err(pathname, ERR_READ);
+ die("unrecoverable error: error reading \"%s\": %s\n",
+ pathname, strerror(errno));
base = ((unsigned long long *)buf)[0];
end = base + ((unsigned long long *)buf)[1];
@@ -204,7 +185,8 @@ static void putprops(char *fn, struct dirent **nlist, int numlist)
continue;
if (lstat(pathname, &statbuf))
- err(pathname, ERR_STAT);
+ die("unrecoverable error: could not stat \"%s\": %s\n",
+ pathname, strerror(errno));
if (!crash_param && !strcmp(fn,"linux,crashkernel-base"))
continue;
@@ -244,10 +226,12 @@ static void putprops(char *fn, struct dirent **nlist, int numlist)
fd = open(pathname, O_RDONLY);
if (fd == -1)
- err(pathname, ERR_OPEN);
+ die("unrecoverable error: could not open \"%s\": %s\n",
+ pathname, strerror(errno));
if (read(fd, dt, len) != len)
- err(pathname, ERR_READ);
+ die("unrecoverable error: could not read \"%s\": %s\n",
+ pathname, strerror(errno));
checkprop(fn, dt);
@@ -293,7 +277,7 @@ static void putprops(char *fn, struct dirent **nlist, int numlist)
if(errno == ENOSYS)
errno = 0;
if (errno)
- err(pathname, ERR_READDIR);
+ die("inrecoverable error: XXX: %s\n", strerror(errno));
checkprop(pathname, NULL);
}
@@ -341,7 +325,8 @@ static void putnode(void)
numlist = scandir(pathname, &namelist, 0, comparefunc);
if (numlist == 0)
- err(pathname, ERR_OPENDIR);
+ die("unrecoverable error: could not scan \"%s\": %s\n",
+ pathname, strerror(errno));
basename = strrchr(pathname,'/');
@@ -390,13 +375,14 @@ static void putnode(void)
continue;
if (lstat(pathname, &statbuf))
- err(pathname, ERR_STAT);
+ die("unrecoverable error: could not stat \"%s\": %s\n",
+ pathname, strerror(errno));
if (S_ISDIR(statbuf.st_mode))
putnode();
}
if (errno)
- err(pathname, ERR_READDIR);
+ die("unrecoverable error: XXX %s\n", strerror(errno));
*dt++ = 2;
dn[-1] = '\0';