better errstr
This commit is contained in:
parent
0d7fd01125
commit
a695bc7db9
4 changed files with 169 additions and 8 deletions
|
|
@ -48,4 +48,3 @@ char* estrdup(char *p);
|
||||||
|
|
||||||
int errstr2errno(void);
|
int errstr2errno(void);
|
||||||
void unmountatexit(void);
|
void unmountatexit(void);
|
||||||
|
|
||||||
|
|
|
||||||
165
src/cmd/9pfuse/errstr.c
Normal file
165
src/cmd/9pfuse/errstr.c
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
#include "a.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
EPLAN9 = 0x19283745 /* see /usr/local/plan9/src/lib9/errstr.c */
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct Error Error;
|
||||||
|
struct Error
|
||||||
|
{
|
||||||
|
char *text;
|
||||||
|
int err;
|
||||||
|
int len;
|
||||||
|
};
|
||||||
|
|
||||||
|
static Error errortab[] = {
|
||||||
|
{"Operation not permitted", EPERM},
|
||||||
|
{"wstat prohibited", EPERM},
|
||||||
|
{"No such file or directory", ENOENT},
|
||||||
|
{"file not found", ENOENT},
|
||||||
|
{"Interrupted system call", EINTR},
|
||||||
|
{"Input/output error", EIO},
|
||||||
|
{"No such device or address", ENXIO},
|
||||||
|
{"Argument list too long", E2BIG},
|
||||||
|
{"Bad file descriptor", EBADF},
|
||||||
|
{"Resource temporarily unavailable", EAGAIN},
|
||||||
|
{"Cannot allocate memory", ENOMEM},
|
||||||
|
{"Permission denied", EACCES},
|
||||||
|
{"Bad address", EFAULT},
|
||||||
|
{"Block device required", ENOTBLK},
|
||||||
|
{"Device or resource busy", EBUSY},
|
||||||
|
{"File exists", EEXIST},
|
||||||
|
{"Invalid cross-device link", EXDEV},
|
||||||
|
{"No such device", ENODEV},
|
||||||
|
{"Not a directory", ENOTDIR},
|
||||||
|
{"Is a directory", EISDIR},
|
||||||
|
{"Invalid argument", EINVAL},
|
||||||
|
{"Too many open files in system", ENFILE},
|
||||||
|
{"Too many open files", EMFILE},
|
||||||
|
{"Text file busy", ETXTBSY},
|
||||||
|
{"File too large", EFBIG},
|
||||||
|
{"No space left on device", ENOSPC},
|
||||||
|
{"Illegal seek", ESPIPE},
|
||||||
|
{"Read-only file system", EROFS},
|
||||||
|
{"Too many links", EMLINK},
|
||||||
|
{"Broken pipe", EPIPE},
|
||||||
|
{"Numerical argument out of domain", EDOM},
|
||||||
|
{"Numerical result out of range", ERANGE},
|
||||||
|
{"Resource deadlock avoided", EDEADLK},
|
||||||
|
{"File name too long", ENAMETOOLONG},
|
||||||
|
{"No locks available", ENOLCK},
|
||||||
|
{"Function not implemented", ENOSYS},
|
||||||
|
{"Directory not empty", ENOTEMPTY},
|
||||||
|
{"Too many levels of symbolic links", ELOOP},
|
||||||
|
{"No message of desired type", ENOMSG},
|
||||||
|
{"Identifier removed", EIDRM},
|
||||||
|
{"No data available", ENODATA},
|
||||||
|
{"Machine is not on the network", ENONET},
|
||||||
|
{"Package not installed", ENOPKG},
|
||||||
|
{"Object is remote", EREMOTE},
|
||||||
|
{"Link has been severed", ENOLINK},
|
||||||
|
{"Communication error on send", ECOMM},
|
||||||
|
{"Protocol error", EPROTO},
|
||||||
|
{"Bad message", EBADMSG},
|
||||||
|
{"File descriptor in bad state", EBADFD},
|
||||||
|
{"Streams pipe error", ESTRPIPE},
|
||||||
|
{"Too many users", EUSERS},
|
||||||
|
{"Socket operation on non-socket", ENOTSOCK},
|
||||||
|
{"Message too long", EMSGSIZE},
|
||||||
|
{"Protocol not available", ENOPROTOOPT},
|
||||||
|
{"Protocol not supported", EPROTONOSUPPORT},
|
||||||
|
{"Socket type not supported", ESOCKTNOSUPPORT},
|
||||||
|
{"Operation not supported", EOPNOTSUPP},
|
||||||
|
{"Protocol family not supported", EPFNOSUPPORT},
|
||||||
|
{"Network is down", ENETDOWN},
|
||||||
|
{"Network is unreachable", ENETUNREACH},
|
||||||
|
{"Network dropped connection on reset", ENETRESET},
|
||||||
|
{"Software caused connection abort", ECONNABORTED},
|
||||||
|
{"Connection reset by peer", ECONNRESET},
|
||||||
|
{"No buffer space available", ENOBUFS},
|
||||||
|
{"Transport endpoint is already connected", EISCONN},
|
||||||
|
{"Transport endpoint is not connected", ENOTCONN},
|
||||||
|
{"Cannot send after transport endpoint shutdown", ESHUTDOWN},
|
||||||
|
{"Connection timed out", ETIMEDOUT},
|
||||||
|
{"Connection refused", ECONNREFUSED},
|
||||||
|
{"Host is down", EHOSTDOWN},
|
||||||
|
{"No route to host", EHOSTUNREACH},
|
||||||
|
{"Operation already in progress", EALREADY},
|
||||||
|
{"Operation now in progress", EINPROGRESS},
|
||||||
|
{"Is a named type file", EISNAM},
|
||||||
|
{"Remote I/O error", EREMOTEIO},
|
||||||
|
{"Disk quota exceeded", EDQUOT},
|
||||||
|
/* errors from fossil, vacfs, and u9fs */
|
||||||
|
{"fid unknown or out of range", EBADF},
|
||||||
|
{"permission denied", EACCES},
|
||||||
|
{"file does not exist", ENOENT},
|
||||||
|
{"authentication failed", ECONNREFUSED},
|
||||||
|
{"bad offset in directory read", ESPIPE},
|
||||||
|
{"bad use of fid", EBADF},
|
||||||
|
{"wstat can't convert between files and directories", EPERM},
|
||||||
|
{"directory is not empty", ENOTEMPTY},
|
||||||
|
{"file exists", EEXIST},
|
||||||
|
{"file already exists", EEXIST},
|
||||||
|
{"file or directory already exists", EEXIST},
|
||||||
|
{"fid already in use", EBADF},
|
||||||
|
{"file in use", ETXTBSY},
|
||||||
|
{"i/o error", EIO},
|
||||||
|
{"file already open for I/O", ETXTBSY},
|
||||||
|
{"illegal mode", EINVAL},
|
||||||
|
{"illegal name", ENAMETOOLONG},
|
||||||
|
{"not a directory", ENOTDIR},
|
||||||
|
{"not a member of proposed group", EPERM},
|
||||||
|
{"not owner", EACCES},
|
||||||
|
{"only owner can change group in wstat", EACCES},
|
||||||
|
{"read only file system", EROFS},
|
||||||
|
{"no access to special file", EPERM},
|
||||||
|
{"i/o count too large", EIO},
|
||||||
|
{"unknown group", EINVAL},
|
||||||
|
{"unknown user", EINVAL},
|
||||||
|
{"bogus wstat buffer", EPROTO},
|
||||||
|
{"exclusive use file already open", EAGAIN},
|
||||||
|
{"corrupted directory entry", EIO},
|
||||||
|
{"corrupted file entry", EIO},
|
||||||
|
{"corrupted block label", EIO},
|
||||||
|
{"corrupted meta data", EIO},
|
||||||
|
{"illegal offset", EINVAL},
|
||||||
|
{"illegal path element", ENOENT},
|
||||||
|
{"root of file system is corrupted", EIO},
|
||||||
|
{"corrupted super block", EIO},
|
||||||
|
{"protocol botch", EPROTO},
|
||||||
|
{"file system is full", ENOSPC},
|
||||||
|
{"file is in use", EAGAIN},
|
||||||
|
{"directory entry is not allocated", ENOENT},
|
||||||
|
{"file is read only", EROFS},
|
||||||
|
{"file has been removed", EIDRM},
|
||||||
|
{"only support truncation to zero length", EPERM},
|
||||||
|
{"cannot remove root", EPERM},
|
||||||
|
{"file too big", EFBIG},
|
||||||
|
{"venti i/o error", EIO},
|
||||||
|
/* these are not errors */
|
||||||
|
{"u9fs rhostsauth: no authentication required", 0},
|
||||||
|
{"u9fs authnone: no authentication required", 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
errstr2errno(void)
|
||||||
|
{
|
||||||
|
char e[ERRMAX];
|
||||||
|
int i, len;
|
||||||
|
|
||||||
|
if(errno != EPLAN9)
|
||||||
|
return errno;
|
||||||
|
|
||||||
|
if(errortab[0].len == 0)
|
||||||
|
for(i=0; i<nelem(errortab); i++)
|
||||||
|
errortab[i].len = strlen(errortab[i].text);
|
||||||
|
|
||||||
|
rerrstr(e, sizeof e);
|
||||||
|
len = strlen(e);
|
||||||
|
for(i=0; i<nelem(errortab); i++)
|
||||||
|
if(errortab[i].len <= len && cistrstr(e, errortab[i].text))
|
||||||
|
return errortab[i].err;
|
||||||
|
return ERANGE; /* who knows? */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -87,6 +87,8 @@ threadmain(int argc, char **argv)
|
||||||
fmtinstall('M', dirmodefmt);
|
fmtinstall('M', dirmodefmt);
|
||||||
fmtinstall('G', fusefmt);
|
fmtinstall('G', fusefmt);
|
||||||
|
|
||||||
|
setsid(); /* won't be able to use console, but can't be interrupted */
|
||||||
|
|
||||||
init9p(argv[0]);
|
init9p(argv[0]);
|
||||||
initfuse(argv[1]);
|
initfuse(argv[1]);
|
||||||
|
|
||||||
|
|
@ -122,13 +124,6 @@ init9p(char *addr)
|
||||||
fsysroot = fsroot(fsys);
|
fsysroot = fsroot(fsys);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
errstr2errno(void)
|
|
||||||
{
|
|
||||||
/* TODO: a better job */
|
|
||||||
return EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUSE uses nodeids to refer to active "struct inodes"
|
* FUSE uses nodeids to refer to active "struct inodes"
|
||||||
* (9P's unopened fids). FUSE uses fhs to refer to active
|
* (9P's unopened fids). FUSE uses fhs to refer to active
|
||||||
|
|
@ -454,6 +449,7 @@ fusesetattr(FuseMsg *m)
|
||||||
if(fsfopen(nfid, OWRITE|OTRUNC) < 0){
|
if(fsfopen(nfid, OWRITE|OTRUNC) < 0){
|
||||||
replyfuseerrstr(m);
|
replyfuseerrstr(m);
|
||||||
fsclose(nfid);
|
fsclose(nfid);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
fsclose(nfid);
|
fsclose(nfid);
|
||||||
goto stat;
|
goto stat;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
TARG=9pfuse
|
TARG=9pfuse
|
||||||
|
|
||||||
OFILES=\
|
OFILES=\
|
||||||
|
errstr.$O\
|
||||||
fuse.$O\
|
fuse.$O\
|
||||||
main.$O\
|
main.$O\
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue