1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
16 void* handle_clone(void* src_hanp, u_int hlen );
122 ((errno<NUM_ERRS)?(errno_names[errno]):("an unknown errno"))
124 #define ERRTEST(EXPECTED, NAME, FUNCTION) \
125 if ((FUNCTION) < 0) { \
126 if (errno == (EXPECTED)) { \
128 fprintf(stdout,"\treport on test for " #EXPECTED \
129 " in %s: test successful\n", (NAME)); \
132 fprintf(stdout, "\tERROR testing for " #EXPECTED \
133 " in %s: found %s.\n", (NAME), ERR_NAME); \
137 fprintf(stdout, "\tERROR testing for " #EXPECTED \
138 " in %s: no error was produced!\n", (NAME)); \
142 #define EXCLTEST(NAME, HANP, HLEN, TOKEN, FUNCTION) \
143 if (dm_create_userevent(sid, 10, "DMAPI" NAME, &(TOKEN))) { \
145 "\tERROR: can't create token (%s); skipping EACCES test\n", \
149 ERRTEST(EACCES, "no-right " NAME, (FUNCTION)) \
151 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_SHARED)) \
152 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to SHARED. %s\n", \
154 else ERRTEST(EACCES, "SHARED " NAME, (FUNCTION)) \
156 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_EXCL)) \
157 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL: %s\n", \
159 else if ((FUNCTION) < 0) \
160 fprintf(stdout, "\t"NAME" ERROR: token with DM_RIGHT_EXCL was " \
161 "denied access: %s\n", ERR_NAME); \
163 fprintf(stdout, "\treport on test for success in EXCL "NAME": " \
164 "test successful.\n"); \
166 if (dm_respond_event(sid, (TOKEN), DM_RESP_CONTINUE, 0, 0, 0)) \
167 fprintf(stdout, "\tERROR in responding to token: %s\n", ERR_NAME); \
172 #define SHAREDTEST(NAME, HANP, HLEN, TOKEN, FUNCTION) \
173 if (dm_create_userevent(sid, 10, "DMAPI" NAME, &(TOKEN))) { \
175 "\tCannot create_userevent (%s); skipping EACCES test\n", \
179 ERRTEST(EACCES, "no-right " NAME, (FUNCTION)) \
181 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), \
182 0, DM_RIGHT_SHARED)) \
183 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL. %s\n", \
185 else if ((FUNCTION) < 0) \
186 fprintf(stdout, "\t" NAME" ERROR: token with DM_RIGHT_SHARED " \
187 "was denied access. %s\n", ERR_NAME); \
189 fprintf(stdout, "\treport on test for success in SHARED "NAME": " \
190 "test successful.\n"); \
192 if (dm_request_right(sid, (HANP), (HLEN), (TOKEN), 0, DM_RIGHT_EXCL)) \
193 fprintf(stdout, "\t"NAME" ERROR: Couldn't upgrade to EXCL. %s\n", \
195 else if ((FUNCTION) < 0) \
196 fprintf(stdout, "\t" NAME" ERROR: token with DM_RIGHT_EXCL was " \
197 "denied access. %s\n", ERR_NAME); \
199 fprintf(stdout, "\treport on test for success in EXCL "NAME": " \
200 "test successful.\n"); \
202 if (dm_respond_event(sid, (TOKEN), DM_RESP_CONTINUE, 0, 0, 0)) \
203 fprintf(stderr, "\tERROR in responding to token: %s\n", ERR_NAME); \
209 handle_clone(void* src_hanp, u_int hlen )
213 if ((dest_hanp = malloc(hlen)) == NULL) return(NULL);
214 bcopy(src_hanp, dest_hanp, hlen);