]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/cifs/doserrstr.c
kbdfs: simplfy
[plan9front.git] / sys / src / cmd / cifs / doserrstr.c
1 #include <u.h>
2 #include <libc.h>
3
4 /*
5  * This file is derrived from nterr.h in the samba distribution
6  */
7
8 /*
9    Unix SMB/CIFS implementation.
10    DOS error code constants
11    Copyright (C) Andrew Tridgell              1992-2000
12    Copyright (C) John H Terpstra              1996-2000
13    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
14    Copyright (C) Paul Ashton                  1998-2000
15
16    This program is free software; you can redistribute it and/or modify
17    it under the terms of the GNU General Public License as published by
18    the Free Software Foundation; either version 2 of the License, or
19    (at your option) any later version.
20
21    This program is distributed in the hope that it will be useful,
22    but WITHOUT ANY WARRANTY; without even the implied warranty of
23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24    GNU General Public License for more details.
25
26    You should have received a copy of the GNU General Public License
27    along with this program; if not, write to the Free Software
28    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29  */
30
31
32 static struct {
33         int     err;
34         char    *msg;
35 } DOSerrs[] = {
36         /* smb x/open error codes for the errdos error class */
37         { (0<<16)|1,    "no error" },
38         { (1<<16)|1,    "invalid function" },
39         { (2<<16)|1,    "file not found" },
40         { (3<<16)|1,    "directory not found" },
41         { (4<<16)|1,    "too many open files" },
42         { (5<<16)|1,    "access denied" },
43         { (6<<16)|1,    "invalid fid" },
44         { (7<<16)|1,    "memory control blocks destroyed." },
45         { (8<<16)|1,    "out of memory" },
46         { (9<<16)|1,    "invalid memory block address" },
47         { (10<<16)|1,   "invalid environment" },
48         { (12<<16)|1,   "invalid open mode" },
49         { (13<<16)|1,   "invalid data (only from ioctl call)" },
50         { (14<<16)|1,   "reserved" },
51         { (15<<16)|1,   "invalid drive" },
52         { (16<<16)|1,   "attempt to delete current directory" },
53         { (17<<16)|1,   "rename/move across filesystems" },
54         { (18<<16)|1,   "no more files found" },
55         { (31<<16)|1,   "general failure" },
56         { (32<<16)|1,   "share mode conflict with open mode" },
57         { (33<<16)|1,   "lock conflicts" },
58         { (50<<16)|1,   "request unsupported" },
59         { (64<<16)|1,   "network name not available" },
60         { (66<<16)|1,   "ipc unsupported (guess)" },
61         { (67<<16)|1,   "invalid share name" },
62         { (80<<16)|1,   "file already exists" },
63         { (87<<16)|1,   "invalid paramater" },
64         { (110<<16)|1,  "cannot open" },
65         { (122<<16)|1,  "insufficent buffer" },
66         { (123<<16)|1,  "invalid name" },
67         { (124<<16)|1,  "unknown level" },
68         { (158<<16)|1,  "this region already locked" },
69
70         { (183<<16)|1,  "rename failed" },
71
72         { (230<<16)|1,  "named pipe invalid" },
73         { (231<<16)|1,  "pipe busy" },
74         { (232<<16)|1,  "close in progress" },
75         { (233<<16)|1,  "no reader of named pipe" },
76         { (234<<16)|1,  "more data to be returned" },
77         { (259<<16)|1,  "no more items" },
78         { (267<<16)|1,  "invalid directory name in a path" },
79         { (282<<16)|1,  "extended attributes" },
80         { (1326<<16)|1, "authentication failed" },
81         { (2123<<16)|1, "buffer too small" },
82         { (2142<<16)|1, "unknown ipc" },
83         { (2151<<16)|1, "no such print job" },
84         { (2455<<16)|1, "invalid group" },
85
86         /* Error codes for the ERRSRV class */
87         { (1<<16)|2,    "non specific error" },
88         { (2<<16)|2,    "bad password" },
89         { (3<<16)|2,    "reserved" },
90         { (4<<16)|2,    "permission denied" },
91         { (5<<16)|2,    "tid invalid" },
92         { (6<<16)|2,    "invalid server name" },
93         { (7<<16)|2,    "invalid device" },
94         { (22<<16)|2,   "unknown smb" },
95         { (49<<16)|2,   "print queue full" },
96         { (50<<16)|2,   "queued item too big" },
97         { (52<<16)|2,   "fid invalid in print file" },
98         { (64<<16)|2,   "unrecognised command" },
99         { (65<<16)|2,   "smb server internal error" },
100         { (67<<16)|2,   "fid/pathname invalid" },
101         { (68<<16)|2,   "reserved 68" },
102         { (69<<16)|2,   "access is invalid" },
103         { (70<<16)|2,   "reserved 70" },
104         { (71<<16)|2,   "attribute mode invalid" },
105         { (81<<16)|2,   "message server paused" },
106         { (82<<16)|2,   "not receiving messages" },
107         { (83<<16)|2,   "no room for message" },
108         { (87<<16)|2,   "too many remote usernames" },
109         { (88<<16)|2,   "operation timed out" },
110         { (89<<16)|2,   "no resources" },
111         { (90<<16)|2,   "too many userids" },
112         { (91<<16)|2,   "bad userid" },
113         { (250<<16)|2,  "retry with mpx mode" },
114         { (251<<16)|2,  "retry with standard mode" },
115         { (252<<16)|2,  "resume mpx mode" },
116         { (0xffff<<16)|2, "function not supported" },
117
118         /* Error codes for the ERRHRD class */
119         { (19<<16)|3,   "read only media" },
120         { (20<<16)|3,   "unknown device" },
121         { (21<<16)|3,   "drive not ready" },
122         { (22<<16)|3,   "unknown command" },
123         { (23<<16)|3,   "data (CRC) error" },
124         { (24<<16)|3,   "bad request length" },
125         { (25<<16)|3,   "seek failed" },
126         { (26<<16)|3,   "bad media" },
127         { (27<<16)|3,   "bad sector" },
128         { (28<<16)|3,   "no paper" },
129         { (29<<16)|3,   "write fault" },
130         { (30<<16)|3,   "read fault" },
131         { (31<<16)|3,   "general hardware failure" },
132         { (34<<16)|3,   "wrong disk" },
133         { (35<<16)|3,   "FCB unavailable" },
134         { (36<<16)|3,   "share buffer exceeded" },
135         { (39<<16)|3,   "disk full" },
136
137 };
138
139 char *
140 doserrstr(uint err)
141 {
142         int i, match;
143         char *class;
144         static char buf[0xff];
145
146         switch(err & 0xff){
147         case 1:
148                 class = "dos";
149                 break;
150         case 2:
151                 class = "network";
152                 break;
153         case 3:
154                 class = "hardware";
155                 break;
156         case 4:
157                 class = "Xos";
158                 break;
159         case 0xe1:
160                 class = "mx1";
161                 break;
162         case 0xe2:
163                 class = "mx2";
164                 break;
165         case 0xe3:
166                 class = "mx3";
167                 break;
168         case 0xff:
169                 class = "packet";
170                 break;
171         default:
172                 class = "unknown";
173                 break;
174         }
175
176         match = -1;
177         for(i = 0; i < nelem(DOSerrs); i++)
178                 if(DOSerrs[i].err == err)
179                         match = i;
180
181         if(match != -1)
182                 snprint(buf, sizeof(buf), "%s, %s", class, DOSerrs[match].msg);
183         else
184                 snprint(buf, sizeof(buf), "%s, %ud/0x%ux - unknown error",
185                         class, err >> 16, err >> 16);
186         return buf;
187 }