199767f8919635c4928607450d9e0abb932109ceToomas Soome/* $NetBSD: strerror.c,v 1.12 1997/01/25 00:37:50 cgd Exp $ */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/cdefs.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome__FBSDID("$FreeBSD$");
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include "stand.h"
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestatic struct
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome int err;
199767f8919635c4928607450d9e0abb932109ceToomas Soome char *msg;
199767f8919635c4928607450d9e0abb932109ceToomas Soome} errtab[] = {
199767f8919635c4928607450d9e0abb932109ceToomas Soome {0, "no error"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* standard errors */
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EPERM, "operation not permitted"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ENOENT, "no such file or directory"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EIO, "input/output error"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ENXIO, "device not configured"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ENOEXEC, "exec format error"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EBADF, "bad file descriptor"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ENOMEM, "cannot allocate memory"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ENODEV, "operation not supported by device"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ENOTDIR, "not a directory"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EISDIR, "is a directory"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EINVAL, "invalid argument"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EMFILE, "too many open files"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EFBIG, "file too large"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EROFS, "read-only filesystem"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EOPNOTSUPP, "operation not supported"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ETIMEDOUT, "operation timed out"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ESTALE, "stale NFS file handle"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EBADRPC, "RPC struct is bad"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EFTYPE, "inappropriate file type or format"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EADAPT, "bad adaptor number"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ECTLR, "bad controller number"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EUNIT, "bad unit number"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ESLICE, "bad slice number"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EPART, "bad partition"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {ERDLAB, "can't read disk label"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EUNLAB, "disk unlabelled"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {EOFFSET, "illegal seek"},
199767f8919635c4928607450d9e0abb932109ceToomas Soome {0, NULL}
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomechar *
199767f8919635c4928607450d9e0abb932109ceToomas Soomestrerror(int err)
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome static char msg[32];
199767f8919635c4928607450d9e0abb932109ceToomas Soome int i;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome for (i = 0; errtab[i].msg != NULL; i++)
199767f8919635c4928607450d9e0abb932109ceToomas Soome if (errtab[i].err == err)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return(errtab[i].msg);
199767f8919635c4928607450d9e0abb932109ceToomas Soome sprintf(msg, "unknown error (%d)", err);
199767f8919635c4928607450d9e0abb932109ceToomas Soome return(msg);
199767f8919635c4928607450d9e0abb932109ceToomas Soome}