• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *   Copyright (c) International Business Machines  Corp., 2004
3  *
4  *   This program is free software;  you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12  *   the GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program;  if not, write to the Free Software
16  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * TEST CASE	: attr.c - DMAPI attributes
21  *
22  * VARIATIONS	: 204
23  *
24  * API'S TESTED	: dm_set_dmattr
25  * 		  dm_get_dmattr
26  * 		  dm_remove_dmattr
27  * 		  dm_getall_dmattr
28  * 		  dm_set_fileattr
29  * 		  dm_get_fileattr
30  * 		  dm_get_dirattrs
31  * 		  dm_set_inherit
32  * 		  dm_clear_inherit
33  * 		  dm_getall_inherit
34  */
35 #include <string.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <errno.h>
39 #include <unistd.h>
40 #include <fcntl.h>
41 #include <sys/stat.h>
42 #include <sys/xattr.h>
43 #include "dm_test.h"
44 
45 #define TMP_FILELEN 1000
46 #define ATTR_NAME2 "DMAttr02"
47 #define NUM_ATTRS 15
48 #define ATTR_SMALLLEN (DWALIGN(sizeof(dm_stat_t)+1) + DWALIGN(sizeof(DUMMY_FILE)+1))
49 #define MIN_ENTRYLEN (DWALIGN(sizeof(dm_stat_t)+1) + DWALIGN(sizeof(CURRENT_DIR)+1))
50 #define DM_AT_ALL_DIRATTRS (DM_AT_DTIME|DM_AT_HANDLE|DM_AT_EMASK|DM_AT_PMANR|DM_AT_PATTR|DM_AT_STAT|DM_AT_CFLAG)
51 #define NON_DM_ATTR_NAME "user.non-dm.attr"
52 #define NON_DM_ATTR_VALUE "This is a non-DM attribute's value"
53 
54 /*
55  * DIRENTS_FILES is very implementation-dependent, and is the number of files
56  * that will just fill up the buffer passed to jfs_get_dirents; NUM_FILES
57  * should be at least 3 times DIRENTS_FILES; ATTR_LISTLEN needs to be large
58  * enough to contain 3 files (., .. and dummy.txt) worth of information while
59  * ATTR_BIGLISTLEN needs to be large enough to contain NUM_FILES files worth
60  * of information
61  */
62 #define DIRENTS_FILES 5
63 #define NUM_FILES 15
64 #define ATTR_LISTLEN 1000
65 #define ATTR_BIGLISTLEN 10000
66 
67 char command[4096];
68 char fullAttrName[32];
69 dm_sessid_t sid;
70 dm_size_t maxAttrSize;
71 dm_size_t persInheritAttr;
72 
LogDmStat(dm_stat_t * statdm)73 void LogDmStat(dm_stat_t * statdm)
74 {
75 
76 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_dev %d\n", statdm->dt_dev);
77 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_ino %d\n", statdm->dt_ino);
78 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_mode 0x%x\n", statdm->dt_mode);
79 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_nlink %d\n", statdm->dt_nlink);
80 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_uid %d\n", statdm->dt_uid);
81 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_gid %d\n", statdm->dt_gid);
82 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_rdev %d\n", statdm->dt_rdev);
83 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_size %lld\n", statdm->dt_size);
84 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_blksize %d\n", statdm->dt_blksize);
85 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_blocks %d\n", statdm->dt_blocks);
86 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_atime %d\n", statdm->dt_atime);
87 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_mtime %d\n", statdm->dt_mtime);
88 	DMLOG_PRINT(DMLVL_DEBUG, "    dt_ctime %d\n", statdm->dt_ctime);
89 
90 }
91 
LogDmAttrs(dm_attrlist_t * attrlist)92 void LogDmAttrs(dm_attrlist_t * attrlist)
93 {
94 
95 	int i = 0;
96 	dm_attrlist_t *attr = attrlist;
97 
98 	while (attr != NULL) {
99 		DMLOG_PRINT(DMLVL_DEBUG, "  dmattr %d: name %.*s, value %.*s\n",
100 			    i++, DM_ATTR_NAME_SIZE, attr->al_name.an_chars,
101 			    DM_GET_LEN(attr, al_data), DM_GET_VALUE(attr,
102 								    al_data,
103 								    char *));
104 		attr = DM_STEP_TO_NEXT(attr, dm_attrlist_t *);
105 	}
106 }
107 
LogDirAttrs(void * attrlist,u_int mask)108 void LogDirAttrs(void *attrlist, u_int mask)
109 {
110 	int i = 0;
111 	dm_stat_t *stat = (dm_stat_t *) attrlist;
112 
113 	while (stat != NULL) {
114 		DMLOG_PRINT(DMLVL_DEBUG, "  dirattr %d:\n", i++);
115 		DMLOG_PRINT(DMLVL_DEBUG, "    dt_compname: %s\n",
116 			    DM_GET_VALUE(stat, dt_compname, char *));
117 		if (mask & DM_AT_HANDLE)
118 			dm_LogHandle(DM_GET_VALUE(stat, dt_handle, void *),
119 				     DM_GET_LEN(stat, dt_handle));
120 		if (mask & DM_AT_EMASK)
121 			DMLOG_PRINT(DMLVL_DEBUG, "    dt_emask: %x\n",
122 				    stat->dt_emask);
123 		if (mask & DM_AT_PMANR)
124 			DMLOG_PRINT(DMLVL_DEBUG, "    dt_pmanreg: %s\n",
125 				    stat->dt_pmanreg ? "DM_TRUE" : "DM_FALSE");
126 		if (mask & DM_AT_PATTR)
127 			DMLOG_PRINT(DMLVL_DEBUG, "    dt_pers: %s\n",
128 				    stat->dt_pers ? "DM_TRUE" : "DM_FALSE");
129 		if (mask & DM_AT_DTIME)
130 			DMLOG_PRINT(DMLVL_DEBUG, "    dt_dtime: %d\n",
131 				    stat->dt_dtime);
132 		if (mask & DM_AT_CFLAG)
133 			DMLOG_PRINT(DMLVL_DEBUG, "    dt_change: %d\n",
134 				    stat->dt_change);
135 		if (mask & DM_AT_STAT)
136 			LogDmStat(stat);
137 
138 		stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
139 	}
140 }
141 
GetDirEntry(void * attrlist,char * compname)142 dm_stat_t *GetDirEntry(void *attrlist, char *compname)
143 {
144 
145 	dm_stat_t *stat = (dm_stat_t *) attrlist;
146 
147 	while (stat != NULL) {
148 		if (strcmp(DM_GET_VALUE(stat, dt_compname, char *), compname) ==
149 		    0)
150 			return stat;
151 		stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
152 	}
153 	return NULL;
154 
155 }
156 
GetLastDirEntry(void * attrlist)157 dm_stat_t *GetLastDirEntry(void *attrlist)
158 {
159 
160 	dm_stat_t *stat = (dm_stat_t *) attrlist;
161 	dm_stat_t *laststat = NULL;
162 
163 	while (stat != NULL) {
164 		laststat = stat;
165 		stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
166 	}
167 	return laststat;
168 
169 }
170 
GetNumDirEntry(void * attrlist)171 int GetNumDirEntry(void *attrlist)
172 {
173 
174 	dm_stat_t *stat = (dm_stat_t *) attrlist;
175 	int i = 0;
176 
177 	while (stat != NULL) {
178 		i++;
179 		stat = DM_STEP_TO_NEXT(stat, dm_stat_t *);
180 	}
181 	return i;
182 
183 }
184 
main(int argc,char ** argv)185 int main(int argc, char **argv)
186 {
187 
188 	char *szFuncName;
189 	char *varstr;
190 	int i;
191 	int rc;
192 	char *szSessionInfo = "dm_test session info";
193 
194 	DMOPT_PARSE(argc, argv);
195 	DMLOG_START();
196 
197 	/* CANNOT DO ANYTHING WITHOUT SUCCESSFUL INITIALIZATION!!! */
198 	if ((rc = dm_init_service(&varstr)) != 0) {
199 		DMLOG_PRINT(DMLVL_ERR,
200 			    "dm_init_service failed! (rc = %d, errno = %d)\n",
201 			    rc, errno);
202 		DM_EXIT();
203 	} else if ((rc = dm_create_session(DM_NO_SESSION, szSessionInfo, &sid))
204 		   != 0) {
205 		DMLOG_PRINT(DMLVL_ERR,
206 			    "dm_create_session failed! (rc = %d, errno = %d)\n",
207 			    rc, errno);
208 		DM_EXIT();
209 	} else {
210 		int fd;
211 		void *fshanp;
212 		size_t fshlen;
213 
214 		fd = open(DUMMY_TMP, O_RDWR | O_CREAT | O_TRUNC,
215 			  DUMMY_FILE_RW_MODE);
216 		if (fd != -1) {
217 			for (i = 0; i < (TMP_FILELEN / DUMMY_STRLEN); i++) {
218 				if (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
219 				    DUMMY_STRLEN) {
220 					rc = -1;
221 					break;
222 				}
223 			}
224 		} else {
225 			rc = -1;
226 		}
227 		if (rc == 0) {
228 			rc = close(fd);
229 		}
230 		if (rc == -1) {
231 			DMLOG_PRINT(DMLVL_ERR,
232 				    "creating dummy file failed! (rc = %d, errno = %d)\n",
233 				    rc, errno);
234 			dm_destroy_session(sid);
235 			DM_EXIT();
236 		}
237 
238 		rc = dm_path_to_fshandle(DUMMY_TMP, &fshanp, &fshlen);
239 		if (rc == -1) {
240 			DMLOG_PRINT(DMLVL_ERR,
241 				    "dm_path_to_fshandle! (rc = %d, errno = %d)\n",
242 				    rc, errno);
243 			dm_destroy_session(sid);
244 			DM_EXIT();
245 		}
246 
247 		rc = dm_get_config(fshanp, fshlen, DM_CONFIG_MAX_ATTRIBUTE_SIZE,
248 				   &maxAttrSize);
249 		if (rc == -1) {
250 			DMLOG_PRINT(DMLVL_ERR,
251 				    "dm_get_config failed! (rc = %d, errno = %d)\n",
252 				    rc, errno);
253 			dm_handle_free(fshanp, fshlen);
254 			dm_destroy_session(sid);
255 			DM_EXIT();
256 		}
257 
258 		rc = dm_get_config(fshanp, fshlen,
259 				   DM_CONFIG_PERS_INHERIT_ATTRIBS,
260 				   &persInheritAttr);
261 		if (rc == -1) {
262 			DMLOG_PRINT(DMLVL_ERR,
263 				    "dm_get_config failed! (rc = %d, errno = %d)\n",
264 				    rc, errno);
265 			dm_handle_free(fshanp, fshlen);
266 			dm_destroy_session(sid);
267 			DM_EXIT();
268 		}
269 
270 		dm_handle_free(fshanp, fshlen);
271 
272 		sprintf(fullAttrName, "%s%s", DMAPI_ATTR_PREFIX, ATTR_NAME);
273 
274 		/* Clean up any possible leftovers that could get in the way */
275 		remove(DUMMY_SUBDIR_FILE);
276 		unlink(DUMMY_SUBDIR_LINK);
277 		rmdir(DUMMY_SUBDIR_SUBDIR);
278 		remove(DUMMY_FILE);
279 		remove(DUMMY_FILE2);
280 		unlink(DUMMY_LINK);
281 		rmdir(DUMMY_SUBDIR);
282 	}
283 
284 	DMLOG_PRINT(DMLVL_DEBUG, "Starting DMAPI attribute tests\n");
285 
286 	szFuncName = "dm_set_dmattr";
287 
288 	/*
289 	 * TEST    : dm_set_dmattr - invalid sid
290 	 * EXPECTED: rc = -1, errno = EINVAL
291 	 */
292 	if (DMVAR_EXEC(SET_DMATTR_BASE + 1)) {
293 		int fd;
294 		void *hanp;
295 		size_t hlen;
296 		dm_attrname_t attrname;
297 		char buf[ATTR_VALUELEN];
298 
299 		/* Variation set up */
300 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
301 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
302 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
303 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
304 		if ((rc = system(command)) == -1) {
305 			/* No clean up */
306 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
307 			remove(DUMMY_FILE);
308 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
309 			close(fd);
310 			remove(DUMMY_FILE);
311 		}
312 		if (fd == -1 || rc == -1) {
313 			DMLOG_PRINT(DMLVL_DEBUG,
314 				    "Unable to set up variation! (errno = %d)\n",
315 				    errno);
316 			DMVAR_SKIP();
317 		} else {
318 			/* Variation */
319 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
320 				    szFuncName);
321 			rc = dm_set_dmattr(INVALID_ADDR, hanp, hlen,
322 					   DM_NO_TOKEN, &attrname, 0,
323 					   sizeof(buf), buf);
324 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
325 
326 			/* Variation clean up */
327 			rc = close(fd);
328 			rc |= remove(DUMMY_FILE);
329 			if (rc == -1) {
330 				DMLOG_PRINT(DMLVL_DEBUG,
331 					    "Unable to clean up variation! (errno = %d)\n",
332 					    errno);
333 			}
334 			dm_handle_free(hanp, hlen);
335 		}
336 	}
337 
338 	/*
339 	 * TEST    : dm_set_dmattr - invalid hanp
340 	 * EXPECTED: rc = -1, errno = EFAULT
341 	 */
342 	if (DMVAR_EXEC(SET_DMATTR_BASE + 2)) {
343 		int fd;
344 		void *hanp;
345 		size_t hlen;
346 		dm_attrname_t attrname;
347 		char buf[ATTR_VALUELEN];
348 
349 		/* Variation set up */
350 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
351 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
352 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
353 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
354 		if ((rc = system(command)) == -1) {
355 			/* No clean up */
356 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
357 			remove(DUMMY_FILE);
358 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
359 			close(fd);
360 			remove(DUMMY_FILE);
361 		}
362 		if (fd == -1 || rc == -1) {
363 			DMLOG_PRINT(DMLVL_DEBUG,
364 				    "Unable to set up variation! (errno = %d)\n",
365 				    errno);
366 			DMVAR_SKIP();
367 		} else {
368 			/* Variation */
369 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
370 				    szFuncName);
371 			rc = dm_set_dmattr(sid, (void *)INVALID_ADDR, hlen,
372 					   DM_NO_TOKEN, &attrname, 0,
373 					   sizeof(buf), buf);
374 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
375 
376 			/* Variation clean up */
377 			rc = close(fd);
378 			rc |= remove(DUMMY_FILE);
379 			if (rc == -1) {
380 				DMLOG_PRINT(DMLVL_DEBUG,
381 					    "Unable to clean up variation! (errno = %d)\n",
382 					    errno);
383 			}
384 			dm_handle_free(hanp, hlen);
385 		}
386 	}
387 
388 	/*
389 	 * TEST    : dm_set_dmattr - invalid hlen
390 	 * EXPECTED: rc = -1, errno = EBADF
391 	 */
392 	if (DMVAR_EXEC(SET_DMATTR_BASE + 3)) {
393 		int fd;
394 		void *hanp;
395 		size_t hlen;
396 		dm_attrname_t attrname;
397 		char buf[ATTR_VALUELEN];
398 
399 		/* Variation set up */
400 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
401 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
402 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
403 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
404 		if ((rc = system(command)) == -1) {
405 			/* No clean up */
406 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
407 			remove(DUMMY_FILE);
408 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
409 			close(fd);
410 			remove(DUMMY_FILE);
411 		}
412 		if (fd == -1 || rc == -1) {
413 			DMLOG_PRINT(DMLVL_DEBUG,
414 				    "Unable to set up variation! (errno = %d)\n",
415 				    errno);
416 			DMVAR_SKIP();
417 		} else {
418 			/* Variation */
419 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
420 				    szFuncName);
421 			rc = dm_set_dmattr(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
422 					   &attrname, 0, sizeof(buf), buf);
423 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
424 
425 			/* Variation clean up */
426 			rc = close(fd);
427 			rc |= remove(DUMMY_FILE);
428 			if (rc == -1) {
429 				DMLOG_PRINT(DMLVL_DEBUG,
430 					    "Unable to clean up variation! (errno = %d)\n",
431 					    errno);
432 			}
433 			dm_handle_free(hanp, hlen);
434 		}
435 	}
436 
437 	/*
438 	 * TEST    : dm_set_dmattr - invalid token
439 	 * EXPECTED: rc = -1, errno = EINVAL
440 	 */
441 	if (DMVAR_EXEC(SET_DMATTR_BASE + 4)) {
442 		int fd;
443 		void *hanp;
444 		size_t hlen;
445 		dm_attrname_t attrname;
446 		char buf[ATTR_VALUELEN];
447 
448 		/* Variation set up */
449 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
450 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
451 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
452 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
453 		if ((rc = system(command)) == -1) {
454 			/* No clean up */
455 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
456 			remove(DUMMY_FILE);
457 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
458 			close(fd);
459 			remove(DUMMY_FILE);
460 		}
461 		if (fd == -1 || rc == -1) {
462 			DMLOG_PRINT(DMLVL_DEBUG,
463 				    "Unable to set up variation! (errno = %d)\n",
464 				    errno);
465 			DMVAR_SKIP();
466 		} else {
467 			/* Variation */
468 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
469 				    szFuncName);
470 			rc = dm_set_dmattr(sid, hanp, hlen, INVALID_ADDR,
471 					   &attrname, 0, sizeof(buf), buf);
472 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
473 
474 			/* Variation clean up */
475 			rc = close(fd);
476 			rc |= remove(DUMMY_FILE);
477 			if (rc == -1) {
478 				DMLOG_PRINT(DMLVL_DEBUG,
479 					    "Unable to clean up variation! (errno = %d)\n",
480 					    errno);
481 			}
482 			dm_handle_free(hanp, hlen);
483 		}
484 	}
485 
486 	/*
487 	 * TEST    : dm_set_dmattr - invalid attrnamep
488 	 * EXPECTED: rc = -1, errno = EFAULT
489 	 *
490 	 * This variation uncovered XFS BUG #10 (0 return code from strnlen_user
491 	 * ignored, which indicated fault)
492 	 */
493 	if (DMVAR_EXEC(SET_DMATTR_BASE + 5)) {
494 		int fd;
495 		void *hanp;
496 		size_t hlen;
497 		dm_attrname_t attrname;
498 		char buf[ATTR_VALUELEN];
499 
500 		/* Variation set up */
501 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
502 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
503 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
504 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
505 		if ((rc = system(command)) == -1) {
506 			/* No clean up */
507 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
508 			remove(DUMMY_FILE);
509 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
510 			close(fd);
511 			remove(DUMMY_FILE);
512 		}
513 		if (fd == -1 || rc == -1) {
514 			DMLOG_PRINT(DMLVL_DEBUG,
515 				    "Unable to set up variation! (errno = %d)\n",
516 				    errno);
517 			DMVAR_SKIP();
518 		} else {
519 			/* Variation */
520 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
521 				    szFuncName);
522 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
523 					   (dm_attrname_t *) INVALID_ADDR, 0,
524 					   sizeof(buf), buf);
525 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
526 
527 			/* Variation clean up */
528 			rc = close(fd);
529 			rc |= remove(DUMMY_FILE);
530 			if (rc == -1) {
531 				DMLOG_PRINT(DMLVL_DEBUG,
532 					    "Unable to clean up variation! (errno = %d)\n",
533 					    errno);
534 			}
535 			dm_handle_free(hanp, hlen);
536 		}
537 	}
538 
539 	/*
540 	 * TEST    : dm_set_dmattr - invalid buflen
541 	 * EXPECTED: rc = -1, errno = E2BIG
542 	 */
543 	if (DMVAR_EXEC(SET_DMATTR_BASE + 6)) {
544 		int fd;
545 		void *hanp;
546 		size_t hlen;
547 		dm_attrname_t attrname;
548 		char buf[ATTR_VALUELEN];
549 
550 		/* Variation set up */
551 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
552 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
553 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
554 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
555 		if ((rc = system(command)) == -1) {
556 			/* No clean up */
557 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
558 			remove(DUMMY_FILE);
559 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
560 			close(fd);
561 			remove(DUMMY_FILE);
562 		}
563 		if (fd == -1 || rc == -1) {
564 			DMLOG_PRINT(DMLVL_DEBUG,
565 				    "Unable to set up variation! (errno = %d)\n",
566 				    errno);
567 			DMVAR_SKIP();
568 		} else {
569 			/* Variation */
570 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
571 				    szFuncName);
572 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
573 					   &attrname, 0, INVALID_ADDR, buf);
574 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
575 
576 			/* Variation clean up */
577 			rc = close(fd);
578 			rc |= remove(DUMMY_FILE);
579 			if (rc == -1) {
580 				DMLOG_PRINT(DMLVL_DEBUG,
581 					    "Unable to clean up variation! (errno = %d)\n",
582 					    errno);
583 			}
584 			dm_handle_free(hanp, hlen);
585 		}
586 	}
587 
588 	/*
589 	 * TEST    : dm_set_dmattr - invalid bufp
590 	 * EXPECTED: rc = -1, errno = EFAULT
591 	 */
592 	if (DMVAR_EXEC(SET_DMATTR_BASE + 7)) {
593 		int fd;
594 		void *hanp;
595 		size_t hlen;
596 		dm_attrname_t attrname;
597 		char buf[ATTR_VALUELEN];
598 
599 		/* Variation set up */
600 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
601 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
602 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
603 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
604 		if ((rc = system(command)) == -1) {
605 			/* No clean up */
606 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
607 			remove(DUMMY_FILE);
608 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
609 			close(fd);
610 			remove(DUMMY_FILE);
611 		}
612 		if (fd == -1 || rc == -1) {
613 			DMLOG_PRINT(DMLVL_DEBUG,
614 				    "Unable to set up variation! (errno = %d)\n",
615 				    errno);
616 			DMVAR_SKIP();
617 		} else {
618 			/* Variation */
619 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
620 				    szFuncName);
621 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
622 					   &attrname, 0, sizeof(buf),
623 					   (void *)INVALID_ADDR);
624 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
625 
626 			/* Variation clean up */
627 			rc = close(fd);
628 			rc |= remove(DUMMY_FILE);
629 			if (rc == -1) {
630 				DMLOG_PRINT(DMLVL_DEBUG,
631 					    "Unable to clean up variation! (errno = %d)\n",
632 					    errno);
633 			}
634 			dm_handle_free(hanp, hlen);
635 		}
636 	}
637 
638 	/*
639 	 * TEST    : dm_set_dmattr - empty attrname
640 	 * EXPECTED: rc = -1, errno = EINVAL
641 	 */
642 	if (DMVAR_EXEC(SET_DMATTR_BASE + 8)) {
643 		int fd;
644 		void *hanp;
645 		size_t hlen;
646 		dm_attrname_t attrname;
647 		char buf[ATTR_VALUELEN];
648 
649 		/* Variation set up */
650 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
651 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
652 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
653 		if ((rc = system(command)) == -1) {
654 			/* No clean up */
655 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
656 			remove(DUMMY_FILE);
657 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
658 			close(fd);
659 			remove(DUMMY_FILE);
660 		}
661 		if (fd == -1 || rc == -1) {
662 			DMLOG_PRINT(DMLVL_DEBUG,
663 				    "Unable to set up variation! (errno = %d)\n",
664 				    errno);
665 			DMVAR_SKIP();
666 		} else {
667 			/* Variation */
668 			DMLOG_PRINT(DMLVL_DEBUG, "%s(empty attrname)\n",
669 				    szFuncName);
670 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
671 					   &attrname, 0, sizeof(buf), buf);
672 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
673 
674 			/* Variation clean up */
675 			rc = close(fd);
676 			rc |= remove(DUMMY_FILE);
677 			if (rc == -1) {
678 				DMLOG_PRINT(DMLVL_DEBUG,
679 					    "Unable to clean up variation! (errno = %d)\n",
680 					    errno);
681 			}
682 			dm_handle_free(hanp, hlen);
683 		}
684 	}
685 
686 	/*
687 	 * TEST    : dm_set_dmattr - zero buflen
688 	 * EXPECTED: rc = 0
689 	 */
690 	if (DMVAR_EXEC(SET_DMATTR_BASE + 9)) {
691 		int fd;
692 		void *hanp;
693 		size_t hlen;
694 		dm_attrname_t attrname;
695 		char buf[ATTR_VALUELEN], value[ATTR_VALUELEN];
696 
697 		/* Variation set up */
698 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
699 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
700 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
701 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
702 		if ((rc = system(command)) == -1) {
703 			/* No clean up */
704 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
705 			remove(DUMMY_FILE);
706 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
707 			close(fd);
708 			remove(DUMMY_FILE);
709 		}
710 		if (fd == -1 || rc == -1) {
711 			DMLOG_PRINT(DMLVL_DEBUG,
712 				    "Unable to set up variation! (errno = %d)\n",
713 				    errno);
714 			DMVAR_SKIP();
715 		} else {
716 			/* Variation */
717 			DMLOG_PRINT(DMLVL_DEBUG, "%s(zero buflen)\n",
718 				    szFuncName);
719 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
720 					   &attrname, 0, 0, NULL);
721 			if (rc == 0) {
722 				if ((rc =
723 				     getxattr(DUMMY_FILE, fullAttrName, value,
724 					      sizeof(value))) == 0) {
725 					DMLOG_PRINT(DMLVL_DEBUG,
726 						    "%s passed with expected rc = %d\n",
727 						    szFuncName, 0);
728 					DMVAR_PASS();
729 				} else {
730 					DMLOG_PRINT(DMLVL_ERR,
731 						    "%s failed with expected rc = %d but unexpected attribute length (%d vs %d)\n",
732 						    szFuncName, 0, 0, rc);
733 					DMVAR_FAIL();
734 				}
735 			} else {
736 				DMLOG_PRINT(DMLVL_ERR,
737 					    "%s failed with unexpected rc = %d (errno = %d)\n",
738 					    szFuncName, rc, errno);
739 				DMVAR_FAIL();
740 			}
741 
742 			/* Variation clean up */
743 			rc = close(fd);
744 			rc |= remove(DUMMY_FILE);
745 			if (rc == -1) {
746 				DMLOG_PRINT(DMLVL_DEBUG,
747 					    "Unable to clean up variation! (errno = %d)\n",
748 					    errno);
749 			}
750 			dm_handle_free(hanp, hlen);
751 		}
752 	}
753 
754 	/*
755 	 * TEST    : dm_set_dmattr - maximum buflen
756 	 * EXPECTED: rc = 0
757 	 */
758 	if (DMVAR_EXEC(SET_DMATTR_BASE + 10)) {
759 		int fd;
760 		void *hanp;
761 		size_t hlen;
762 		dm_attrname_t attrname;
763 		char *buf, *value;
764 
765 		/* Variation set up */
766 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
767 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
768 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
769 		if ((buf = malloc(maxAttrSize)) == NULL) {
770 			/* No clean up */
771 		} else if ((memset(buf, '1', maxAttrSize) == NULL) ||
772 			   ((value = malloc(maxAttrSize)) == NULL)) {
773 			free(buf);
774 		} else if ((memset(value, 0, maxAttrSize) == NULL) ||
775 			   ((rc = system(command)) == -1)) {
776 			free(value);
777 			free(buf);
778 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
779 			remove(DUMMY_FILE);
780 			free(value);
781 			free(buf);
782 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
783 			close(fd);
784 			remove(DUMMY_FILE);
785 			free(value);
786 			free(buf);
787 		}
788 		if (fd == -1 || rc == -1 || buf == NULL || value == NULL) {
789 			DMLOG_PRINT(DMLVL_DEBUG,
790 				    "Unable to set up variation! (errno = %d)\n",
791 				    errno);
792 			DMVAR_SKIP();
793 		} else {
794 			/* Variation */
795 			DMLOG_PRINT(DMLVL_DEBUG, "%s(max buflen)\n",
796 				    szFuncName);
797 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
798 					   &attrname, 0, maxAttrSize, buf);
799 			if (rc == 0) {
800 				if ((rc =
801 				     getxattr(DUMMY_FILE, fullAttrName, value,
802 					      maxAttrSize)) == maxAttrSize) {
803 					if (memcmp(buf, value, maxAttrSize) ==
804 					    0) {
805 						DMLOG_PRINT(DMLVL_DEBUG,
806 							    "%s passed with expected rc = %d\n",
807 							    szFuncName, 0);
808 						DMVAR_PASS();
809 					} else {
810 						DMLOG_PRINT(DMLVL_ERR,
811 							    "%s failed with expected rc = %d but unexpected attribute value (%s vs %s)\n",
812 							    szFuncName, 0, buf,
813 							    value);
814 						DMVAR_FAIL();
815 					}
816 				} else {
817 					DMLOG_PRINT(DMLVL_ERR,
818 						    "%s failed with expected rc = %d but unexpected attribute length (%d vs %d)\n",
819 						    szFuncName, 0, maxAttrSize,
820 						    rc);
821 					DMVAR_FAIL();
822 				}
823 			} else {
824 				DMLOG_PRINT(DMLVL_ERR,
825 					    "%s failed with unexpected rc = %d (errno = %d)\n",
826 					    szFuncName, rc, errno);
827 				DMVAR_FAIL();
828 			}
829 
830 			/* Variation clean up */
831 			rc = close(fd);
832 			rc |= remove(DUMMY_FILE);
833 			if (rc == -1) {
834 				DMLOG_PRINT(DMLVL_DEBUG,
835 					    "Unable to clean up variation! (errno = %d)\n",
836 					    errno);
837 			}
838 			free(buf);
839 			free(value);
840 			dm_handle_free(hanp, hlen);
841 		}
842 	}
843 
844 	/*
845 	 * TEST    : dm_set_dmattr - buflen too big
846 	 * EXPECTED: rc = -1, errno = E2BIG
847 	 */
848 	if (DMVAR_EXEC(SET_DMATTR_BASE + 11)) {
849 		int fd;
850 		void *hanp;
851 		size_t hlen;
852 		dm_attrname_t attrname;
853 		char *buf;
854 
855 		/* Variation set up */
856 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
857 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
858 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
859 		if ((buf = malloc(maxAttrSize + 1)) == NULL) {
860 			/* No clean up */
861 		} else if ((memset(buf, '2', maxAttrSize + 1) == NULL) ||
862 			   ((rc = system(command)) == -1)) {
863 			free(buf);
864 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
865 			remove(DUMMY_FILE);
866 			free(buf);
867 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
868 			close(fd);
869 			remove(DUMMY_FILE);
870 			free(buf);
871 		}
872 		if (fd == -1 || rc == -1 || buf == NULL) {
873 			DMLOG_PRINT(DMLVL_DEBUG,
874 				    "Unable to set up variation! (errno = %d)\n",
875 				    errno);
876 			DMVAR_SKIP();
877 		} else {
878 			/* Variation */
879 			DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen too big)\n",
880 				    szFuncName);
881 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
882 					   &attrname, 0, maxAttrSize + 1, buf);
883 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
884 
885 			/* Variation clean up */
886 			rc = close(fd);
887 			rc |= remove(DUMMY_FILE);
888 			if (rc == -1) {
889 				DMLOG_PRINT(DMLVL_DEBUG,
890 					    "Unable to clean up variation! (errno = %d)\n",
891 					    errno);
892 			}
893 			free(buf);
894 			dm_handle_free(hanp, hlen);
895 		}
896 	}
897 
898 	/*
899 	 * TEST    : dm_set_dmattr - one file attribute, setdtime zero
900 	 * EXPECTED: rc = 0
901 	 */
902 	if (DMVAR_EXEC(SET_DMATTR_BASE + 12)) {
903 		int fd;
904 		int rc2;
905 		void *hanp;
906 		size_t hlen;
907 		dm_attrname_t attrname;
908 		char buf[ATTR_VALUELEN];
909 		struct stat statfs1, statfs2;
910 
911 		/* Variation set up */
912 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
913 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
914 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
915 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
916 		if ((rc = system(command)) == -1) {
917 			/* No clean up */
918 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
919 			remove(DUMMY_FILE);
920 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
921 			close(fd);
922 			remove(DUMMY_FILE);
923 		}
924 		if (fd == -1 || rc == -1) {
925 			DMLOG_PRINT(DMLVL_DEBUG,
926 				    "Unable to set up variation! (errno = %d)\n",
927 				    errno);
928 			DMVAR_SKIP();
929 		} else {
930 			/* Variation */
931 			rc2 = stat(DUMMY_FILE, &statfs1);
932 			TIMESTAMP_DELAY;
933 			DMLOG_PRINT(DMLVL_DEBUG,
934 				    "%s(one file attr, setdtime zero)\n",
935 				    szFuncName);
936 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
937 					   &attrname, 0, sizeof(buf), buf);
938 			rc2 |= stat(DUMMY_FILE, &statfs2);
939 			if (rc == 0) {
940 				if ((rc2 == 0)
941 				    && (statfs1.st_ctime == statfs2.st_ctime)) {
942 					DMLOG_PRINT(DMLVL_DEBUG,
943 						    "%s passed with expected rc = %d and dtime unmodified\n",
944 						    szFuncName, 0);
945 					DMVAR_PASS();
946 				} else {
947 					DMLOG_PRINT(DMLVL_ERR,
948 						    "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
949 						    szFuncName, 0,
950 						    statfs1.st_ctime,
951 						    statfs2.st_ctime);
952 					DMVAR_FAIL();
953 				}
954 			} else {
955 				DMLOG_PRINT(DMLVL_ERR,
956 					    "%s failed with unexpected rc = %d (errno = %d)\n",
957 					    szFuncName, rc, errno);
958 				DMVAR_FAIL();
959 			}
960 
961 			/* Variation clean up */
962 			rc = close(fd);
963 			rc |= remove(DUMMY_FILE);
964 			if (rc == -1) {
965 				DMLOG_PRINT(DMLVL_DEBUG,
966 					    "Unable to clean up variation! (errno = %d)\n",
967 					    errno);
968 			}
969 			dm_handle_free(hanp, hlen);
970 		}
971 	}
972 
973 	/*
974 	 * TEST    : dm_set_dmattr - one file attribute, setdtime non-zero
975 	 * EXPECTED: rc = 0
976 	 */
977 	if (DMVAR_EXEC(SET_DMATTR_BASE + 13)) {
978 		int fd;
979 		int rc2;
980 		void *hanp;
981 		size_t hlen;
982 		dm_attrname_t attrname;
983 		char buf[ATTR_VALUELEN];
984 		struct stat statfs1, statfs2;
985 
986 		/* Variation set up */
987 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
988 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
989 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
990 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
991 		if ((rc = system(command)) == -1) {
992 			/* No clean up */
993 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
994 			remove(DUMMY_FILE);
995 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
996 			close(fd);
997 			remove(DUMMY_FILE);
998 		}
999 		if (fd == -1 || rc == -1) {
1000 			DMLOG_PRINT(DMLVL_DEBUG,
1001 				    "Unable to set up variation! (errno = %d)\n",
1002 				    errno);
1003 			DMVAR_SKIP();
1004 		} else {
1005 			/* Variation */
1006 			rc2 = stat(DUMMY_FILE, &statfs1);
1007 			TIMESTAMP_DELAY;
1008 			DMLOG_PRINT(DMLVL_DEBUG,
1009 				    "%s(one file attr, setdtime non-zero)\n",
1010 				    szFuncName);
1011 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1012 					   &attrname, 1, sizeof(buf), buf);
1013 			rc2 |= stat(DUMMY_FILE, &statfs2);
1014 			if (rc == 0) {
1015 				if ((rc2 == 0)
1016 				    && (statfs1.st_ctime != statfs2.st_ctime)) {
1017 					DMLOG_PRINT(DMLVL_DEBUG,
1018 						    "%s passed with expected rc = %d and dtime modified\n",
1019 						    szFuncName, 0);
1020 					DMVAR_PASS();
1021 				} else {
1022 					DMLOG_PRINT(DMLVL_ERR,
1023 						    "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
1024 						    szFuncName, 0,
1025 						    statfs1.st_ctime,
1026 						    statfs2.st_ctime);
1027 					DMVAR_FAIL();
1028 				}
1029 			} else {
1030 				DMLOG_PRINT(DMLVL_ERR,
1031 					    "%s failed with unexpected rc = %d (errno = %d)\n",
1032 					    szFuncName, rc, errno);
1033 				DMVAR_FAIL();
1034 			}
1035 
1036 			/* Variation clean up */
1037 			rc = close(fd);
1038 			rc |= remove(DUMMY_FILE);
1039 			if (rc == -1) {
1040 				DMLOG_PRINT(DMLVL_DEBUG,
1041 					    "Unable to clean up variation! (errno = %d)\n",
1042 					    errno);
1043 			}
1044 			dm_handle_free(hanp, hlen);
1045 		}
1046 	}
1047 
1048 	/*
1049 	 * TEST    : dm_set_dmattr - two file attributes
1050 	 * EXPECTED: rc = 0
1051 	 */
1052 	if (DMVAR_EXEC(SET_DMATTR_BASE + 14)) {
1053 		int fd;
1054 		void *hanp;
1055 		size_t hlen;
1056 		dm_attrname_t attrname;
1057 		char buf[ATTR_VALUELEN];
1058 		int buf2 = INVALID_ADDR;
1059 
1060 		/* Variation set up */
1061 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1062 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1063 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1064 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1065 		if ((rc = system(command)) == -1) {
1066 			/* No clean up */
1067 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1068 			remove(DUMMY_FILE);
1069 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1070 			close(fd);
1071 			remove(DUMMY_FILE);
1072 		}
1073 		if (fd == -1 || rc == -1) {
1074 			DMLOG_PRINT(DMLVL_DEBUG,
1075 				    "Unable to set up variation! (errno = %d)\n",
1076 				    errno);
1077 			DMVAR_SKIP();
1078 		} else {
1079 			/* Variation */
1080 			DMLOG_PRINT(DMLVL_DEBUG, "%s(two file attr)\n",
1081 				    szFuncName);
1082 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1083 					   &attrname, 0, sizeof(buf), buf);
1084 			if (rc == 0) {
1085 				memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1086 				memcpy(attrname.an_chars, ATTR_NAME2,
1087 				       DM_ATTR_NAME_SIZE);
1088 				rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1089 						   &attrname, 0, sizeof(buf2),
1090 						   (void *)&buf2);
1091 			}
1092 			DMVAR_ENDPASSEXP(szFuncName, 0, rc);
1093 
1094 			/* Variation clean up */
1095 			rc = close(fd);
1096 			rc |= remove(DUMMY_FILE);
1097 			if (rc == -1) {
1098 				DMLOG_PRINT(DMLVL_DEBUG,
1099 					    "Unable to clean up variation! (errno = %d)\n",
1100 					    errno);
1101 			}
1102 			dm_handle_free(hanp, hlen);
1103 		}
1104 	}
1105 
1106 	/*
1107 	 * TEST    : dm_set_dmattr - multiple file attributes
1108 	 * EXPECTED: rc = 0
1109 	 */
1110 	if (DMVAR_EXEC(SET_DMATTR_BASE + 15)) {
1111 		int fd;
1112 		void *hanp;
1113 		size_t hlen;
1114 		dm_attrname_t attrname;
1115 		char buf[ATTR_VALUELEN];
1116 
1117 		/* Variation set up */
1118 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1119 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1120 		if ((rc = system(command)) == -1) {
1121 			/* No clean up */
1122 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1123 			remove(DUMMY_FILE);
1124 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1125 			close(fd);
1126 			remove(DUMMY_FILE);
1127 		}
1128 		if (fd == -1 || rc == -1) {
1129 			DMLOG_PRINT(DMLVL_DEBUG,
1130 				    "Unable to set up variation! (errno = %d)\n",
1131 				    errno);
1132 			DMVAR_SKIP();
1133 		} else {
1134 			/* Variation */
1135 			DMLOG_PRINT(DMLVL_DEBUG, "%s(multiple file attr)\n",
1136 				    szFuncName);
1137 			for (i = 1; (i <= NUM_ATTRS) && (rc == 0); i++) {
1138 				memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1139 				memcpy(attrname.an_chars, ATTR_NAME,
1140 				       DM_ATTR_NAME_SIZE);
1141 				attrname.an_chars[DM_ATTR_NAME_SIZE - 2] =
1142 				    '0' + (i / 10);
1143 				attrname.an_chars[DM_ATTR_NAME_SIZE - 1] =
1144 				    '0' + (i % 10);
1145 				DMLOG_PRINT(DMLVL_DEBUG, "%s(%.*s)\n",
1146 					    szFuncName, DM_ATTR_NAME_SIZE,
1147 					    attrname.an_chars);
1148 				rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1149 						   &attrname, 0, sizeof(buf),
1150 						   buf);
1151 			}
1152 			DMVAR_ENDPASSEXP(szFuncName, 0, rc);
1153 
1154 			/* Variation clean up */
1155 			rc = close(fd);
1156 			rc |= remove(DUMMY_FILE);
1157 			if (rc == -1) {
1158 				DMLOG_PRINT(DMLVL_DEBUG,
1159 					    "Unable to clean up variation! (errno = %d)\n",
1160 					    errno);
1161 			}
1162 			dm_handle_free(hanp, hlen);
1163 		}
1164 	}
1165 
1166 	/*
1167 	 * TEST    : dm_set_dmattr - replace file attribute
1168 	 * EXPECTED: rc = 0
1169 	 */
1170 	if (DMVAR_EXEC(SET_DMATTR_BASE + 16)) {
1171 		int fd;
1172 		void *hanp;
1173 		size_t hlen;
1174 		dm_attrname_t attrname;
1175 		char buf[ATTR_VALUELEN], value[ATTR_VALUELEN];
1176 
1177 		/* Variation set up */
1178 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1179 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1180 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1181 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1182 		if ((rc = system(command)) == -1) {
1183 			/* No clean up */
1184 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1185 			remove(DUMMY_FILE);
1186 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1187 			close(fd);
1188 			remove(DUMMY_FILE);
1189 		} else
1190 		    if (((rc =
1191 			  dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1192 					0, sizeof(attrname), &attrname)) == -1)
1193 			||
1194 			((rc =
1195 			  (getxattr
1196 			   (DUMMY_FILE, fullAttrName, value,
1197 			    sizeof(value)) == sizeof(attrname)) ? 0 : -1) == -1)
1198 			||
1199 			((rc =
1200 			  (memcmp(&attrname, value, sizeof(attrname)) ==
1201 			   0) ? 0 : -1) == -1)) {
1202 			dm_handle_free(hanp, hlen);
1203 			close(fd);
1204 			remove(DUMMY_FILE);
1205 		}
1206 		if (fd == -1 || rc == -1) {
1207 			DMLOG_PRINT(DMLVL_DEBUG,
1208 				    "Unable to set up variation! (errno = %d)\n",
1209 				    errno);
1210 			DMVAR_SKIP();
1211 		} else {
1212 			/* Variation */
1213 			DMLOG_PRINT(DMLVL_DEBUG, "%s(replace file attr)\n",
1214 				    szFuncName);
1215 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1216 					   &attrname, 0, sizeof(buf), buf);
1217 			if (rc == 0) {
1218 				if ((rc =
1219 				     getxattr(DUMMY_FILE, fullAttrName, value,
1220 					      sizeof(value))) ==
1221 				    ATTR_VALUELEN) {
1222 					if (memcmp(buf, value, sizeof(buf)) ==
1223 					    0) {
1224 						DMLOG_PRINT(DMLVL_DEBUG,
1225 							    "%s passed with expected rc = %d\n",
1226 							    szFuncName, 0);
1227 						DMVAR_PASS();
1228 					} else {
1229 						DMLOG_PRINT(DMLVL_ERR,
1230 							    "%s failed with expected rc = %d but unexpected attribute value (%s vs %s)\n",
1231 							    szFuncName, 0, buf,
1232 							    value);
1233 						DMVAR_FAIL();
1234 					}
1235 				} else {
1236 					DMLOG_PRINT(DMLVL_ERR,
1237 						    "%s failed with expected rc = %d but unexpected attribute length (%d vs %d)\n",
1238 						    szFuncName, 0,
1239 						    ATTR_VALUELEN, rc);
1240 					DMVAR_FAIL();
1241 				}
1242 			} else {
1243 				DMLOG_PRINT(DMLVL_ERR,
1244 					    "%s failed with unexpected rc = %d (errno = %d)\n",
1245 					    szFuncName, rc, errno);
1246 				DMVAR_FAIL();
1247 			}
1248 
1249 			/* Variation clean up */
1250 			rc = close(fd);
1251 			rc |= remove(DUMMY_FILE);
1252 			if (rc == -1) {
1253 				DMLOG_PRINT(DMLVL_DEBUG,
1254 					    "Unable to clean up variation! (errno = %d)\n",
1255 					    errno);
1256 			}
1257 			dm_handle_free(hanp, hlen);
1258 		}
1259 	}
1260 
1261 	/*
1262 	 * TEST    : dm_set_dmattr - one directory attribute, setdtime zero
1263 	 * EXPECTED: rc = 0
1264 	 */
1265 	if (DMVAR_EXEC(SET_DMATTR_BASE + 17)) {
1266 		int rc2;
1267 		void *hanp;
1268 		size_t hlen;
1269 		dm_attrname_t attrname;
1270 		char buf[ATTR_VALUELEN];
1271 		struct stat statfs1, statfs2;
1272 
1273 		/* Variation set up */
1274 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1275 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1276 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1277 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
1278 			/* No clean up */
1279 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
1280 			   == -1) {
1281 			rmdir(DUMMY_SUBDIR);
1282 		}
1283 		if (rc == -1) {
1284 			DMLOG_PRINT(DMLVL_DEBUG,
1285 				    "Unable to set up variation! (errno = %d)\n",
1286 				    errno);
1287 			rmdir(DUMMY_SUBDIR);
1288 			DMVAR_SKIP();
1289 		} else {
1290 			/* Variation */
1291 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
1292 			TIMESTAMP_DELAY;
1293 			DMLOG_PRINT(DMLVL_DEBUG,
1294 				    "%s(one dir attr, setdtime zero)\n",
1295 				    szFuncName);
1296 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1297 					   &attrname, 0, sizeof(buf), buf);
1298 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
1299 			if (rc == 0) {
1300 				if ((rc2 == 0)
1301 				    && (statfs1.st_ctime == statfs2.st_ctime)) {
1302 					DMLOG_PRINT(DMLVL_DEBUG,
1303 						    "%s passed with expected rc = %d and dtime unmodified\n",
1304 						    szFuncName, 0);
1305 					DMVAR_PASS();
1306 				} else {
1307 					DMLOG_PRINT(DMLVL_ERR,
1308 						    "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
1309 						    szFuncName, 0,
1310 						    statfs1.st_ctime,
1311 						    statfs2.st_ctime);
1312 					DMVAR_FAIL();
1313 				}
1314 			} else {
1315 				DMLOG_PRINT(DMLVL_ERR,
1316 					    "%s failed with unexpected rc = %d (errno = %d)\n",
1317 					    szFuncName, rc, errno);
1318 				DMVAR_FAIL();
1319 			}
1320 
1321 			/* Variation clean up */
1322 			rc = rmdir(DUMMY_SUBDIR);
1323 			if (rc == -1) {
1324 				DMLOG_PRINT(DMLVL_DEBUG,
1325 					    "Unable to clean up variation! (errno = %d)\n",
1326 					    errno);
1327 			}
1328 			dm_handle_free(hanp, hlen);
1329 		}
1330 	}
1331 
1332 	/*
1333 	 * TEST    : dm_set_dmattr - one directory attribute, setdtime non-zero
1334 	 * EXPECTED: rc = 0
1335 	 */
1336 	if (DMVAR_EXEC(SET_DMATTR_BASE + 18)) {
1337 		int rc2;
1338 		void *hanp;
1339 		size_t hlen;
1340 		dm_attrname_t attrname;
1341 		char buf[ATTR_VALUELEN];
1342 		struct stat statfs1, statfs2;
1343 
1344 		/* Variation set up */
1345 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1346 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1347 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1348 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
1349 			/* No clean up */
1350 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
1351 			   == -1) {
1352 			rmdir(DUMMY_SUBDIR);
1353 		}
1354 		if (rc == -1) {
1355 			DMLOG_PRINT(DMLVL_DEBUG,
1356 				    "Unable to set up variation! (errno = %d)\n",
1357 				    errno);
1358 			rmdir(DUMMY_SUBDIR);
1359 			DMVAR_SKIP();
1360 		} else {
1361 			/* Variation */
1362 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
1363 			TIMESTAMP_DELAY;
1364 			DMLOG_PRINT(DMLVL_DEBUG,
1365 				    "%s(one dir attr, setdtime non-zero)\n",
1366 				    szFuncName);
1367 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1368 					   &attrname, 1, sizeof(buf), buf);
1369 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
1370 			if (rc == 0) {
1371 				if ((rc2 == 0)
1372 				    && (statfs1.st_ctime != statfs2.st_ctime)) {
1373 					DMLOG_PRINT(DMLVL_DEBUG,
1374 						    "%s passed with expected rc = %d and dtime modified\n",
1375 						    szFuncName, 0);
1376 					DMVAR_PASS();
1377 				} else {
1378 					DMLOG_PRINT(DMLVL_ERR,
1379 						    "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
1380 						    szFuncName, 0,
1381 						    statfs1.st_ctime,
1382 						    statfs2.st_ctime);
1383 					DMVAR_FAIL();
1384 				}
1385 			} else {
1386 				DMLOG_PRINT(DMLVL_ERR,
1387 					    "%s failed with unexpected rc = %d (errno = %d)\n",
1388 					    szFuncName, rc, errno);
1389 				DMVAR_FAIL();
1390 			}
1391 
1392 			/* Variation clean up */
1393 			rc = rmdir(DUMMY_SUBDIR);
1394 			if (rc == -1) {
1395 				DMLOG_PRINT(DMLVL_DEBUG,
1396 					    "Unable to clean up variation! (errno = %d)\n",
1397 					    errno);
1398 			}
1399 			dm_handle_free(hanp, hlen);
1400 		}
1401 	}
1402 
1403 	/*
1404 	 * TEST    : dm_set_dmattr - fs handle
1405 	 * EXPECTED: rc = -1, errno = EINVAL
1406 	 */
1407 	if (DMVAR_EXEC(SET_DMATTR_BASE + 19)) {
1408 		void *hanp;
1409 		size_t hlen;
1410 		dm_attrname_t attrname;
1411 		char buf[ATTR_VALUELEN];
1412 
1413 		/* Variation set up */
1414 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1415 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1416 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1417 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1418 		if ((rc = system(command)) == -1) {
1419 			/* No clean up */
1420 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
1421 			   == -1) {
1422 			remove(DUMMY_FILE);
1423 		}
1424 		if (rc == -1) {
1425 			DMLOG_PRINT(DMLVL_DEBUG,
1426 				    "Unable to set up variation! (errno = %d)\n",
1427 				    errno);
1428 			DMVAR_SKIP();
1429 		} else {
1430 			/* Variation */
1431 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
1432 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1433 					   &attrname, 0, sizeof(buf), buf);
1434 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1435 
1436 			/* Variation clean up */
1437 			rc = remove(DUMMY_FILE);
1438 			if (rc == -1) {
1439 				DMLOG_PRINT(DMLVL_DEBUG,
1440 					    "Unable to clean up variation! (errno = %d)\n",
1441 					    errno);
1442 			}
1443 			dm_handle_free(hanp, hlen);
1444 		}
1445 	}
1446 
1447 	/*
1448 	 * TEST    : dm_set_dmattr - DM_NO_SESSION sid
1449 	 * EXPECTED: rc = -1, errno = EINVAL
1450 	 */
1451 	if (DMVAR_EXEC(SET_DMATTR_BASE + 20)) {
1452 		int fd;
1453 		void *hanp;
1454 		size_t hlen;
1455 		dm_attrname_t attrname;
1456 		char buf[ATTR_VALUELEN];
1457 
1458 		/* Variation set up */
1459 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1460 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1461 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1462 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1463 		if ((rc = system(command)) == -1) {
1464 			/* No clean up */
1465 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1466 			remove(DUMMY_FILE);
1467 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1468 			close(fd);
1469 			remove(DUMMY_FILE);
1470 		}
1471 		if (fd == -1 || rc == -1) {
1472 			DMLOG_PRINT(DMLVL_DEBUG,
1473 				    "Unable to set up variation! (errno = %d)\n",
1474 				    errno);
1475 			DMVAR_SKIP();
1476 		} else {
1477 			/* Variation */
1478 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
1479 				    szFuncName);
1480 			rc = dm_set_dmattr(DM_NO_SESSION, hanp, hlen,
1481 					   DM_NO_TOKEN, &attrname, 0,
1482 					   sizeof(buf), buf);
1483 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1484 
1485 			/* Variation clean up */
1486 			rc = close(fd);
1487 			rc |= remove(DUMMY_FILE);
1488 			if (rc == -1) {
1489 				DMLOG_PRINT(DMLVL_DEBUG,
1490 					    "Unable to clean up variation! (errno = %d)\n",
1491 					    errno);
1492 			}
1493 			dm_handle_free(hanp, hlen);
1494 		}
1495 	}
1496 
1497 	/*
1498 	 * TEST    : dm_set_dmattr - global handle
1499 	 * EXPECTED: rc = -1, errno = EBADF
1500 	 */
1501 	if (DMVAR_EXEC(SET_DMATTR_BASE + 21)) {
1502 		dm_attrname_t attrname;
1503 		char buf[ATTR_VALUELEN];
1504 
1505 		/* Variation set up */
1506 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1507 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1508 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1509 
1510 		/* Variation */
1511 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
1512 		rc = dm_set_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
1513 				   DM_NO_TOKEN, &attrname, 0, sizeof(buf), buf);
1514 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
1515 
1516 		/* Variation clean up */
1517 	}
1518 
1519 	/*
1520 	 * TEST    : dm_set_dmattr - invalidated hanp
1521 	 * EXPECTED: rc = -1, errno = BADF
1522 	 */
1523 	if (DMVAR_EXEC(SET_DMATTR_BASE + 22)) {
1524 		int fd;
1525 		void *hanp;
1526 		size_t hlen;
1527 		dm_attrname_t attrname;
1528 		char buf[ATTR_VALUELEN];
1529 
1530 		/* Variation set up */
1531 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1532 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1533 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1534 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1535 		if ((rc = system(command)) == -1) {
1536 			/* No clean up */
1537 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1538 			remove(DUMMY_FILE);
1539 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1540 			close(fd);
1541 			remove(DUMMY_FILE);
1542 		} else if ((rc = close(fd)) == -1) {
1543 			dm_handle_free(hanp, hlen);
1544 			remove(DUMMY_FILE);
1545 		} else if ((rc = remove(DUMMY_FILE)) == -1) {
1546 			dm_handle_free(hanp, hlen);
1547 		}
1548 		if (fd == -1 || rc == -1) {
1549 			DMLOG_PRINT(DMLVL_DEBUG,
1550 				    "Unable to set up variation! (errno = %d)\n",
1551 				    errno);
1552 			DMVAR_SKIP();
1553 		} else {
1554 			/* Variation */
1555 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
1556 				    szFuncName);
1557 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1558 					   &attrname, 0, sizeof(buf), buf);
1559 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
1560 
1561 			/* Variation clean up */
1562 			dm_handle_free(hanp, hlen);
1563 		}
1564 	}
1565 
1566 	szFuncName = "dm_get_dmattr";
1567 
1568 	/*
1569 	 * TEST    : dm_get_dmattr - invalid sid
1570 	 * EXPECTED: rc = -1, errno = EINVAL
1571 	 */
1572 	if (DMVAR_EXEC(GET_DMATTR_BASE + 1)) {
1573 		int fd;
1574 		void *hanp;
1575 		size_t hlen;
1576 		dm_attrname_t attrname;
1577 		char buf[ATTR_VALUELEN];
1578 		size_t rlen;
1579 
1580 		/* Variation set up */
1581 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1582 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1583 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1584 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1585 		if ((rc = system(command)) == -1) {
1586 			/* No clean up */
1587 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1588 			remove(DUMMY_FILE);
1589 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1590 			close(fd);
1591 			remove(DUMMY_FILE);
1592 		} else
1593 		    if ((rc =
1594 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1595 				       0, sizeof(buf), buf)) == -1) {
1596 			dm_handle_free(hanp, hlen);
1597 			close(fd);
1598 			remove(DUMMY_FILE);
1599 		}
1600 		if (fd == -1 || rc == -1) {
1601 			DMLOG_PRINT(DMLVL_DEBUG,
1602 				    "Unable to set up variation! (errno = %d)\n",
1603 				    errno);
1604 			DMVAR_SKIP();
1605 		} else {
1606 			/* Variation */
1607 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
1608 				    szFuncName);
1609 			rc = dm_get_dmattr(INVALID_ADDR, hanp, hlen,
1610 					   DM_NO_TOKEN, &attrname, sizeof(buf),
1611 					   buf, &rlen);
1612 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1613 
1614 			/* Variation clean up */
1615 			rc = close(fd);
1616 			rc |= remove(DUMMY_FILE);
1617 			if (rc == -1) {
1618 				DMLOG_PRINT(DMLVL_DEBUG,
1619 					    "Unable to clean up variation! (errno = %d)\n",
1620 					    errno);
1621 			}
1622 			dm_handle_free(hanp, hlen);
1623 		}
1624 	}
1625 
1626 	/*
1627 	 * TEST    : dm_get_dmattr - invalid hanp
1628 	 * EXPECTED: rc = -1, errno = EFAULT
1629 	 */
1630 	if (DMVAR_EXEC(GET_DMATTR_BASE + 2)) {
1631 		int fd;
1632 		void *hanp;
1633 		size_t hlen;
1634 		dm_attrname_t attrname;
1635 		char buf[ATTR_VALUELEN];
1636 		size_t rlen;
1637 
1638 		/* Variation set up */
1639 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1640 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1641 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1642 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1643 		if ((rc = system(command)) == -1) {
1644 			/* No clean up */
1645 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1646 			remove(DUMMY_FILE);
1647 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1648 			close(fd);
1649 			remove(DUMMY_FILE);
1650 		} else
1651 		    if ((rc =
1652 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1653 				       0, sizeof(buf), buf)) == -1) {
1654 			dm_handle_free(hanp, hlen);
1655 			close(fd);
1656 			remove(DUMMY_FILE);
1657 		}
1658 		if (fd == -1 || rc == -1) {
1659 			DMLOG_PRINT(DMLVL_DEBUG,
1660 				    "Unable to set up variation! (errno = %d)\n",
1661 				    errno);
1662 			DMVAR_SKIP();
1663 		} else {
1664 			/* Variation */
1665 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
1666 				    szFuncName);
1667 			rc = dm_get_dmattr(sid, (void *)INVALID_ADDR, hlen,
1668 					   DM_NO_TOKEN, &attrname, sizeof(buf),
1669 					   buf, &rlen);
1670 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1671 
1672 			/* Variation clean up */
1673 			rc = close(fd);
1674 			rc |= remove(DUMMY_FILE);
1675 			if (rc == -1) {
1676 				DMLOG_PRINT(DMLVL_DEBUG,
1677 					    "Unable to clean up variation! (errno = %d)\n",
1678 					    errno);
1679 			}
1680 			dm_handle_free(hanp, hlen);
1681 		}
1682 	}
1683 
1684 	/*
1685 	 * TEST    : dm_get_dmattr - invalid hlen
1686 	 * EXPECTED: rc = -1, errno = EBADF
1687 	 */
1688 	if (DMVAR_EXEC(GET_DMATTR_BASE + 3)) {
1689 		int fd;
1690 		void *hanp;
1691 		size_t hlen;
1692 		dm_attrname_t attrname;
1693 		char buf[ATTR_VALUELEN];
1694 		size_t rlen;
1695 
1696 		/* Variation set up */
1697 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1698 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1699 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1700 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1701 		if ((rc = system(command)) == -1) {
1702 			/* No clean up */
1703 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1704 			remove(DUMMY_FILE);
1705 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1706 			close(fd);
1707 			remove(DUMMY_FILE);
1708 		} else
1709 		    if ((rc =
1710 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1711 				       0, sizeof(buf), buf)) == -1) {
1712 			dm_handle_free(hanp, hlen);
1713 			close(fd);
1714 			remove(DUMMY_FILE);
1715 		}
1716 		if (fd == -1 || rc == -1) {
1717 			DMLOG_PRINT(DMLVL_DEBUG,
1718 				    "Unable to set up variation! (errno = %d)\n",
1719 				    errno);
1720 			DMVAR_SKIP();
1721 		} else {
1722 			/* Variation */
1723 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
1724 				    szFuncName);
1725 			rc = dm_get_dmattr(sid, hanp, INVALID_ADDR, DM_NO_TOKEN,
1726 					   &attrname, sizeof(buf), buf, &rlen);
1727 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
1728 
1729 			/* Variation clean up */
1730 			rc = close(fd);
1731 			rc |= remove(DUMMY_FILE);
1732 			if (rc == -1) {
1733 				DMLOG_PRINT(DMLVL_DEBUG,
1734 					    "Unable to clean up variation! (errno = %d)\n",
1735 					    errno);
1736 			}
1737 			dm_handle_free(hanp, hlen);
1738 		}
1739 	}
1740 
1741 	/*
1742 	 * TEST    : dm_get_dmattr - invalid token
1743 	 * EXPECTED: rc = -1, errno = EINVAL
1744 	 */
1745 	if (DMVAR_EXEC(GET_DMATTR_BASE + 4)) {
1746 		int fd;
1747 		void *hanp;
1748 		size_t hlen;
1749 		dm_attrname_t attrname;
1750 		char buf[ATTR_VALUELEN];
1751 		size_t rlen;
1752 
1753 		/* Variation set up */
1754 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1755 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1756 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1757 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1758 		if ((rc = system(command)) == -1) {
1759 			/* No clean up */
1760 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1761 			remove(DUMMY_FILE);
1762 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1763 			close(fd);
1764 			remove(DUMMY_FILE);
1765 		} else
1766 		    if ((rc =
1767 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1768 				       0, sizeof(buf), buf)) == -1) {
1769 			dm_handle_free(hanp, hlen);
1770 			close(fd);
1771 			remove(DUMMY_FILE);
1772 		}
1773 		if (fd == -1 || rc == -1) {
1774 			DMLOG_PRINT(DMLVL_DEBUG,
1775 				    "Unable to set up variation! (errno = %d)\n",
1776 				    errno);
1777 			DMVAR_SKIP();
1778 		} else {
1779 			/* Variation */
1780 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
1781 				    szFuncName);
1782 			rc = dm_get_dmattr(sid, hanp, hlen, INVALID_ADDR,
1783 					   &attrname, sizeof(buf), buf, &rlen);
1784 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
1785 
1786 			/* Variation clean up */
1787 			rc = close(fd);
1788 			rc |= remove(DUMMY_FILE);
1789 			if (rc == -1) {
1790 				DMLOG_PRINT(DMLVL_DEBUG,
1791 					    "Unable to clean up variation! (errno = %d)\n",
1792 					    errno);
1793 			}
1794 			dm_handle_free(hanp, hlen);
1795 		}
1796 	}
1797 
1798 	/*
1799 	 * TEST    : dm_get_dmattr - invalid attrnamep
1800 	 * EXPECTED: rc = -1, errno = EFAULT
1801 	 */
1802 	if (DMVAR_EXEC(GET_DMATTR_BASE + 5)) {
1803 		int fd;
1804 		void *hanp;
1805 		size_t hlen;
1806 		dm_attrname_t attrname;
1807 		char buf[ATTR_VALUELEN];
1808 		size_t rlen;
1809 
1810 		/* Variation set up */
1811 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1812 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1813 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1814 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1815 		if ((rc = system(command)) == -1) {
1816 			/* No clean up */
1817 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1818 			remove(DUMMY_FILE);
1819 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1820 			close(fd);
1821 			remove(DUMMY_FILE);
1822 		} else
1823 		    if ((rc =
1824 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1825 				       0, sizeof(buf), buf)) == -1) {
1826 			dm_handle_free(hanp, hlen);
1827 			close(fd);
1828 			remove(DUMMY_FILE);
1829 		}
1830 		if (fd == -1 || rc == -1) {
1831 			DMLOG_PRINT(DMLVL_DEBUG,
1832 				    "Unable to set up variation! (errno = %d)\n",
1833 				    errno);
1834 			DMVAR_SKIP();
1835 		} else {
1836 			/* Variation */
1837 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
1838 				    szFuncName);
1839 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1840 					   (dm_attrname_t *) INVALID_ADDR,
1841 					   sizeof(buf), buf, &rlen);
1842 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1843 
1844 			/* Variation clean up */
1845 			rc = close(fd);
1846 			rc |= remove(DUMMY_FILE);
1847 			if (rc == -1) {
1848 				DMLOG_PRINT(DMLVL_DEBUG,
1849 					    "Unable to clean up variation! (errno = %d)\n",
1850 					    errno);
1851 			}
1852 			dm_handle_free(hanp, hlen);
1853 		}
1854 	}
1855 
1856 	/*
1857 	 * TEST    : dm_get_dmattr - invalid buflen
1858 	 * EXPECTED: rc = -1, errno = E2BIG
1859 	 */
1860 	if (DMVAR_EXEC(GET_DMATTR_BASE + 6)) {
1861 		int fd;
1862 		void *hanp;
1863 		size_t hlen;
1864 		dm_attrname_t attrname;
1865 		char buf[ATTR_VALUELEN];
1866 		size_t rlen;
1867 
1868 		/* Variation set up */
1869 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1870 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1871 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1872 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1873 		if ((rc = system(command)) == -1) {
1874 			/* No clean up */
1875 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1876 			remove(DUMMY_FILE);
1877 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1878 			close(fd);
1879 			remove(DUMMY_FILE);
1880 		} else
1881 		    if ((rc =
1882 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1883 				       0, sizeof(buf), buf)) == -1) {
1884 			dm_handle_free(hanp, hlen);
1885 			close(fd);
1886 			remove(DUMMY_FILE);
1887 		}
1888 		if (fd == -1 || rc == -1) {
1889 			DMLOG_PRINT(DMLVL_DEBUG,
1890 				    "Unable to set up variation! (errno = %d)\n",
1891 				    errno);
1892 			DMVAR_SKIP();
1893 		} else {
1894 			/* Variation */
1895 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
1896 				    szFuncName);
1897 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1898 					   &attrname, 1, buf, &rlen);
1899 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
1900 			DMLOG_PRINT(DMLVL_DEBUG, "rlen %d\n");
1901 
1902 			/* Variation clean up */
1903 			rc = close(fd);
1904 			rc |= remove(DUMMY_FILE);
1905 			if (rc == -1) {
1906 				DMLOG_PRINT(DMLVL_DEBUG,
1907 					    "Unable to clean up variation! (errno = %d)\n",
1908 					    errno);
1909 			}
1910 			dm_handle_free(hanp, hlen);
1911 		}
1912 	}
1913 
1914 	/*
1915 	 * TEST    : dm_get_dmattr - invalid bufp
1916 	 * EXPECTED: rc = -1, errno = EFAULT
1917 	 *
1918 	 * This variation uncovered XFS BUG #13 (attrname not null-terminated)
1919 	 */
1920 	if (DMVAR_EXEC(GET_DMATTR_BASE + 7)) {
1921 		int fd;
1922 		void *hanp;
1923 		size_t hlen;
1924 		dm_attrname_t attrname;
1925 		char buf[ATTR_VALUELEN];
1926 		size_t rlen;
1927 
1928 		/* Variation set up */
1929 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1930 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1931 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1932 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1933 		if ((rc = system(command)) == -1) {
1934 			/* No clean up */
1935 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1936 			remove(DUMMY_FILE);
1937 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1938 			close(fd);
1939 			remove(DUMMY_FILE);
1940 		} else
1941 		    if ((rc =
1942 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
1943 				       0, sizeof(buf), buf)) == -1) {
1944 			dm_handle_free(hanp, hlen);
1945 			close(fd);
1946 			remove(DUMMY_FILE);
1947 		}
1948 		if (fd == -1 || rc == -1) {
1949 			DMLOG_PRINT(DMLVL_DEBUG,
1950 				    "Unable to set up variation! (errno = %d)\n",
1951 				    errno);
1952 			DMVAR_SKIP();
1953 		} else {
1954 			/* Variation */
1955 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
1956 				    szFuncName);
1957 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
1958 					   &attrname, sizeof(buf),
1959 					   (void *)INVALID_ADDR, &rlen);
1960 			DMLOG_PRINT(DMLVL_DEBUG, "rc = %d, %s", rc, &attrname);
1961 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
1962 
1963 			/* Variation clean up */
1964 			rc = close(fd);
1965 			rc |= remove(DUMMY_FILE);
1966 			if (rc == -1) {
1967 				DMLOG_PRINT(DMLVL_DEBUG,
1968 					    "Unable to clean up variation! (errno = %d)\n",
1969 					    errno);
1970 			}
1971 			dm_handle_free(hanp, hlen);
1972 		}
1973 	}
1974 
1975 	/*
1976 	 * TEST    : dm_get_dmattr - invalid rlenp
1977 	 * EXPECTED: rc = -1, errno = EFAULT
1978 	 */
1979 	if (DMVAR_EXEC(GET_DMATTR_BASE + 8)) {
1980 		int fd;
1981 		void *hanp;
1982 		size_t hlen;
1983 		dm_attrname_t attrname;
1984 		char buf[ATTR_VALUELEN];
1985 
1986 		/* Variation set up */
1987 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
1988 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
1989 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
1990 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
1991 		if ((rc = system(command)) == -1) {
1992 			/* No clean up */
1993 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
1994 			remove(DUMMY_FILE);
1995 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
1996 			close(fd);
1997 			remove(DUMMY_FILE);
1998 		} else
1999 		    if ((rc =
2000 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2001 				       0, sizeof(buf), buf)) == -1) {
2002 			dm_handle_free(hanp, hlen);
2003 			close(fd);
2004 			remove(DUMMY_FILE);
2005 		}
2006 		if (fd == -1 || rc == -1) {
2007 			DMLOG_PRINT(DMLVL_DEBUG,
2008 				    "Unable to set up variation! (errno = %d)\n",
2009 				    errno);
2010 			DMVAR_SKIP();
2011 		} else {
2012 			/* Variation */
2013 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
2014 				    szFuncName);
2015 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2016 					   &attrname, sizeof(buf), buf,
2017 					   (size_t *) INVALID_ADDR);
2018 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
2019 
2020 			/* Variation clean up */
2021 			rc = close(fd);
2022 			rc |= remove(DUMMY_FILE);
2023 			if (rc == -1) {
2024 				DMLOG_PRINT(DMLVL_DEBUG,
2025 					    "Unable to clean up variation! (errno = %d)\n",
2026 					    errno);
2027 			}
2028 			dm_handle_free(hanp, hlen);
2029 		}
2030 	}
2031 
2032 	/*
2033 	 * TEST    : dm_get_dmattr - zero buflen, zero attribute length
2034 	 * EXPECTED: rc = 0
2035 	 */
2036 	if (DMVAR_EXEC(GET_DMATTR_BASE + 9)) {
2037 		int fd;
2038 		void *hanp;
2039 		size_t hlen;
2040 		dm_attrname_t attrname;
2041 		size_t rlen;
2042 
2043 		/* Variation set up */
2044 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2045 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2046 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2047 		if ((rc = system(command)) == -1) {
2048 			/* No clean up */
2049 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2050 			remove(DUMMY_FILE);
2051 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2052 			close(fd);
2053 			remove(DUMMY_FILE);
2054 		} else
2055 		    if ((rc =
2056 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2057 				       0, 0, NULL)) == -1) {
2058 			dm_handle_free(hanp, hlen);
2059 			close(fd);
2060 			remove(DUMMY_FILE);
2061 		}
2062 		if (fd == -1 || rc == -1) {
2063 			DMLOG_PRINT(DMLVL_DEBUG,
2064 				    "Unable to set up variation! (errno = %d)\n",
2065 				    errno);
2066 			DMVAR_SKIP();
2067 		} else {
2068 			/* Variation */
2069 			DMLOG_PRINT(DMLVL_DEBUG,
2070 				    "%s(zero buflen, zero attr len)\n",
2071 				    szFuncName);
2072 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2073 					   &attrname, 0, NULL, &rlen);
2074 			if (rc == 0) {
2075 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
2076 			}
2077 			DMVAR_ENDPASSEXP(szFuncName, 0, rc);
2078 
2079 			/* Variation clean up */
2080 			rc = close(fd);
2081 			rc |= remove(DUMMY_FILE);
2082 			if (rc == -1) {
2083 				DMLOG_PRINT(DMLVL_DEBUG,
2084 					    "Unable to clean up variation! (errno = %d)\n",
2085 					    errno);
2086 			}
2087 			dm_handle_free(hanp, hlen);
2088 		}
2089 	}
2090 
2091 	/*
2092 	 * TEST    : dm_get_dmattr - zero buflen, non-zero attribute length
2093 	 * EXPECTED: rc = -1, errno = E2BIG
2094 	 */
2095 	if (DMVAR_EXEC(GET_DMATTR_BASE + 10)) {
2096 		int fd;
2097 		void *hanp;
2098 		size_t hlen;
2099 		dm_attrname_t attrname;
2100 		char buf[ATTR_VALUELEN];
2101 		size_t rlen;
2102 
2103 		/* Variation set up */
2104 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2105 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2106 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2107 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2108 		if ((rc = system(command)) == -1) {
2109 			/* No clean up */
2110 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2111 			remove(DUMMY_FILE);
2112 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2113 			close(fd);
2114 			remove(DUMMY_FILE);
2115 		} else
2116 		    if ((rc =
2117 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2118 				       0, sizeof(buf), buf)) == -1) {
2119 			dm_handle_free(hanp, hlen);
2120 			close(fd);
2121 			remove(DUMMY_FILE);
2122 		}
2123 		if (fd == -1 || rc == -1) {
2124 			DMLOG_PRINT(DMLVL_DEBUG,
2125 				    "Unable to set up variation! (errno = %d)\n",
2126 				    errno);
2127 			DMVAR_SKIP();
2128 		} else {
2129 			/* Variation */
2130 			DMLOG_PRINT(DMLVL_DEBUG,
2131 				    "%s(zero buflen, non-zero attr len)\n",
2132 				    szFuncName);
2133 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2134 					   &attrname, 0, NULL, &rlen);
2135 			if (rc == -1) {
2136 				if (errno == E2BIG) {
2137 					DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n",
2138 						    rlen);
2139 					if (rlen == ATTR_VALUELEN) {
2140 						DMLOG_PRINT(DMLVL_DEBUG,
2141 							    "%s passed with expected rc = %d and expected errno = %d\n",
2142 							    szFuncName, -1,
2143 							    E2BIG);
2144 						DMVAR_PASS();
2145 					} else {
2146 						DMLOG_PRINT(DMLVL_ERR,
2147 							    "%s failed with expected rc = %d and expected errno = %d but unexpected rlen (%d vs %d)\n",
2148 							    szFuncName, -1,
2149 							    E2BIG, rlen,
2150 							    ATTR_VALUELEN);
2151 						DMVAR_FAIL();
2152 					}
2153 				} else {
2154 					DMLOG_PRINT(DMLVL_ERR,
2155 						    "%s failed with expected rc = %d but unexpected errno = %d\n",
2156 						    szFuncName, -1, E2BIG);
2157 					DMVAR_FAIL();
2158 				}
2159 			} else {
2160 				DMLOG_PRINT(DMLVL_ERR,
2161 					    "%s failed with unexpected rc = %d\n",
2162 					    szFuncName, -1);
2163 				DMVAR_FAIL();
2164 			}
2165 
2166 			/* Variation clean up */
2167 			rc = close(fd);
2168 			rc |= remove(DUMMY_FILE);
2169 			if (rc == -1) {
2170 				DMLOG_PRINT(DMLVL_DEBUG,
2171 					    "Unable to clean up variation! (errno = %d)\n",
2172 					    errno);
2173 			}
2174 			dm_handle_free(hanp, hlen);
2175 		}
2176 	}
2177 
2178 	/*
2179 	 * TEST    : dm_get_dmattr - attribute not exist
2180 	 * EXPECTED: rc = -1, errno = ENOENT
2181 	 */
2182 	if (DMVAR_EXEC(GET_DMATTR_BASE + 11)) {
2183 		int fd;
2184 		void *hanp;
2185 		size_t hlen;
2186 		dm_attrname_t attrname;
2187 		char buf[ATTR_VALUELEN];
2188 		size_t rlen;
2189 
2190 		/* Variation set up */
2191 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2192 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2193 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2194 		if ((rc = system(command)) == -1) {
2195 			/* No clean up */
2196 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2197 			remove(DUMMY_FILE);
2198 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2199 			close(fd);
2200 			remove(DUMMY_FILE);
2201 		}
2202 		if (fd == -1 || rc == -1) {
2203 			DMLOG_PRINT(DMLVL_DEBUG,
2204 				    "Unable to set up variation! (errno = %d)\n",
2205 				    errno);
2206 			DMVAR_SKIP();
2207 		} else {
2208 			/* Variation */
2209 			DMLOG_PRINT(DMLVL_DEBUG, "%s(attr not exist)\n",
2210 				    szFuncName);
2211 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2212 					   &attrname, sizeof(buf), buf, &rlen);
2213 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
2214 
2215 			/* Variation clean up */
2216 			rc = close(fd);
2217 			rc |= remove(DUMMY_FILE);
2218 			if (rc == -1) {
2219 				DMLOG_PRINT(DMLVL_DEBUG,
2220 					    "Unable to clean up variation! (errno = %d)\n",
2221 					    errno);
2222 			}
2223 			dm_handle_free(hanp, hlen);
2224 		}
2225 	}
2226 
2227 	/*
2228 	 * TEST    : dm_get_dmattr - buf too small
2229 	 * EXPECTED: rc = -1, errno = E2BIG
2230 	 */
2231 	if (DMVAR_EXEC(GET_DMATTR_BASE + 12)) {
2232 		int fd;
2233 		void *hanp;
2234 		size_t hlen;
2235 		dm_attrname_t attrname;
2236 		char buf[ATTR_VALUELEN];
2237 		size_t rlen;
2238 
2239 		/* Variation set up */
2240 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2241 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2242 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2243 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2244 		if ((rc = system(command)) == -1) {
2245 			/* No clean up */
2246 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2247 			remove(DUMMY_FILE);
2248 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2249 			close(fd);
2250 			remove(DUMMY_FILE);
2251 		} else
2252 		    if ((rc =
2253 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2254 				       0, sizeof(buf), buf)) == -1) {
2255 			dm_handle_free(hanp, hlen);
2256 			close(fd);
2257 			remove(DUMMY_FILE);
2258 		}
2259 		if (fd == -1 || rc == -1) {
2260 			DMLOG_PRINT(DMLVL_DEBUG,
2261 				    "Unable to set up variation! (errno = %d)\n",
2262 				    errno);
2263 			DMVAR_SKIP();
2264 		} else {
2265 			/* Variation */
2266 			DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen too small)\n",
2267 				    szFuncName);
2268 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2269 					   &attrname, sizeof(buf) - 1, buf,
2270 					   &rlen);
2271 			if (rc == -1 && errno == E2BIG) {
2272 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
2273 			}
2274 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
2275 
2276 			/* Variation clean up */
2277 			rc = close(fd);
2278 			rc |= remove(DUMMY_FILE);
2279 			if (rc == -1) {
2280 				DMLOG_PRINT(DMLVL_DEBUG,
2281 					    "Unable to clean up variation! (errno = %d)\n",
2282 					    errno);
2283 			}
2284 			dm_handle_free(hanp, hlen);
2285 		}
2286 	}
2287 
2288 	/*
2289 	 * TEST    : dm_get_dmattr - file handle
2290 	 * EXPECTED: rc = 0
2291 	 */
2292 	if (DMVAR_EXEC(GET_DMATTR_BASE + 13)) {
2293 		int fd;
2294 		void *hanp;
2295 		size_t hlen;
2296 		dm_attrname_t attrname;
2297 		char buf[ATTR_VALUELEN];
2298 		size_t rlen;
2299 
2300 		/* Variation set up */
2301 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2302 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2303 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2304 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2305 		if ((rc = system(command)) == -1) {
2306 			/* No clean up */
2307 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2308 			remove(DUMMY_FILE);
2309 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2310 			close(fd);
2311 			remove(DUMMY_FILE);
2312 		} else
2313 		    if ((rc =
2314 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2315 				       0, sizeof(buf), buf)) == -1) {
2316 			dm_handle_free(hanp, hlen);
2317 			close(fd);
2318 			remove(DUMMY_FILE);
2319 		}
2320 		if (fd == -1 || rc == -1) {
2321 			DMLOG_PRINT(DMLVL_DEBUG,
2322 				    "Unable to set up variation! (errno = %d)\n",
2323 				    errno);
2324 			DMVAR_SKIP();
2325 		} else {
2326 			/* Variation */
2327 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
2328 				    szFuncName);
2329 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2330 					   &attrname, sizeof(buf), buf, &rlen);
2331 			if (rc == 0) {
2332 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
2333 				if (rlen == ATTR_VALUELEN) {
2334 					if (memcmp
2335 					    (buf, ATTR_VALUE,
2336 					     ATTR_VALUELEN) == 0) {
2337 						DMLOG_PRINT(DMLVL_DEBUG,
2338 							    "%s passed with expected rc = %d\n",
2339 							    szFuncName, 0);
2340 						DMVAR_PASS();
2341 					} else {
2342 						DMLOG_PRINT(DMLVL_ERR,
2343 							    "%s failed with expected rc = %d and rlen = %d but unexpected buf %s",
2344 							    szFuncName, 0, rlen,
2345 							    buf);
2346 						DMVAR_FAIL();
2347 					}
2348 				} else {
2349 					DMLOG_PRINT(DMLVL_ERR,
2350 						    "%s failed with expected rc = %d but unexpected rlen = %d\n",
2351 						    szFuncName, 0, rlen);
2352 					DMVAR_FAIL();
2353 				}
2354 			} else {
2355 				DMLOG_PRINT(DMLVL_ERR,
2356 					    "%s failed with unexpected rc = %d (errno = %d)\n",
2357 					    szFuncName, rc, errno);
2358 				DMVAR_FAIL();
2359 			}
2360 
2361 			/* Variation clean up */
2362 			rc = close(fd);
2363 			rc |= remove(DUMMY_FILE);
2364 			if (rc == -1) {
2365 				DMLOG_PRINT(DMLVL_DEBUG,
2366 					    "Unable to clean up variation! (errno = %d)\n",
2367 					    errno);
2368 			}
2369 			dm_handle_free(hanp, hlen);
2370 		}
2371 	}
2372 
2373 	/*
2374 	 * TEST    : dm_get_dmattr - maximum buflen
2375 	 * EXPECTED: rc = 0
2376 	 */
2377 	if (DMVAR_EXEC(GET_DMATTR_BASE + 14)) {
2378 		int fd;
2379 		void *hanp;
2380 		size_t hlen;
2381 		dm_attrname_t attrname;
2382 		char *buf;
2383 		size_t rlen;
2384 
2385 		/* Variation set up */
2386 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2387 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2388 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2389 		if ((buf = malloc(maxAttrSize)) == NULL) {
2390 			/* No clean up */
2391 		} else if ((memset(buf, '3', maxAttrSize) == NULL) ||
2392 			   ((rc = system(command)) == -1)) {
2393 			free(buf);
2394 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2395 			free(buf);
2396 			remove(DUMMY_FILE);
2397 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2398 			free(buf);
2399 			close(fd);
2400 			remove(DUMMY_FILE);
2401 		} else
2402 		    if ((rc =
2403 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2404 				       0, maxAttrSize, buf)) == -1) {
2405 			free(buf);
2406 			dm_handle_free(hanp, hlen);
2407 			close(fd);
2408 			remove(DUMMY_FILE);
2409 		}
2410 		if (fd == -1 || rc == -1 || buf == NULL) {
2411 			DMLOG_PRINT(DMLVL_DEBUG,
2412 				    "Unable to set up variation! (errno = %d)\n",
2413 				    errno);
2414 			DMVAR_SKIP();
2415 		} else {
2416 			/* Variation */
2417 			DMLOG_PRINT(DMLVL_DEBUG, "%s(max buflen)\n",
2418 				    szFuncName);
2419 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2420 					   &attrname, maxAttrSize, buf, &rlen);
2421 			if (rc == 0) {
2422 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
2423 				if (rlen == maxAttrSize) {
2424 					DMLOG_PRINT(DMLVL_DEBUG,
2425 						    "%s passed with expected rc = %d\n",
2426 						    szFuncName, 0);
2427 					DMVAR_PASS();
2428 				} else {
2429 					DMLOG_PRINT(DMLVL_ERR,
2430 						    "%s failed with expected rc = %d but unexpected rlen (%d vs %d)\n",
2431 						    szFuncName, 0, rlen,
2432 						    maxAttrSize);
2433 					DMVAR_FAIL();
2434 				}
2435 			} else {
2436 				DMLOG_PRINT(DMLVL_ERR,
2437 					    "%s failed with unexpected rc = %d (errno = %d)\n",
2438 					    szFuncName, rc, errno);
2439 				DMVAR_FAIL();
2440 			}
2441 
2442 			/* Variation clean up */
2443 			rc = close(fd);
2444 			rc |= remove(DUMMY_FILE);
2445 			if (rc == -1) {
2446 				DMLOG_PRINT(DMLVL_DEBUG,
2447 					    "Unable to clean up variation! (errno = %d)\n",
2448 					    errno);
2449 			}
2450 			free(buf);
2451 			dm_handle_free(hanp, hlen);
2452 		}
2453 	}
2454 
2455 	/*
2456 	 * TEST    : dm_get_dmattr - directory handle
2457 	 * EXPECTED: rc = 0
2458 	 */
2459 	if (DMVAR_EXEC(GET_DMATTR_BASE + 15)) {
2460 		void *hanp;
2461 		size_t hlen;
2462 		dm_attrname_t attrname;
2463 		char buf[ATTR_VALUELEN];
2464 		size_t rlen;
2465 
2466 		/* Variation set up */
2467 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2468 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2469 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2470 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
2471 			/* No clean up */
2472 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
2473 			   == -1) {
2474 			rmdir(DUMMY_SUBDIR);
2475 		} else
2476 		    if ((rc =
2477 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2478 				       0, sizeof(buf), buf)) == -1) {
2479 			dm_handle_free(hanp, hlen);
2480 			rmdir(DUMMY_SUBDIR);
2481 		}
2482 		if (rc == -1) {
2483 			DMLOG_PRINT(DMLVL_DEBUG,
2484 				    "Unable to set up variation! (errno = %d)\n",
2485 				    errno);
2486 			DMVAR_SKIP();
2487 		} else {
2488 			/* Variation */
2489 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
2490 				    szFuncName);
2491 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2492 					   &attrname, sizeof(buf), buf, &rlen);
2493 			if (rc == 0) {
2494 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
2495 				if (rlen == ATTR_VALUELEN) {
2496 					if (memcmp
2497 					    (buf, ATTR_VALUE,
2498 					     ATTR_VALUELEN) == 0) {
2499 						DMLOG_PRINT(DMLVL_DEBUG,
2500 							    "%s passed with expected rc = %d\n",
2501 							    szFuncName, 0);
2502 						DMVAR_PASS();
2503 					} else {
2504 						DMLOG_PRINT(DMLVL_ERR,
2505 							    "%s failed with expected rc = %d and rlen = %d but unexpected buf %s",
2506 							    szFuncName, 0, rlen,
2507 							    buf);
2508 						DMVAR_FAIL();
2509 					}
2510 				} else {
2511 					DMLOG_PRINT(DMLVL_ERR,
2512 						    "%s failed with expected rc = %d but unexpected rlen = %d\n",
2513 						    szFuncName, 0, rlen);
2514 					DMVAR_FAIL();
2515 				}
2516 			} else {
2517 				DMLOG_PRINT(DMLVL_ERR,
2518 					    "%s failed with unexpected rc = %d (errno = %d)\n",
2519 					    szFuncName, rc, errno);
2520 				DMVAR_FAIL();
2521 			}
2522 
2523 			/* Variation clean up */
2524 			rc = rmdir(DUMMY_SUBDIR);
2525 			if (rc == -1) {
2526 				DMLOG_PRINT(DMLVL_DEBUG,
2527 					    "Unable to clean up variation! (errno = %d)\n",
2528 					    errno);
2529 			}
2530 			dm_handle_free(hanp, hlen);
2531 		}
2532 	}
2533 
2534 	/*
2535 	 * TEST    : dm_get_dmattr - fs handle
2536 	 * EXPECTED: rc = -1, errno = EINVAL
2537 	 */
2538 	if (DMVAR_EXEC(GET_DMATTR_BASE + 16)) {
2539 		void *hanp;
2540 		size_t hlen;
2541 		dm_attrname_t attrname;
2542 		char buf[ATTR_VALUELEN];
2543 		size_t rlen;
2544 
2545 		/* Variation set up */
2546 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2547 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2548 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2549 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2550 		if ((rc = system(command)) == -1) {
2551 			/* No clean up */
2552 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
2553 			   == -1) {
2554 			remove(DUMMY_FILE);
2555 		}
2556 		if (rc == -1) {
2557 			DMLOG_PRINT(DMLVL_DEBUG,
2558 				    "Unable to set up variation! (errno = %d)\n",
2559 				    errno);
2560 			DMVAR_SKIP();
2561 		} else {
2562 			/* Variation */
2563 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
2564 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2565 					   &attrname, sizeof(buf), buf, &rlen);
2566 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
2567 
2568 			/* Variation clean up */
2569 			rc = remove(DUMMY_FILE);
2570 			if (rc == -1) {
2571 				DMLOG_PRINT(DMLVL_DEBUG,
2572 					    "Unable to clean up variation! (errno = %d)\n",
2573 					    errno);
2574 			}
2575 			dm_handle_free(hanp, hlen);
2576 		}
2577 	}
2578 
2579 	/*
2580 	 * TEST    : dm_get_dmattr - DM_NO_SESSION sid
2581 	 * EXPECTED: rc = -1, errno = EINVAL
2582 	 */
2583 	if (DMVAR_EXEC(GET_DMATTR_BASE + 17)) {
2584 		int fd;
2585 		void *hanp;
2586 		size_t hlen;
2587 		dm_attrname_t attrname;
2588 		char buf[ATTR_VALUELEN];
2589 		size_t rlen;
2590 
2591 		/* Variation set up */
2592 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2593 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2594 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2595 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2596 		if ((rc = system(command)) == -1) {
2597 			/* No clean up */
2598 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2599 			remove(DUMMY_FILE);
2600 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2601 			close(fd);
2602 			remove(DUMMY_FILE);
2603 		} else
2604 		    if ((rc =
2605 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2606 				       0, sizeof(buf), buf)) == -1) {
2607 			dm_handle_free(hanp, hlen);
2608 			close(fd);
2609 			remove(DUMMY_FILE);
2610 		}
2611 		if (fd == -1 || rc == -1) {
2612 			DMLOG_PRINT(DMLVL_DEBUG,
2613 				    "Unable to set up variation! (errno = %d)\n",
2614 				    errno);
2615 			DMVAR_SKIP();
2616 		} else {
2617 			/* Variation */
2618 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
2619 				    szFuncName);
2620 			rc = dm_get_dmattr(DM_NO_SESSION, hanp, hlen,
2621 					   DM_NO_TOKEN, &attrname, sizeof(buf),
2622 					   buf, &rlen);
2623 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
2624 
2625 			/* Variation clean up */
2626 			rc = close(fd);
2627 			rc |= remove(DUMMY_FILE);
2628 			if (rc == -1) {
2629 				DMLOG_PRINT(DMLVL_DEBUG,
2630 					    "Unable to clean up variation! (errno = %d)\n",
2631 					    errno);
2632 			}
2633 			dm_handle_free(hanp, hlen);
2634 		}
2635 	}
2636 
2637 	/*
2638 	 * TEST    : dm_get_dmattr - global handle
2639 	 * EXPECTED: rc = -1, errno = EBADF
2640 	 */
2641 	if (DMVAR_EXEC(GET_DMATTR_BASE + 18)) {
2642 		dm_attrname_t attrname;
2643 		char buf[ATTR_VALUELEN];
2644 		size_t rlen;
2645 
2646 		/* Variation set up */
2647 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2648 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2649 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2650 
2651 		/* Variation */
2652 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
2653 		rc = dm_get_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
2654 				   DM_NO_TOKEN, &attrname, sizeof(buf), buf,
2655 				   &rlen);
2656 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
2657 
2658 		/* Variation clean up */
2659 	}
2660 
2661 	/*
2662 	 * TEST    : dm_get_dmattr - invalidated hanp
2663 	 * EXPECTED: rc = -1, errno = EBADF
2664 	 */
2665 	if (DMVAR_EXEC(GET_DMATTR_BASE + 19)) {
2666 		int fd;
2667 		void *hanp;
2668 		size_t hlen;
2669 		dm_attrname_t attrname;
2670 		char buf[ATTR_VALUELEN];
2671 		size_t rlen;
2672 
2673 		/* Variation set up */
2674 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2675 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2676 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
2677 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2678 		if ((rc = system(command)) == -1) {
2679 			/* No clean up */
2680 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2681 			remove(DUMMY_FILE);
2682 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2683 			close(fd);
2684 			remove(DUMMY_FILE);
2685 		} else
2686 		    if ((rc =
2687 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
2688 				       0, sizeof(buf), buf)) == -1) {
2689 			dm_handle_free(hanp, hlen);
2690 			close(fd);
2691 			remove(DUMMY_FILE);
2692 		} else if ((rc = close(fd)) == -1) {
2693 			dm_handle_free(hanp, hlen);
2694 			remove(DUMMY_FILE);
2695 		} else if ((rc == remove(DUMMY_FILE)) == -1) {
2696 			dm_handle_free(hanp, hlen);
2697 		}
2698 		if (fd == -1 || rc == -1) {
2699 			DMLOG_PRINT(DMLVL_DEBUG,
2700 				    "Unable to set up variation! (errno = %d)\n",
2701 				    errno);
2702 			DMVAR_SKIP();
2703 		} else {
2704 			/* Variation */
2705 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
2706 				    szFuncName);
2707 			rc = dm_get_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
2708 					   &attrname, sizeof(buf), buf, &rlen);
2709 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
2710 
2711 			/* Variation clean up */
2712 			dm_handle_free(hanp, hlen);
2713 		}
2714 	}
2715 
2716 	szFuncName = "dm_remove_dmattr";
2717 
2718 	/*
2719 	 * TEST    : dm_remove_dmattr - invalid sid
2720 	 * EXPECTED: rc = -1, errno = EINVAL
2721 	 */
2722 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 1)) {
2723 		int fd;
2724 		void *hanp;
2725 		size_t hlen;
2726 		dm_attrname_t attrname;
2727 
2728 		/* Variation set up */
2729 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2730 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2731 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2732 		if ((rc = system(command)) == -1) {
2733 			/* No clean up */
2734 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2735 			remove(DUMMY_FILE);
2736 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2737 			close(fd);
2738 			remove(DUMMY_FILE);
2739 		}
2740 		if (fd == -1 || rc == -1) {
2741 			DMLOG_PRINT(DMLVL_DEBUG,
2742 				    "Unable to set up variation! (errno = %d)\n",
2743 				    errno);
2744 			DMVAR_SKIP();
2745 		} else {
2746 			/* Variation */
2747 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
2748 				    szFuncName);
2749 			rc = dm_remove_dmattr(INVALID_ADDR, hanp, hlen,
2750 					      DM_NO_TOKEN, 0, &attrname);
2751 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
2752 
2753 			/* Variation clean up */
2754 			rc = close(fd);
2755 			rc |= remove(DUMMY_FILE);
2756 			if (rc == -1) {
2757 				DMLOG_PRINT(DMLVL_DEBUG,
2758 					    "Unable to clean up variation! (errno = %d)\n",
2759 					    errno);
2760 			}
2761 			dm_handle_free(hanp, hlen);
2762 		}
2763 	}
2764 
2765 	/*
2766 	 * TEST    : dm_remove_dmattr - invalid hanp
2767 	 * EXPECTED: rc = -1, errno = EFAULT
2768 	 */
2769 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 2)) {
2770 		int fd;
2771 		void *hanp;
2772 		size_t hlen;
2773 		dm_attrname_t attrname;
2774 
2775 		/* Variation set up */
2776 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2777 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2778 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2779 		if ((rc = system(command)) == -1) {
2780 			/* No clean up */
2781 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2782 			remove(DUMMY_FILE);
2783 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2784 			close(fd);
2785 			remove(DUMMY_FILE);
2786 		}
2787 		if (fd == -1 || rc == -1) {
2788 			DMLOG_PRINT(DMLVL_DEBUG,
2789 				    "Unable to set up variation! (errno = %d)\n",
2790 				    errno);
2791 			DMVAR_SKIP();
2792 		} else {
2793 			/* Variation */
2794 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
2795 				    szFuncName);
2796 			rc = dm_remove_dmattr(sid, (void *)INVALID_ADDR, hlen,
2797 					      DM_NO_TOKEN, 0, &attrname);
2798 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
2799 
2800 			/* Variation clean up */
2801 			rc = close(fd);
2802 			rc |= remove(DUMMY_FILE);
2803 			if (rc == -1) {
2804 				DMLOG_PRINT(DMLVL_DEBUG,
2805 					    "Unable to clean up variation! (errno = %d)\n",
2806 					    errno);
2807 			}
2808 			dm_handle_free(hanp, hlen);
2809 		}
2810 	}
2811 
2812 	/*
2813 	 * TEST    : dm_remove_dmattr - invalid hlen
2814 	 * EXPECTED: rc = -1, errno = EBADF
2815 	 */
2816 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 3)) {
2817 		int fd;
2818 		void *hanp;
2819 		size_t hlen;
2820 		dm_attrname_t attrname;
2821 
2822 		/* Variation set up */
2823 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2824 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2825 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2826 		if ((rc = system(command)) == -1) {
2827 			/* No clean up */
2828 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2829 			remove(DUMMY_FILE);
2830 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2831 			close(fd);
2832 			remove(DUMMY_FILE);
2833 		}
2834 		if (fd == -1 || rc == -1) {
2835 			DMLOG_PRINT(DMLVL_DEBUG,
2836 				    "Unable to set up variation! (errno = %d)\n",
2837 				    errno);
2838 			DMVAR_SKIP();
2839 		} else {
2840 			/* Variation */
2841 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
2842 				    szFuncName);
2843 			rc = dm_remove_dmattr(sid, hanp, INVALID_ADDR,
2844 					      DM_NO_TOKEN, 0, &attrname);
2845 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
2846 
2847 			/* Variation clean up */
2848 			rc = close(fd);
2849 			rc |= remove(DUMMY_FILE);
2850 			if (rc == -1) {
2851 				DMLOG_PRINT(DMLVL_DEBUG,
2852 					    "Unable to clean up variation! (errno = %d)\n",
2853 					    errno);
2854 			}
2855 			dm_handle_free(hanp, hlen);
2856 		}
2857 	}
2858 
2859 	/*
2860 	 * TEST    : dm_remove_dmattr - invalid token
2861 	 * EXPECTED: rc = -1, errno = EINVAL
2862 	 */
2863 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 4)) {
2864 		int fd;
2865 		void *hanp;
2866 		size_t hlen;
2867 		dm_attrname_t attrname;
2868 
2869 		/* Variation set up */
2870 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2871 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2872 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2873 		if ((rc = system(command)) == -1) {
2874 			/* No clean up */
2875 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2876 			remove(DUMMY_FILE);
2877 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2878 			close(fd);
2879 			remove(DUMMY_FILE);
2880 		}
2881 		if (fd == -1 || rc == -1) {
2882 			DMLOG_PRINT(DMLVL_DEBUG,
2883 				    "Unable to set up variation! (errno = %d)\n",
2884 				    errno);
2885 			DMVAR_SKIP();
2886 		} else {
2887 			/* Variation */
2888 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
2889 				    szFuncName);
2890 			rc = dm_remove_dmattr(sid, hanp, hlen, INVALID_ADDR, 0,
2891 					      &attrname);
2892 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
2893 
2894 			/* Variation clean up */
2895 			rc = close(fd);
2896 			rc |= remove(DUMMY_FILE);
2897 			if (rc == -1) {
2898 				DMLOG_PRINT(DMLVL_DEBUG,
2899 					    "Unable to clean up variation! (errno = %d)\n",
2900 					    errno);
2901 			}
2902 			dm_handle_free(hanp, hlen);
2903 		}
2904 	}
2905 
2906 	/*
2907 	 * TEST    : dm_remove_dmattr - invalid attrnamep
2908 	 * EXPECTED: rc = -1, errno = EFAULT
2909 	 */
2910 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 5)) {
2911 		int fd;
2912 		void *hanp;
2913 		size_t hlen;
2914 		dm_attrname_t attrname;
2915 
2916 		/* Variation set up */
2917 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2918 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2919 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2920 		if ((rc = system(command)) == -1) {
2921 			/* No clean up */
2922 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2923 			remove(DUMMY_FILE);
2924 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2925 			close(fd);
2926 			remove(DUMMY_FILE);
2927 		}
2928 		if (fd == -1 || rc == -1) {
2929 			DMLOG_PRINT(DMLVL_DEBUG,
2930 				    "Unable to set up variation! (errno = %d)\n",
2931 				    errno);
2932 			DMVAR_SKIP();
2933 		} else {
2934 			/* Variation */
2935 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
2936 				    szFuncName);
2937 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
2938 					      (dm_attrname_t *) INVALID_ADDR);
2939 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
2940 
2941 			/* Variation clean up */
2942 			rc = close(fd);
2943 			rc |= remove(DUMMY_FILE);
2944 			if (rc == -1) {
2945 				DMLOG_PRINT(DMLVL_DEBUG,
2946 					    "Unable to clean up variation! (errno = %d)\n",
2947 					    errno);
2948 			}
2949 			dm_handle_free(hanp, hlen);
2950 		}
2951 	}
2952 
2953 	/*
2954 	 * TEST    : dm_remove_dmattr - attribute not exist
2955 	 * EXPECTED: rc = -1, errno = ENOENT
2956 	 */
2957 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 6)) {
2958 		int fd;
2959 		void *hanp;
2960 		size_t hlen;
2961 		dm_attrname_t attrname;
2962 
2963 		/* Variation set up */
2964 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
2965 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
2966 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
2967 		if ((rc = system(command)) == -1) {
2968 			/* No clean up */
2969 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
2970 			remove(DUMMY_FILE);
2971 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
2972 			close(fd);
2973 			remove(DUMMY_FILE);
2974 		}
2975 		if (fd == -1 || rc == -1) {
2976 			DMLOG_PRINT(DMLVL_DEBUG,
2977 				    "Unable to set up variation! (errno = %d)\n",
2978 				    errno);
2979 			DMVAR_SKIP();
2980 		} else {
2981 			/* Variation */
2982 			DMLOG_PRINT(DMLVL_DEBUG, "%s(attr not exist)\n",
2983 				    szFuncName);
2984 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
2985 					      &attrname);
2986 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, ENOENT);
2987 
2988 			/* Variation clean up */
2989 			rc = close(fd);
2990 			rc |= remove(DUMMY_FILE);
2991 			if (rc == -1) {
2992 				DMLOG_PRINT(DMLVL_DEBUG,
2993 					    "Unable to clean up variation! (errno = %d)\n",
2994 					    errno);
2995 			}
2996 			dm_handle_free(hanp, hlen);
2997 		}
2998 	}
2999 
3000 	/*
3001 	 * TEST    : dm_remove_dmattr - file attribute, setdtime zero
3002 	 * EXPECTED: rc = 0
3003 	 */
3004 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 7)) {
3005 		int fd;
3006 		int rc2;
3007 		void *hanp;
3008 		size_t hlen;
3009 		dm_attrname_t attrname;
3010 		char buf[ATTR_VALUELEN];
3011 		size_t rlen;
3012 		struct stat statfs1, statfs2;
3013 
3014 		/* Variation set up */
3015 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3016 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3017 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3018 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3019 		if ((rc = system(command)) == -1) {
3020 			/* No clean up */
3021 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3022 			remove(DUMMY_FILE);
3023 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3024 			close(fd);
3025 			remove(DUMMY_FILE);
3026 		} else
3027 		    if ((rc =
3028 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3029 				       0, sizeof(buf), buf)) == -1) {
3030 			dm_handle_free(hanp, hlen);
3031 			close(fd);
3032 			remove(DUMMY_FILE);
3033 		}
3034 		if (fd == -1 || rc == -1) {
3035 			DMLOG_PRINT(DMLVL_DEBUG,
3036 				    "Unable to set up variation! (errno = %d)\n",
3037 				    errno);
3038 			DMVAR_SKIP();
3039 		} else {
3040 			/* Variation */
3041 			rc2 = stat(DUMMY_FILE, &statfs1);
3042 			TIMESTAMP_DELAY;
3043 			DMLOG_PRINT(DMLVL_DEBUG,
3044 				    "%s(file attr, setdtime zero)\n",
3045 				    szFuncName);
3046 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
3047 					      &attrname);
3048 			rc2 |= stat(DUMMY_FILE, &statfs2);
3049 			if (rc == 0) {
3050 				if (((rc =
3051 				      dm_get_dmattr(sid, hanp, hlen,
3052 						    DM_NO_TOKEN, &attrname,
3053 						    sizeof(buf), buf,
3054 						    &rlen)) == -1)
3055 				    && (errno == ENOENT)) {
3056 					if ((rc2 == 0)
3057 					    && (statfs1.st_ctime ==
3058 						statfs2.st_ctime)) {
3059 						DMLOG_PRINT(DMLVL_DEBUG,
3060 							    "%s passed with expected rc = %d and dtime unmodified\n",
3061 							    szFuncName, 0);
3062 						DMVAR_PASS();
3063 					} else {
3064 						DMLOG_PRINT(DMLVL_ERR,
3065 							    "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
3066 							    szFuncName, 0,
3067 							    statfs1.st_ctime,
3068 							    statfs2.st_ctime);
3069 						DMVAR_FAIL();
3070 					}
3071 				} else {
3072 					DMLOG_PRINT(DMLVL_ERR,
3073 						    "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
3074 						    szFuncName, 0, errno);
3075 					DMVAR_FAIL();
3076 				}
3077 			} else {
3078 				DMLOG_PRINT(DMLVL_ERR,
3079 					    "%s failed with unexpected rc = %d (errno = %d)\n",
3080 					    szFuncName, rc, errno);
3081 				DMVAR_FAIL();
3082 			}
3083 
3084 			/* Variation clean up */
3085 			rc = close(fd);
3086 			rc |= remove(DUMMY_FILE);
3087 			if (rc == -1) {
3088 				DMLOG_PRINT(DMLVL_DEBUG,
3089 					    "Unable to clean up variation! (errno = %d)\n",
3090 					    errno);
3091 			}
3092 			dm_handle_free(hanp, hlen);
3093 		}
3094 	}
3095 
3096 	/*
3097 	 * TEST    : dm_remove_dmattr - file attribute, setdtime non-zero
3098 	 * EXPECTED: rc = 0
3099 	 */
3100 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 8)) {
3101 		int fd;
3102 		int rc2;
3103 		void *hanp;
3104 		size_t hlen;
3105 		dm_attrname_t attrname;
3106 		char buf[ATTR_VALUELEN];
3107 		size_t rlen;
3108 		struct stat statfs1, statfs2;
3109 
3110 		/* Variation set up */
3111 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3112 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3113 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3114 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3115 		if ((rc = system(command)) == -1) {
3116 			/* No clean up */
3117 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3118 			remove(DUMMY_FILE);
3119 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3120 			close(fd);
3121 			remove(DUMMY_FILE);
3122 		} else
3123 		    if ((rc =
3124 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3125 				       0, sizeof(buf), buf)) == -1) {
3126 			dm_handle_free(hanp, hlen);
3127 			close(fd);
3128 			remove(DUMMY_FILE);
3129 		}
3130 		if (fd == -1 || rc == -1) {
3131 			DMLOG_PRINT(DMLVL_DEBUG,
3132 				    "Unable to set up variation! (errno = %d)\n",
3133 				    errno);
3134 			DMVAR_SKIP();
3135 		} else {
3136 			/* Variation */
3137 			rc2 = stat(DUMMY_FILE, &statfs1);
3138 			TIMESTAMP_DELAY;
3139 			DMLOG_PRINT(DMLVL_DEBUG,
3140 				    "%s(file attr, setdtime non-zero)\n",
3141 				    szFuncName);
3142 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 1,
3143 					      &attrname);
3144 			rc2 |= stat(DUMMY_FILE, &statfs2);
3145 			if (rc == 0) {
3146 				if (((rc =
3147 				      dm_get_dmattr(sid, hanp, hlen,
3148 						    DM_NO_TOKEN, &attrname,
3149 						    sizeof(buf), buf,
3150 						    &rlen)) == -1)
3151 				    && (errno == ENOENT)) {
3152 					if ((rc2 == 0)
3153 					    && (statfs1.st_ctime !=
3154 						statfs2.st_ctime)) {
3155 						DMLOG_PRINT(DMLVL_DEBUG,
3156 							    "%s passed with expected rc = %d and dtime modified\n",
3157 							    szFuncName, 0);
3158 						DMVAR_PASS();
3159 					} else {
3160 						DMLOG_PRINT(DMLVL_ERR,
3161 							    "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
3162 							    szFuncName, 0,
3163 							    statfs1.st_ctime,
3164 							    statfs2.st_ctime);
3165 						DMVAR_FAIL();
3166 					}
3167 				} else {
3168 					DMLOG_PRINT(DMLVL_ERR,
3169 						    "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
3170 						    szFuncName, 0, errno);
3171 					DMVAR_FAIL();
3172 				}
3173 			} else {
3174 				DMLOG_PRINT(DMLVL_ERR,
3175 					    "%s failed with unexpected rc = %d (errno = %d)\n",
3176 					    szFuncName, rc, errno);
3177 				DMVAR_FAIL();
3178 			}
3179 
3180 			/* Variation clean up */
3181 			rc = close(fd);
3182 			rc |= remove(DUMMY_FILE);
3183 			if (rc == -1) {
3184 				DMLOG_PRINT(DMLVL_DEBUG,
3185 					    "Unable to clean up variation! (errno = %d)\n",
3186 					    errno);
3187 			}
3188 			dm_handle_free(hanp, hlen);
3189 		}
3190 	}
3191 
3192 	/*
3193 	 * TEST    : dm_remove_dmattr - directory attribute, setdtime zero
3194 	 * EXPECTED: rc = 0
3195 	 */
3196 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 9)) {
3197 		int rc2;
3198 		void *hanp;
3199 		size_t hlen;
3200 		dm_attrname_t attrname;
3201 		char buf[ATTR_VALUELEN];
3202 		size_t rlen;
3203 		struct stat statfs1, statfs2;
3204 
3205 		/* Variation set up */
3206 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3207 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3208 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3209 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
3210 			/* No clean up */
3211 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
3212 			   == -1) {
3213 			rmdir(DUMMY_SUBDIR);
3214 		} else
3215 		    if ((rc =
3216 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3217 				       0, sizeof(buf), buf)) == -1) {
3218 			dm_handle_free(hanp, hlen);
3219 			rmdir(DUMMY_SUBDIR);
3220 		}
3221 		if (rc == -1) {
3222 			DMLOG_PRINT(DMLVL_DEBUG,
3223 				    "Unable to set up variation! (errno = %d)\n",
3224 				    errno);
3225 			DMVAR_SKIP();
3226 		} else {
3227 			/* Variation */
3228 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
3229 			TIMESTAMP_DELAY;
3230 			DMLOG_PRINT(DMLVL_DEBUG,
3231 				    "%s(dir attr, setdtime zero)\n",
3232 				    szFuncName);
3233 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
3234 					      &attrname);
3235 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
3236 			if (rc == 0) {
3237 				if (((rc =
3238 				      dm_get_dmattr(sid, hanp, hlen,
3239 						    DM_NO_TOKEN, &attrname,
3240 						    sizeof(buf), buf,
3241 						    &rlen)) == -1)
3242 				    && (errno == ENOENT)) {
3243 					if ((rc2 == 0)
3244 					    && (statfs1.st_ctime ==
3245 						statfs2.st_ctime)) {
3246 						DMLOG_PRINT(DMLVL_DEBUG,
3247 							    "%s passed with expected rc = %d and dtime unmodified\n",
3248 							    szFuncName, 0);
3249 						DMVAR_PASS();
3250 					} else {
3251 						DMLOG_PRINT(DMLVL_ERR,
3252 							    "%s failed with expected rc = %d but dtime modified (%d vs %d)\n",
3253 							    szFuncName, 0,
3254 							    statfs1.st_ctime,
3255 							    statfs2.st_ctime);
3256 						DMVAR_FAIL();
3257 					}
3258 				} else {
3259 					DMLOG_PRINT(DMLVL_ERR,
3260 						    "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
3261 						    szFuncName, 0, errno);
3262 					DMVAR_FAIL();
3263 				}
3264 			} else {
3265 				DMLOG_PRINT(DMLVL_ERR,
3266 					    "%s failed with unexpected rc = %d (errno = %d)\n",
3267 					    szFuncName, rc, errno);
3268 				DMVAR_FAIL();
3269 			}
3270 
3271 			/* Variation clean up */
3272 			rc = rmdir(DUMMY_SUBDIR);
3273 			if (rc == -1) {
3274 				DMLOG_PRINT(DMLVL_DEBUG,
3275 					    "Unable to clean up variation! (errno = %d)\n",
3276 					    errno);
3277 			}
3278 			dm_handle_free(hanp, hlen);
3279 		}
3280 	}
3281 
3282 	/*
3283 	 * TEST    : dm_remove_dmattr - directory attribute, setdtime non-zero
3284 	 * EXPECTED: rc = 0
3285 	 */
3286 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 10)) {
3287 		int rc2;
3288 		void *hanp;
3289 		size_t hlen;
3290 		dm_attrname_t attrname;
3291 		char buf[ATTR_VALUELEN];
3292 		size_t rlen;
3293 		struct stat statfs1, statfs2;
3294 
3295 		/* Variation set up */
3296 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3297 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3298 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3299 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
3300 			/* No clean up */
3301 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
3302 			   == -1) {
3303 			rmdir(DUMMY_SUBDIR);
3304 		} else
3305 		    if ((rc =
3306 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3307 				       0, sizeof(buf), buf)) == -1) {
3308 			dm_handle_free(hanp, hlen);
3309 			rmdir(DUMMY_SUBDIR);
3310 		}
3311 		if (rc == -1) {
3312 			DMLOG_PRINT(DMLVL_DEBUG,
3313 				    "Unable to set up variation! (errno = %d)\n",
3314 				    errno);
3315 			DMVAR_SKIP();
3316 		} else {
3317 			/* Variation */
3318 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
3319 			TIMESTAMP_DELAY;
3320 			DMLOG_PRINT(DMLVL_DEBUG,
3321 				    "%s(dir attr, setdtime non-zero)\n",
3322 				    szFuncName);
3323 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 1,
3324 					      &attrname);
3325 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
3326 			if (rc == 0) {
3327 				if (((rc =
3328 				      dm_get_dmattr(sid, hanp, hlen,
3329 						    DM_NO_TOKEN, &attrname,
3330 						    sizeof(buf), buf,
3331 						    &rlen)) == -1)
3332 				    && (errno == ENOENT)) {
3333 					if ((rc2 == 0)
3334 					    && (statfs1.st_ctime !=
3335 						statfs2.st_ctime)) {
3336 						DMLOG_PRINT(DMLVL_DEBUG,
3337 							    "%s passed with expected rc = %d and dtime modified\n",
3338 							    szFuncName, 0);
3339 						DMVAR_PASS();
3340 					} else {
3341 						DMLOG_PRINT(DMLVL_ERR,
3342 							    "%s failed with expected rc = %d but dtime unmodified (%d vs %d)\n",
3343 							    szFuncName, 0,
3344 							    statfs1.st_ctime,
3345 							    statfs2.st_ctime);
3346 						DMVAR_FAIL();
3347 					}
3348 				} else {
3349 					DMLOG_PRINT(DMLVL_ERR,
3350 						    "%s failed with expected rc = %d but attr still exist (errno = %d)\n",
3351 						    szFuncName, 0, errno);
3352 					DMVAR_FAIL();
3353 				}
3354 			} else {
3355 				DMLOG_PRINT(DMLVL_ERR,
3356 					    "%s failed with unexpected rc = %d (errno = %d)\n",
3357 					    szFuncName, rc, errno);
3358 				DMVAR_FAIL();
3359 			}
3360 
3361 			/* Variation clean up */
3362 			rc = rmdir(DUMMY_SUBDIR);
3363 			if (rc == -1) {
3364 				DMLOG_PRINT(DMLVL_DEBUG,
3365 					    "Unable to clean up variation! (errno = %d)\n",
3366 					    errno);
3367 			}
3368 			dm_handle_free(hanp, hlen);
3369 		}
3370 	}
3371 
3372 	/*
3373 	 * TEST    : dm_remove_dmattr - fs handle
3374 	 * EXPECTED: rc = -1, errno = EINVAL
3375 	 */
3376 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 11)) {
3377 		void *hanp;
3378 		size_t hlen;
3379 		dm_attrname_t attrname;
3380 
3381 		/* Variation set up */
3382 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3383 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3384 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3385 		if ((rc = system(command)) == -1) {
3386 			/* No clean up */
3387 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
3388 			   == -1) {
3389 			remove(DUMMY_FILE);
3390 		}
3391 		if (rc == -1) {
3392 			DMLOG_PRINT(DMLVL_DEBUG,
3393 				    "Unable to set up variation! (errno = %d)\n",
3394 				    errno);
3395 			DMVAR_SKIP();
3396 		} else {
3397 			/* Variation */
3398 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
3399 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
3400 					      &attrname);
3401 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
3402 
3403 			/* Variation clean up */
3404 			rc = remove(DUMMY_FILE);
3405 			if (rc == -1) {
3406 				DMLOG_PRINT(DMLVL_DEBUG,
3407 					    "Unable to clean up variation! (errno = %d)\n",
3408 					    errno);
3409 			}
3410 			dm_handle_free(hanp, hlen);
3411 		}
3412 	}
3413 
3414 	/*
3415 	 * TEST    : dm_remove_dmattr - DM_NO_SESSION sid
3416 	 * EXPECTED: rc = -1, errno = EINVAL
3417 	 */
3418 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 12)) {
3419 		int fd;
3420 		void *hanp;
3421 		size_t hlen;
3422 		dm_attrname_t attrname;
3423 
3424 		/* Variation set up */
3425 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3426 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3427 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3428 		if ((rc = system(command)) == -1) {
3429 			/* No clean up */
3430 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3431 			remove(DUMMY_FILE);
3432 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3433 			close(fd);
3434 			remove(DUMMY_FILE);
3435 		}
3436 		if (fd == -1 || rc == -1) {
3437 			DMLOG_PRINT(DMLVL_DEBUG,
3438 				    "Unable to set up variation! (errno = %d)\n",
3439 				    errno);
3440 			DMVAR_SKIP();
3441 		} else {
3442 			/* Variation */
3443 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
3444 				    szFuncName);
3445 			rc = dm_remove_dmattr(DM_NO_SESSION, hanp, hlen,
3446 					      DM_NO_TOKEN, 0, &attrname);
3447 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
3448 
3449 			/* Variation clean up */
3450 			rc = close(fd);
3451 			rc |= remove(DUMMY_FILE);
3452 			if (rc == -1) {
3453 				DMLOG_PRINT(DMLVL_DEBUG,
3454 					    "Unable to clean up variation! (errno = %d)\n",
3455 					    errno);
3456 			}
3457 			dm_handle_free(hanp, hlen);
3458 		}
3459 	}
3460 
3461 	/*
3462 	 * TEST    : dm_remove_dmattr - global handle
3463 	 * EXPECTED: rc = -1, errno = EBADF
3464 	 */
3465 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 13)) {
3466 		dm_attrname_t attrname;
3467 		char buf[ATTR_VALUELEN];
3468 
3469 		/* Variation set up */
3470 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3471 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3472 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3473 
3474 		/* Variation */
3475 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
3476 		rc = dm_remove_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
3477 				      DM_NO_TOKEN, 0, &attrname);
3478 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
3479 
3480 		/* Variation clean up */
3481 	}
3482 
3483 	/*
3484 	 * TEST    : dm_remove_dmattr - invalidated handle
3485 	 * EXPECTED: rc = -1, errno = EBADF
3486 	 */
3487 	if (DMVAR_EXEC(REMOVE_DMATTR_BASE + 14)) {
3488 		int fd;
3489 		void *hanp;
3490 		size_t hlen;
3491 		dm_attrname_t attrname;
3492 		char buf[ATTR_VALUELEN];
3493 
3494 		/* Variation set up */
3495 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3496 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3497 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3498 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3499 		if ((rc = system(command)) == -1) {
3500 			/* No clean up */
3501 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3502 			remove(DUMMY_FILE);
3503 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3504 			close(fd);
3505 			remove(DUMMY_FILE);
3506 		} else
3507 		    if ((rc =
3508 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3509 				       0, sizeof(buf), buf)) == -1) {
3510 			dm_handle_free(hanp, hlen);
3511 			close(fd);
3512 			remove(DUMMY_FILE);
3513 		} else if ((rc = close(fd)) == -1) {
3514 			dm_handle_free(hanp, hlen);
3515 			remove(DUMMY_FILE);
3516 		} else if ((rc = remove(DUMMY_FILE)) == -1) {
3517 			dm_handle_free(hanp, hlen);
3518 		}
3519 		if (fd == -1 || rc == -1) {
3520 			DMLOG_PRINT(DMLVL_DEBUG,
3521 				    "Unable to set up variation! (errno = %d)\n",
3522 				    errno);
3523 			DMVAR_SKIP();
3524 		} else {
3525 			/* Variation */
3526 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
3527 				    szFuncName);
3528 			rc = dm_remove_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 0,
3529 					      &attrname);
3530 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
3531 
3532 			/* Variation clean up */
3533 			dm_handle_free(hanp, hlen);
3534 		}
3535 	}
3536 
3537 	szFuncName = "dm_getall_dmattr";
3538 
3539 	/*
3540 	 * TEST    : dm_getall_dmattr - invalid sid
3541 	 * EXPECTED: rc = -1, errno = EINVAL
3542 	 */
3543 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 1)) {
3544 		int fd;
3545 		void *hanp;
3546 		size_t hlen;
3547 		dm_attrname_t attrname;
3548 		char buf[ATTR_LISTLEN];
3549 		size_t rlen;
3550 
3551 		/* Variation set up */
3552 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3553 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3554 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3555 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3556 		if ((rc = system(command)) == -1) {
3557 			/* No clean up */
3558 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3559 			remove(DUMMY_FILE);
3560 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3561 			close(fd);
3562 			remove(DUMMY_FILE);
3563 		} else
3564 		    if ((rc =
3565 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3566 				       0, sizeof(buf), buf)) == -1) {
3567 			dm_handle_free(hanp, hlen);
3568 			close(fd);
3569 			remove(DUMMY_FILE);
3570 		}
3571 		if (fd == -1 || rc == -1) {
3572 			DMLOG_PRINT(DMLVL_DEBUG,
3573 				    "Unable to set up variation! (errno = %d)\n",
3574 				    errno);
3575 			DMVAR_SKIP();
3576 		} else {
3577 			/* Variation */
3578 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
3579 				    szFuncName);
3580 			rc = dm_getall_dmattr(INVALID_ADDR, hanp, hlen,
3581 					      DM_NO_TOKEN, sizeof(buf), buf,
3582 					      &rlen);
3583 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
3584 
3585 			/* Variation clean up */
3586 			rc = close(fd);
3587 			rc |= remove(DUMMY_FILE);
3588 			if (rc == -1) {
3589 				DMLOG_PRINT(DMLVL_DEBUG,
3590 					    "Unable to clean up variation! (errno = %d)\n",
3591 					    errno);
3592 			}
3593 			dm_handle_free(hanp, hlen);
3594 		}
3595 	}
3596 
3597 	/*
3598 	 * TEST    : dm_getall_dmattr - invalid hanp
3599 	 * EXPECTED: rc = -1, errno = EFAULT
3600 	 */
3601 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 2)) {
3602 		int fd;
3603 		void *hanp;
3604 		size_t hlen;
3605 		dm_attrname_t attrname;
3606 		char buf[ATTR_LISTLEN];
3607 		size_t rlen;
3608 
3609 		/* Variation set up */
3610 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3611 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3612 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3613 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3614 		if ((rc = system(command)) == -1) {
3615 			/* No clean up */
3616 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3617 			remove(DUMMY_FILE);
3618 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3619 			close(fd);
3620 			remove(DUMMY_FILE);
3621 		} else
3622 		    if ((rc =
3623 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3624 				       0, sizeof(buf), buf)) == -1) {
3625 			dm_handle_free(hanp, hlen);
3626 			close(fd);
3627 			remove(DUMMY_FILE);
3628 		}
3629 		if (fd == -1 || rc == -1) {
3630 			DMLOG_PRINT(DMLVL_DEBUG,
3631 				    "Unable to set up variation! (errno = %d)\n",
3632 				    errno);
3633 			DMVAR_SKIP();
3634 		} else {
3635 			/* Variation */
3636 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
3637 				    szFuncName);
3638 			rc = dm_getall_dmattr(sid, (void *)INVALID_ADDR, hlen,
3639 					      DM_NO_TOKEN, sizeof(buf), buf,
3640 					      &rlen);
3641 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
3642 
3643 			/* Variation clean up */
3644 			rc = close(fd);
3645 			rc |= remove(DUMMY_FILE);
3646 			if (rc == -1) {
3647 				DMLOG_PRINT(DMLVL_DEBUG,
3648 					    "Unable to clean up variation! (errno = %d)\n",
3649 					    errno);
3650 			}
3651 			dm_handle_free(hanp, hlen);
3652 		}
3653 	}
3654 
3655 	/*
3656 	 * TEST    : dm_getall_dmattr - invalid hlen
3657 	 * EXPECTED: rc = -1, errno = EBADF
3658 	 */
3659 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 3)) {
3660 		int fd;
3661 		void *hanp;
3662 		size_t hlen;
3663 		dm_attrname_t attrname;
3664 		char buf[ATTR_LISTLEN];
3665 		size_t rlen;
3666 
3667 		/* Variation set up */
3668 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3669 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3670 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3671 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3672 		if ((rc = system(command)) == -1) {
3673 			/* No clean up */
3674 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3675 			remove(DUMMY_FILE);
3676 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3677 			close(fd);
3678 			remove(DUMMY_FILE);
3679 		} else
3680 		    if ((rc =
3681 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3682 				       0, sizeof(buf), buf)) == -1) {
3683 			dm_handle_free(hanp, hlen);
3684 			close(fd);
3685 			remove(DUMMY_FILE);
3686 		}
3687 		if (fd == -1 || rc == -1) {
3688 			DMLOG_PRINT(DMLVL_DEBUG,
3689 				    "Unable to set up variation! (errno = %d)\n",
3690 				    errno);
3691 			DMVAR_SKIP();
3692 		} else {
3693 			/* Variation */
3694 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
3695 				    szFuncName);
3696 			rc = dm_getall_dmattr(sid, hanp, INVALID_ADDR,
3697 					      DM_NO_TOKEN, sizeof(buf), buf,
3698 					      &rlen);
3699 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
3700 
3701 			/* Variation clean up */
3702 			rc = close(fd);
3703 			rc |= remove(DUMMY_FILE);
3704 			if (rc == -1) {
3705 				DMLOG_PRINT(DMLVL_DEBUG,
3706 					    "Unable to clean up variation! (errno = %d)\n",
3707 					    errno);
3708 			}
3709 			dm_handle_free(hanp, hlen);
3710 		}
3711 	}
3712 
3713 	/*
3714 	 * TEST    : dm_getall_dmattr - invalid token
3715 	 * EXPECTED: rc = -1, errno = EINVAL
3716 	 */
3717 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 4)) {
3718 		int fd;
3719 		void *hanp;
3720 		size_t hlen;
3721 		dm_attrname_t attrname;
3722 		char buf[ATTR_LISTLEN];
3723 		size_t rlen;
3724 
3725 		/* Variation set up */
3726 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3727 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3728 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3729 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3730 		if ((rc = system(command)) == -1) {
3731 			/* No clean up */
3732 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3733 			remove(DUMMY_FILE);
3734 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3735 			close(fd);
3736 			remove(DUMMY_FILE);
3737 		} else
3738 		    if ((rc =
3739 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3740 				       0, sizeof(buf), buf)) == -1) {
3741 			dm_handle_free(hanp, hlen);
3742 			close(fd);
3743 			remove(DUMMY_FILE);
3744 		}
3745 		if (fd == -1 || rc == -1) {
3746 			DMLOG_PRINT(DMLVL_DEBUG,
3747 				    "Unable to set up variation! (errno = %d)\n",
3748 				    errno);
3749 			DMVAR_SKIP();
3750 		} else {
3751 			/* Variation */
3752 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
3753 				    szFuncName);
3754 			rc = dm_getall_dmattr(sid, hanp, hlen, INVALID_ADDR,
3755 					      sizeof(buf), buf, &rlen);
3756 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
3757 
3758 			/* Variation clean up */
3759 			rc = close(fd);
3760 			rc |= remove(DUMMY_FILE);
3761 			if (rc == -1) {
3762 				DMLOG_PRINT(DMLVL_DEBUG,
3763 					    "Unable to clean up variation! (errno = %d)\n",
3764 					    errno);
3765 			}
3766 			dm_handle_free(hanp, hlen);
3767 		}
3768 	}
3769 
3770 	/*
3771 	 * TEST    : dm_getall_dmattr - invalid buflen
3772 	 * EXPECTED: rc = -1, errno = E2BIG
3773 	 */
3774 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 5)) {
3775 		int fd;
3776 		void *hanp;
3777 		size_t hlen;
3778 		dm_attrname_t attrname;
3779 		char buf[ATTR_LISTLEN];
3780 		size_t rlen;
3781 
3782 		/* Variation set up */
3783 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3784 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3785 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3786 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3787 		if ((rc = system(command)) == -1) {
3788 			/* No clean up */
3789 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3790 			remove(DUMMY_FILE);
3791 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3792 			close(fd);
3793 			remove(DUMMY_FILE);
3794 		} else
3795 		    if ((rc =
3796 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3797 				       0, sizeof(buf), buf)) == -1) {
3798 			dm_handle_free(hanp, hlen);
3799 			close(fd);
3800 			remove(DUMMY_FILE);
3801 		}
3802 		if (fd == -1 || rc == -1) {
3803 			DMLOG_PRINT(DMLVL_DEBUG,
3804 				    "Unable to set up variation! (errno = %d)\n",
3805 				    errno);
3806 			DMVAR_SKIP();
3807 		} else {
3808 			/* Variation */
3809 			DMLOG_PRINT(DMLVL_DEBUG, "%s(buflen too small)\n",
3810 				    szFuncName);
3811 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN, 1,
3812 					      buf, &rlen);
3813 			if (rc == -1 && errno == E2BIG) {
3814 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
3815 			}
3816 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, E2BIG);
3817 
3818 			/* Variation clean up */
3819 			rc = close(fd);
3820 			rc |= remove(DUMMY_FILE);
3821 			if (rc == -1) {
3822 				DMLOG_PRINT(DMLVL_DEBUG,
3823 					    "Unable to clean up variation! (errno = %d)\n",
3824 					    errno);
3825 			}
3826 			dm_handle_free(hanp, hlen);
3827 		}
3828 	}
3829 
3830 	/*
3831 	 * TEST    : dm_getall_dmattr - invalid bufp
3832 	 * EXPECTED: rc = -1, errno = EFAULT
3833 	 */
3834 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 6)) {
3835 		int fd;
3836 		void *hanp;
3837 		size_t hlen;
3838 		dm_attrname_t attrname;
3839 		char buf[ATTR_LISTLEN];
3840 		size_t rlen;
3841 
3842 		/* Variation set up */
3843 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3844 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3845 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3846 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3847 		if ((rc = system(command)) == -1) {
3848 			/* No clean up */
3849 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3850 			remove(DUMMY_FILE);
3851 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3852 			close(fd);
3853 			remove(DUMMY_FILE);
3854 		} else
3855 		    if ((rc =
3856 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3857 				       0, sizeof(buf), buf)) == -1) {
3858 			dm_handle_free(hanp, hlen);
3859 			close(fd);
3860 			remove(DUMMY_FILE);
3861 		}
3862 		if (fd == -1 || rc == -1) {
3863 			DMLOG_PRINT(DMLVL_DEBUG,
3864 				    "Unable to set up variation! (errno = %d)\n",
3865 				    errno);
3866 			DMVAR_SKIP();
3867 		} else {
3868 			/* Variation */
3869 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
3870 				    szFuncName);
3871 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
3872 					      sizeof(buf), (void *)INVALID_ADDR,
3873 					      &rlen);
3874 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
3875 
3876 			/* Variation clean up */
3877 			rc = close(fd);
3878 			rc |= remove(DUMMY_FILE);
3879 			if (rc == -1) {
3880 				DMLOG_PRINT(DMLVL_DEBUG,
3881 					    "Unable to clean up variation! (errno = %d)\n",
3882 					    errno);
3883 			}
3884 			dm_handle_free(hanp, hlen);
3885 		}
3886 	}
3887 
3888 	/*
3889 	 * TEST    : dm_getall_dmattr - invalid rlenp
3890 	 * EXPECTED: rc = -1, errno = EFAULT
3891 	 */
3892 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 7)) {
3893 		int fd;
3894 		void *hanp;
3895 		size_t hlen;
3896 		dm_attrname_t attrname;
3897 		char buf[ATTR_LISTLEN];
3898 
3899 		/* Variation set up */
3900 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3901 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3902 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
3903 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3904 		if ((rc = system(command)) == -1) {
3905 			/* No clean up */
3906 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3907 			remove(DUMMY_FILE);
3908 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3909 			close(fd);
3910 			remove(DUMMY_FILE);
3911 		} else
3912 		    if ((rc =
3913 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
3914 				       0, sizeof(buf), buf)) == -1) {
3915 			dm_handle_free(hanp, hlen);
3916 			close(fd);
3917 			remove(DUMMY_FILE);
3918 		}
3919 		if (fd == -1 || rc == -1) {
3920 			DMLOG_PRINT(DMLVL_DEBUG,
3921 				    "Unable to set up variation! (errno = %d)\n",
3922 				    errno);
3923 			DMVAR_SKIP();
3924 		} else {
3925 			/* Variation */
3926 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
3927 				    szFuncName);
3928 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
3929 					      sizeof(buf), buf,
3930 					      (size_t *) INVALID_ADDR);
3931 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
3932 
3933 			/* Variation clean up */
3934 			rc = close(fd);
3935 			rc |= remove(DUMMY_FILE);
3936 			if (rc == -1) {
3937 				DMLOG_PRINT(DMLVL_DEBUG,
3938 					    "Unable to clean up variation! (errno = %d)\n",
3939 					    errno);
3940 			}
3941 			dm_handle_free(hanp, hlen);
3942 		}
3943 	}
3944 
3945 	/*
3946 	 * TEST    : dm_getall_dmattr - no file attribute
3947 	 * EXPECTED: rc = 0
3948 	 */
3949 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 8)) {
3950 		int fd;
3951 		void *hanp;
3952 		size_t hlen;
3953 		dm_attrname_t attrname;
3954 		char buf[ATTR_LISTLEN];
3955 		size_t rlen;
3956 
3957 		/* Variation set up */
3958 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
3959 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
3960 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
3961 		if ((rc = system(command)) == -1) {
3962 			/* No clean up */
3963 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
3964 			remove(DUMMY_FILE);
3965 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
3966 			close(fd);
3967 			remove(DUMMY_FILE);
3968 		}
3969 		if (fd == -1 || rc == -1) {
3970 			DMLOG_PRINT(DMLVL_DEBUG,
3971 				    "Unable to set up variation! (errno = %d)\n",
3972 				    errno);
3973 			DMVAR_SKIP();
3974 		} else {
3975 			/* Variation */
3976 			DMLOG_PRINT(DMLVL_DEBUG, "%s(no file attr)\n",
3977 				    szFuncName);
3978 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
3979 					      sizeof(buf), buf, &rlen);
3980 			if (rc == 0) {
3981 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
3982 				if (rlen == 0) {
3983 					DMLOG_PRINT(DMLVL_DEBUG,
3984 						    "%s passed with expected rc = %d\n",
3985 						    szFuncName, 0);
3986 					DMVAR_PASS();
3987 				} else {
3988 					DMLOG_PRINT(DMLVL_ERR,
3989 						    "%s failed with expected rc = %d but unexpected rlen %d\n",
3990 						    szFuncName, 0, rlen);
3991 					DMVAR_FAIL();
3992 				}
3993 			} else {
3994 				DMLOG_PRINT(DMLVL_ERR,
3995 					    "%s failed with unexpected rc = %d (errno = %d)\n",
3996 					    szFuncName, rc, errno);
3997 				DMVAR_FAIL();
3998 			}
3999 
4000 			/* Variation clean up */
4001 			rc = close(fd);
4002 			rc |= remove(DUMMY_FILE);
4003 			if (rc == -1) {
4004 				DMLOG_PRINT(DMLVL_DEBUG,
4005 					    "Unable to clean up variation! (errno = %d)\n",
4006 					    errno);
4007 			}
4008 			dm_handle_free(hanp, hlen);
4009 		}
4010 	}
4011 
4012 	/*
4013 	 * TEST    : dm_getall_dmattr - one file attribute
4014 	 * EXPECTED: rc = 0
4015 	 */
4016 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 9)) {
4017 		int fd;
4018 		void *hanp;
4019 		size_t hlen;
4020 		dm_attrname_t attrname;
4021 		char buf[ATTR_LISTLEN];
4022 		size_t rlen;
4023 
4024 		/* Variation set up */
4025 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4026 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4027 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4028 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4029 		if ((rc = system(command)) == -1) {
4030 			/* No clean up */
4031 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4032 			remove(DUMMY_FILE);
4033 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4034 			close(fd);
4035 			remove(DUMMY_FILE);
4036 		} else
4037 		    if ((rc =
4038 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4039 				       0, ATTR_VALUELEN, buf)) == -1) {
4040 			dm_handle_free(hanp, hlen);
4041 			close(fd);
4042 			remove(DUMMY_FILE);
4043 		}
4044 		if (fd == -1 || rc == -1) {
4045 			DMLOG_PRINT(DMLVL_DEBUG,
4046 				    "Unable to set up variation! (errno = %d)\n",
4047 				    errno);
4048 			DMVAR_SKIP();
4049 		} else {
4050 			/* Variation */
4051 			DMLOG_PRINT(DMLVL_DEBUG, "%s(one file attr)\n",
4052 				    szFuncName);
4053 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4054 					      sizeof(buf), buf, &rlen);
4055 			if (rc == 0) {
4056 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
4057 				LogDmAttrs((dm_attrlist_t *) buf);
4058 				if (rlen ==
4059 				    DWALIGN(sizeof(dm_attrlist_t) +
4060 					    ATTR_VALUELEN)) {
4061 					DMLOG_PRINT(DMLVL_DEBUG,
4062 						    "%s passed with expected rc = %d\n",
4063 						    szFuncName, 0);
4064 					DMVAR_PASS();
4065 				} else {
4066 					DMLOG_PRINT(DMLVL_ERR,
4067 						    "%s failed with expected rc = %d but unexpected rlen %d\n",
4068 						    szFuncName, 0, rlen);
4069 					DMVAR_FAIL();
4070 				}
4071 			} else {
4072 				DMLOG_PRINT(DMLVL_ERR,
4073 					    "%s failed with unexpected rc = %d (errno = %d) %d\n",
4074 					    szFuncName, rc, errno, rlen);
4075 				DMVAR_FAIL();
4076 			}
4077 
4078 			/* Variation clean up */
4079 			rc = close(fd);
4080 			rc |= remove(DUMMY_FILE);
4081 			if (rc == -1) {
4082 				DMLOG_PRINT(DMLVL_DEBUG,
4083 					    "Unable to clean up variation! (errno = %d)\n",
4084 					    errno);
4085 			}
4086 			dm_handle_free(hanp, hlen);
4087 		}
4088 	}
4089 
4090 	/*
4091 	 * TEST    : dm_getall_dmattr - two file attributes
4092 	 * EXPECTED: rc = 0
4093 	 */
4094 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 10)) {
4095 		int fd;
4096 		void *hanp;
4097 		size_t hlen;
4098 		dm_attrname_t attrname;
4099 		char buf[ATTR_LISTLEN];
4100 		size_t rlen;
4101 
4102 		/* Variation set up */
4103 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4104 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4105 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4106 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4107 		if ((rc = system(command)) == -1) {
4108 			/* No clean up */
4109 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4110 			remove(DUMMY_FILE);
4111 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4112 			close(fd);
4113 			remove(DUMMY_FILE);
4114 		} else
4115 		    if (((rc =
4116 			  dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4117 					0, ATTR_VALUELEN, buf)) == -1)
4118 			|| (memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE) ==
4119 			    NULL)
4120 			||
4121 			(memcpy
4122 			 (attrname.an_chars, ATTR_NAME2,
4123 			  DM_ATTR_NAME_SIZE) == NULL)
4124 			||
4125 			((rc =
4126 			  dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4127 					0, ATTR_VALUELEN, buf)) == -1)) {
4128 			dm_handle_free(hanp, hlen);
4129 			close(fd);
4130 			remove(DUMMY_FILE);
4131 		}
4132 		if (fd == -1 || rc == -1) {
4133 			DMLOG_PRINT(DMLVL_DEBUG,
4134 				    "Unable to set up variation! (errno = %d)\n",
4135 				    errno);
4136 			DMVAR_SKIP();
4137 		} else {
4138 			/* Variation */
4139 			DMLOG_PRINT(DMLVL_DEBUG, "%s(two file attr)\n",
4140 				    szFuncName);
4141 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4142 					      sizeof(buf), buf, &rlen);
4143 			if (rc == 0) {
4144 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
4145 				LogDmAttrs((dm_attrlist_t *) buf);
4146 				if (rlen ==
4147 				    2 * DWALIGN(sizeof(dm_attrlist_t) +
4148 						ATTR_VALUELEN)) {
4149 					DMLOG_PRINT(DMLVL_DEBUG,
4150 						    "%s passed with expected rc = %d\n",
4151 						    szFuncName, 0);
4152 					DMVAR_PASS();
4153 				} else {
4154 					DMLOG_PRINT(DMLVL_ERR,
4155 						    "%s failed with expected rc = %d but unexpected rlen %d\n",
4156 						    szFuncName, 0, rlen);
4157 					DMVAR_FAIL();
4158 				}
4159 			} else {
4160 				DMLOG_PRINT(DMLVL_ERR,
4161 					    "%s failed with unexpected rc = %d (errno = %d) %d\n",
4162 					    szFuncName, rc, errno, rlen);
4163 				DMVAR_FAIL();
4164 			}
4165 
4166 			/* Variation clean up */
4167 			rc = close(fd);
4168 			rc |= remove(DUMMY_FILE);
4169 			if (rc == -1) {
4170 				DMLOG_PRINT(DMLVL_DEBUG,
4171 					    "Unable to clean up variation! (errno = %d)\n",
4172 					    errno);
4173 			}
4174 			dm_handle_free(hanp, hlen);
4175 		}
4176 	}
4177 
4178 	/*
4179 	 * TEST    : dm_getall_dmattr - multiple file attributes
4180 	 * EXPECTED: rc = 0
4181 	 */
4182 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 11)) {
4183 		int fd;
4184 		void *hanp;
4185 		size_t hlen;
4186 		dm_attrname_t attrname;
4187 		char buf[ATTR_LISTLEN];
4188 		size_t rlen;
4189 		size_t len;
4190 		size_t totlen;
4191 		int i;
4192 		void *totbuf;
4193 
4194 		/* Variation set up */
4195 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4196 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4197 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4198 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4199 		if ((rc = system(command)) == -1) {
4200 			/* No clean up */
4201 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4202 			remove(DUMMY_FILE);
4203 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4204 			close(fd);
4205 			remove(DUMMY_FILE);
4206 		}
4207 		for (i = 0, len = 0, totlen = 0; i < NUM_ATTRS && rc == 0; i++) {
4208 			memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4209 			memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4210 			attrname.an_chars[DM_ATTR_NAME_SIZE - 2] =
4211 			    '0' + (i / 10);
4212 			attrname.an_chars[DM_ATTR_NAME_SIZE - 1] =
4213 			    '0' + (i % 10);
4214 			memcpy(buf + len, DUMMY_STRING, DUMMY_STRLEN);
4215 			len += DUMMY_STRLEN;
4216 			totlen += DWALIGN(len + sizeof(dm_attrlist_t));
4217 			rc = dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4218 					   &attrname, 0, len, buf);
4219 		}
4220 		if (rc != -1) {
4221 			if ((totbuf = malloc(totlen)) == NULL) {
4222 				close(fd);
4223 				remove(DUMMY_FILE);
4224 			}
4225 		}
4226 		if (fd == -1 || rc == -1 || totbuf == NULL) {
4227 			DMLOG_PRINT(DMLVL_DEBUG,
4228 				    "Unable to set up variation! (errno = %d)\n",
4229 				    errno);
4230 			DMVAR_SKIP();
4231 		} else {
4232 			/* Variation */
4233 			DMLOG_PRINT(DMLVL_DEBUG, "%s(%d file attr)\n",
4234 				    szFuncName, NUM_ATTRS);
4235 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4236 					      totlen, totbuf, &rlen);
4237 			if (rc == 0) {
4238 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
4239 				LogDmAttrs((dm_attrlist_t *) totbuf);
4240 				if (rlen == totlen) {
4241 					DMLOG_PRINT(DMLVL_DEBUG,
4242 						    "%s passed with expected rc = %d\n",
4243 						    szFuncName, 0);
4244 					DMVAR_PASS();
4245 				} else {
4246 					DMLOG_PRINT(DMLVL_ERR,
4247 						    "%s failed with expected rc = %d but unexpected rlen %d\n",
4248 						    szFuncName, 0, rlen);
4249 					DMVAR_FAIL();
4250 				}
4251 			} else {
4252 				DMLOG_PRINT(DMLVL_ERR,
4253 					    "%s failed with unexpected rc = %d (errno = %d) %d\n",
4254 					    szFuncName, rc, errno, rlen);
4255 				DMVAR_FAIL();
4256 			}
4257 
4258 			/* Variation clean up */
4259 			rc = close(fd);
4260 			rc |= remove(DUMMY_FILE);
4261 			if (rc == -1) {
4262 				DMLOG_PRINT(DMLVL_DEBUG,
4263 					    "Unable to clean up variation! (errno = %d)\n",
4264 					    errno);
4265 			}
4266 			free(totbuf);
4267 			dm_handle_free(hanp, hlen);
4268 		}
4269 	}
4270 
4271 	/*
4272 	 * TEST    : dm_getall_dmattr - one file attribute with non-DM attribute
4273 	 * EXPECTED: rc = 0
4274 	 */
4275 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 12)) {
4276 		int fd;
4277 		void *hanp;
4278 		size_t hlen;
4279 		dm_attrname_t attrname;
4280 		char buf[ATTR_LISTLEN];
4281 		size_t rlen;
4282 
4283 		/* Variation set up */
4284 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4285 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4286 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4287 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4288 		if ((rc = system(command)) == -1) {
4289 			/* No clean up */
4290 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4291 			remove(DUMMY_FILE);
4292 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4293 			close(fd);
4294 			remove(DUMMY_FILE);
4295 		} else
4296 		    if (((rc =
4297 			  dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4298 					0, ATTR_VALUELEN, buf)) == -1)
4299 			||
4300 			((rc =
4301 			  setxattr(DUMMY_FILE, NON_DM_ATTR_NAME,
4302 				   NON_DM_ATTR_VALUE, sizeof(NON_DM_ATTR_VALUE),
4303 				   0)) == -1)) {
4304 			dm_handle_free(hanp, hlen);
4305 			close(fd);
4306 			remove(DUMMY_FILE);
4307 		}
4308 		if (fd == -1 || rc == -1) {
4309 			DMLOG_PRINT(DMLVL_DEBUG,
4310 				    "Unable to set up variation! (errno = %d)\n",
4311 				    errno);
4312 			DMVAR_SKIP();
4313 		} else {
4314 			/* Variation */
4315 			DMLOG_PRINT(DMLVL_DEBUG,
4316 				    "%s(one file attr with non-DM attr)\n",
4317 				    szFuncName);
4318 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4319 					      sizeof(buf), buf, &rlen);
4320 			if (rc == 0) {
4321 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
4322 				LogDmAttrs((dm_attrlist_t *) buf);
4323 				if (rlen ==
4324 				    DWALIGN(sizeof(dm_attrlist_t) +
4325 					    ATTR_VALUELEN)) {
4326 					DMLOG_PRINT(DMLVL_DEBUG,
4327 						    "%s passed with expected rc = %d\n",
4328 						    szFuncName, 0);
4329 					DMVAR_PASS();
4330 				} else {
4331 					DMLOG_PRINT(DMLVL_ERR,
4332 						    "%s failed with expected rc = %d but unexpected rlen %d\n",
4333 						    szFuncName, 0, rlen);
4334 					DMVAR_FAIL();
4335 				}
4336 			} else {
4337 				DMLOG_PRINT(DMLVL_ERR,
4338 					    "%s failed with unexpected rc = %d (errno = %d) %d\n",
4339 					    szFuncName, rc, errno, rlen);
4340 				DMVAR_FAIL();
4341 			}
4342 
4343 			/* Variation clean up */
4344 			rc = close(fd);
4345 			rc |= remove(DUMMY_FILE);
4346 			if (rc == -1) {
4347 				DMLOG_PRINT(DMLVL_DEBUG,
4348 					    "Unable to clean up variation! (errno = %d)\n",
4349 					    errno);
4350 			}
4351 			dm_handle_free(hanp, hlen);
4352 		}
4353 	}
4354 
4355 	/*
4356 	 * TEST    : dm_getall_dmattr - one directory attribute
4357 	 * EXPECTED: rc = 0
4358 	 */
4359 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 13)) {
4360 		void *hanp;
4361 		size_t hlen;
4362 		dm_attrname_t attrname;
4363 		char buf[ATTR_LISTLEN];
4364 		size_t rlen;
4365 
4366 		/* Variation set up */
4367 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4368 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4369 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4370 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
4371 			/* No claen up */
4372 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
4373 			   == -1) {
4374 			rmdir(DUMMY_SUBDIR);
4375 		} else
4376 		    if ((rc =
4377 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4378 				       0, ATTR_VALUELEN, buf)) == -1) {
4379 			dm_handle_free(hanp, hlen);
4380 			rmdir(DUMMY_SUBDIR);
4381 		}
4382 		if (rc == -1) {
4383 			DMLOG_PRINT(DMLVL_DEBUG,
4384 				    "Unable to set up variation! (errno = %d)\n",
4385 				    errno);
4386 			DMVAR_SKIP();
4387 		} else {
4388 			/* Variation */
4389 			DMLOG_PRINT(DMLVL_DEBUG, "%s(one dir attr)\n",
4390 				    szFuncName);
4391 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4392 					      sizeof(buf), buf, &rlen);
4393 			if (rc == 0) {
4394 				DMLOG_PRINT(DMLVL_DEBUG, "rlen = %d\n", rlen);
4395 				LogDmAttrs((dm_attrlist_t *) buf);
4396 				if (rlen ==
4397 				    DWALIGN(sizeof(dm_attrlist_t) +
4398 					    ATTR_VALUELEN)) {
4399 					DMLOG_PRINT(DMLVL_DEBUG,
4400 						    "%s passed with expected rc = %d\n",
4401 						    szFuncName, 0);
4402 					DMVAR_PASS();
4403 				} else {
4404 					DMLOG_PRINT(DMLVL_ERR,
4405 						    "%s failed with expected rc = %d but unexpected rlen %d\n",
4406 						    szFuncName, 0, rlen);
4407 					DMVAR_FAIL();
4408 				}
4409 			} else {
4410 				DMLOG_PRINT(DMLVL_ERR,
4411 					    "%s failed with unexpected rc = %d (errno = %d) %d\n",
4412 					    szFuncName, rc, errno, rlen);
4413 				DMVAR_FAIL();
4414 			}
4415 
4416 			/* Variation clean up */
4417 			rc = rmdir(DUMMY_SUBDIR);
4418 			if (rc == -1) {
4419 				DMLOG_PRINT(DMLVL_DEBUG,
4420 					    "Unable to clean up variation! (errno = %d)\n",
4421 					    errno);
4422 			}
4423 			dm_handle_free(hanp, hlen);
4424 		}
4425 	}
4426 
4427 	/*
4428 	 * TEST    : dm_getall_dmattr - fs handle
4429 	 * EXPECTED: rc = -1, errno = EINVAL
4430 	 */
4431 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 14)) {
4432 		void *hanp;
4433 		size_t hlen;
4434 		dm_attrname_t attrname;
4435 		char buf[ATTR_LISTLEN];
4436 		size_t rlen;
4437 
4438 		/* Variation set up */
4439 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4440 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4441 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4442 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4443 		if ((rc = system(command)) == -1) {
4444 			/* No clean up */
4445 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
4446 			   == -1) {
4447 			remove(DUMMY_FILE);
4448 		}
4449 		if (rc == -1) {
4450 			DMLOG_PRINT(DMLVL_DEBUG,
4451 				    "Unable to set up variation! (errno = %d)\n",
4452 				    errno);
4453 			DMVAR_SKIP();
4454 		} else {
4455 			/* Variation */
4456 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
4457 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4458 					      sizeof(buf), buf, &rlen);
4459 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
4460 
4461 			/* Variation clean up */
4462 			rc = remove(DUMMY_FILE);
4463 			if (rc == -1) {
4464 				DMLOG_PRINT(DMLVL_DEBUG,
4465 					    "Unable to clean up variation! (errno = %d)\n",
4466 					    errno);
4467 			}
4468 			dm_handle_free(hanp, hlen);
4469 		}
4470 	}
4471 
4472 	/*
4473 	 * TEST    : dm_getall_dmattr - DM_NO_SESSION sid
4474 	 * EXPECTED: rc = -1, errno = EINVAL
4475 	 */
4476 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 15)) {
4477 		int fd;
4478 		void *hanp;
4479 		size_t hlen;
4480 		dm_attrname_t attrname;
4481 		char buf[ATTR_LISTLEN];
4482 		size_t rlen;
4483 
4484 		/* Variation set up */
4485 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4486 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4487 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4488 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4489 		if ((rc = system(command)) == -1) {
4490 			/* No clean up */
4491 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4492 			remove(DUMMY_FILE);
4493 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4494 			close(fd);
4495 			remove(DUMMY_FILE);
4496 		} else
4497 		    if ((rc =
4498 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4499 				       0, sizeof(buf), buf)) == -1) {
4500 			dm_handle_free(hanp, hlen);
4501 			close(fd);
4502 			remove(DUMMY_FILE);
4503 		}
4504 		if (fd == -1 || rc == -1) {
4505 			DMLOG_PRINT(DMLVL_DEBUG,
4506 				    "Unable to set up variation! (errno = %d)\n",
4507 				    errno);
4508 			DMVAR_SKIP();
4509 		} else {
4510 			/* Variation */
4511 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
4512 				    szFuncName);
4513 			rc = dm_getall_dmattr(DM_NO_SESSION, hanp, hlen,
4514 					      DM_NO_TOKEN, sizeof(buf), buf,
4515 					      &rlen);
4516 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
4517 
4518 			/* Variation clean up */
4519 			rc = close(fd);
4520 			rc |= remove(DUMMY_FILE);
4521 			if (rc == -1) {
4522 				DMLOG_PRINT(DMLVL_DEBUG,
4523 					    "Unable to clean up variation! (errno = %d)\n",
4524 					    errno);
4525 			}
4526 			dm_handle_free(hanp, hlen);
4527 		}
4528 	}
4529 
4530 	/*
4531 	 * TEST    : dm_getall_dmattr - global handle
4532 	 * EXPECTED: rc = -1, errno = EBADF
4533 	 */
4534 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 16)) {
4535 		dm_attrname_t attrname;
4536 		char buf[ATTR_LISTLEN];
4537 		size_t rlen;
4538 
4539 		/* Variation set up */
4540 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4541 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4542 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4543 
4544 		/* Variation */
4545 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
4546 		rc = dm_getall_dmattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
4547 				      DM_NO_TOKEN, sizeof(buf), buf, &rlen);
4548 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
4549 
4550 		/* Variation clean up */
4551 	}
4552 
4553 	/*
4554 	 * TEST    : dm_getall_dmattr - invalidated handle
4555 	 * EXPECTED: rc = -1, errno = EBADF
4556 	 */
4557 	if (DMVAR_EXEC(GETALL_DMATTR_BASE + 17)) {
4558 		int fd;
4559 		void *hanp;
4560 		size_t hlen;
4561 		dm_attrname_t attrname;
4562 		char buf[ATTR_LISTLEN];
4563 		size_t rlen;
4564 
4565 		/* Variation set up */
4566 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
4567 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
4568 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
4569 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4570 		if ((rc = system(command)) == -1) {
4571 			/* No clean up */
4572 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4573 			remove(DUMMY_FILE);
4574 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4575 			close(fd);
4576 			remove(DUMMY_FILE);
4577 		} else
4578 		    if ((rc =
4579 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
4580 				       0, ATTR_VALUELEN, buf)) == -1) {
4581 			dm_handle_free(hanp, hlen);
4582 			close(fd);
4583 			remove(DUMMY_FILE);
4584 		} else if ((rc = close(fd)) == -1) {
4585 			dm_handle_free(hanp, hlen);
4586 			remove(DUMMY_FILE);
4587 		} else if ((rc = remove(DUMMY_FILE)) == -1) {
4588 			dm_handle_free(hanp, hlen);
4589 		}
4590 		if (fd == -1 || rc == -1) {
4591 			DMLOG_PRINT(DMLVL_DEBUG,
4592 				    "Unable to set up variation! (errno = %d)\n",
4593 				    errno);
4594 			DMVAR_SKIP();
4595 		} else {
4596 			/* Variation */
4597 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated handle)\n",
4598 				    szFuncName);
4599 			rc = dm_getall_dmattr(sid, hanp, hlen, DM_NO_TOKEN,
4600 					      sizeof(buf), buf, &rlen);
4601 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
4602 
4603 			/* Variation clean up */
4604 			dm_handle_free(hanp, hlen);
4605 		}
4606 	}
4607 
4608 	szFuncName = "dm_set_fileattr";
4609 
4610 	/*
4611 	 * TEST    : dm_set_fileattr - invalid sid
4612 	 * EXPECTED: rc = -1, errno = EINVAL
4613 	 */
4614 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 1)) {
4615 		int fd;
4616 		void *hanp;
4617 		size_t hlen;
4618 		dm_fileattr_t fileattr;
4619 
4620 		/* Variation set up */
4621 		fileattr.fa_uid = DUMMY_UID;
4622 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4623 		if ((rc = system(command)) == -1) {
4624 			/* No clean up */
4625 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4626 			remove(DUMMY_FILE);
4627 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4628 			close(fd);
4629 			remove(DUMMY_FILE);
4630 		}
4631 		if (fd == -1 || rc == -1) {
4632 			DMLOG_PRINT(DMLVL_DEBUG,
4633 				    "Unable to set up variation! (errno = %d)\n",
4634 				    errno);
4635 			DMVAR_SKIP();
4636 		} else {
4637 			/* Variation */
4638 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
4639 				    szFuncName);
4640 			rc = dm_set_fileattr(INVALID_ADDR, hanp, hlen,
4641 					     DM_NO_TOKEN, DM_AT_UID, &fileattr);
4642 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
4643 
4644 			/* Variation clean up */
4645 			rc = close(fd);
4646 			rc |= remove(DUMMY_FILE);
4647 			if (rc == -1) {
4648 				DMLOG_PRINT(DMLVL_DEBUG,
4649 					    "Unable to clean up variation! (errno = %d)\n",
4650 					    errno);
4651 			}
4652 			dm_handle_free(hanp, hlen);
4653 		}
4654 	}
4655 
4656 	/*
4657 	 * TEST    : dm_set_fileattr - invalid hanp
4658 	 * EXPECTED: rc = -1, errno = EFAULT
4659 	 */
4660 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 2)) {
4661 		int fd;
4662 		void *hanp;
4663 		size_t hlen;
4664 		dm_fileattr_t fileattr;
4665 
4666 		/* Variation set up */
4667 		fileattr.fa_uid = DUMMY_UID;
4668 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4669 		if ((rc = system(command)) == -1) {
4670 			/* No clean up */
4671 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4672 			remove(DUMMY_FILE);
4673 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4674 			close(fd);
4675 			remove(DUMMY_FILE);
4676 		}
4677 		if (fd == -1 || rc == -1) {
4678 			DMLOG_PRINT(DMLVL_DEBUG,
4679 				    "Unable to set up variation! (errno = %d)\n",
4680 				    errno);
4681 			DMVAR_SKIP();
4682 		} else {
4683 			/* Variation */
4684 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
4685 				    szFuncName);
4686 			rc = dm_set_fileattr(sid, (void *)INVALID_ADDR, hlen,
4687 					     DM_NO_TOKEN, DM_AT_UID, &fileattr);
4688 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
4689 
4690 			/* Variation clean up */
4691 			rc = close(fd);
4692 			rc |= remove(DUMMY_FILE);
4693 			if (rc == -1) {
4694 				DMLOG_PRINT(DMLVL_DEBUG,
4695 					    "Unable to clean up variation! (errno = %d)\n",
4696 					    errno);
4697 			}
4698 			dm_handle_free(hanp, hlen);
4699 		}
4700 	}
4701 
4702 	/*
4703 	 * TEST    : dm_set_fileattr - invalid hlen
4704 	 * EXPECTED: rc = -1, errno = EBADF
4705 	 */
4706 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 3)) {
4707 		int fd;
4708 		void *hanp;
4709 		size_t hlen;
4710 		dm_fileattr_t fileattr;
4711 
4712 		/* Variation set up */
4713 		fileattr.fa_uid = DUMMY_UID;
4714 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4715 		if ((rc = system(command)) == -1) {
4716 			/* No clean up */
4717 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4718 			remove(DUMMY_FILE);
4719 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4720 			close(fd);
4721 			remove(DUMMY_FILE);
4722 		}
4723 		if (fd == -1 || rc == -1) {
4724 			DMLOG_PRINT(DMLVL_DEBUG,
4725 				    "Unable to set up variation! (errno = %d)\n",
4726 				    errno);
4727 			DMVAR_SKIP();
4728 		} else {
4729 			/* Variation */
4730 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
4731 				    szFuncName);
4732 			rc = dm_set_fileattr(sid, hanp, INVALID_ADDR,
4733 					     DM_NO_TOKEN, DM_AT_UID, &fileattr);
4734 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
4735 
4736 			/* Variation clean up */
4737 			rc = close(fd);
4738 			rc |= remove(DUMMY_FILE);
4739 			if (rc == -1) {
4740 				DMLOG_PRINT(DMLVL_DEBUG,
4741 					    "Unable to clean up variation! (errno = %d)\n",
4742 					    errno);
4743 			}
4744 			dm_handle_free(hanp, hlen);
4745 		}
4746 	}
4747 
4748 	/*
4749 	 * TEST    : dm_set_fileattr - invalid token
4750 	 * EXPECTED: rc = -1, errno = EINVAL
4751 	 */
4752 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 4)) {
4753 		int fd;
4754 		void *hanp;
4755 		size_t hlen;
4756 		dm_fileattr_t fileattr;
4757 
4758 		/* Variation set up */
4759 		fileattr.fa_uid = DUMMY_UID;
4760 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4761 		if ((rc = system(command)) == -1) {
4762 			/* No clean up */
4763 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4764 			remove(DUMMY_FILE);
4765 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4766 			close(fd);
4767 			remove(DUMMY_FILE);
4768 		}
4769 		if (fd == -1 || rc == -1) {
4770 			DMLOG_PRINT(DMLVL_DEBUG,
4771 				    "Unable to set up variation! (errno = %d)\n",
4772 				    errno);
4773 			DMVAR_SKIP();
4774 		} else {
4775 			/* Variation */
4776 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
4777 				    szFuncName);
4778 			rc = dm_set_fileattr(sid, hanp, hlen, INVALID_ADDR,
4779 					     DM_AT_UID, &fileattr);
4780 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
4781 
4782 			/* Variation clean up */
4783 			rc = close(fd);
4784 			rc |= remove(DUMMY_FILE);
4785 			if (rc == -1) {
4786 				DMLOG_PRINT(DMLVL_DEBUG,
4787 					    "Unable to clean up variation! (errno = %d)\n",
4788 					    errno);
4789 			}
4790 			dm_handle_free(hanp, hlen);
4791 		}
4792 	}
4793 
4794 	/*
4795 	 * TEST    : dm_set_fileattr - invalid mask
4796 	 * EXPECTED: rc = -1, errno = EINVAL
4797 	 *
4798 	 * This variation uncovered XFS BUG #20 (0 returned instead of -1 and
4799 	 * EINVAL errno)
4800 	 */
4801 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 5)) {
4802 		int fd;
4803 		void *hanp;
4804 		size_t hlen;
4805 		dm_fileattr_t fileattr;
4806 
4807 		/* Variation set up */
4808 		fileattr.fa_uid = DUMMY_UID;
4809 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4810 		if ((rc = system(command)) == -1) {
4811 			/* No clean up */
4812 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4813 			remove(DUMMY_FILE);
4814 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4815 			close(fd);
4816 			remove(DUMMY_FILE);
4817 		}
4818 		if (fd == -1 || rc == -1) {
4819 			DMLOG_PRINT(DMLVL_DEBUG,
4820 				    "Unable to set up variation! (errno = %d)\n",
4821 				    errno);
4822 			DMVAR_SKIP();
4823 		} else {
4824 			/* Variation */
4825 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid mask)\n",
4826 				    szFuncName);
4827 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
4828 					     DM_AT_HANDLE, &fileattr);
4829 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
4830 
4831 			/* Variation clean up */
4832 			rc = close(fd);
4833 			rc |= remove(DUMMY_FILE);
4834 			if (rc == -1) {
4835 				DMLOG_PRINT(DMLVL_DEBUG,
4836 					    "Unable to clean up variation! (errno = %d)\n",
4837 					    errno);
4838 			}
4839 			dm_handle_free(hanp, hlen);
4840 		}
4841 	}
4842 
4843 	/*
4844 	 * TEST    : dm_set_fileattr - invalid attrp
4845 	 * EXPECTED: rc = -1, errno = EFAULT
4846 	 */
4847 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 6)) {
4848 		int fd;
4849 		void *hanp;
4850 		size_t hlen;
4851 		dm_fileattr_t fileattr;
4852 
4853 		/* Variation set up */
4854 		fileattr.fa_uid = DUMMY_UID;
4855 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4856 		if ((rc = system(command)) == -1) {
4857 			/* No clean up */
4858 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4859 			remove(DUMMY_FILE);
4860 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4861 			close(fd);
4862 			remove(DUMMY_FILE);
4863 		}
4864 		if (fd == -1 || rc == -1) {
4865 			DMLOG_PRINT(DMLVL_DEBUG,
4866 				    "Unable to set up variation! (errno = %d)\n",
4867 				    errno);
4868 			DMVAR_SKIP();
4869 		} else {
4870 			/* Variation */
4871 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrp)\n",
4872 				    szFuncName);
4873 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
4874 					     DM_AT_UID,
4875 					     (dm_fileattr_t *) INVALID_ADDR);
4876 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
4877 
4878 			/* Variation clean up */
4879 			rc = close(fd);
4880 			rc |= remove(DUMMY_FILE);
4881 			if (rc == -1) {
4882 				DMLOG_PRINT(DMLVL_DEBUG,
4883 					    "Unable to clean up variation! (errno = %d)\n",
4884 					    errno);
4885 			}
4886 			dm_handle_free(hanp, hlen);
4887 		}
4888 	}
4889 
4890 	/*
4891 	 * TEST    : dm_set_fileattr - DM_AT_ATIME on file
4892 	 * EXPECTED: rc = 0
4893 	 */
4894 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 7)) {
4895 		int fd;
4896 		void *hanp;
4897 		size_t hlen;
4898 		dm_fileattr_t fileattr;
4899 		struct stat statfs1, statfs2;
4900 		int rc2;
4901 
4902 		/* Variation set up */
4903 		fileattr.fa_atime = DUMMY_TIME;
4904 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4905 		if ((rc = system(command)) == -1) {
4906 			/* No clean up */
4907 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4908 			remove(DUMMY_FILE);
4909 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4910 			close(fd);
4911 			remove(DUMMY_FILE);
4912 		}
4913 		if (fd == -1 || rc == -1) {
4914 			DMLOG_PRINT(DMLVL_DEBUG,
4915 				    "Unable to set up variation! (errno = %d)\n",
4916 				    errno);
4917 			DMVAR_SKIP();
4918 		} else {
4919 			/* Variation */
4920 			rc2 = stat(DUMMY_FILE, &statfs1);
4921 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_ATIME)\n",
4922 				    szFuncName);
4923 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
4924 					     DM_AT_ATIME, &fileattr);
4925 			rc2 |= stat(DUMMY_FILE, &statfs2);
4926 			if (rc == 0) {
4927 				if ((rc2 == 0)
4928 				    && (statfs1.st_atime != statfs2.st_atime)
4929 				    && (statfs2.st_atime == DUMMY_TIME)) {
4930 					DMLOG_PRINT(DMLVL_DEBUG,
4931 						    "%s passed with expected rc = %d and atime modified\n",
4932 						    szFuncName, 0);
4933 					DMVAR_PASS();
4934 				} else {
4935 					DMLOG_PRINT(DMLVL_ERR,
4936 						    "%s failed with expected rc = %d but atime unmodified (%d vs %d)\n",
4937 						    szFuncName, 0,
4938 						    statfs1.st_atime,
4939 						    statfs2.st_atime);
4940 					DMVAR_FAIL();
4941 				}
4942 			} else {
4943 				DMLOG_PRINT(DMLVL_ERR,
4944 					    "%s failed with unexpected rc = %d (errno = %d)\n",
4945 					    szFuncName, rc, errno);
4946 				DMVAR_FAIL();
4947 			}
4948 
4949 			/* Variation clean up */
4950 			rc = close(fd);
4951 			rc |= remove(DUMMY_FILE);
4952 			if (rc == -1) {
4953 				DMLOG_PRINT(DMLVL_DEBUG,
4954 					    "Unable to clean up variation! (errno = %d)\n",
4955 					    errno);
4956 			}
4957 			dm_handle_free(hanp, hlen);
4958 		}
4959 	}
4960 
4961 	/*
4962 	 * TEST    : dm_set_fileattr - DM_AT_MTIME on file
4963 	 * EXPECTED: rc = 0
4964 	 */
4965 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 8)) {
4966 		int fd;
4967 		void *hanp;
4968 		size_t hlen;
4969 		dm_fileattr_t fileattr;
4970 		struct stat statfs1, statfs2;
4971 		int rc2;
4972 
4973 		/* Variation set up */
4974 		fileattr.fa_mtime = DUMMY_TIME;
4975 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
4976 		if ((rc = system(command)) == -1) {
4977 			/* No clean up */
4978 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
4979 			remove(DUMMY_FILE);
4980 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
4981 			close(fd);
4982 			remove(DUMMY_FILE);
4983 		}
4984 		if (fd == -1 || rc == -1) {
4985 			DMLOG_PRINT(DMLVL_DEBUG,
4986 				    "Unable to set up variation! (errno = %d)\n",
4987 				    errno);
4988 			DMVAR_SKIP();
4989 		} else {
4990 			/* Variation */
4991 			rc2 = stat(DUMMY_FILE, &statfs1);
4992 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_MTIME)\n",
4993 				    szFuncName);
4994 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
4995 					     DM_AT_MTIME, &fileattr);
4996 			rc2 |= stat(DUMMY_FILE, &statfs2);
4997 			if (rc == 0) {
4998 				if ((rc2 == 0)
4999 				    && (statfs1.st_mtime != statfs2.st_mtime)
5000 				    && (statfs2.st_mtime == DUMMY_TIME)) {
5001 					DMLOG_PRINT(DMLVL_DEBUG,
5002 						    "%s passed with expected rc = %d and mtime modified\n",
5003 						    szFuncName, 0);
5004 					DMVAR_PASS();
5005 				} else {
5006 					DMLOG_PRINT(DMLVL_ERR,
5007 						    "%s failed with expected rc = %d but mtime unmodified (%d vs %d)\n",
5008 						    szFuncName, 0,
5009 						    statfs1.st_mtime,
5010 						    statfs2.st_mtime);
5011 					DMVAR_FAIL();
5012 				}
5013 			} else {
5014 				DMLOG_PRINT(DMLVL_ERR,
5015 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5016 					    szFuncName, rc, errno);
5017 				DMVAR_FAIL();
5018 			}
5019 
5020 			/* Variation clean up */
5021 			rc = close(fd);
5022 			rc |= remove(DUMMY_FILE);
5023 			if (rc == -1) {
5024 				DMLOG_PRINT(DMLVL_DEBUG,
5025 					    "Unable to clean up variation! (errno = %d)\n",
5026 					    errno);
5027 			}
5028 			dm_handle_free(hanp, hlen);
5029 		}
5030 	}
5031 
5032 	/*
5033 	 * TEST    : dm_set_fileattr - DM_AT_CTIME on file
5034 	 * EXPECTED: rc = 0
5035 	 */
5036 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 9)) {
5037 		int fd;
5038 		void *hanp;
5039 		size_t hlen;
5040 		dm_fileattr_t fileattr;
5041 		struct stat statfs1, statfs2;
5042 		int rc2;
5043 
5044 		/* Variation set up */
5045 		fileattr.fa_ctime = DUMMY_TIME;
5046 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5047 		if ((rc = system(command)) == -1) {
5048 			/* No clean up */
5049 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5050 			remove(DUMMY_FILE);
5051 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5052 			close(fd);
5053 			remove(DUMMY_FILE);
5054 		}
5055 		if (fd == -1 || rc == -1) {
5056 			DMLOG_PRINT(DMLVL_DEBUG,
5057 				    "Unable to set up variation! (errno = %d)\n",
5058 				    errno);
5059 			DMVAR_SKIP();
5060 		} else {
5061 			/* Variation */
5062 			rc2 = stat(DUMMY_FILE, &statfs1);
5063 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_CTIME)\n",
5064 				    szFuncName);
5065 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5066 					     DM_AT_CTIME, &fileattr);
5067 			rc2 |= stat(DUMMY_FILE, &statfs2);
5068 			if (rc == 0) {
5069 				if ((rc2 == 0)
5070 				    && (statfs1.st_ctime != statfs2.st_ctime)
5071 				    && (statfs2.st_ctime == DUMMY_TIME)) {
5072 					DMLOG_PRINT(DMLVL_DEBUG,
5073 						    "%s passed with expected rc = %d and ctime modified\n",
5074 						    szFuncName, 0);
5075 					DMVAR_PASS();
5076 				} else {
5077 					DMLOG_PRINT(DMLVL_ERR,
5078 						    "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
5079 						    szFuncName, 0,
5080 						    statfs1.st_ctime,
5081 						    statfs2.st_ctime);
5082 					DMVAR_FAIL();
5083 				}
5084 			} else {
5085 				DMLOG_PRINT(DMLVL_ERR,
5086 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5087 					    szFuncName, rc, errno);
5088 				DMVAR_FAIL();
5089 			}
5090 
5091 			/* Variation clean up */
5092 			rc = close(fd);
5093 			rc |= remove(DUMMY_FILE);
5094 			if (rc == -1) {
5095 				DMLOG_PRINT(DMLVL_DEBUG,
5096 					    "Unable to clean up variation! (errno = %d)\n",
5097 					    errno);
5098 			}
5099 			dm_handle_free(hanp, hlen);
5100 		}
5101 	}
5102 
5103 	/*
5104 	 * TEST    : dm_set_fileattr - DM_AT_DTIME on file with DM attribute
5105 	 * EXPECTED: rc = 0
5106 	 */
5107 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 10)) {
5108 		int fd;
5109 		void *hanp;
5110 		size_t hlen;
5111 		dm_fileattr_t fileattr;
5112 		dm_attrname_t attrname;
5113 		char buf[ATTR_LISTLEN];
5114 		struct stat statfs1, statfs2;
5115 		int rc2;
5116 
5117 		/* Variation set up */
5118 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
5119 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
5120 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
5121 		fileattr.fa_dtime = DUMMY_TIME;
5122 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5123 		if ((rc = system(command)) == -1) {
5124 			/* No clean up */
5125 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5126 			remove(DUMMY_FILE);
5127 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5128 			close(fd);
5129 			remove(DUMMY_FILE);
5130 		} else
5131 		    if ((rc =
5132 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
5133 				       0, ATTR_VALUELEN, buf)) == -1) {
5134 			dm_handle_free(hanp, hlen);
5135 			close(fd);
5136 			remove(DUMMY_FILE);
5137 		}
5138 		if (fd == -1 || rc == -1) {
5139 			DMLOG_PRINT(DMLVL_DEBUG,
5140 				    "Unable to set up variation! (errno = %d)\n",
5141 				    errno);
5142 			DMVAR_SKIP();
5143 		} else {
5144 			/* Variation */
5145 			rc2 = stat(DUMMY_FILE, &statfs1);
5146 			DMLOG_PRINT(DMLVL_DEBUG,
5147 				    "%s(file DM_AT_DTIME with attr)\n",
5148 				    szFuncName);
5149 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5150 					     DM_AT_DTIME, &fileattr);
5151 			rc2 |= stat(DUMMY_FILE, &statfs2);
5152 			if (rc == 0) {
5153 				if ((rc2 == 0)
5154 				    && (statfs1.st_ctime != statfs2.st_ctime)
5155 				    && (statfs2.st_ctime == DUMMY_TIME)) {
5156 					DMLOG_PRINT(DMLVL_DEBUG,
5157 						    "%s passed with expected rc = %d and ctime modified\n",
5158 						    szFuncName, 0);
5159 					DMVAR_PASS();
5160 				} else {
5161 					DMLOG_PRINT(DMLVL_ERR,
5162 						    "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
5163 						    szFuncName, 0,
5164 						    statfs1.st_ctime,
5165 						    statfs2.st_ctime);
5166 					DMVAR_FAIL();
5167 				}
5168 			} else {
5169 				DMLOG_PRINT(DMLVL_ERR,
5170 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5171 					    szFuncName, rc, errno);
5172 				DMVAR_FAIL();
5173 			}
5174 
5175 			/* Variation clean up */
5176 			rc = close(fd);
5177 			rc |= remove(DUMMY_FILE);
5178 			if (rc == -1) {
5179 				DMLOG_PRINT(DMLVL_DEBUG,
5180 					    "Unable to clean up variation! (errno = %d)\n",
5181 					    errno);
5182 			}
5183 			dm_handle_free(hanp, hlen);
5184 		}
5185 	}
5186 
5187 	/*
5188 	 * TEST    : dm_set_fileattr - DM_AT_DTIME on file without DM attr
5189 	 * EXPECTED: rc = -1, errno = EINVAL
5190 	 *
5191 	 * This variation uncovered XFS BUG #21 (dtime updated without any DM
5192 	 * attributes)
5193 	 */
5194 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 11)) {
5195 		int fd;
5196 		void *hanp;
5197 		size_t hlen;
5198 		dm_fileattr_t fileattr;
5199 		struct stat statfs1, statfs2;
5200 		int rc2;
5201 
5202 		/* Variation set up */
5203 		fileattr.fa_dtime = DUMMY_TIME;
5204 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5205 		if ((rc = system(command)) == -1) {
5206 			/* No clean up */
5207 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5208 			remove(DUMMY_FILE);
5209 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5210 			close(fd);
5211 			remove(DUMMY_FILE);
5212 		}
5213 		if (fd == -1 || rc == -1) {
5214 			DMLOG_PRINT(DMLVL_DEBUG,
5215 				    "Unable to set up variation! (errno = %d)\n",
5216 				    errno);
5217 			DMVAR_SKIP();
5218 		} else {
5219 			/* Variation */
5220 			rc2 = stat(DUMMY_FILE, &statfs1);
5221 			DMLOG_PRINT(DMLVL_DEBUG,
5222 				    "%s(file DM_AT_DTIME without attr)\n",
5223 				    szFuncName);
5224 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5225 					     DM_AT_DTIME, &fileattr);
5226 			rc2 |= stat(DUMMY_FILE, &statfs2);
5227 			if (rc == 0) {
5228 				if ((rc2 == 0)
5229 				    && (statfs1.st_ctime == statfs2.st_ctime)
5230 				    && (statfs2.st_ctime != DUMMY_TIME)) {
5231 					DMLOG_PRINT(DMLVL_DEBUG,
5232 						    "%s passed with expected rc = %d and ctime unmodified\n",
5233 						    szFuncName, 0);
5234 					DMVAR_PASS();
5235 				} else {
5236 					DMLOG_PRINT(DMLVL_ERR,
5237 						    "%s failed with expected rc = %d but ctime modified (%d vs %d)\n",
5238 						    szFuncName, 0,
5239 						    statfs1.st_ctime,
5240 						    statfs2.st_ctime);
5241 					DMVAR_FAIL();
5242 				}
5243 			} else {
5244 				DMLOG_PRINT(DMLVL_ERR,
5245 					    "%s failed with unexpected rc = %d\n",
5246 					    szFuncName, rc);
5247 				DMVAR_FAIL();
5248 			}
5249 
5250 			/* Variation clean up */
5251 			rc = close(fd);
5252 			rc |= remove(DUMMY_FILE);
5253 			if (rc == -1) {
5254 				DMLOG_PRINT(DMLVL_DEBUG,
5255 					    "Unable to clean up variation! (errno = %d)\n",
5256 					    errno);
5257 			}
5258 			dm_handle_free(hanp, hlen);
5259 		}
5260 	}
5261 
5262 	/*
5263 	 * TEST    : dm_set_fileattr - DM_AT_UID on file
5264 	 * EXPECTED: rc = 0
5265 	 */
5266 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 12)) {
5267 		int fd;
5268 		void *hanp;
5269 		size_t hlen;
5270 		dm_fileattr_t fileattr;
5271 		struct stat statfs1, statfs2;
5272 		int rc2;
5273 
5274 		/* Variation set up */
5275 		fileattr.fa_uid = DUMMY_UID;
5276 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5277 		if ((rc = system(command)) == -1) {
5278 			/* No clean up */
5279 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5280 			remove(DUMMY_FILE);
5281 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5282 			close(fd);
5283 			remove(DUMMY_FILE);
5284 		}
5285 		if (fd == -1 || rc == -1) {
5286 			DMLOG_PRINT(DMLVL_DEBUG,
5287 				    "Unable to set up variation! (errno = %d)\n",
5288 				    errno);
5289 			DMVAR_SKIP();
5290 		} else {
5291 			/* Variation */
5292 			rc2 = stat(DUMMY_FILE, &statfs1);
5293 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_UID)\n",
5294 				    szFuncName);
5295 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5296 					     DM_AT_UID, &fileattr);
5297 			rc2 |= stat(DUMMY_FILE, &statfs2);
5298 			if (rc == 0) {
5299 				if ((rc2 == 0)
5300 				    && (statfs1.st_uid != statfs2.st_uid)
5301 				    && (statfs2.st_uid == DUMMY_UID)) {
5302 					DMLOG_PRINT(DMLVL_DEBUG,
5303 						    "%s passed with expected rc = %d and uid modified\n",
5304 						    szFuncName, 0);
5305 					DMVAR_PASS();
5306 				} else {
5307 					DMLOG_PRINT(DMLVL_ERR,
5308 						    "%s failed with expected rc = %d but uid unmodified (%d vs %d)\n",
5309 						    szFuncName, 0,
5310 						    statfs1.st_uid,
5311 						    statfs2.st_uid);
5312 					DMVAR_FAIL();
5313 				}
5314 			} else {
5315 				DMLOG_PRINT(DMLVL_ERR,
5316 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5317 					    szFuncName, rc, errno);
5318 				DMVAR_FAIL();
5319 			}
5320 
5321 			/* Variation clean up */
5322 			rc = close(fd);
5323 			rc |= remove(DUMMY_FILE);
5324 			if (rc == -1) {
5325 				DMLOG_PRINT(DMLVL_DEBUG,
5326 					    "Unable to clean up variation! (errno = %d)\n",
5327 					    errno);
5328 			}
5329 			dm_handle_free(hanp, hlen);
5330 		}
5331 	}
5332 
5333 	/*
5334 	 * TEST    : dm_set_fileattr - DM_AT_GID on file
5335 	 * EXPECTED: rc = 0
5336 	 */
5337 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 13)) {
5338 		int fd;
5339 		void *hanp;
5340 		size_t hlen;
5341 		dm_fileattr_t fileattr;
5342 		struct stat statfs1, statfs2;
5343 		int rc2;
5344 
5345 		/* Variation set up */
5346 		fileattr.fa_gid = DUMMY_GID;
5347 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5348 		if ((rc = system(command)) == -1) {
5349 			/* No clean up */
5350 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5351 			remove(DUMMY_FILE);
5352 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5353 			close(fd);
5354 			remove(DUMMY_FILE);
5355 		}
5356 		if (fd == -1 || rc == -1) {
5357 			DMLOG_PRINT(DMLVL_DEBUG,
5358 				    "Unable to set up variation! (errno = %d)\n",
5359 				    errno);
5360 			DMVAR_SKIP();
5361 		} else {
5362 			/* Variation */
5363 			rc2 = stat(DUMMY_FILE, &statfs1);
5364 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_GID)\n",
5365 				    szFuncName);
5366 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5367 					     DM_AT_GID, &fileattr);
5368 			rc2 |= stat(DUMMY_FILE, &statfs2);
5369 			if (rc == 0) {
5370 				if ((rc2 == 0)
5371 				    && (statfs1.st_gid != statfs2.st_gid)
5372 				    && (statfs2.st_gid == DUMMY_GID)) {
5373 					DMLOG_PRINT(DMLVL_DEBUG,
5374 						    "%s passed with expected rc = %d and gid modified\n",
5375 						    szFuncName, 0);
5376 					DMVAR_PASS();
5377 				} else {
5378 					DMLOG_PRINT(DMLVL_ERR,
5379 						    "%s failed with expected rc = %d but gid unmodified (%d vs %d)\n",
5380 						    szFuncName, 0,
5381 						    statfs1.st_gid,
5382 						    statfs2.st_gid);
5383 					DMVAR_FAIL();
5384 				}
5385 			} else {
5386 				DMLOG_PRINT(DMLVL_ERR,
5387 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5388 					    szFuncName, rc, errno);
5389 				DMVAR_FAIL();
5390 			}
5391 
5392 			/* Variation clean up */
5393 			rc = close(fd);
5394 			rc |= remove(DUMMY_FILE);
5395 			if (rc == -1) {
5396 				DMLOG_PRINT(DMLVL_DEBUG,
5397 					    "Unable to clean up variation! (errno = %d)\n",
5398 					    errno);
5399 			}
5400 			dm_handle_free(hanp, hlen);
5401 		}
5402 	}
5403 
5404 	/*
5405 	 * TEST    : dm_set_fileattr - DM_AT_MODE on file
5406 	 * EXPECTED: rc = 0
5407 	 */
5408 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 14)) {
5409 		int fd;
5410 		void *hanp;
5411 		size_t hlen;
5412 		dm_fileattr_t fileattr;
5413 		struct stat statfs1, statfs2;
5414 		int rc2;
5415 
5416 		/* Variation set up */
5417 		fileattr.fa_mode = DUMMY_MODE;
5418 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5419 		if ((rc = system(command)) == -1) {
5420 			/* No clean up */
5421 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5422 			remove(DUMMY_FILE);
5423 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5424 			close(fd);
5425 			remove(DUMMY_FILE);
5426 		}
5427 		if (fd == -1 || rc == -1) {
5428 			DMLOG_PRINT(DMLVL_DEBUG,
5429 				    "Unable to set up variation! (errno = %d)\n",
5430 				    errno);
5431 			DMVAR_SKIP();
5432 		} else {
5433 			/* Variation */
5434 			rc2 = stat(DUMMY_FILE, &statfs1);
5435 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_MODE)\n",
5436 				    szFuncName);
5437 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5438 					     DM_AT_MODE, &fileattr);
5439 			rc2 |= stat(DUMMY_FILE, &statfs2);
5440 			if (rc == 0) {
5441 				if ((rc2 == 0)
5442 				    && (statfs1.st_mode != statfs2.st_mode)
5443 				    && ((statfs2.st_mode & MODE_MASK) ==
5444 					DUMMY_MODE)) {
5445 					DMLOG_PRINT(DMLVL_DEBUG,
5446 						    "%s passed with expected rc = %d and mode modified\n",
5447 						    szFuncName, 0);
5448 					DMVAR_PASS();
5449 				} else {
5450 					DMLOG_PRINT(DMLVL_ERR,
5451 						    "%s failed with expected rc = %d but mode unmodified (%x vs %x)\n",
5452 						    szFuncName, 0,
5453 						    statfs1.st_mode,
5454 						    statfs2.st_mode);
5455 					DMVAR_FAIL();
5456 				}
5457 			} else {
5458 				DMLOG_PRINT(DMLVL_ERR,
5459 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5460 					    szFuncName, rc, errno);
5461 				DMVAR_FAIL();
5462 			}
5463 
5464 			/* Variation clean up */
5465 			rc = close(fd);
5466 			rc |= remove(DUMMY_FILE);
5467 			if (rc == -1) {
5468 				DMLOG_PRINT(DMLVL_DEBUG,
5469 					    "Unable to clean up variation! (errno = %d)\n",
5470 					    errno);
5471 			}
5472 			dm_handle_free(hanp, hlen);
5473 		}
5474 	}
5475 
5476 	/*
5477 	 * TEST    : dm_set_fileattr - DM_AT_SIZE on file, shrink
5478 	 * EXPECTED: rc = 0
5479 	 */
5480 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 15)) {
5481 		int fd;
5482 		void *hanp;
5483 		size_t hlen;
5484 		dm_fileattr_t fileattr;
5485 		struct stat statfs1, statfs2;
5486 		int rc2;
5487 
5488 		/* Variation set up */
5489 		fileattr.fa_size = TMP_FILELEN / 2;
5490 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5491 		if ((rc = system(command)) == -1) {
5492 			/* No clean up */
5493 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5494 			remove(DUMMY_FILE);
5495 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5496 			close(fd);
5497 			remove(DUMMY_FILE);
5498 		}
5499 		if (fd == -1 || rc == -1) {
5500 			DMLOG_PRINT(DMLVL_DEBUG,
5501 				    "Unable to set up variation! (errno = %d)\n",
5502 				    errno);
5503 			DMVAR_SKIP();
5504 		} else {
5505 			/* Variation */
5506 			rc2 = stat(DUMMY_FILE, &statfs1);
5507 			DMLOG_PRINT(DMLVL_DEBUG,
5508 				    "%s(file DM_AT_SIZE, shrink)\n",
5509 				    szFuncName);
5510 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5511 					     DM_AT_SIZE, &fileattr);
5512 			rc2 |= stat(DUMMY_FILE, &statfs2);
5513 			if (rc == 0) {
5514 				if ((rc2 == 0)
5515 				    && (statfs1.st_size != statfs2.st_size)
5516 				    && (statfs2.st_size == TMP_FILELEN / 2)) {
5517 					DMLOG_PRINT(DMLVL_DEBUG,
5518 						    "%s passed with expected rc = %d and size modified\n",
5519 						    szFuncName, 0);
5520 					DMVAR_PASS();
5521 				} else {
5522 					DMLOG_PRINT(DMLVL_ERR,
5523 						    "%s failed with expected rc = %d but size unmodified (%x vs %x)\n",
5524 						    szFuncName, 0,
5525 						    statfs1.st_size,
5526 						    statfs2.st_size);
5527 					DMVAR_FAIL();
5528 				}
5529 			} else {
5530 				DMLOG_PRINT(DMLVL_ERR,
5531 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5532 					    szFuncName, rc, errno);
5533 				DMVAR_FAIL();
5534 			}
5535 
5536 			/* Variation clean up */
5537 			rc = close(fd);
5538 			rc |= remove(DUMMY_FILE);
5539 			if (rc == -1) {
5540 				DMLOG_PRINT(DMLVL_DEBUG,
5541 					    "Unable to clean up variation! (errno = %d)\n",
5542 					    errno);
5543 			}
5544 			dm_handle_free(hanp, hlen);
5545 		}
5546 	}
5547 
5548 	/*
5549 	 * TEST    : dm_set_fileattr - DM_AT_SIZE on file, expand
5550 	 * EXPECTED: rc = 0
5551 	 */
5552 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 16)) {
5553 		int fd;
5554 		void *hanp;
5555 		size_t hlen;
5556 		dm_fileattr_t fileattr;
5557 		struct stat statfs1, statfs2;
5558 		int rc2;
5559 
5560 		/* Variation set up */
5561 		fileattr.fa_size = TMP_FILELEN * 2;
5562 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5563 		if ((rc = system(command)) == -1) {
5564 			/* No clean up */
5565 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5566 			remove(DUMMY_FILE);
5567 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
5568 			close(fd);
5569 			remove(DUMMY_FILE);
5570 		}
5571 		if (fd == -1 || rc == -1) {
5572 			DMLOG_PRINT(DMLVL_DEBUG,
5573 				    "Unable to set up variation! (errno = %d)\n",
5574 				    errno);
5575 			DMVAR_SKIP();
5576 		} else {
5577 			/* Variation */
5578 			rc2 = stat(DUMMY_FILE, &statfs1);
5579 			DMLOG_PRINT(DMLVL_DEBUG,
5580 				    "%s(file DM_AT_SIZE, expand)\n",
5581 				    szFuncName);
5582 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5583 					     DM_AT_SIZE, &fileattr);
5584 			rc2 |= stat(DUMMY_FILE, &statfs2);
5585 			if (rc == 0) {
5586 				if ((rc2 == 0)
5587 				    && (statfs1.st_size != statfs2.st_size)
5588 				    && (statfs2.st_size == TMP_FILELEN * 2)) {
5589 					DMLOG_PRINT(DMLVL_DEBUG,
5590 						    "%s passed with expected rc = %d and size modified\n",
5591 						    szFuncName, 0);
5592 					DMVAR_PASS();
5593 				} else {
5594 					DMLOG_PRINT(DMLVL_ERR,
5595 						    "%s failed with expected rc = %d but size unmodified (%x vs %x)\n",
5596 						    szFuncName, 0,
5597 						    statfs1.st_size,
5598 						    statfs2.st_size);
5599 					DMVAR_FAIL();
5600 				}
5601 			} else {
5602 				DMLOG_PRINT(DMLVL_ERR,
5603 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5604 					    szFuncName, rc, errno);
5605 				DMVAR_FAIL();
5606 			}
5607 
5608 			/* Variation clean up */
5609 			rc = close(fd);
5610 			rc |= remove(DUMMY_FILE);
5611 			if (rc == -1) {
5612 				DMLOG_PRINT(DMLVL_DEBUG,
5613 					    "Unable to clean up variation! (errno = %d)\n",
5614 					    errno);
5615 			}
5616 			dm_handle_free(hanp, hlen);
5617 		}
5618 	}
5619 
5620 	/*
5621 	 * TEST    : dm_set_fileattr - fs handle
5622 	 * EXPECTED: rc = -1, errno = EINVAL
5623 	 */
5624 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 17)) {
5625 		int fd;
5626 		void *hanp;
5627 		size_t hlen;
5628 		dm_fileattr_t fileattr;
5629 		struct stat statfs1, statfs2;
5630 		int rc2;
5631 
5632 		/* Variation set up */
5633 		fileattr.fa_uid = DUMMY_UID;
5634 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
5635 		if ((rc = system(command)) == -1) {
5636 			/* No clean up */
5637 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
5638 			remove(DUMMY_FILE);
5639 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
5640 			   == -1) {
5641 			close(fd);
5642 			remove(DUMMY_FILE);
5643 		}
5644 		if (fd == -1 || rc == -1) {
5645 			DMLOG_PRINT(DMLVL_DEBUG,
5646 				    "Unable to set up variation! (errno = %d)\n",
5647 				    errno);
5648 			DMVAR_SKIP();
5649 		} else {
5650 			/* Variation */
5651 			rc2 = stat(DUMMY_FILE, &statfs1);
5652 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
5653 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5654 					     DM_AT_UID, &fileattr);
5655 			rc2 |= stat(DUMMY_FILE, &statfs2);
5656 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
5657 
5658 			/* Variation clean up */
5659 			rc = close(fd);
5660 			rc |= remove(DUMMY_FILE);
5661 			if (rc == -1) {
5662 				DMLOG_PRINT(DMLVL_DEBUG,
5663 					    "Unable to clean up variation! (errno = %d)\n",
5664 					    errno);
5665 			}
5666 			dm_handle_free(hanp, hlen);
5667 		}
5668 	}
5669 
5670 	/*
5671 	 * TEST    : dm_set_fileattr - DM_AT_ATIME on directory
5672 	 * EXPECTED: rc = 0
5673 	 */
5674 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 18)) {
5675 		void *hanp;
5676 		size_t hlen;
5677 		dm_fileattr_t fileattr;
5678 		struct stat statfs1, statfs2;
5679 		int rc2;
5680 
5681 		/* Variation set up */
5682 		fileattr.fa_atime = DUMMY_TIME;
5683 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
5684 			/* No clean up */
5685 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
5686 			   == -1) {
5687 			rmdir(DUMMY_SUBDIR);
5688 		}
5689 		if (rc == -1) {
5690 			DMLOG_PRINT(DMLVL_DEBUG,
5691 				    "Unable to set up variation! (errno = %d)\n",
5692 				    errno);
5693 			DMVAR_SKIP();
5694 		} else {
5695 			/* Variation */
5696 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
5697 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_ATIME)\n",
5698 				    szFuncName);
5699 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5700 					     DM_AT_ATIME, &fileattr);
5701 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
5702 			if (rc == 0) {
5703 				if ((rc2 == 0)
5704 				    && (statfs1.st_atime != statfs2.st_atime)
5705 				    && (statfs2.st_atime == DUMMY_TIME)) {
5706 					DMLOG_PRINT(DMLVL_DEBUG,
5707 						    "%s passed with expected rc = %d and atime modified\n",
5708 						    szFuncName, 0);
5709 					DMVAR_PASS();
5710 				} else {
5711 					DMLOG_PRINT(DMLVL_ERR,
5712 						    "%s failed with expected rc = %d but atime unmodified (%d vs %d)\n",
5713 						    szFuncName, 0,
5714 						    statfs1.st_atime,
5715 						    statfs2.st_atime);
5716 					DMVAR_FAIL();
5717 				}
5718 			} else {
5719 				DMLOG_PRINT(DMLVL_ERR,
5720 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5721 					    szFuncName, rc, errno);
5722 				DMVAR_FAIL();
5723 			}
5724 
5725 			/* Variation clean up */
5726 			rc = rmdir(DUMMY_SUBDIR);
5727 			if (rc == -1) {
5728 				DMLOG_PRINT(DMLVL_DEBUG,
5729 					    "Unable to clean up variation! (errno = %d)\n",
5730 					    errno);
5731 			}
5732 			dm_handle_free(hanp, hlen);
5733 		}
5734 	}
5735 
5736 	/*
5737 	 * TEST    : dm_set_fileattr - DM_AT_MTIME on directory
5738 	 * EXPECTED: rc = 0
5739 	 */
5740 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 19)) {
5741 		void *hanp;
5742 		size_t hlen;
5743 		dm_fileattr_t fileattr;
5744 		struct stat statfs1, statfs2;
5745 		int rc2;
5746 
5747 		/* Variation set up */
5748 		fileattr.fa_mtime = DUMMY_TIME;
5749 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
5750 			/* No clean up */
5751 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
5752 			   == -1) {
5753 			rmdir(DUMMY_SUBDIR);
5754 		}
5755 		if (rc == -1) {
5756 			DMLOG_PRINT(DMLVL_DEBUG,
5757 				    "Unable to set up variation! (errno = %d)\n",
5758 				    errno);
5759 			DMVAR_SKIP();
5760 		} else {
5761 			/* Variation */
5762 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
5763 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_MTIME)\n",
5764 				    szFuncName);
5765 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5766 					     DM_AT_MTIME, &fileattr);
5767 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
5768 			if (rc == 0) {
5769 				if ((rc2 == 0)
5770 				    && (statfs1.st_mtime != statfs2.st_mtime)
5771 				    && (statfs2.st_mtime == DUMMY_TIME)) {
5772 					DMLOG_PRINT(DMLVL_DEBUG,
5773 						    "%s passed with expected rc = %d and mtime modified\n",
5774 						    szFuncName, 0);
5775 					DMVAR_PASS();
5776 				} else {
5777 					DMLOG_PRINT(DMLVL_ERR,
5778 						    "%s failed with expected rc = %d but mtime unmodified (%d vs %d)\n",
5779 						    szFuncName, 0,
5780 						    statfs1.st_mtime,
5781 						    statfs2.st_mtime);
5782 					DMVAR_FAIL();
5783 				}
5784 			} else {
5785 				DMLOG_PRINT(DMLVL_ERR,
5786 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5787 					    szFuncName, rc, errno);
5788 				DMVAR_FAIL();
5789 			}
5790 
5791 			/* Variation clean up */
5792 			rc = rmdir(DUMMY_SUBDIR);
5793 			if (rc == -1) {
5794 				DMLOG_PRINT(DMLVL_DEBUG,
5795 					    "Unable to clean up variation! (errno = %d)\n",
5796 					    errno);
5797 			}
5798 			dm_handle_free(hanp, hlen);
5799 		}
5800 	}
5801 
5802 	/*
5803 	 * TEST    : dm_set_fileattr - DM_AT_CTIME on directory
5804 	 * EXPECTED: rc = 0
5805 	 */
5806 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 20)) {
5807 		void *hanp;
5808 		size_t hlen;
5809 		dm_fileattr_t fileattr;
5810 		struct stat statfs1, statfs2;
5811 		int rc2;
5812 
5813 		/* Variation set up */
5814 		fileattr.fa_ctime = DUMMY_TIME;
5815 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
5816 			/* No clean up */
5817 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
5818 			   == -1) {
5819 			rmdir(DUMMY_SUBDIR);
5820 		}
5821 		if (rc == -1) {
5822 			DMLOG_PRINT(DMLVL_DEBUG,
5823 				    "Unable to set up variation! (errno = %d)\n",
5824 				    errno);
5825 			DMVAR_SKIP();
5826 		} else {
5827 			/* Variation */
5828 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
5829 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_CTIME)\n",
5830 				    szFuncName);
5831 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5832 					     DM_AT_CTIME, &fileattr);
5833 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
5834 			if (rc == 0) {
5835 				if ((rc2 == 0)
5836 				    && (statfs1.st_ctime != statfs2.st_ctime)
5837 				    && (statfs2.st_ctime == DUMMY_TIME)) {
5838 					DMLOG_PRINT(DMLVL_DEBUG,
5839 						    "%s passed with expected rc = %d and ctime modified\n",
5840 						    szFuncName, 0);
5841 					DMVAR_PASS();
5842 				} else {
5843 					DMLOG_PRINT(DMLVL_ERR,
5844 						    "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
5845 						    szFuncName, 0,
5846 						    statfs1.st_ctime,
5847 						    statfs2.st_ctime);
5848 					DMVAR_FAIL();
5849 				}
5850 			} else {
5851 				DMLOG_PRINT(DMLVL_ERR,
5852 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5853 					    szFuncName, rc, errno);
5854 				DMVAR_FAIL();
5855 			}
5856 
5857 			/* Variation clean up */
5858 			rc = rmdir(DUMMY_SUBDIR);
5859 			if (rc == -1) {
5860 				DMLOG_PRINT(DMLVL_DEBUG,
5861 					    "Unable to clean up variation! (errno = %d)\n",
5862 					    errno);
5863 			}
5864 			dm_handle_free(hanp, hlen);
5865 		}
5866 	}
5867 
5868 	/*
5869 	 * TEST    : dm_set_fileattr - DM_AT_DTIME on directory with DM attribute
5870 	 * EXPECTED: rc = 0
5871 	 */
5872 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 21)) {
5873 		void *hanp;
5874 		size_t hlen;
5875 		dm_fileattr_t fileattr;
5876 		dm_attrname_t attrname;
5877 		char buf[ATTR_LISTLEN];
5878 		struct stat statfs1, statfs2;
5879 		int rc2;
5880 
5881 		/* Variation set up */
5882 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
5883 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
5884 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
5885 		fileattr.fa_dtime = DUMMY_TIME;
5886 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
5887 			/* No clean up */
5888 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
5889 			   == -1) {
5890 			rmdir(DUMMY_SUBDIR);
5891 		} else
5892 		    if ((rc =
5893 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
5894 				       0, ATTR_VALUELEN, buf)) == -1) {
5895 			dm_handle_free(hanp, hlen);
5896 			rmdir(DUMMY_SUBDIR);
5897 		}
5898 		if (rc == -1) {
5899 			DMLOG_PRINT(DMLVL_DEBUG,
5900 				    "Unable to set up variation! (errno = %d)\n",
5901 				    errno);
5902 			DMVAR_SKIP();
5903 		} else {
5904 			/* Variation */
5905 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
5906 			DMLOG_PRINT(DMLVL_DEBUG,
5907 				    "%s(dir DM_AT_DTIME with attr)\n",
5908 				    szFuncName);
5909 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5910 					     DM_AT_DTIME, &fileattr);
5911 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
5912 			if (rc == 0) {
5913 				if ((rc2 == 0)
5914 				    && (statfs1.st_ctime != statfs2.st_ctime)
5915 				    && (statfs2.st_ctime == DUMMY_TIME)) {
5916 					DMLOG_PRINT(DMLVL_DEBUG,
5917 						    "%s passed with expected rc = %d and ctime modified\n",
5918 						    szFuncName, 0);
5919 					DMVAR_PASS();
5920 				} else {
5921 					DMLOG_PRINT(DMLVL_ERR,
5922 						    "%s failed with expected rc = %d but ctime unmodified (%d vs %d)\n",
5923 						    szFuncName, 0,
5924 						    statfs1.st_ctime,
5925 						    statfs2.st_ctime);
5926 					DMVAR_FAIL();
5927 				}
5928 			} else {
5929 				DMLOG_PRINT(DMLVL_ERR,
5930 					    "%s failed with unexpected rc = %d (errno = %d)\n",
5931 					    szFuncName, rc, errno);
5932 				DMVAR_FAIL();
5933 			}
5934 
5935 			/* Variation clean up */
5936 			rc = rmdir(DUMMY_SUBDIR);
5937 			if (rc == -1) {
5938 				DMLOG_PRINT(DMLVL_DEBUG,
5939 					    "Unable to clean up variation! (errno = %d)\n",
5940 					    errno);
5941 			}
5942 			dm_handle_free(hanp, hlen);
5943 		}
5944 	}
5945 
5946 	/*
5947 	 * TEST    : dm_set_fileattr - DM_AT_DTIME on directory without DM attribute
5948 	 * EXPECTED: rc = -1, errno = EINVAL
5949 	 */
5950 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 22)) {
5951 		void *hanp;
5952 		size_t hlen;
5953 		dm_fileattr_t fileattr;
5954 		struct stat statfs1, statfs2;
5955 		int rc2;
5956 
5957 		/* Variation set up */
5958 		fileattr.fa_dtime = DUMMY_TIME;
5959 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
5960 			/* No clean up */
5961 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
5962 			   == -1) {
5963 			rmdir(DUMMY_SUBDIR);
5964 		}
5965 		if (rc == -1) {
5966 			DMLOG_PRINT(DMLVL_DEBUG,
5967 				    "Unable to set up variation! (errno = %d)\n",
5968 				    errno);
5969 			DMVAR_SKIP();
5970 		} else {
5971 			/* Variation */
5972 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
5973 			DMLOG_PRINT(DMLVL_DEBUG,
5974 				    "%s(dir DM_AT_DTIME without attr)\n",
5975 				    szFuncName);
5976 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
5977 					     DM_AT_DTIME, &fileattr);
5978 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
5979 			if (rc == 0) {
5980 				if ((rc2 == 0)
5981 				    && (statfs1.st_ctime == statfs2.st_ctime)
5982 				    && (statfs2.st_ctime != DUMMY_TIME)) {
5983 					DMLOG_PRINT(DMLVL_DEBUG,
5984 						    "%s passed with expected rc = %d and ctime unmodified\n",
5985 						    szFuncName, 0);
5986 					DMVAR_PASS();
5987 				} else {
5988 					DMLOG_PRINT(DMLVL_ERR,
5989 						    "%s failed with expected rc = %d but ctime modified (%d vs %d)\n",
5990 						    szFuncName, 0,
5991 						    statfs1.st_ctime,
5992 						    statfs2.st_ctime);
5993 					DMVAR_FAIL();
5994 				}
5995 			} else {
5996 				DMLOG_PRINT(DMLVL_ERR,
5997 					    "%s failed with unexpected rc = %d\n",
5998 					    szFuncName, rc);
5999 				DMVAR_FAIL();
6000 			}
6001 
6002 			/* Variation clean up */
6003 			rc = rmdir(DUMMY_SUBDIR);
6004 			if (rc == -1) {
6005 				DMLOG_PRINT(DMLVL_DEBUG,
6006 					    "Unable to clean up variation! (errno = %d)\n",
6007 					    errno);
6008 			}
6009 			dm_handle_free(hanp, hlen);
6010 		}
6011 	}
6012 
6013 	/*
6014 	 * TEST    : dm_set_fileattr - DM_AT_UID on directory
6015 	 * EXPECTED: rc = 0
6016 	 */
6017 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 23)) {
6018 		void *hanp;
6019 		size_t hlen;
6020 		dm_fileattr_t fileattr;
6021 		struct stat statfs1, statfs2;
6022 		int rc2;
6023 
6024 		/* Variation set up */
6025 		fileattr.fa_uid = DUMMY_UID;
6026 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
6027 			/* No clean up */
6028 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
6029 			   == -1) {
6030 			rmdir(DUMMY_SUBDIR);
6031 		}
6032 		if (rc == -1) {
6033 			DMLOG_PRINT(DMLVL_DEBUG,
6034 				    "Unable to set up variation! (errno = %d)\n",
6035 				    errno);
6036 			DMVAR_SKIP();
6037 		} else {
6038 			/* Variation */
6039 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
6040 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_UID)\n",
6041 				    szFuncName);
6042 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6043 					     DM_AT_UID, &fileattr);
6044 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
6045 			if (rc == 0) {
6046 				if ((rc2 == 0)
6047 				    && (statfs1.st_uid != statfs2.st_uid)
6048 				    && (statfs2.st_uid == DUMMY_UID)) {
6049 					DMLOG_PRINT(DMLVL_DEBUG,
6050 						    "%s passed with expected rc = %d and uid modified\n",
6051 						    szFuncName, 0);
6052 					DMVAR_PASS();
6053 				} else {
6054 					DMLOG_PRINT(DMLVL_ERR,
6055 						    "%s failed with expected rc = %d but uid unmodified (%d vs %d)\n",
6056 						    szFuncName, 0,
6057 						    statfs1.st_uid,
6058 						    statfs2.st_uid);
6059 					DMVAR_FAIL();
6060 				}
6061 			} else {
6062 				DMLOG_PRINT(DMLVL_ERR,
6063 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6064 					    szFuncName, rc, errno);
6065 				DMVAR_FAIL();
6066 			}
6067 
6068 			/* Variation clean up */
6069 			rc = rmdir(DUMMY_SUBDIR);
6070 			if (rc == -1) {
6071 				DMLOG_PRINT(DMLVL_DEBUG,
6072 					    "Unable to clean up variation! (errno = %d)\n",
6073 					    errno);
6074 			}
6075 			dm_handle_free(hanp, hlen);
6076 		}
6077 	}
6078 
6079 	/*
6080 	 * TEST    : dm_set_fileattr - DM_AT_GID on directory
6081 	 * EXPECTED: rc = 0
6082 	 */
6083 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 24)) {
6084 		void *hanp;
6085 		size_t hlen;
6086 		dm_fileattr_t fileattr;
6087 		struct stat statfs1, statfs2;
6088 		int rc2;
6089 
6090 		/* Variation set up */
6091 		fileattr.fa_gid = DUMMY_GID;
6092 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
6093 			/* No clean up */
6094 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
6095 			   == -1) {
6096 			rmdir(DUMMY_SUBDIR);
6097 		}
6098 		if (rc == -1) {
6099 			DMLOG_PRINT(DMLVL_DEBUG,
6100 				    "Unable to set up variation! (errno = %d)\n",
6101 				    errno);
6102 			DMVAR_SKIP();
6103 		} else {
6104 			/* Variation */
6105 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
6106 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_GID)\n",
6107 				    szFuncName);
6108 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6109 					     DM_AT_GID, &fileattr);
6110 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
6111 			if (rc == 0) {
6112 				if ((rc2 == 0)
6113 				    && (statfs1.st_gid != statfs2.st_gid)
6114 				    && (statfs2.st_gid == DUMMY_GID)) {
6115 					DMLOG_PRINT(DMLVL_DEBUG,
6116 						    "%s passed with expected rc = %d and gid modified\n",
6117 						    szFuncName, 0);
6118 					DMVAR_PASS();
6119 				} else {
6120 					DMLOG_PRINT(DMLVL_ERR,
6121 						    "%s failed with expected rc = %d but gid unmodified (%d vs %d)\n",
6122 						    szFuncName, 0,
6123 						    statfs1.st_gid,
6124 						    statfs2.st_gid);
6125 					DMVAR_FAIL();
6126 				}
6127 			} else {
6128 				DMLOG_PRINT(DMLVL_ERR,
6129 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6130 					    szFuncName, rc, errno);
6131 				DMVAR_FAIL();
6132 			}
6133 
6134 			/* Variation clean up */
6135 			rc = rmdir(DUMMY_SUBDIR);
6136 			if (rc == -1) {
6137 				DMLOG_PRINT(DMLVL_DEBUG,
6138 					    "Unable to clean up variation! (errno = %d)\n",
6139 					    errno);
6140 			}
6141 			dm_handle_free(hanp, hlen);
6142 		}
6143 	}
6144 
6145 	/*
6146 	 * TEST    : dm_set_fileattr - DM_AT_MODE on directory
6147 	 * EXPECTED: rc = 0
6148 	 */
6149 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 25)) {
6150 		void *hanp;
6151 		size_t hlen;
6152 		dm_fileattr_t fileattr;
6153 		struct stat statfs1, statfs2;
6154 		int rc2;
6155 
6156 		/* Variation set up */
6157 		fileattr.fa_mode = DUMMY_MODE;
6158 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
6159 			/* No clean up */
6160 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
6161 			   == -1) {
6162 			rmdir(DUMMY_SUBDIR);
6163 		}
6164 		if (rc == -1) {
6165 			DMLOG_PRINT(DMLVL_DEBUG,
6166 				    "Unable to set up variation! (errno = %d)\n",
6167 				    errno);
6168 			DMVAR_SKIP();
6169 		} else {
6170 			/* Variation */
6171 			rc2 = stat(DUMMY_SUBDIR, &statfs1);
6172 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_MODE)\n",
6173 				    szFuncName);
6174 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6175 					     DM_AT_MODE, &fileattr);
6176 			rc2 |= stat(DUMMY_SUBDIR, &statfs2);
6177 			if (rc == 0) {
6178 				if ((rc2 == 0)
6179 				    && (statfs1.st_mode != statfs2.st_mode)
6180 				    && ((statfs2.st_mode & MODE_MASK) ==
6181 					DUMMY_MODE)) {
6182 					DMLOG_PRINT(DMLVL_DEBUG,
6183 						    "%s passed with expected rc = %d and mode modified\n",
6184 						    szFuncName, 0);
6185 					DMVAR_PASS();
6186 				} else {
6187 					DMLOG_PRINT(DMLVL_ERR,
6188 						    "%s failed with expected rc = %d but mode unmodified (%x vs %x)\n",
6189 						    szFuncName, 0,
6190 						    statfs1.st_mode,
6191 						    statfs2.st_mode);
6192 					DMVAR_FAIL();
6193 				}
6194 			} else {
6195 				DMLOG_PRINT(DMLVL_ERR,
6196 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6197 					    szFuncName, rc, errno);
6198 				DMVAR_FAIL();
6199 			}
6200 
6201 			/* Variation clean up */
6202 			rc = rmdir(DUMMY_SUBDIR);
6203 			if (rc == -1) {
6204 				DMLOG_PRINT(DMLVL_DEBUG,
6205 					    "Unable to clean up variation! (errno = %d)\n",
6206 					    errno);
6207 			}
6208 			dm_handle_free(hanp, hlen);
6209 		}
6210 	}
6211 
6212 	/*
6213 	 * TEST    : dm_set_fileattr - DM_NO_SESSION sid
6214 	 * EXPECTED: rc = -1, errno = EINVAL
6215 	 */
6216 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 26)) {
6217 		int fd;
6218 		void *hanp;
6219 		size_t hlen;
6220 		dm_fileattr_t fileattr;
6221 
6222 		/* Variation set up */
6223 		fileattr.fa_uid = DUMMY_UID;
6224 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6225 		if ((rc = system(command)) == -1) {
6226 			/* No clean up */
6227 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6228 			remove(DUMMY_FILE);
6229 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6230 			close(fd);
6231 			remove(DUMMY_FILE);
6232 		}
6233 		if (fd == -1 || rc == -1) {
6234 			DMLOG_PRINT(DMLVL_DEBUG,
6235 				    "Unable to set up variation! (errno = %d)\n",
6236 				    errno);
6237 			DMVAR_SKIP();
6238 		} else {
6239 			/* Variation */
6240 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
6241 				    szFuncName);
6242 			rc = dm_set_fileattr(DM_NO_SESSION, hanp, hlen,
6243 					     DM_NO_TOKEN, DM_AT_UID, &fileattr);
6244 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
6245 
6246 			/* Variation clean up */
6247 			rc = close(fd);
6248 			rc |= remove(DUMMY_FILE);
6249 			if (rc == -1) {
6250 				DMLOG_PRINT(DMLVL_DEBUG,
6251 					    "Unable to clean up variation! (errno = %d)\n",
6252 					    errno);
6253 			}
6254 			dm_handle_free(hanp, hlen);
6255 		}
6256 	}
6257 
6258 	/*
6259 	 * TEST    : dm_set_fileattr - global handle
6260 	 * EXPECTED: rc = -1, errno = EBADF
6261 	 */
6262 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 27)) {
6263 		dm_fileattr_t fileattr;
6264 
6265 		/* Variation set up */
6266 		fileattr.fa_uid = DUMMY_UID;
6267 
6268 		/* Variation */
6269 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
6270 		rc = dm_set_fileattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
6271 				     DM_NO_TOKEN, DM_AT_UID, &fileattr);
6272 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
6273 
6274 		/* Variation clean up */
6275 	}
6276 
6277 	/*
6278 	 * TEST    : dm_set_fileattr - invalidated hanp
6279 	 * EXPECTED: rc = -1, errno = EBADF
6280 	 */
6281 	if (DMVAR_EXEC(SET_FILEATTR_BASE + 28)) {
6282 		int fd;
6283 		void *hanp;
6284 		size_t hlen;
6285 		dm_fileattr_t fileattr;
6286 
6287 		/* Variation set up */
6288 		fileattr.fa_uid = DUMMY_UID;
6289 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6290 		if ((rc = system(command)) == -1) {
6291 			/* No clean up */
6292 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6293 			remove(DUMMY_FILE);
6294 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6295 			close(fd);
6296 			remove(DUMMY_FILE);
6297 		} else if ((rc = close(fd)) == -1) {
6298 			dm_handle_free(hanp, hlen);
6299 			remove(DUMMY_FILE);
6300 		} else if ((rc = remove(DUMMY_FILE)) == -1) {
6301 			dm_handle_free(hanp, hlen);
6302 		}
6303 		if (fd == -1 || rc == -1) {
6304 			DMLOG_PRINT(DMLVL_DEBUG,
6305 				    "Unable to set up variation! (errno = %d)\n",
6306 				    errno);
6307 			DMVAR_SKIP();
6308 		} else {
6309 			/* Variation */
6310 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
6311 				    szFuncName);
6312 			rc = dm_set_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6313 					     DM_AT_UID, &fileattr);
6314 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
6315 
6316 			/* Variation clean up */
6317 			dm_handle_free(hanp, hlen);
6318 		}
6319 	}
6320 
6321 	szFuncName = "dm_get_fileattr";
6322 
6323 	/*
6324 	 * TEST    : dm_get_fileattr - invalid sid
6325 	 * EXPECTED: rc = -1, errno = EINVAL
6326 	 */
6327 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 1)) {
6328 		int fd;
6329 		void *hanp;
6330 		size_t hlen;
6331 		dm_stat_t stat;
6332 
6333 		/* Variation set up */
6334 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6335 		if ((rc = system(command)) == -1) {
6336 			/* No clean up */
6337 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6338 			remove(DUMMY_FILE);
6339 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6340 			close(fd);
6341 			remove(DUMMY_FILE);
6342 		}
6343 		if (fd == -1 || rc == -1) {
6344 			DMLOG_PRINT(DMLVL_DEBUG,
6345 				    "Unable to set up variation! (errno = %d)\n",
6346 				    errno);
6347 			DMVAR_SKIP();
6348 		} else {
6349 			/* Variation */
6350 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
6351 				    szFuncName);
6352 			rc = dm_get_fileattr(INVALID_ADDR, hanp, hlen,
6353 					     DM_NO_TOKEN, DM_AT_EMASK, &stat);
6354 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
6355 
6356 			/* Variation clean up */
6357 			rc = close(fd);
6358 			rc |= remove(DUMMY_FILE);
6359 			if (rc == -1) {
6360 				DMLOG_PRINT(DMLVL_DEBUG,
6361 					    "Unable to clean up variation! (errno = %d)\n",
6362 					    errno);
6363 			}
6364 			dm_handle_free(hanp, hlen);
6365 		}
6366 	}
6367 
6368 	/*
6369 	 * TEST    : dm_get_fileattr - invalid hanp
6370 	 * EXPECTED: rc = -1, errno = EFAULT
6371 	 */
6372 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 2)) {
6373 		int fd;
6374 		void *hanp;
6375 		size_t hlen;
6376 		dm_stat_t stat;
6377 
6378 		/* Variation set up */
6379 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6380 		if ((rc = system(command)) == -1) {
6381 			/* No clean up */
6382 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6383 			remove(DUMMY_FILE);
6384 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6385 			close(fd);
6386 			remove(DUMMY_FILE);
6387 		}
6388 		if (fd == -1 || rc == -1) {
6389 			DMLOG_PRINT(DMLVL_DEBUG,
6390 				    "Unable to set up variation! (errno = %d)\n",
6391 				    errno);
6392 			DMVAR_SKIP();
6393 		} else {
6394 			/* Variation */
6395 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
6396 				    szFuncName);
6397 			rc = dm_get_fileattr(sid, (void *)INVALID_ADDR, hlen,
6398 					     DM_NO_TOKEN, DM_AT_EMASK, &stat);
6399 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
6400 
6401 			/* Variation clean up */
6402 			rc = close(fd);
6403 			rc |= remove(DUMMY_FILE);
6404 			if (rc == -1) {
6405 				DMLOG_PRINT(DMLVL_DEBUG,
6406 					    "Unable to clean up variation! (errno = %d)\n",
6407 					    errno);
6408 			}
6409 			dm_handle_free(hanp, hlen);
6410 		}
6411 	}
6412 
6413 	/*
6414 	 * TEST    : dm_get_fileattr - invalid hlen
6415 	 * EXPECTED: rc = -1, errno = EBADF
6416 	 */
6417 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 3)) {
6418 		int fd;
6419 		void *hanp;
6420 		size_t hlen;
6421 		dm_stat_t stat;
6422 
6423 		/* Variation set up */
6424 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6425 		if ((rc = system(command)) == -1) {
6426 			/* No clean up */
6427 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6428 			remove(DUMMY_FILE);
6429 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6430 			close(fd);
6431 			remove(DUMMY_FILE);
6432 		}
6433 		if (fd == -1 || rc == -1) {
6434 			DMLOG_PRINT(DMLVL_DEBUG,
6435 				    "Unable to set up variation! (errno = %d)\n",
6436 				    errno);
6437 			DMVAR_SKIP();
6438 		} else {
6439 			/* Variation */
6440 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
6441 				    szFuncName);
6442 			rc = dm_get_fileattr(sid, hanp, INVALID_ADDR,
6443 					     DM_NO_TOKEN, DM_AT_EMASK, &stat);
6444 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
6445 
6446 			/* Variation clean up */
6447 			rc = close(fd);
6448 			rc |= remove(DUMMY_FILE);
6449 			if (rc == -1) {
6450 				DMLOG_PRINT(DMLVL_DEBUG,
6451 					    "Unable to clean up variation! (errno = %d)\n",
6452 					    errno);
6453 			}
6454 			dm_handle_free(hanp, hlen);
6455 		}
6456 	}
6457 
6458 	/*
6459 	 * TEST    : dm_get_fileattr - invalid token
6460 	 * EXPECTED: rc = -1, errno = EINVAL
6461 	 */
6462 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 4)) {
6463 		int fd;
6464 		void *hanp;
6465 		size_t hlen;
6466 		dm_stat_t stat;
6467 
6468 		/* Variation set up */
6469 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6470 		if ((rc = system(command)) == -1) {
6471 			/* No clean up */
6472 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6473 			remove(DUMMY_FILE);
6474 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6475 			close(fd);
6476 			remove(DUMMY_FILE);
6477 		}
6478 		if (fd == -1 || rc == -1) {
6479 			DMLOG_PRINT(DMLVL_DEBUG,
6480 				    "Unable to set up variation! (errno = %d)\n",
6481 				    errno);
6482 			DMVAR_SKIP();
6483 		} else {
6484 			/* Variation */
6485 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
6486 				    szFuncName);
6487 			rc = dm_get_fileattr(sid, hanp, hlen, INVALID_ADDR,
6488 					     DM_AT_EMASK, &stat);
6489 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
6490 
6491 			/* Variation clean up */
6492 			rc = close(fd);
6493 			rc |= remove(DUMMY_FILE);
6494 			if (rc == -1) {
6495 				DMLOG_PRINT(DMLVL_DEBUG,
6496 					    "Unable to clean up variation! (errno = %d)\n",
6497 					    errno);
6498 			}
6499 			dm_handle_free(hanp, hlen);
6500 		}
6501 	}
6502 
6503 	/*
6504 	 * TEST    : dm_get_fileattr - invalid mask
6505 	 * EXPECTED: rc = -1, errno = EINVAL
6506 	 *
6507 	 * This variation uncovered XFS BUG #22 (0 returned instead of -1 and
6508 	 * EINVAL errno)
6509 	 */
6510 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 5)) {
6511 		int fd;
6512 		void *hanp;
6513 		size_t hlen;
6514 		dm_stat_t stat;
6515 
6516 		/* Variation set up */
6517 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6518 		if ((rc = system(command)) == -1) {
6519 			/* No clean up */
6520 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6521 			remove(DUMMY_FILE);
6522 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6523 			close(fd);
6524 			remove(DUMMY_FILE);
6525 		}
6526 		if (fd == -1 || rc == -1) {
6527 			DMLOG_PRINT(DMLVL_DEBUG,
6528 				    "Unable to set up variation! (errno = %d)\n",
6529 				    errno);
6530 			DMVAR_SKIP();
6531 		} else {
6532 			/* Variation */
6533 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid mask)\n",
6534 				    szFuncName);
6535 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6536 					     DM_AT_HANDLE, &stat);
6537 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
6538 
6539 			/* Variation clean up */
6540 			rc = close(fd);
6541 			rc |= remove(DUMMY_FILE);
6542 			if (rc == -1) {
6543 				DMLOG_PRINT(DMLVL_DEBUG,
6544 					    "Unable to clean up variation! (errno = %d)\n",
6545 					    errno);
6546 			}
6547 			dm_handle_free(hanp, hlen);
6548 		}
6549 	}
6550 
6551 	/*
6552 	 * TEST    : dm_get_fileattr - invalid statp
6553 	 * EXPECTED: rc = -1, errno = EFAULT
6554 	 */
6555 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 6)) {
6556 		int fd;
6557 		void *hanp;
6558 		size_t hlen;
6559 
6560 		/* Variation set up */
6561 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6562 		if ((rc = system(command)) == -1) {
6563 			/* No clean up */
6564 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6565 			remove(DUMMY_FILE);
6566 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6567 			close(fd);
6568 			remove(DUMMY_FILE);
6569 		}
6570 		if (fd == -1 || rc == -1) {
6571 			DMLOG_PRINT(DMLVL_DEBUG,
6572 				    "Unable to set up variation! (errno = %d)\n",
6573 				    errno);
6574 			DMVAR_SKIP();
6575 		} else {
6576 			/* Variation */
6577 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid statp)\n",
6578 				    szFuncName);
6579 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6580 					     DM_AT_EMASK,
6581 					     (dm_stat_t *) INVALID_ADDR);
6582 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
6583 
6584 			/* Variation clean up */
6585 			rc = close(fd);
6586 			rc |= remove(DUMMY_FILE);
6587 			if (rc == -1) {
6588 				DMLOG_PRINT(DMLVL_DEBUG,
6589 					    "Unable to clean up variation! (errno = %d)\n",
6590 					    errno);
6591 			}
6592 			dm_handle_free(hanp, hlen);
6593 		}
6594 	}
6595 
6596 	/*
6597 	 * TEST    : dm_get_fileattr - DM_AT_EMASK on file
6598 	 * EXPECTED: rc = 0
6599 	 */
6600 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 7)) {
6601 		int fd;
6602 		void *hanp;
6603 		size_t hlen;
6604 		dm_stat_t stat;
6605 		dm_eventset_t eventset;
6606 
6607 		/* Variation set up */
6608 		DMEV_ZERO(eventset);
6609 		DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
6610 		DMEV_SET(DM_EVENT_CLOSE, eventset);
6611 		DMEV_SET(DM_EVENT_DESTROY, eventset);
6612 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6613 		if ((rc = system(command)) == -1) {
6614 			/* No clean up */
6615 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6616 			remove(DUMMY_FILE);
6617 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6618 			close(fd);
6619 			remove(DUMMY_FILE);
6620 		} else
6621 		    if ((rc =
6622 			 dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
6623 					  &eventset, DM_EVENT_MAX)) == -1) {
6624 			dm_handle_free(hanp, hlen);
6625 			close(fd);
6626 			remove(DUMMY_FILE);
6627 		}
6628 		if (fd == -1 || rc == -1) {
6629 			DMLOG_PRINT(DMLVL_DEBUG,
6630 				    "Unable to set up variation! (errno = %d)\n",
6631 				    errno);
6632 			DMVAR_SKIP();
6633 		} else {
6634 			/* Variation */
6635 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_EMASK)\n",
6636 				    szFuncName);
6637 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6638 					     DM_AT_EMASK, &stat);
6639 			if (rc == 0) {
6640 				if (memcmp
6641 				    (&eventset, &stat.dt_emask,
6642 				     sizeof(dm_eventset_t)) == 0) {
6643 					DMLOG_PRINT(DMLVL_DEBUG,
6644 						    "%s passed with expected rc = %d\n",
6645 						    szFuncName, 0);
6646 					DMVAR_PASS();
6647 				} else {
6648 					DMLOG_PRINT(DMLVL_ERR,
6649 						    "%s failed with expected rc = %d but unexpected emask (%llx vs %llx)\n",
6650 						    szFuncName, 0, eventset,
6651 						    stat.dt_emask);
6652 					DMVAR_FAIL();
6653 				}
6654 			} else {
6655 				DMLOG_PRINT(DMLVL_ERR,
6656 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6657 					    szFuncName, rc, errno);
6658 				DMVAR_FAIL();
6659 			}
6660 
6661 			/* Variation clean up */
6662 			DMEV_ZERO(eventset);
6663 			rc |=
6664 			    dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
6665 					     &eventset, DM_EVENT_MAX);
6666 			rc |= close(fd);
6667 			rc |= remove(DUMMY_FILE);
6668 			if (rc == -1) {
6669 				DMLOG_PRINT(DMLVL_DEBUG,
6670 					    "Unable to clean up variation! (errno = %d)\n",
6671 					    errno);
6672 			}
6673 			dm_handle_free(hanp, hlen);
6674 		}
6675 	}
6676 
6677 	/*
6678 	 * TEST    : dm_get_fileattr - file DM_AT_PMANR with region
6679 	 * EXPECTED: rc = 0
6680 	 */
6681 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 8)) {
6682 		int fd;
6683 		void *hanp;
6684 		size_t hlen;
6685 		dm_stat_t stat;
6686 		dm_region_t region = { 0, 0, DM_REGION_READ };
6687 		dm_boolean_t exactflag;
6688 
6689 		/* Variation set up */
6690 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6691 		if ((rc = system(command)) == -1) {
6692 			/* No clean up */
6693 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6694 			remove(DUMMY_FILE);
6695 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6696 			close(fd);
6697 			remove(DUMMY_FILE);
6698 		} else
6699 		    if ((rc =
6700 			 dm_set_region(sid, hanp, hlen, DM_NO_TOKEN, 1, &region,
6701 				       &exactflag)) == -1) {
6702 			dm_handle_free(hanp, hlen);
6703 			close(fd);
6704 			remove(DUMMY_FILE);
6705 			close(fd);
6706 			remove(DUMMY_FILE);
6707 		}
6708 		if (fd == -1 || rc == -1) {
6709 			DMLOG_PRINT(DMLVL_DEBUG,
6710 				    "Unable to set up variation! (errno = %d)\n",
6711 				    errno);
6712 			DMVAR_SKIP();
6713 		} else {
6714 			/* Variation */
6715 			DMLOG_PRINT(DMLVL_DEBUG,
6716 				    "%s(file DM_AT_PMANR with region)\n",
6717 				    szFuncName);
6718 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6719 					     DM_AT_PMANR, &stat);
6720 			if (rc == 0) {
6721 				if (stat.dt_pmanreg == DM_TRUE) {
6722 					DMLOG_PRINT(DMLVL_DEBUG,
6723 						    "%s passed with expected rc = %d\n",
6724 						    szFuncName, 0);
6725 					DMVAR_PASS();
6726 				} else {
6727 					DMLOG_PRINT(DMLVL_ERR,
6728 						    "%s failed with expected rc = %d but unexpected pmanreg (%d vs %d)\n",
6729 						    szFuncName, 0, DM_TRUE,
6730 						    stat.dt_pmanreg);
6731 					DMVAR_FAIL();
6732 				}
6733 			} else {
6734 				DMLOG_PRINT(DMLVL_ERR,
6735 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6736 					    szFuncName, rc, errno);
6737 				DMVAR_FAIL();
6738 			}
6739 
6740 			/* Variation clean up */
6741 			rc = close(fd);
6742 			rc |= remove(DUMMY_FILE);
6743 			if (rc == -1) {
6744 				DMLOG_PRINT(DMLVL_DEBUG,
6745 					    "Unable to clean up variation! (errno = %d)\n",
6746 					    errno);
6747 			}
6748 			dm_handle_free(hanp, hlen);
6749 		}
6750 	}
6751 
6752 	/*
6753 	 * TEST    : dm_get_fileattr - file DM_AT_PMANR without region
6754 	 * EXPECTED: rc = 0
6755 	 */
6756 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 9)) {
6757 		int fd;
6758 		void *hanp;
6759 		size_t hlen;
6760 		dm_stat_t stat;
6761 
6762 		/* Variation set up */
6763 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6764 		if ((rc = system(command)) == -1) {
6765 			/* No clean up */
6766 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6767 			remove(DUMMY_FILE);
6768 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6769 			close(fd);
6770 			remove(DUMMY_FILE);
6771 		}
6772 		if (fd == -1 || rc == -1) {
6773 			DMLOG_PRINT(DMLVL_DEBUG,
6774 				    "Unable to set up variation! (errno = %d)\n",
6775 				    errno);
6776 			DMVAR_SKIP();
6777 		} else {
6778 			/* Variation */
6779 			DMLOG_PRINT(DMLVL_DEBUG,
6780 				    "%s(file DM_AT_PMANR without region)\n",
6781 				    szFuncName);
6782 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6783 					     DM_AT_PMANR, &stat);
6784 			if (rc == 0) {
6785 				if (stat.dt_pmanreg == DM_FALSE) {
6786 					DMLOG_PRINT(DMLVL_DEBUG,
6787 						    "%s passed with expected rc = %d\n",
6788 						    szFuncName, 0);
6789 					DMVAR_PASS();
6790 				} else {
6791 					DMLOG_PRINT(DMLVL_ERR,
6792 						    "%s failed with expected rc = %d but unexpected pmanreg (%d vs %d)\n",
6793 						    szFuncName, 0, DM_FALSE,
6794 						    stat.dt_pmanreg);
6795 					DMVAR_FAIL();
6796 				}
6797 			} else {
6798 				DMLOG_PRINT(DMLVL_ERR,
6799 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6800 					    szFuncName, rc, errno);
6801 				DMVAR_FAIL();
6802 			}
6803 
6804 			/* Variation clean up */
6805 			rc = close(fd);
6806 			rc |= remove(DUMMY_FILE);
6807 			if (rc == -1) {
6808 				DMLOG_PRINT(DMLVL_DEBUG,
6809 					    "Unable to clean up variation! (errno = %d)\n",
6810 					    errno);
6811 			}
6812 			dm_handle_free(hanp, hlen);
6813 		}
6814 	}
6815 
6816 	/*
6817 	 * TEST    : dm_get_fileattr - file DM_AT_PATTR with DM attribute
6818 	 * EXPECTED: rc = 0
6819 	 */
6820 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 10)) {
6821 		int fd;
6822 		void *hanp;
6823 		size_t hlen;
6824 		dm_stat_t stat;
6825 		dm_attrname_t attrname;
6826 		char buf[ATTR_VALUELEN];
6827 
6828 		/* Variation set up */
6829 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
6830 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
6831 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
6832 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6833 		if ((rc = system(command)) == -1) {
6834 			/* No clean up */
6835 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6836 			remove(DUMMY_FILE);
6837 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6838 			close(fd);
6839 			remove(DUMMY_FILE);
6840 		} else
6841 		    if ((rc =
6842 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
6843 				       0, sizeof(buf), buf)) == -1) {
6844 			dm_handle_free(hanp, hlen);
6845 			close(fd);
6846 			remove(DUMMY_FILE);
6847 		}
6848 		if (fd == -1 || rc == -1) {
6849 			DMLOG_PRINT(DMLVL_DEBUG,
6850 				    "Unable to set up variation! (errno = %d)\n",
6851 				    errno);
6852 			DMVAR_SKIP();
6853 		} else {
6854 			/* Variation */
6855 			DMLOG_PRINT(DMLVL_DEBUG,
6856 				    "%s(file DM_AT_PATTR with attr)\n",
6857 				    szFuncName);
6858 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6859 					     DM_AT_PATTR, &stat);
6860 			if (rc == 0) {
6861 				if (stat.dt_pers == DM_TRUE) {
6862 					DMLOG_PRINT(DMLVL_DEBUG,
6863 						    "%s passed with expected rc = %d\n",
6864 						    szFuncName, 0);
6865 					DMVAR_PASS();
6866 				} else {
6867 					DMLOG_PRINT(DMLVL_ERR,
6868 						    "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
6869 						    szFuncName, 0, DM_TRUE,
6870 						    stat.dt_pers);
6871 					DMVAR_FAIL();
6872 				}
6873 			} else {
6874 				DMLOG_PRINT(DMLVL_ERR,
6875 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6876 					    szFuncName, rc, errno);
6877 				DMVAR_FAIL();
6878 			}
6879 
6880 			/* Variation clean up */
6881 			rc = close(fd);
6882 			rc |= remove(DUMMY_FILE);
6883 			if (rc == -1) {
6884 				DMLOG_PRINT(DMLVL_DEBUG,
6885 					    "Unable to clean up variation! (errno = %d)\n",
6886 					    errno);
6887 			}
6888 			dm_handle_free(hanp, hlen);
6889 		}
6890 	}
6891 
6892 	/*
6893 	 * TEST    : dm_get_fileattr - file DM_AT_PATTR without DM attribute
6894 	 * EXPECTED: rc = 0
6895 	 */
6896 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 11)) {
6897 		int fd;
6898 		void *hanp;
6899 		size_t hlen;
6900 		dm_stat_t stat;
6901 
6902 		/* Variation set up */
6903 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6904 		if ((rc = system(command)) == -1) {
6905 			/* No clean up */
6906 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6907 			remove(DUMMY_FILE);
6908 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6909 			close(fd);
6910 			remove(DUMMY_FILE);
6911 		}
6912 		if (fd == -1 || rc == -1) {
6913 			DMLOG_PRINT(DMLVL_DEBUG,
6914 				    "Unable to set up variation! (errno = %d)\n",
6915 				    errno);
6916 			DMVAR_SKIP();
6917 		} else {
6918 			/* Variation */
6919 			DMLOG_PRINT(DMLVL_DEBUG,
6920 				    "%s(file DM_AT_PATTR without attr)\n",
6921 				    szFuncName);
6922 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
6923 					     DM_AT_PATTR, &stat);
6924 			if (rc == 0) {
6925 				if (stat.dt_pers == DM_FALSE) {
6926 					DMLOG_PRINT(DMLVL_DEBUG,
6927 						    "%s passed with expected rc = %d\n",
6928 						    szFuncName, 0);
6929 					DMVAR_PASS();
6930 				} else {
6931 					DMLOG_PRINT(DMLVL_ERR,
6932 						    "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
6933 						    szFuncName, 0, DM_FALSE,
6934 						    stat.dt_pers);
6935 					DMVAR_FAIL();
6936 				}
6937 			} else {
6938 				DMLOG_PRINT(DMLVL_ERR,
6939 					    "%s failed with unexpected rc = %d (errno = %d)\n",
6940 					    szFuncName, rc, errno);
6941 				DMVAR_FAIL();
6942 			}
6943 
6944 			/* Variation clean up */
6945 			rc = close(fd);
6946 			rc |= remove(DUMMY_FILE);
6947 			if (rc == -1) {
6948 				DMLOG_PRINT(DMLVL_DEBUG,
6949 					    "Unable to clean up variation! (errno = %d)\n",
6950 					    errno);
6951 			}
6952 			dm_handle_free(hanp, hlen);
6953 		}
6954 	}
6955 
6956 	/*
6957 	 * TEST    : dm_get_fileattr - file DM_AT_DTIME with DM attribute
6958 	 * EXPECTED: rc = 0
6959 	 */
6960 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 12)) {
6961 		int fd;
6962 		void *hanp;
6963 		size_t hlen;
6964 		dm_stat_t stat;
6965 		dm_attrname_t attrname;
6966 		char buf[ATTR_VALUELEN];
6967 
6968 		/* Variation set up */
6969 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
6970 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
6971 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
6972 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
6973 		if ((rc = system(command)) == -1) {
6974 			/* No clean up */
6975 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
6976 			remove(DUMMY_FILE);
6977 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
6978 			close(fd);
6979 			remove(DUMMY_FILE);
6980 		} else
6981 		    if ((rc =
6982 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
6983 				       0, sizeof(buf), buf)) == -1) {
6984 			dm_handle_free(hanp, hlen);
6985 			close(fd);
6986 			remove(DUMMY_FILE);
6987 		}
6988 		if (fd == -1 || rc == -1) {
6989 			DMLOG_PRINT(DMLVL_DEBUG,
6990 				    "Unable to set up variation! (errno = %d)\n",
6991 				    errno);
6992 			DMVAR_SKIP();
6993 		} else {
6994 			/* Variation */
6995 			stat.dt_dtime = 0;
6996 			DMLOG_PRINT(DMLVL_DEBUG,
6997 				    "%s(file DM_AT_DTIME with attr)\n",
6998 				    szFuncName);
6999 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7000 					     DM_AT_DTIME, &stat);
7001 			if (rc == 0) {
7002 				if (stat.dt_dtime != 0) {
7003 					DMLOG_PRINT(DMLVL_DEBUG,
7004 						    "%s passed with expected rc = %d\n",
7005 						    szFuncName, 0);
7006 					DMVAR_PASS();
7007 				} else {
7008 					DMLOG_PRINT(DMLVL_ERR,
7009 						    "%s failed with expected rc = %d but dtime not set\n",
7010 						    szFuncName, 0);
7011 					DMVAR_FAIL();
7012 				}
7013 			} else {
7014 				DMLOG_PRINT(DMLVL_ERR,
7015 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7016 					    szFuncName, rc, errno);
7017 				DMVAR_FAIL();
7018 			}
7019 
7020 			/* Variation clean up */
7021 			rc = close(fd);
7022 			rc |= remove(DUMMY_FILE);
7023 			if (rc == -1) {
7024 				DMLOG_PRINT(DMLVL_DEBUG,
7025 					    "Unable to clean up variation! (errno = %d)\n",
7026 					    errno);
7027 			}
7028 			dm_handle_free(hanp, hlen);
7029 		}
7030 	}
7031 
7032 	/*
7033 	 * TEST    : dm_get_fileattr - file DM_AT_DTIME without DM attribute
7034 	 * EXPECTED: rc = 0
7035 	 *
7036 	 * This variation uncovered XFS BUG #23 (dtime updated without any DM
7037 	 * attributes)
7038 	 */
7039 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 13)) {
7040 		int fd;
7041 		void *hanp;
7042 		size_t hlen;
7043 		dm_stat_t stat;
7044 
7045 		/* Variation set up */
7046 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
7047 		if ((rc = system(command)) == -1) {
7048 			/* No clean up */
7049 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
7050 			remove(DUMMY_FILE);
7051 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
7052 			close(fd);
7053 			remove(DUMMY_FILE);
7054 		}
7055 		if (fd == -1 || rc == -1) {
7056 			DMLOG_PRINT(DMLVL_DEBUG,
7057 				    "Unable to set up variation! (errno = %d)\n",
7058 				    errno);
7059 			DMVAR_SKIP();
7060 		} else {
7061 			/* Variation */
7062 			stat.dt_dtime = 0;
7063 			DMLOG_PRINT(DMLVL_DEBUG,
7064 				    "%s(file DM_AT_DTIME without attr)\n",
7065 				    szFuncName);
7066 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7067 					     DM_AT_DTIME, &stat);
7068 			if (rc == 0) {
7069 				if (stat.dt_dtime == 0) {
7070 					DMLOG_PRINT(DMLVL_DEBUG,
7071 						    "%s passed with expected rc = %d\n",
7072 						    szFuncName, 0);
7073 					DMVAR_PASS();
7074 				} else {
7075 					DMLOG_PRINT(DMLVL_ERR,
7076 						    "%s failed with expected rc = %d but dtime set\n",
7077 						    szFuncName, 0);
7078 					DMVAR_FAIL();
7079 				}
7080 			} else {
7081 				DMLOG_PRINT(DMLVL_ERR,
7082 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7083 					    szFuncName, rc, errno);
7084 				DMVAR_FAIL();
7085 			}
7086 
7087 			/* Variation clean up */
7088 			rc = close(fd);
7089 			rc |= remove(DUMMY_FILE);
7090 			if (rc == -1) {
7091 				DMLOG_PRINT(DMLVL_DEBUG,
7092 					    "Unable to clean up variation! (errno = %d)\n",
7093 					    errno);
7094 			}
7095 			dm_handle_free(hanp, hlen);
7096 		}
7097 	}
7098 
7099 	/*
7100 	 * TEST    : dm_get_fileattr - file DM_AT_STAT
7101 	 * EXPECTED: rc = 0
7102 	 */
7103 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 14)) {
7104 		int fd;
7105 		void *hanp;
7106 		size_t hlen;
7107 		dm_stat_t statdm;
7108 		struct stat statfs;
7109 		int varStatus;
7110 
7111 		/* Variation set up */
7112 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
7113 		if ((rc = system(command)) == -1) {
7114 			/* No clean up */
7115 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
7116 			remove(DUMMY_FILE);
7117 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
7118 			close(fd);
7119 			remove(DUMMY_FILE);
7120 		} else if ((rc = stat(DUMMY_FILE, &statfs)) == -1) {
7121 			dm_handle_free(hanp, hlen);
7122 			close(fd);
7123 			remove(DUMMY_FILE);
7124 		}
7125 		if (fd == -1 || rc == -1) {
7126 			DMLOG_PRINT(DMLVL_DEBUG,
7127 				    "Unable to set up variation! (errno = %d)\n",
7128 				    errno);
7129 			DMVAR_SKIP();
7130 		} else {
7131 			/* Variation */
7132 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file DM_AT_STAT)\n",
7133 				    szFuncName);
7134 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7135 					     DM_AT_STAT, &statdm);
7136 			if (rc == 0) {
7137 				varStatus = DMSTAT_PASS;
7138 				DMLOG_PRINT(DMLVL_DEBUG,
7139 					    "%s returned expected rc = %d\n",
7140 					    szFuncName, rc);
7141 				if (statfs.st_dev != statdm.dt_dev) {
7142 					DMLOG_PRINT(DMLVL_ERR,
7143 						    "%s failed with nonmatching dev (%lld vs %lld)\n",
7144 						    szFuncName, statfs.st_dev,
7145 						    statdm.dt_dev);
7146 					varStatus = DMSTAT_FAIL;
7147 				}
7148 				if (statfs.st_ino != statdm.dt_ino) {
7149 					DMLOG_PRINT(DMLVL_ERR,
7150 						    "%s failed with nonmatching ino (%lld vs %lld)\n",
7151 						    szFuncName, statfs.st_ino,
7152 						    statdm.dt_ino);
7153 					varStatus = DMSTAT_FAIL;
7154 				}
7155 				if (statfs.st_mode != statdm.dt_mode) {
7156 					DMLOG_PRINT(DMLVL_ERR,
7157 						    "%s failed with nonmatching mode (%d vs %d)\n",
7158 						    szFuncName, statfs.st_mode,
7159 						    statdm.dt_mode);
7160 					varStatus = DMSTAT_FAIL;
7161 				}
7162 				if (statfs.st_nlink != statdm.dt_nlink) {
7163 					DMLOG_PRINT(DMLVL_ERR,
7164 						    "%s failed with nonmatching nlink (%d vs %d)\n",
7165 						    szFuncName, statfs.st_nlink,
7166 						    statdm.dt_nlink);
7167 					varStatus = DMSTAT_FAIL;
7168 				}
7169 				if (statfs.st_uid != statdm.dt_uid) {
7170 					DMLOG_PRINT(DMLVL_ERR,
7171 						    "%s failed with nonmatching uid (%d vs %d)\n",
7172 						    szFuncName, statfs.st_uid,
7173 						    statdm.dt_uid);
7174 					varStatus = DMSTAT_FAIL;
7175 				}
7176 				if (statfs.st_gid != statdm.dt_gid) {
7177 					DMLOG_PRINT(DMLVL_ERR,
7178 						    "%s failed with nonmatching gid (%d vs %d)\n",
7179 						    szFuncName, statfs.st_gid,
7180 						    statdm.dt_gid);
7181 					varStatus = DMSTAT_FAIL;
7182 				}
7183 				if (statfs.st_rdev != statdm.dt_rdev) {
7184 					DMLOG_PRINT(DMLVL_ERR,
7185 						    "%s failed with nonmatching rdev (%lld vs %lld)\n",
7186 						    szFuncName, statfs.st_rdev,
7187 						    statdm.dt_rdev);
7188 					varStatus = DMSTAT_FAIL;
7189 				}
7190 				if (statfs.st_size != statdm.dt_size) {
7191 					DMLOG_PRINT(DMLVL_ERR,
7192 						    "%s failed with nonmatching size (%lld vs %lld)\n",
7193 						    szFuncName, statfs.st_size,
7194 						    statdm.dt_size);
7195 					varStatus = DMSTAT_FAIL;
7196 				}
7197 				if (statfs.st_atime != statdm.dt_atime) {
7198 					DMLOG_PRINT(DMLVL_ERR,
7199 						    "%s failed with nonmatching atime (%d vs %d)\n",
7200 						    szFuncName, statfs.st_atime,
7201 						    statdm.dt_atime);
7202 					varStatus = DMSTAT_FAIL;
7203 				}
7204 				if (statfs.st_mtime != statdm.dt_mtime) {
7205 					DMLOG_PRINT(DMLVL_ERR,
7206 						    "%s failed with nonmatching mtime (%d vs %d)\n",
7207 						    szFuncName, statfs.st_mtime,
7208 						    statdm.dt_mtime);
7209 					varStatus = DMSTAT_FAIL;
7210 				}
7211 				if (statfs.st_ctime != statdm.dt_ctime) {
7212 					DMLOG_PRINT(DMLVL_ERR,
7213 						    "%s failed with nonmatching ctime (%d vs %d)\n",
7214 						    szFuncName, statfs.st_ctime,
7215 						    statdm.dt_ctime);
7216 					varStatus = DMSTAT_FAIL;
7217 				}
7218 				if (statfs.st_blksize != statdm.dt_blksize) {
7219 					DMLOG_PRINT(DMLVL_ERR,
7220 						    "%s failed with nonmatching blksize (%d vs %d)\n",
7221 						    szFuncName,
7222 						    statfs.st_blksize,
7223 						    statdm.dt_blksize);
7224 					varStatus = DMSTAT_FAIL;
7225 				}
7226 				if (statfs.st_blocks != statdm.dt_blocks) {
7227 					DMLOG_PRINT(DMLVL_ERR,
7228 						    "%s failed with nonmatching blocks (%lld vs %lld)\n",
7229 						    szFuncName,
7230 						    statfs.st_blocks,
7231 						    statdm.dt_blocks);
7232 					varStatus = DMSTAT_FAIL;
7233 				}
7234 			} else {
7235 				DMLOG_PRINT(DMLVL_ERR,
7236 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7237 					    szFuncName, rc, errno);
7238 				varStatus = DMSTAT_FAIL;
7239 			}
7240 			DMVAR_END(varStatus);
7241 
7242 			/* Variation clean up */
7243 			rc = close(fd);
7244 			rc |= remove(DUMMY_FILE);
7245 			if (rc == -1) {
7246 				DMLOG_PRINT(DMLVL_DEBUG,
7247 					    "Unable to clean up variation! (errno = %d)\n",
7248 					    errno);
7249 			}
7250 			dm_handle_free(hanp, hlen);
7251 		}
7252 	}
7253 
7254 	/*
7255 	 * TEST    : dm_get_fileattr - DM_AT_EMASK on directory
7256 	 * EXPECTED: rc = 0
7257 	 */
7258 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 15)) {
7259 		void *hanp;
7260 		size_t hlen;
7261 		dm_stat_t stat;
7262 		dm_eventset_t eventset;
7263 
7264 		/* Variation set up */
7265 		DMEV_ZERO(eventset);
7266 		DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
7267 		DMEV_SET(DM_EVENT_CLOSE, eventset);
7268 		DMEV_SET(DM_EVENT_DESTROY, eventset);
7269 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7270 			/* No clean up */
7271 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7272 			   == -1) {
7273 			rmdir(DUMMY_SUBDIR);
7274 		} else
7275 		    if ((rc =
7276 			 dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
7277 					  &eventset, DM_EVENT_MAX)) == -1) {
7278 			dm_handle_free(hanp, hlen);
7279 			rmdir(DUMMY_SUBDIR);
7280 		}
7281 		if (rc == -1) {
7282 			DMLOG_PRINT(DMLVL_DEBUG,
7283 				    "Unable to set up variation! (errno = %d)\n",
7284 				    errno);
7285 			DMVAR_SKIP();
7286 		} else {
7287 			/* Variation */
7288 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_EMASK)\n",
7289 				    szFuncName);
7290 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7291 					     DM_AT_EMASK, &stat);
7292 			if (rc == 0) {
7293 				if (memcmp
7294 				    (&eventset, &stat.dt_emask,
7295 				     sizeof(dm_eventset_t)) == 0) {
7296 					DMLOG_PRINT(DMLVL_DEBUG,
7297 						    "%s passed with expected rc = %d\n",
7298 						    szFuncName, 0);
7299 					DMVAR_PASS();
7300 				} else {
7301 					DMLOG_PRINT(DMLVL_ERR,
7302 						    "%s failed with expected rc = %d but unexpected emask (%llx vs %llx)\n",
7303 						    szFuncName, 0, eventset,
7304 						    stat.dt_emask);
7305 					DMVAR_FAIL();
7306 				}
7307 			} else {
7308 				DMLOG_PRINT(DMLVL_ERR,
7309 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7310 					    szFuncName, rc, errno);
7311 				DMVAR_FAIL();
7312 			}
7313 
7314 			/* Variation clean up */
7315 			DMEV_ZERO(eventset);
7316 			rc |=
7317 			    dm_set_eventlist(sid, hanp, hlen, DM_NO_TOKEN,
7318 					     &eventset, DM_EVENT_MAX);
7319 			rc = rmdir(DUMMY_SUBDIR);
7320 			if (rc == -1) {
7321 				DMLOG_PRINT(DMLVL_DEBUG,
7322 					    "Unable to clean up variation! (errno = %d)\n",
7323 					    errno);
7324 			}
7325 			dm_handle_free(hanp, hlen);
7326 		}
7327 	}
7328 
7329 	/*
7330 	 * TEST    : dm_get_fileattr - DM_AT_PMANR on directory
7331 	 * EXPECTED: rc = 0
7332 	 */
7333 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 16)) {
7334 		void *hanp;
7335 		size_t hlen;
7336 		dm_stat_t stat;
7337 
7338 		/* Variation set up */
7339 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7340 			/* No clean up */
7341 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7342 			   == -1) {
7343 			rmdir(DUMMY_SUBDIR);
7344 		}
7345 		if (rc == -1) {
7346 			DMLOG_PRINT(DMLVL_DEBUG,
7347 				    "Unable to set up variation! (errno = %d)\n",
7348 				    errno);
7349 			DMVAR_SKIP();
7350 		} else {
7351 			/* Variation */
7352 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_PMANR)\n",
7353 				    szFuncName);
7354 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7355 					     DM_AT_PMANR, &stat);
7356 			if (rc == 0) {
7357 				if (stat.dt_pmanreg == DM_FALSE) {
7358 					DMLOG_PRINT(DMLVL_DEBUG,
7359 						    "%s passed with expected rc = %d\n",
7360 						    szFuncName, 0);
7361 					DMVAR_PASS();
7362 				} else {
7363 					DMLOG_PRINT(DMLVL_ERR,
7364 						    "%s failed with expected rc = %d but unexpected pmanreg (%d vs %d)\n",
7365 						    szFuncName, 0, DM_FALSE,
7366 						    stat.dt_pmanreg);
7367 					DMVAR_FAIL();
7368 				}
7369 			} else {
7370 				DMLOG_PRINT(DMLVL_ERR,
7371 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7372 					    szFuncName, rc, errno);
7373 				DMVAR_FAIL();
7374 			}
7375 
7376 			/* Variation clean up */
7377 			rc = rmdir(DUMMY_SUBDIR);
7378 			if (rc == -1) {
7379 				DMLOG_PRINT(DMLVL_DEBUG,
7380 					    "Unable to clean up variation! (errno = %d)\n",
7381 					    errno);
7382 			}
7383 			dm_handle_free(hanp, hlen);
7384 		}
7385 	}
7386 
7387 	/*
7388 	 * TEST    : dm_get_fileattr - DM_AT_PATTR on directory with DM attribute
7389 	 * EXPECTED: rc = 0
7390 	 */
7391 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 17)) {
7392 		void *hanp;
7393 		size_t hlen;
7394 		dm_stat_t stat;
7395 		dm_attrname_t attrname;
7396 		char buf[ATTR_VALUELEN];
7397 
7398 		/* Variation set up */
7399 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
7400 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
7401 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
7402 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7403 			/* No clean up */
7404 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7405 			   == -1) {
7406 			rmdir(DUMMY_SUBDIR);
7407 		} else
7408 		    if ((rc =
7409 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
7410 				       0, sizeof(buf), buf)) == -1) {
7411 			dm_handle_free(hanp, hlen);
7412 			rmdir(DUMMY_SUBDIR);
7413 		}
7414 		if (rc == -1) {
7415 			DMLOG_PRINT(DMLVL_DEBUG,
7416 				    "Unable to set up variation! (errno = %d)\n",
7417 				    errno);
7418 			DMVAR_SKIP();
7419 		} else {
7420 			/* Variation */
7421 			DMLOG_PRINT(DMLVL_DEBUG,
7422 				    "%s(dir DM_AT_PATTR with attr)\n",
7423 				    szFuncName);
7424 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7425 					     DM_AT_PATTR, &stat);
7426 			if (rc == 0) {
7427 				if (stat.dt_pers == DM_TRUE) {
7428 					DMLOG_PRINT(DMLVL_DEBUG,
7429 						    "%s passed with expected rc = %d\n",
7430 						    szFuncName, 0);
7431 					DMVAR_PASS();
7432 				} else {
7433 					DMLOG_PRINT(DMLVL_ERR,
7434 						    "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
7435 						    szFuncName, 0, DM_TRUE,
7436 						    stat.dt_pers);
7437 					DMVAR_FAIL();
7438 				}
7439 			} else {
7440 				DMLOG_PRINT(DMLVL_ERR,
7441 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7442 					    szFuncName, rc, errno);
7443 				DMVAR_FAIL();
7444 			}
7445 
7446 			/* Variation clean up */
7447 			rc = rmdir(DUMMY_SUBDIR);
7448 			if (rc == -1) {
7449 				DMLOG_PRINT(DMLVL_DEBUG,
7450 					    "Unable to clean up variation! (errno = %d)\n",
7451 					    errno);
7452 			}
7453 			dm_handle_free(hanp, hlen);
7454 		}
7455 	}
7456 
7457 	/*
7458 	 * TEST    : dm_get_fileattr - DM_AT_PATTR on directory without DM attribute
7459 	 * EXPECTED: rc = 0
7460 	 */
7461 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 18)) {
7462 		void *hanp;
7463 		size_t hlen;
7464 		dm_stat_t stat;
7465 
7466 		/* Variation set up */
7467 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7468 			/* No clean up */
7469 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7470 			   == -1) {
7471 			rmdir(DUMMY_SUBDIR);
7472 		}
7473 		if (rc == -1) {
7474 			DMLOG_PRINT(DMLVL_DEBUG,
7475 				    "Unable to set up variation! (errno = %d)\n",
7476 				    errno);
7477 			DMVAR_SKIP();
7478 		} else {
7479 			/* Variation */
7480 			DMLOG_PRINT(DMLVL_DEBUG,
7481 				    "%s(dir DM_AT_PATTR without attr)\n",
7482 				    szFuncName);
7483 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7484 					     DM_AT_PATTR, &stat);
7485 			if (rc == 0) {
7486 				if (stat.dt_pers == DM_FALSE) {
7487 					DMLOG_PRINT(DMLVL_DEBUG,
7488 						    "%s passed with expected rc = %d\n",
7489 						    szFuncName, 0);
7490 					DMVAR_PASS();
7491 				} else {
7492 					DMLOG_PRINT(DMLVL_ERR,
7493 						    "%s failed with expected rc = %d but unexpected pers (%d vs %d)\n",
7494 						    szFuncName, 0, DM_FALSE,
7495 						    stat.dt_pers);
7496 					DMVAR_FAIL();
7497 				}
7498 			} else {
7499 				DMLOG_PRINT(DMLVL_ERR,
7500 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7501 					    szFuncName, rc, errno);
7502 				DMVAR_FAIL();
7503 			}
7504 
7505 			/* Variation clean up */
7506 			rc = rmdir(DUMMY_SUBDIR);
7507 			if (rc == -1) {
7508 				DMLOG_PRINT(DMLVL_DEBUG,
7509 					    "Unable to clean up variation! (errno = %d)\n",
7510 					    errno);
7511 			}
7512 			dm_handle_free(hanp, hlen);
7513 		}
7514 	}
7515 
7516 	/*
7517 	 * TEST    : dm_get_fileattr - DM_AT_DTIME on directory with DM attribute
7518 	 * EXPECTED: rc = 0
7519 	 */
7520 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 19)) {
7521 		void *hanp;
7522 		size_t hlen;
7523 		dm_stat_t stat;
7524 		dm_attrname_t attrname;
7525 		char buf[ATTR_VALUELEN];
7526 
7527 		/* Variation set up */
7528 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
7529 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
7530 		memcpy(buf, ATTR_VALUE, ATTR_VALUELEN);
7531 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7532 			/* No clean up */
7533 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7534 			   == -1) {
7535 			rmdir(DUMMY_SUBDIR);
7536 		} else
7537 		    if ((rc =
7538 			 dm_set_dmattr(sid, hanp, hlen, DM_NO_TOKEN, &attrname,
7539 				       0, sizeof(buf), buf)) == -1) {
7540 			dm_handle_free(hanp, hlen);
7541 			rmdir(DUMMY_SUBDIR);
7542 		}
7543 		if (rc == -1) {
7544 			DMLOG_PRINT(DMLVL_DEBUG,
7545 				    "Unable to set up variation! (errno = %d)\n",
7546 				    errno);
7547 			DMVAR_SKIP();
7548 		} else {
7549 			/* Variation */
7550 			stat.dt_dtime = 0;
7551 			DMLOG_PRINT(DMLVL_DEBUG,
7552 				    "%s(dir DM_AT_DTIME with attr)\n",
7553 				    szFuncName);
7554 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7555 					     DM_AT_DTIME, &stat);
7556 			if (rc == 0) {
7557 				if (stat.dt_dtime != 0) {
7558 					DMLOG_PRINT(DMLVL_DEBUG,
7559 						    "%s passed with expected rc = %d\n",
7560 						    szFuncName, 0);
7561 					DMVAR_PASS();
7562 				} else {
7563 					DMLOG_PRINT(DMLVL_ERR,
7564 						    "%s failed with expected rc = %d but dtime not set\n",
7565 						    szFuncName, 0);
7566 					DMVAR_FAIL();
7567 				}
7568 			} else {
7569 				DMLOG_PRINT(DMLVL_ERR,
7570 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7571 					    szFuncName, rc, errno);
7572 				DMVAR_FAIL();
7573 			}
7574 
7575 			/* Variation clean up */
7576 			rc = rmdir(DUMMY_SUBDIR);
7577 			if (rc == -1) {
7578 				DMLOG_PRINT(DMLVL_DEBUG,
7579 					    "Unable to clean up variation! (errno = %d)\n",
7580 					    errno);
7581 			}
7582 			dm_handle_free(hanp, hlen);
7583 		}
7584 	}
7585 
7586 	/*
7587 	 * TEST    : dm_get_fileattr - DM_AT_DTIME on directory without DM attribute
7588 	 * EXPECTED: rc = 0
7589 	 */
7590 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 20)) {
7591 		void *hanp;
7592 		size_t hlen;
7593 		dm_stat_t stat;
7594 
7595 		/* Variation set up */
7596 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7597 			/* No clean up */
7598 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7599 			   == -1) {
7600 			rmdir(DUMMY_SUBDIR);
7601 		}
7602 		if (rc == -1) {
7603 			DMLOG_PRINT(DMLVL_DEBUG,
7604 				    "Unable to set up variation! (errno = %d)\n",
7605 				    errno);
7606 			DMVAR_SKIP();
7607 		} else {
7608 			/* Variation */
7609 			stat.dt_dtime = 0;
7610 			DMLOG_PRINT(DMLVL_DEBUG,
7611 				    "%s(dir DM_AT_DTIME without attr)\n",
7612 				    szFuncName);
7613 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7614 					     DM_AT_DTIME, &stat);
7615 			if (rc == 0) {
7616 				if (stat.dt_dtime == 0) {
7617 					DMLOG_PRINT(DMLVL_DEBUG,
7618 						    "%s passed with expected rc = %d\n",
7619 						    szFuncName, 0);
7620 					DMVAR_PASS();
7621 				} else {
7622 					DMLOG_PRINT(DMLVL_ERR,
7623 						    "%s failed with expected rc = %d but dtime set\n",
7624 						    szFuncName, 0);
7625 					DMVAR_FAIL();
7626 				}
7627 			} else {
7628 				DMLOG_PRINT(DMLVL_ERR,
7629 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7630 					    szFuncName, rc, errno);
7631 				DMVAR_FAIL();
7632 			}
7633 
7634 			/* Variation clean up */
7635 			rc = rmdir(DUMMY_SUBDIR);
7636 			if (rc == -1) {
7637 				DMLOG_PRINT(DMLVL_DEBUG,
7638 					    "Unable to clean up variation! (errno = %d)\n",
7639 					    errno);
7640 			}
7641 			dm_handle_free(hanp, hlen);
7642 		}
7643 	}
7644 
7645 	/*
7646 	 * TEST    : dm_get_fileattr - DM_AT_STAT on directory
7647 	 * EXPECTED: rc = 0
7648 	 */
7649 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 21)) {
7650 		void *hanp;
7651 		size_t hlen;
7652 		dm_stat_t statdm;
7653 		struct stat statfs;
7654 		int varStatus;
7655 
7656 		/* Variation set up */
7657 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7658 			/* No clean up */
7659 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7660 			   == -1) {
7661 			rmdir(DUMMY_SUBDIR);
7662 		} else if ((rc = stat(DUMMY_SUBDIR, &statfs)) == -1) {
7663 			dm_handle_free(hanp, hlen);
7664 			rmdir(DUMMY_SUBDIR);
7665 		}
7666 		if (rc == -1) {
7667 			DMLOG_PRINT(DMLVL_DEBUG,
7668 				    "Unable to set up variation! (errno = %d)\n",
7669 				    errno);
7670 			DMVAR_SKIP();
7671 		} else {
7672 			/* Variation */
7673 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir DM_AT_STAT)\n",
7674 				    szFuncName);
7675 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7676 					     DM_AT_STAT, &statdm);
7677 			if (rc == 0) {
7678 				varStatus = DMSTAT_PASS;
7679 				DMLOG_PRINT(DMLVL_DEBUG,
7680 					    "%s returned expected rc = %d\n",
7681 					    szFuncName, rc);
7682 				if (statfs.st_dev != statdm.dt_dev) {
7683 					DMLOG_PRINT(DMLVL_ERR,
7684 						    "%s failed with nonmatching dev (%lld vs %lld)\n",
7685 						    szFuncName, statfs.st_dev,
7686 						    statdm.dt_dev);
7687 					varStatus = DMSTAT_FAIL;
7688 				}
7689 				if (statfs.st_ino != statdm.dt_ino) {
7690 					DMLOG_PRINT(DMLVL_ERR,
7691 						    "%s failed with nonmatching ino (%lld vs %lld)\n",
7692 						    szFuncName, statfs.st_ino,
7693 						    statdm.dt_ino);
7694 					varStatus = DMSTAT_FAIL;
7695 				}
7696 				if (statfs.st_mode != statdm.dt_mode) {
7697 					DMLOG_PRINT(DMLVL_ERR,
7698 						    "%s failed with nonmatching mode (%d vs %d)\n",
7699 						    szFuncName, statfs.st_mode,
7700 						    statdm.dt_mode);
7701 					varStatus = DMSTAT_FAIL;
7702 				}
7703 				if (statfs.st_nlink != statdm.dt_nlink) {
7704 					DMLOG_PRINT(DMLVL_ERR,
7705 						    "%s failed with nonmatching nlink (%d vs %d)\n",
7706 						    szFuncName, statfs.st_nlink,
7707 						    statdm.dt_nlink);
7708 					varStatus = DMSTAT_FAIL;
7709 				}
7710 				if (statfs.st_uid != statdm.dt_uid) {
7711 					DMLOG_PRINT(DMLVL_ERR,
7712 						    "%s failed with nonmatching uid (%d vs %d)\n",
7713 						    szFuncName, statfs.st_uid,
7714 						    statdm.dt_uid);
7715 					varStatus = DMSTAT_FAIL;
7716 				}
7717 				if (statfs.st_gid != statdm.dt_gid) {
7718 					DMLOG_PRINT(DMLVL_ERR,
7719 						    "%s failed with nonmatching gid (%d vs %d)\n",
7720 						    szFuncName, statfs.st_gid,
7721 						    statdm.dt_gid);
7722 					varStatus = DMSTAT_FAIL;
7723 				}
7724 				if (statfs.st_rdev != statdm.dt_rdev) {
7725 					DMLOG_PRINT(DMLVL_ERR,
7726 						    "%s failed with nonmatching rdev (%lld vs %lld)\n",
7727 						    szFuncName, statfs.st_rdev,
7728 						    statdm.dt_rdev);
7729 					varStatus = DMSTAT_FAIL;
7730 				}
7731 				if (statfs.st_size != statdm.dt_size) {
7732 					DMLOG_PRINT(DMLVL_ERR,
7733 						    "%s failed with nonmatching size (%lld vs %lld)\n",
7734 						    szFuncName, statfs.st_size,
7735 						    statdm.dt_size);
7736 					varStatus = DMSTAT_FAIL;
7737 				}
7738 				if (statfs.st_atime != statdm.dt_atime) {
7739 					DMLOG_PRINT(DMLVL_ERR,
7740 						    "%s failed with nonmatching atime (%d vs %d)\n",
7741 						    szFuncName, statfs.st_atime,
7742 						    statdm.dt_atime);
7743 					varStatus = DMSTAT_FAIL;
7744 				}
7745 				if (statfs.st_mtime != statdm.dt_mtime) {
7746 					DMLOG_PRINT(DMLVL_ERR,
7747 						    "%s failed with nonmatching mtime (%d vs %d)\n",
7748 						    szFuncName, statfs.st_mtime,
7749 						    statdm.dt_mtime);
7750 					varStatus = DMSTAT_FAIL;
7751 				}
7752 				if (statfs.st_ctime != statdm.dt_ctime) {
7753 					DMLOG_PRINT(DMLVL_ERR,
7754 						    "%s failed with nonmatching ctime (%d vs %d)\n",
7755 						    szFuncName, statfs.st_ctime,
7756 						    statdm.dt_ctime);
7757 					varStatus = DMSTAT_FAIL;
7758 				}
7759 				if (statfs.st_blksize != statdm.dt_blksize) {
7760 					DMLOG_PRINT(DMLVL_ERR,
7761 						    "%s failed with nonmatching blksize (%d vs %d)\n",
7762 						    szFuncName,
7763 						    statfs.st_blksize,
7764 						    statdm.dt_blksize);
7765 					varStatus = DMSTAT_FAIL;
7766 				}
7767 				if (statfs.st_blocks != statdm.dt_blocks) {
7768 					DMLOG_PRINT(DMLVL_ERR,
7769 						    "%s failed with nonmatching blocks (%lld vs %lld)\n",
7770 						    szFuncName,
7771 						    statfs.st_blocks,
7772 						    statdm.dt_blocks);
7773 					varStatus = DMSTAT_FAIL;
7774 				}
7775 			} else {
7776 				DMLOG_PRINT(DMLVL_ERR,
7777 					    "%s failed with unexpected rc = %d (errno = %d)\n",
7778 					    szFuncName, rc, errno);
7779 				varStatus = DMSTAT_FAIL;
7780 			}
7781 			DMVAR_END(varStatus);
7782 
7783 			/* Variation clean up */
7784 			rc = rmdir(DUMMY_SUBDIR);
7785 			if (rc == -1) {
7786 				DMLOG_PRINT(DMLVL_DEBUG,
7787 					    "Unable to clean up variation! (errno = %d)\n",
7788 					    errno);
7789 			}
7790 			dm_handle_free(hanp, hlen);
7791 		}
7792 	}
7793 
7794 	/*
7795 	 * TEST    : dm_get_fileattr - fs handle
7796 	 * EXPECTED: rc = -1, errno = EINVAL
7797 	 */
7798 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 22)) {
7799 		void *hanp;
7800 		size_t hlen;
7801 		dm_stat_t stat;
7802 
7803 		/* Variation set up */
7804 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
7805 		if ((rc = system(command)) == -1) {
7806 			/* No clean up */
7807 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
7808 			   == -1) {
7809 			remove(DUMMY_FILE);
7810 		}
7811 		if (rc == -1) {
7812 			DMLOG_PRINT(DMLVL_DEBUG,
7813 				    "Unable to set up variation! (errno = %d)\n",
7814 				    errno);
7815 			DMVAR_SKIP();
7816 		} else {
7817 			/* Variation */
7818 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
7819 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7820 					     DM_AT_EMASK, &stat);
7821 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
7822 
7823 			/* Variation clean up */
7824 			rc = remove(DUMMY_FILE);
7825 			if (rc == -1) {
7826 				DMLOG_PRINT(DMLVL_DEBUG,
7827 					    "Unable to clean up variation! (errno = %d)\n",
7828 					    errno);
7829 			}
7830 			dm_handle_free(hanp, hlen);
7831 		}
7832 	}
7833 
7834 	/*
7835 	 * TEST    : dm_get_fileattr - DM_NO_SESSION sid
7836 	 * EXPECTED: rc = -1, errno = EINVAL
7837 	 */
7838 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 23)) {
7839 		int fd;
7840 		void *hanp;
7841 		size_t hlen;
7842 		dm_stat_t stat;
7843 
7844 		/* Variation set up */
7845 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
7846 		if ((rc = system(command)) == -1) {
7847 			/* No clean up */
7848 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
7849 			remove(DUMMY_FILE);
7850 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
7851 			close(fd);
7852 			remove(DUMMY_FILE);
7853 		}
7854 		if (fd == -1 || rc == -1) {
7855 			DMLOG_PRINT(DMLVL_DEBUG,
7856 				    "Unable to set up variation! (errno = %d)\n",
7857 				    errno);
7858 			DMVAR_SKIP();
7859 		} else {
7860 			/* Variation */
7861 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
7862 				    szFuncName);
7863 			rc = dm_get_fileattr(DM_NO_SESSION, hanp, hlen,
7864 					     DM_NO_TOKEN, DM_AT_EMASK, &stat);
7865 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
7866 
7867 			/* Variation clean up */
7868 			rc = close(fd);
7869 			rc |= remove(DUMMY_FILE);
7870 			if (rc == -1) {
7871 				DMLOG_PRINT(DMLVL_DEBUG,
7872 					    "Unable to clean up variation! (errno = %d)\n",
7873 					    errno);
7874 			}
7875 			dm_handle_free(hanp, hlen);
7876 		}
7877 	}
7878 
7879 	/*
7880 	 * TEST    : dm_get_fileattr - global handle
7881 	 * EXPECTED: rc = -1, errno = EBADF
7882 	 */
7883 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 24)) {
7884 		dm_stat_t stat;
7885 
7886 		/* Variation set up */
7887 
7888 		/* Variation */
7889 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
7890 		rc = dm_get_fileattr(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
7891 				     DM_NO_TOKEN, DM_AT_EMASK, &stat);
7892 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
7893 
7894 		/* Variation clean up */
7895 	}
7896 
7897 	/*
7898 	 * TEST    : dm_get_fileattr - invalidated hanp
7899 	 * EXPECTED: rc = -1, errno = EBADF
7900 	 */
7901 	if (DMVAR_EXEC(GET_FILEATTR_BASE + 25)) {
7902 		int fd;
7903 		void *hanp;
7904 		size_t hlen;
7905 		dm_stat_t stat;
7906 
7907 		/* Variation set up */
7908 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
7909 		if ((rc = system(command)) == -1) {
7910 			/* No clean up */
7911 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
7912 			remove(DUMMY_FILE);
7913 		} else if ((rc = dm_fd_to_handle(fd, &hanp, &hlen)) == -1) {
7914 			close(fd);
7915 			remove(DUMMY_FILE);
7916 		} else if ((rc = close(fd)) == -1) {
7917 			dm_handle_free(hanp, hlen);
7918 			remove(DUMMY_FILE);
7919 		} else if ((rc = remove(DUMMY_FILE)) == -1) {
7920 			dm_handle_free(hanp, hlen);
7921 		}
7922 		if (fd == -1 || rc == -1) {
7923 			DMLOG_PRINT(DMLVL_DEBUG,
7924 				    "Unable to set up variation! (errno = %d)\n",
7925 				    errno);
7926 			DMVAR_SKIP();
7927 		} else {
7928 			/* Variation */
7929 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
7930 				    szFuncName);
7931 			rc = dm_get_fileattr(sid, hanp, hlen, DM_NO_TOKEN,
7932 					     DM_AT_EMASK, &stat);
7933 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
7934 
7935 			/* Variation clean up */
7936 			dm_handle_free(hanp, hlen);
7937 		}
7938 	}
7939 
7940 	szFuncName = "dm_init_attrloc";
7941 
7942 	/*
7943 	 * TEST    : dm_init_attrloc - invalid sid
7944 	 * EXPECTED: rc = -1, errno = EINVAL
7945 	 */
7946 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 1)) {
7947 		void *hanp;
7948 		size_t hlen;
7949 		dm_attrloc_t loc;
7950 
7951 		/* Variation set up */
7952 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
7953 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7954 			/* No clean up */
7955 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
7956 			   == -1) {
7957 			rmdir(DUMMY_SUBDIR);
7958 		} else if ((rc = system(command)) == -1) {
7959 			dm_handle_free(hanp, hlen);
7960 			rmdir(DUMMY_SUBDIR);
7961 		}
7962 		if (rc == -1) {
7963 			DMLOG_PRINT(DMLVL_DEBUG,
7964 				    "Unable to set up variation! (errno = %d)\n",
7965 				    errno);
7966 			DMVAR_SKIP();
7967 		} else {
7968 			/* Variation */
7969 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
7970 				    szFuncName);
7971 			rc = dm_init_attrloc(INVALID_ADDR, hanp, hlen,
7972 					     DM_NO_TOKEN, &loc);
7973 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
7974 
7975 			/* Variation clean up */
7976 			rc = remove(DUMMY_SUBDIR_FILE);
7977 			rc |= rmdir(DUMMY_SUBDIR);
7978 			if (rc == -1) {
7979 				DMLOG_PRINT(DMLVL_DEBUG,
7980 					    "Unable to clean up variation! (errno = %d)\n",
7981 					    errno);
7982 			}
7983 			dm_handle_free(hanp, hlen);
7984 		}
7985 	}
7986 
7987 	/*
7988 	 * TEST    : dm_init_attrloc - invalid hanp
7989 	 * EXPECTED: rc = -1, errno = EFAULT
7990 	 */
7991 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 2)) {
7992 		void *hanp;
7993 		size_t hlen;
7994 		dm_attrloc_t loc;
7995 
7996 		/* Variation set up */
7997 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
7998 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
7999 			/* No clean up */
8000 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8001 			   == -1) {
8002 			rmdir(DUMMY_SUBDIR);
8003 		} else if ((rc = system(command)) == -1) {
8004 			dm_handle_free(hanp, hlen);
8005 			rmdir(DUMMY_SUBDIR);
8006 		}
8007 		if (rc == -1) {
8008 			DMLOG_PRINT(DMLVL_DEBUG,
8009 				    "Unable to set up variation! (errno = %d)\n",
8010 				    errno);
8011 			DMVAR_SKIP();
8012 		} else {
8013 			/* Variation */
8014 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
8015 				    szFuncName);
8016 			rc = dm_init_attrloc(sid, (void *)INVALID_ADDR, hlen,
8017 					     DM_NO_TOKEN, &loc);
8018 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
8019 
8020 			/* Variation clean up */
8021 			rc = remove(DUMMY_SUBDIR_FILE);
8022 			rc |= rmdir(DUMMY_SUBDIR);
8023 			if (rc == -1) {
8024 				DMLOG_PRINT(DMLVL_DEBUG,
8025 					    "Unable to clean up variation! (errno = %d)\n",
8026 					    errno);
8027 			}
8028 			dm_handle_free(hanp, hlen);
8029 		}
8030 	}
8031 
8032 	/*
8033 	 * TEST    : dm_init_attrloc - invalid hlen
8034 	 * EXPECTED: rc = -1, errno = EBADF
8035 	 */
8036 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 3)) {
8037 		void *hanp;
8038 		size_t hlen;
8039 		dm_attrloc_t loc;
8040 
8041 		/* Variation set up */
8042 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8043 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8044 			/* No clean up */
8045 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8046 			   == -1) {
8047 			rmdir(DUMMY_SUBDIR);
8048 		} else if ((rc = system(command)) == -1) {
8049 			dm_handle_free(hanp, hlen);
8050 			rmdir(DUMMY_SUBDIR);
8051 		}
8052 		if (rc == -1) {
8053 			DMLOG_PRINT(DMLVL_DEBUG,
8054 				    "Unable to set up variation! (errno = %d)\n",
8055 				    errno);
8056 			DMVAR_SKIP();
8057 		} else {
8058 			/* Variation */
8059 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
8060 				    szFuncName);
8061 			rc = dm_init_attrloc(sid, hanp, INVALID_ADDR,
8062 					     DM_NO_TOKEN, &loc);
8063 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
8064 
8065 			/* Variation clean up */
8066 			rc = remove(DUMMY_SUBDIR_FILE);
8067 			rc |= rmdir(DUMMY_SUBDIR);
8068 			if (rc == -1) {
8069 				DMLOG_PRINT(DMLVL_DEBUG,
8070 					    "Unable to clean up variation! (errno = %d)\n",
8071 					    errno);
8072 			}
8073 			dm_handle_free(hanp, hlen);
8074 		}
8075 	}
8076 
8077 	/*
8078 	 * TEST    : dm_init_attrloc - invalid token
8079 	 * EXPECTED: rc = -1, errno = EINVAL
8080 	 */
8081 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 4)) {
8082 		void *hanp;
8083 		size_t hlen;
8084 		dm_attrloc_t loc;
8085 
8086 		/* Variation set up */
8087 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8088 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8089 			/* No clean up */
8090 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8091 			   == -1) {
8092 			rmdir(DUMMY_SUBDIR);
8093 		} else if ((rc = system(command)) == -1) {
8094 			dm_handle_free(hanp, hlen);
8095 			rmdir(DUMMY_SUBDIR);
8096 		}
8097 		if (rc == -1) {
8098 			DMLOG_PRINT(DMLVL_DEBUG,
8099 				    "Unable to set up variation! (errno = %d)\n",
8100 				    errno);
8101 			DMVAR_SKIP();
8102 		} else {
8103 			/* Variation */
8104 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
8105 				    szFuncName);
8106 			rc = dm_init_attrloc(sid, hanp, hlen, INVALID_ADDR,
8107 					     &loc);
8108 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8109 
8110 			/* Variation clean up */
8111 			rc = remove(DUMMY_SUBDIR_FILE);
8112 			rc |= rmdir(DUMMY_SUBDIR);
8113 			if (rc == -1) {
8114 				DMLOG_PRINT(DMLVL_DEBUG,
8115 					    "Unable to clean up variation! (errno = %d)\n",
8116 					    errno);
8117 			}
8118 			dm_handle_free(hanp, hlen);
8119 		}
8120 	}
8121 
8122 	/*
8123 	 * TEST    : dm_init_attrloc - invalid locp
8124 	 * EXPECTED: rc = -1, errno = EFAULT
8125 	 */
8126 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 5)) {
8127 		void *hanp;
8128 		size_t hlen;
8129 
8130 		/* Variation set up */
8131 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8132 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8133 			/* No clean up */
8134 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8135 			   == -1) {
8136 			rmdir(DUMMY_SUBDIR);
8137 		} else if ((rc = system(command)) == -1) {
8138 			dm_handle_free(hanp, hlen);
8139 			rmdir(DUMMY_SUBDIR);
8140 		}
8141 		if (rc == -1) {
8142 			DMLOG_PRINT(DMLVL_DEBUG,
8143 				    "Unable to set up variation! (errno = %d)\n",
8144 				    errno);
8145 			DMVAR_SKIP();
8146 		} else {
8147 			/* Variation */
8148 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid locp)\n",
8149 				    szFuncName);
8150 			rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8151 					     (dm_attrloc_t *) INVALID_ADDR);
8152 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
8153 
8154 			/* Variation clean up */
8155 			rc = remove(DUMMY_SUBDIR_FILE);
8156 			rc |= rmdir(DUMMY_SUBDIR);
8157 			if (rc == -1) {
8158 				DMLOG_PRINT(DMLVL_DEBUG,
8159 					    "Unable to clean up variation! (errno = %d)\n",
8160 					    errno);
8161 			}
8162 			dm_handle_free(hanp, hlen);
8163 		}
8164 	}
8165 
8166 	/*
8167 	 * TEST    : dm_init_attrloc - file handle
8168 	 * EXPECTED: rc = -1, errno = EINVAL
8169 	 */
8170 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 6)) {
8171 		void *hanp;
8172 		size_t hlen;
8173 		dm_attrloc_t loc;
8174 
8175 		/* Variation set up */
8176 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
8177 		if ((rc = system(command)) == -1) {
8178 			/* No clean up */
8179 		} else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
8180 			   -1) {
8181 			remove(DUMMY_FILE);
8182 		}
8183 		if (rc == -1) {
8184 			DMLOG_PRINT(DMLVL_DEBUG,
8185 				    "Unable to set up variation! (errno = %d)\n",
8186 				    errno);
8187 			DMVAR_SKIP();
8188 		} else {
8189 			/* Variation */
8190 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
8191 				    szFuncName);
8192 			rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8193 					     &loc);
8194 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8195 
8196 			/* Variation clean up */
8197 			rc = remove(DUMMY_FILE);
8198 			if (rc == -1) {
8199 				DMLOG_PRINT(DMLVL_DEBUG,
8200 					    "Unable to clean up variation! (errno = %d)\n",
8201 					    errno);
8202 			}
8203 			dm_handle_free(hanp, hlen);
8204 		}
8205 	}
8206 
8207 	/*
8208 	 * TEST    : dm_init_attrloc - directory handle
8209 	 * EXPECTED: rc = 0
8210 	 */
8211 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 7)) {
8212 		void *hanp;
8213 		size_t hlen;
8214 		dm_attrloc_t loc;
8215 
8216 		/* Variation set up */
8217 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8218 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8219 			/* No clean up */
8220 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8221 			   == -1) {
8222 			rmdir(DUMMY_SUBDIR);
8223 		} else if ((rc = system(command)) == -1) {
8224 			dm_handle_free(hanp, hlen);
8225 			rmdir(DUMMY_SUBDIR);
8226 		}
8227 		if (rc == -1) {
8228 			DMLOG_PRINT(DMLVL_DEBUG,
8229 				    "Unable to set up variation! (errno = %d)\n",
8230 				    errno);
8231 			DMVAR_SKIP();
8232 		} else {
8233 			/* Variation */
8234 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
8235 				    szFuncName);
8236 			rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8237 					     &loc);
8238 			if (rc == 0) {
8239 				DMLOG_PRINT(DMLVL_DEBUG, "loc = %lld\n", loc);
8240 			}
8241 			DMVAR_ENDPASSEXP(szFuncName, 0, rc);
8242 
8243 			/* Variation clean up */
8244 			rc = remove(DUMMY_SUBDIR_FILE);
8245 			rc |= rmdir(DUMMY_SUBDIR);
8246 			if (rc == -1) {
8247 				DMLOG_PRINT(DMLVL_DEBUG,
8248 					    "Unable to clean up variation! (errno = %d)\n",
8249 					    errno);
8250 			}
8251 			dm_handle_free(hanp, hlen);
8252 		}
8253 	}
8254 
8255 	/*
8256 	 * TEST    : dm_init_attrloc - fs handle
8257 	 * EXPECTED: rc = 0
8258 	 */
8259 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 8)) {
8260 		void *hanp;
8261 		size_t hlen;
8262 		dm_attrloc_t loc;
8263 
8264 		/* Variation set up */
8265 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8266 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8267 			/* No clean up */
8268 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8269 			   == -1) {
8270 			rmdir(DUMMY_SUBDIR);
8271 		} else if ((rc = system(command)) == -1) {
8272 			dm_handle_free(hanp, hlen);
8273 			rmdir(DUMMY_SUBDIR);
8274 		}
8275 		if (rc == -1) {
8276 			DMLOG_PRINT(DMLVL_DEBUG,
8277 				    "Unable to set up variation! (errno = %d)\n",
8278 				    errno);
8279 			DMVAR_SKIP();
8280 		} else {
8281 			/* Variation */
8282 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
8283 			rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8284 					     &loc);
8285 			if (rc == 0) {
8286 				DMLOG_PRINT(DMLVL_DEBUG, "loc = %lld\n", loc);
8287 			}
8288 			DMVAR_ENDPASSEXP(szFuncName, 0, rc);
8289 
8290 			/* Variation clean up */
8291 			rc = remove(DUMMY_SUBDIR_FILE);
8292 			rc |= rmdir(DUMMY_SUBDIR);
8293 			if (rc == -1) {
8294 				DMLOG_PRINT(DMLVL_DEBUG,
8295 					    "Unable to clean up variation! (errno = %d)\n",
8296 					    errno);
8297 			}
8298 			dm_handle_free(hanp, hlen);
8299 		}
8300 	}
8301 
8302 	/*
8303 	 * TEST    : dm_init_attrloc - DM_NO_SESSION sid
8304 	 * EXPECTED: rc = -1, errno = EINVAL
8305 	 */
8306 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 9)) {
8307 		void *hanp;
8308 		size_t hlen;
8309 		dm_attrloc_t loc;
8310 
8311 		/* Variation set up */
8312 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8313 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8314 			/* No clean up */
8315 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8316 			   == -1) {
8317 			rmdir(DUMMY_SUBDIR);
8318 		} else if ((rc = system(command)) == -1) {
8319 			dm_handle_free(hanp, hlen);
8320 			rmdir(DUMMY_SUBDIR);
8321 		}
8322 		if (rc == -1) {
8323 			DMLOG_PRINT(DMLVL_DEBUG,
8324 				    "Unable to set up variation! (errno = %d)\n",
8325 				    errno);
8326 			DMVAR_SKIP();
8327 		} else {
8328 			/* Variation */
8329 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
8330 				    szFuncName);
8331 			rc = dm_init_attrloc(DM_NO_SESSION, hanp, hlen,
8332 					     DM_NO_TOKEN, &loc);
8333 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8334 
8335 			/* Variation clean up */
8336 			rc = remove(DUMMY_SUBDIR_FILE);
8337 			rc |= rmdir(DUMMY_SUBDIR);
8338 			if (rc == -1) {
8339 				DMLOG_PRINT(DMLVL_DEBUG,
8340 					    "Unable to clean up variation! (errno = %d)\n",
8341 					    errno);
8342 			}
8343 			dm_handle_free(hanp, hlen);
8344 		}
8345 	}
8346 
8347 	/*
8348 	 * TEST    : dm_init_attrloc - global handle
8349 	 * EXPECTED: rc = -1, errno = EBADF
8350 	 */
8351 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 10)) {
8352 		dm_attrloc_t loc;
8353 
8354 		/* Variation set up */
8355 
8356 		/* Variation */
8357 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
8358 		rc = dm_init_attrloc(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
8359 				     DM_NO_TOKEN, &loc);
8360 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
8361 
8362 		/* Variation clean up */
8363 	}
8364 
8365 	/*
8366 	 * TEST    : dm_init_attrloc - invalidated hanp
8367 	 * EXPECTED: rc = -1, errno = EBADF
8368 	 */
8369 	if (DMVAR_EXEC(INIT_ATTRLOC_BASE + 11)) {
8370 		void *hanp;
8371 		size_t hlen;
8372 		dm_attrloc_t loc;
8373 
8374 		/* Variation set up */
8375 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8376 			/* No clean up */
8377 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8378 			   == -1) {
8379 			rmdir(DUMMY_SUBDIR);
8380 		} else if ((rmdir(DUMMY_SUBDIR)) == -1) {
8381 			dm_handle_free(hanp, hlen);
8382 		}
8383 		if (rc == -1) {
8384 			DMLOG_PRINT(DMLVL_DEBUG,
8385 				    "Unable to set up variation! (errno = %d)\n",
8386 				    errno);
8387 			DMVAR_SKIP();
8388 		} else {
8389 			/* Variation */
8390 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
8391 				    szFuncName);
8392 			rc = dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8393 					     &loc);
8394 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
8395 
8396 			/* Variation clean up */
8397 			dm_handle_free(hanp, hlen);
8398 		}
8399 	}
8400 
8401 	szFuncName = "dm_get_dirattrs";
8402 
8403 	/*
8404 	 * TEST    : dm_get_dirattrs - invalid sid
8405 	 * EXPECTED: rc = -1, errno = EINVAL
8406 	 */
8407 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 1)) {
8408 		void *hanp;
8409 		size_t hlen;
8410 		dm_attrloc_t loc;
8411 		char buf[ATTR_LISTLEN];
8412 		size_t rlen;
8413 
8414 		/* Variation set up */
8415 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8416 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8417 			/* No clean up */
8418 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8419 			   == -1) {
8420 			rmdir(DUMMY_SUBDIR);
8421 		} else
8422 		    if (((rc =
8423 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8424 					  &loc)) == -1)
8425 			|| ((rc = system(command)) == -1)) {
8426 			dm_handle_free(hanp, hlen);
8427 			rmdir(DUMMY_SUBDIR);
8428 		}
8429 		if (rc == -1) {
8430 			DMLOG_PRINT(DMLVL_DEBUG,
8431 				    "Unable to set up variation! (errno = %d)\n",
8432 				    errno);
8433 			DMVAR_SKIP();
8434 		} else {
8435 			/* Variation */
8436 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
8437 				    szFuncName);
8438 			rc = dm_get_dirattrs(INVALID_ADDR, hanp, hlen,
8439 					     DM_NO_TOKEN, DM_AT_EMASK, &loc,
8440 					     sizeof(buf), buf, &rlen);
8441 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8442 
8443 			/* Variation clean up */
8444 			rc = remove(DUMMY_SUBDIR_FILE);
8445 			rc |= rmdir(DUMMY_SUBDIR);
8446 			if (rc == -1) {
8447 				DMLOG_PRINT(DMLVL_DEBUG,
8448 					    "Unable to clean up variation! (errno = %d)\n",
8449 					    errno);
8450 			}
8451 			dm_handle_free(hanp, hlen);
8452 		}
8453 	}
8454 
8455 	/*
8456 	 * TEST    : dm_get_dirattrs - invalid hanp
8457 	 * EXPECTED: rc = -1, errno = EFAULT
8458 	 */
8459 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 2)) {
8460 		void *hanp;
8461 		size_t hlen;
8462 		dm_attrloc_t loc;
8463 		char buf[ATTR_LISTLEN];
8464 		size_t rlen;
8465 
8466 		/* Variation set up */
8467 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8468 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8469 			/* No clean up */
8470 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8471 			   == -1) {
8472 			rmdir(DUMMY_SUBDIR);
8473 		} else
8474 		    if (((rc =
8475 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8476 					  &loc)) == -1)
8477 			|| ((rc = system(command)) == -1)) {
8478 			dm_handle_free(hanp, hlen);
8479 			rmdir(DUMMY_SUBDIR);
8480 		}
8481 		if (rc == -1) {
8482 			DMLOG_PRINT(DMLVL_DEBUG,
8483 				    "Unable to set up variation! (errno = %d)\n",
8484 				    errno);
8485 			DMVAR_SKIP();
8486 		} else {
8487 			/* Variation */
8488 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
8489 				    szFuncName);
8490 			rc = dm_get_dirattrs(sid, (void *)INVALID_ADDR, hlen,
8491 					     DM_NO_TOKEN, DM_AT_EMASK, &loc,
8492 					     sizeof(buf), buf, &rlen);
8493 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
8494 
8495 			/* Variation clean up */
8496 			rc = remove(DUMMY_SUBDIR_FILE);
8497 			rc |= rmdir(DUMMY_SUBDIR);
8498 			if (rc == -1) {
8499 				DMLOG_PRINT(DMLVL_DEBUG,
8500 					    "Unable to clean up variation! (errno = %d)\n",
8501 					    errno);
8502 			}
8503 			dm_handle_free(hanp, hlen);
8504 		}
8505 	}
8506 
8507 	/*
8508 	 * TEST    : dm_get_dirattrs - invalid hlen
8509 	 * EXPECTED: rc = -1, errno = EINVAL
8510 	 */
8511 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 3)) {
8512 		void *hanp;
8513 		size_t hlen;
8514 		dm_attrloc_t loc;
8515 		char buf[ATTR_LISTLEN];
8516 		size_t rlen;
8517 
8518 		/* Variation set up */
8519 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8520 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8521 			/* No clean up */
8522 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8523 			   == -1) {
8524 			rmdir(DUMMY_SUBDIR);
8525 		} else
8526 		    if (((rc =
8527 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8528 					  &loc)) == -1)
8529 			|| ((rc = system(command)) == -1)) {
8530 			dm_handle_free(hanp, hlen);
8531 			rmdir(DUMMY_SUBDIR);
8532 		}
8533 		if (rc == -1) {
8534 			DMLOG_PRINT(DMLVL_DEBUG,
8535 				    "Unable to set up variation! (errno = %d)\n",
8536 				    errno);
8537 			DMVAR_SKIP();
8538 		} else {
8539 			/* Variation */
8540 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
8541 				    szFuncName);
8542 			rc = dm_get_dirattrs(sid, hanp, INVALID_ADDR,
8543 					     DM_NO_TOKEN, DM_AT_EMASK, &loc,
8544 					     sizeof(buf), buf, &rlen);
8545 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
8546 
8547 			/* Variation clean up */
8548 			rc = remove(DUMMY_SUBDIR_FILE);
8549 			rc |= rmdir(DUMMY_SUBDIR);
8550 			if (rc == -1) {
8551 				DMLOG_PRINT(DMLVL_DEBUG,
8552 					    "Unable to clean up variation! (errno = %d)\n",
8553 					    errno);
8554 			}
8555 			dm_handle_free(hanp, hlen);
8556 		}
8557 	}
8558 
8559 	/*
8560 	 * TEST    : dm_get_dirattrs - invalid token
8561 	 * EXPECTED: rc = -1, errno = EINVAL
8562 	 */
8563 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 4)) {
8564 		void *hanp;
8565 		size_t hlen;
8566 		dm_attrloc_t loc;
8567 		char buf[ATTR_LISTLEN];
8568 		size_t rlen;
8569 
8570 		/* Variation set up */
8571 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8572 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8573 			/* No clean up */
8574 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8575 			   == -1) {
8576 			rmdir(DUMMY_SUBDIR);
8577 		} else
8578 		    if (((rc =
8579 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8580 					  &loc)) == -1)
8581 			|| ((rc = system(command)) == -1)) {
8582 			dm_handle_free(hanp, hlen);
8583 			rmdir(DUMMY_SUBDIR);
8584 		}
8585 		if (rc == -1) {
8586 			DMLOG_PRINT(DMLVL_DEBUG,
8587 				    "Unable to set up variation! (errno = %d)\n",
8588 				    errno);
8589 			DMVAR_SKIP();
8590 		} else {
8591 			/* Variation */
8592 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
8593 				    szFuncName);
8594 			rc = dm_get_dirattrs(sid, hanp, hlen, INVALID_ADDR,
8595 					     DM_AT_EMASK, &loc, sizeof(buf),
8596 					     buf, &rlen);
8597 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8598 
8599 			/* Variation clean up */
8600 			rc = remove(DUMMY_SUBDIR_FILE);
8601 			rc |= rmdir(DUMMY_SUBDIR);
8602 			if (rc == -1) {
8603 				DMLOG_PRINT(DMLVL_DEBUG,
8604 					    "Unable to clean up variation! (errno = %d)\n",
8605 					    errno);
8606 			}
8607 			dm_handle_free(hanp, hlen);
8608 		}
8609 	}
8610 
8611 	/*
8612 	 * TEST    : dm_get_dirattrs - invalid mask
8613 	 * EXPECTED: rc = -1, errno = EINVAL
8614 	 *
8615 	 * This variation uncovered XFS BUG #24 (0 returned instead of -1 and
8616 	 * EINVAL errno)
8617 	 */
8618 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 5)) {
8619 		void *hanp;
8620 		size_t hlen;
8621 		dm_attrloc_t loc;
8622 		char buf[ATTR_LISTLEN];
8623 		size_t rlen;
8624 
8625 		/* Variation set up */
8626 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8627 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8628 			/* No clean up */
8629 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8630 			   == -1) {
8631 			rmdir(DUMMY_SUBDIR);
8632 		} else
8633 		    if (((rc =
8634 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8635 					  &loc)) == -1)
8636 			|| ((rc = system(command)) == -1)) {
8637 			dm_handle_free(hanp, hlen);
8638 			rmdir(DUMMY_SUBDIR);
8639 		}
8640 		if (rc == -1) {
8641 			DMLOG_PRINT(DMLVL_DEBUG,
8642 				    "Unable to set up variation! (errno = %d)\n",
8643 				    errno);
8644 			DMVAR_SKIP();
8645 		} else {
8646 			/* Variation */
8647 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid mask)\n",
8648 				    szFuncName);
8649 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8650 					     DM_AT_SIZE, &loc, sizeof(buf), buf,
8651 					     &rlen);
8652 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8653 
8654 			/* Variation clean up */
8655 			rc = remove(DUMMY_SUBDIR_FILE);
8656 			rc |= rmdir(DUMMY_SUBDIR);
8657 			if (rc == -1) {
8658 				DMLOG_PRINT(DMLVL_DEBUG,
8659 					    "Unable to clean up variation! (errno = %d)\n",
8660 					    errno);
8661 			}
8662 			dm_handle_free(hanp, hlen);
8663 		}
8664 	}
8665 
8666 	/*
8667 	 * TEST    : dm_get_dirattrs - invalid locp
8668 	 * EXPECTED: rc = -1, errno = EFAULT
8669 	 */
8670 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 6)) {
8671 		void *hanp;
8672 		size_t hlen;
8673 		char buf[ATTR_LISTLEN];
8674 		size_t rlen;
8675 
8676 		/* Variation set up */
8677 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8678 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8679 			/* No clean up */
8680 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8681 			   == -1) {
8682 			rmdir(DUMMY_SUBDIR);
8683 		} else if ((rc = system(command)) == -1) {
8684 			dm_handle_free(hanp, hlen);
8685 			rmdir(DUMMY_SUBDIR);
8686 		}
8687 		if (rc == -1) {
8688 			DMLOG_PRINT(DMLVL_DEBUG,
8689 				    "Unable to set up variation! (errno = %d)\n",
8690 				    errno);
8691 			DMVAR_SKIP();
8692 		} else {
8693 			/* Variation */
8694 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid locp)\n",
8695 				    szFuncName);
8696 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8697 					     DM_AT_EMASK,
8698 					     (dm_attrloc_t *) INVALID_ADDR,
8699 					     sizeof(buf), buf, &rlen);
8700 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
8701 
8702 			/* Variation clean up */
8703 			rc = remove(DUMMY_SUBDIR_FILE);
8704 			rc |= rmdir(DUMMY_SUBDIR);
8705 			if (rc == -1) {
8706 				DMLOG_PRINT(DMLVL_DEBUG,
8707 					    "Unable to clean up variation! (errno = %d)\n",
8708 					    errno);
8709 			}
8710 			dm_handle_free(hanp, hlen);
8711 		}
8712 	}
8713 
8714 	/*
8715 	 * TEST    : dm_get_dirattrs - invalid loc
8716 	 * EXPECTED: rc = -1, errno = EINVAL
8717 	 */
8718 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 7)) {
8719 		void *hanp;
8720 		size_t hlen;
8721 		dm_attrloc_t loc;
8722 		char buf[ATTR_LISTLEN];
8723 		size_t rlen;
8724 
8725 		/* Variation set up */
8726 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8727 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8728 			/* No clean up */
8729 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8730 			   == -1) {
8731 			rmdir(DUMMY_SUBDIR);
8732 		} else
8733 		    if (((rc =
8734 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8735 					  &loc)) == -1)
8736 			|| ((rc = system(command)) == -1)) {
8737 			dm_handle_free(hanp, hlen);
8738 			rmdir(DUMMY_SUBDIR);
8739 		}
8740 		if (rc == -1) {
8741 			DMLOG_PRINT(DMLVL_DEBUG,
8742 				    "Unable to set up variation! (errno = %d)\n",
8743 				    errno);
8744 			DMVAR_SKIP();
8745 		} else {
8746 			/* Variation */
8747 			loc = INVALID_ADDR;
8748 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid loc)\n",
8749 				    szFuncName);
8750 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8751 					     DM_AT_EMASK, &loc, sizeof(buf),
8752 					     buf, &rlen);
8753 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8754 
8755 			/* Variation clean up */
8756 			rc = remove(DUMMY_SUBDIR_FILE);
8757 			rc |= rmdir(DUMMY_SUBDIR);
8758 			if (rc == -1) {
8759 				DMLOG_PRINT(DMLVL_DEBUG,
8760 					    "Unable to clean up variation! (errno = %d)\n",
8761 					    errno);
8762 			}
8763 			dm_handle_free(hanp, hlen);
8764 		}
8765 	}
8766 
8767 	/*
8768 	 * TEST    : dm_get_dirattrs - invalid buflen
8769 	 * EXPECTED: rc = 1
8770 	 *
8771 	 * This variation uncovered XFS BUG #26 (-1 and E2BIG errno returned
8772 	 * instead of 1)
8773 	 */
8774 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 8)) {
8775 		void *hanp;
8776 		size_t hlen;
8777 		dm_attrloc_t loc;
8778 		char buf[ATTR_LISTLEN];
8779 		size_t rlen;
8780 
8781 		/* Variation set up */
8782 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8783 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8784 			/* No clean up */
8785 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8786 			   == -1) {
8787 			rmdir(DUMMY_SUBDIR);
8788 		} else
8789 		    if (((rc =
8790 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8791 					  &loc)) == -1)
8792 			|| ((rc = system(command)) == -1)) {
8793 			dm_handle_free(hanp, hlen);
8794 			rmdir(DUMMY_SUBDIR);
8795 		}
8796 		if (rc == -1) {
8797 			DMLOG_PRINT(DMLVL_DEBUG,
8798 				    "Unable to set up variation! (errno = %d)\n",
8799 				    errno);
8800 			DMVAR_SKIP();
8801 		} else {
8802 			/* Variation */
8803 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid buflen)\n",
8804 				    szFuncName);
8805 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8806 					     DM_AT_EMASK, &loc, 0, buf, &rlen);
8807 			DMLOG_PRINT(DMLVL_DEBUG,
8808 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
8809 				    rlen);
8810 			DMVAR_ENDPASSEXP(szFuncName, 1, rc);
8811 
8812 			/* Variation clean up */
8813 			rc = remove(DUMMY_SUBDIR_FILE);
8814 			rc |= rmdir(DUMMY_SUBDIR);
8815 			if (rc == -1) {
8816 				DMLOG_PRINT(DMLVL_DEBUG,
8817 					    "Unable to clean up variation! (errno = %d)\n",
8818 					    errno);
8819 			}
8820 			dm_handle_free(hanp, hlen);
8821 		}
8822 	}
8823 
8824 	/*
8825 	 * TEST    : dm_get_dirattrs - invalid bufp
8826 	 * EXPECTED: rc = -1, errno = EFAULT
8827 	 */
8828 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 9)) {
8829 		void *hanp;
8830 		size_t hlen;
8831 		dm_attrloc_t loc;
8832 		char buf[ATTR_LISTLEN];
8833 		size_t rlen;
8834 
8835 		/* Variation set up */
8836 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8837 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8838 			/* No clean up */
8839 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8840 			   == -1) {
8841 			rmdir(DUMMY_SUBDIR);
8842 		} else
8843 		    if (((rc =
8844 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8845 					  &loc)) == -1)
8846 			|| ((rc = system(command)) == -1)) {
8847 			dm_handle_free(hanp, hlen);
8848 			rmdir(DUMMY_SUBDIR);
8849 		}
8850 		if (rc == -1) {
8851 			DMLOG_PRINT(DMLVL_DEBUG,
8852 				    "Unable to set up variation! (errno = %d)\n",
8853 				    errno);
8854 			DMVAR_SKIP();
8855 		} else {
8856 			/* Variation */
8857 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid bufp)\n",
8858 				    szFuncName);
8859 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8860 					     DM_AT_EMASK, &loc, sizeof(buf),
8861 					     (void *)INVALID_ADDR, &rlen);
8862 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
8863 
8864 			/* Variation clean up */
8865 			rc = remove(DUMMY_SUBDIR_FILE);
8866 			rc |= rmdir(DUMMY_SUBDIR);
8867 			if (rc == -1) {
8868 				DMLOG_PRINT(DMLVL_DEBUG,
8869 					    "Unable to clean up variation! (errno = %d)\n",
8870 					    errno);
8871 			}
8872 			dm_handle_free(hanp, hlen);
8873 		}
8874 	}
8875 
8876 	/*
8877 	 * TEST    : dm_get_dirattrs - invalid rlenp
8878 	 * EXPECTED: rc = -1, errno = EFAULT
8879 	 */
8880 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 10)) {
8881 		void *hanp;
8882 		size_t hlen;
8883 		dm_attrloc_t loc;
8884 		char buf[ATTR_LISTLEN];
8885 
8886 		/* Variation set up */
8887 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8888 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8889 			/* No clean up */
8890 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
8891 			   == -1) {
8892 			rmdir(DUMMY_SUBDIR);
8893 		} else
8894 		    if (((rc =
8895 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
8896 					  &loc)) == -1)
8897 			|| ((rc = system(command)) == -1)) {
8898 			dm_handle_free(hanp, hlen);
8899 			rmdir(DUMMY_SUBDIR);
8900 		}
8901 		if (rc == -1) {
8902 			DMLOG_PRINT(DMLVL_DEBUG,
8903 				    "Unable to set up variation! (errno = %d)\n",
8904 				    errno);
8905 			DMVAR_SKIP();
8906 		} else {
8907 			/* Variation */
8908 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid rlenp)\n",
8909 				    szFuncName);
8910 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8911 					     DM_AT_EMASK, &loc, sizeof(buf),
8912 					     buf, (size_t *) INVALID_ADDR);
8913 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
8914 
8915 			/* Variation clean up */
8916 			rc = remove(DUMMY_SUBDIR_FILE);
8917 			rc |= rmdir(DUMMY_SUBDIR);
8918 			if (rc == -1) {
8919 				DMLOG_PRINT(DMLVL_DEBUG,
8920 					    "Unable to clean up variation! (errno = %d)\n",
8921 					    errno);
8922 			}
8923 			dm_handle_free(hanp, hlen);
8924 		}
8925 	}
8926 
8927 	/*
8928 	 * TEST    : dm_get_dirattrs - file handle
8929 	 * EXPECTED: rc = -1, errno = EINVAL
8930 	 */
8931 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 11)) {
8932 		void *hanp;
8933 		size_t hlen;
8934 		dm_attrloc_t loc;
8935 		char buf[ATTR_LISTLEN];
8936 		size_t rlen;
8937 
8938 		/* Variation set up */
8939 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
8940 		if ((rc = system(command)) == -1) {
8941 			/* No clean up */
8942 		} else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
8943 			   -1) {
8944 			remove(DUMMY_FILE);
8945 		}
8946 		if (rc == -1) {
8947 			DMLOG_PRINT(DMLVL_DEBUG,
8948 				    "Unable to set up variation! (errno = %d)\n",
8949 				    errno);
8950 			DMVAR_SKIP();
8951 		} else {
8952 			/* Variation */
8953 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
8954 				    szFuncName);
8955 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
8956 					     DM_AT_EMASK, &loc, sizeof(buf),
8957 					     buf, &rlen);
8958 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
8959 
8960 			/* Variation clean up */
8961 			rc = remove(DUMMY_FILE);
8962 			if (rc == -1) {
8963 				DMLOG_PRINT(DMLVL_DEBUG,
8964 					    "Unable to clean up variation! (errno = %d)\n",
8965 					    errno);
8966 			}
8967 			dm_handle_free(hanp, hlen);
8968 		}
8969 	}
8970 
8971 	/*
8972 	 * TEST    : dm_get_dirattrs - DM_AT_HANDLE
8973 	 * EXPECTED: rc = 0
8974 	 */
8975 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 12)) {
8976 		void *dhanp, *fhanp;
8977 		size_t dhlen, fhlen;
8978 		dm_attrloc_t loc;
8979 		char buf[ATTR_LISTLEN];
8980 		size_t rlen;
8981 
8982 		/* Variation set up */
8983 		memset(buf, 0, ATTR_LISTLEN);
8984 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
8985 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
8986 			/* No clean up */
8987 		} else
8988 		    if ((rc =
8989 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
8990 					   &dhlen)) == -1) {
8991 			rmdir(DUMMY_SUBDIR);
8992 		} else if ((rc = system(command)) == -1) {
8993 			dm_handle_free(dhanp, dhlen);
8994 			rmdir(DUMMY_SUBDIR);
8995 		} else
8996 		    if ((rc =
8997 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
8998 					   &fhlen)) == -1) {
8999 			remove(DUMMY_SUBDIR_FILE);
9000 			dm_handle_free(dhanp, dhlen);
9001 			rmdir(DUMMY_SUBDIR);
9002 		} else
9003 		    if ((rc =
9004 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9005 					 &loc)) == -1) {
9006 			dm_handle_free(fhanp, fhlen);
9007 			remove(DUMMY_SUBDIR_FILE);
9008 			dm_handle_free(dhanp, dhlen);
9009 			rmdir(DUMMY_SUBDIR);
9010 		}
9011 		if (rc == -1) {
9012 			DMLOG_PRINT(DMLVL_DEBUG,
9013 				    "Unable to set up variation! (errno = %d)\n",
9014 				    errno);
9015 			DMVAR_SKIP();
9016 		} else {
9017 			/* Variation */
9018 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_HANDLE)\n",
9019 				    szFuncName);
9020 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9021 					     DM_AT_HANDLE, &loc, sizeof(buf),
9022 					     buf, &rlen);
9023 			DMLOG_PRINT(DMLVL_DEBUG,
9024 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9025 				    rlen);
9026 			if (rc == 0) {
9027 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9028 				LogDirAttrs(buf, DM_AT_HANDLE);
9029 				if (entry != NULL) {
9030 					if (dm_handle_cmp
9031 					    (fhanp, fhlen,
9032 					     DM_GET_VALUE(entry, dt_handle,
9033 							  void *),
9034 					     DM_GET_LEN(entry,
9035 							dt_handle)) == 0) {
9036 						DMLOG_PRINT(DMLVL_DEBUG,
9037 							    "%s passed with expected rc = %d\n",
9038 							    szFuncName, 0);
9039 						DMVAR_PASS();
9040 					} else {
9041 						DMLOG_PRINT(DMLVL_ERR,
9042 							    "%s failed with expected rc = %d but handles NOT same\n",
9043 							    szFuncName, 0);
9044 						DMVAR_FAIL();
9045 					}
9046 				} else {
9047 					DMLOG_PRINT(DMLVL_ERR,
9048 						    "%s failed with expected rc = %d but unable to find entry %s",
9049 						    szFuncName, 0, DUMMY_FILE);
9050 					DMVAR_FAIL();
9051 				}
9052 			} else {
9053 				DMLOG_PRINT(DMLVL_ERR,
9054 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9055 					    szFuncName, rc, errno);
9056 				DMVAR_FAIL();
9057 			}
9058 
9059 			/* Variation clean up */
9060 			rc = remove(DUMMY_SUBDIR_FILE);
9061 			rc |= rmdir(DUMMY_SUBDIR);
9062 			if (rc == -1) {
9063 				DMLOG_PRINT(DMLVL_DEBUG,
9064 					    "Unable to clean up variation! (errno = %d)\n",
9065 					    errno);
9066 			}
9067 			dm_handle_free(dhanp, dhlen);
9068 			dm_handle_free(fhanp, fhlen);
9069 		}
9070 	}
9071 
9072 	/*
9073 	 * TEST    : dm_get_dirattrs - DM_AT_EMASK
9074 	 * EXPECTED: rc = 0
9075 	 */
9076 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 13)) {
9077 		void *dhanp, *fhanp;
9078 		size_t dhlen, fhlen;
9079 		dm_attrloc_t loc;
9080 		char buf[ATTR_LISTLEN];
9081 		size_t rlen;
9082 		dm_eventset_t eventset;
9083 
9084 		/* Variation set up */
9085 		memset(buf, 0, ATTR_LISTLEN);
9086 		DMEV_ZERO(eventset);
9087 		DMEV_SET(DM_EVENT_ATTRIBUTE, eventset);
9088 		DMEV_SET(DM_EVENT_CLOSE, eventset);
9089 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9090 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9091 			/* No clean up */
9092 		} else
9093 		    if ((rc =
9094 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9095 					   &dhlen)) == -1) {
9096 			rmdir(DUMMY_SUBDIR);
9097 		} else if ((rc = system(command)) == -1) {
9098 			dm_handle_free(dhanp, dhlen);
9099 			rmdir(DUMMY_SUBDIR);
9100 		} else
9101 		    if ((rc =
9102 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
9103 					   &fhlen)) == -1) {
9104 			remove(DUMMY_SUBDIR_FILE);
9105 			dm_handle_free(dhanp, dhlen);
9106 			rmdir(DUMMY_SUBDIR);
9107 		} else
9108 		    if (((rc =
9109 			  dm_set_eventlist(sid, fhanp, fhlen, DM_NO_TOKEN,
9110 					   &eventset, DM_EVENT_MAX)) == -1)
9111 			||
9112 			((rc =
9113 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9114 					  &loc)) == -1)) {
9115 			dm_handle_free(fhanp, fhlen);
9116 			remove(DUMMY_SUBDIR_FILE);
9117 			dm_handle_free(dhanp, dhlen);
9118 			rmdir(DUMMY_SUBDIR);
9119 		}
9120 		if (rc == -1) {
9121 			DMLOG_PRINT(DMLVL_DEBUG,
9122 				    "Unable to set up variation! (errno = %d)\n",
9123 				    errno);
9124 			DMVAR_SKIP();
9125 		} else {
9126 			/* Variation */
9127 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_EMASK)\n",
9128 				    szFuncName);
9129 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9130 					     DM_AT_EMASK, &loc, sizeof(buf),
9131 					     buf, &rlen);
9132 			DMLOG_PRINT(DMLVL_DEBUG,
9133 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9134 				    rlen);
9135 			if (rc == 0) {
9136 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9137 				LogDirAttrs(buf, DM_AT_EMASK);
9138 				if (entry != NULL) {
9139 					if (eventset == entry->dt_emask) {
9140 						DMLOG_PRINT(DMLVL_DEBUG,
9141 							    "%s passed with expected rc = %d\n",
9142 							    szFuncName, 0);
9143 						DMVAR_PASS();
9144 					} else {
9145 						DMLOG_PRINT(DMLVL_ERR,
9146 							    "%s failed with expected rc = %d but emasks NOT same (%llx vs %llx)\n",
9147 							    szFuncName, 0,
9148 							    eventset,
9149 							    entry->dt_emask);
9150 						DMVAR_FAIL();
9151 					}
9152 				} else {
9153 					DMLOG_PRINT(DMLVL_ERR,
9154 						    "%s failed with expected rc = %d but unable to find entry %s",
9155 						    szFuncName, 0, DUMMY_FILE);
9156 					DMVAR_FAIL();
9157 				}
9158 			} else {
9159 				DMLOG_PRINT(DMLVL_ERR,
9160 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9161 					    szFuncName, rc, errno);
9162 				DMVAR_FAIL();
9163 			}
9164 
9165 			/* Variation clean up */
9166 			rc = remove(DUMMY_SUBDIR_FILE);
9167 			rc |= rmdir(DUMMY_SUBDIR);
9168 			if (rc == -1) {
9169 				DMLOG_PRINT(DMLVL_DEBUG,
9170 					    "Unable to clean up variation! (errno = %d)\n",
9171 					    errno);
9172 			}
9173 			dm_handle_free(dhanp, dhlen);
9174 			dm_handle_free(fhanp, fhlen);
9175 		}
9176 	}
9177 
9178 	/*
9179 	 * TEST    : dm_get_dirattrs - DM_AT_PMANR with region
9180 	 * EXPECTED: rc = 0
9181 	 */
9182 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 14)) {
9183 		void *dhanp, *fhanp;
9184 		size_t dhlen, fhlen;
9185 		dm_attrloc_t loc;
9186 		char buf[ATTR_LISTLEN];
9187 		size_t rlen;
9188 		dm_region_t region = { 0, 0, DM_REGION_READ };
9189 		dm_boolean_t exactflag;
9190 
9191 		/* Variation set up */
9192 		memset(buf, 0, ATTR_LISTLEN);
9193 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9194 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9195 			/* No clean up */
9196 		} else
9197 		    if ((rc =
9198 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9199 					   &dhlen)) == -1) {
9200 			rmdir(DUMMY_SUBDIR);
9201 		} else if ((rc = system(command)) == -1) {
9202 			dm_handle_free(dhanp, dhlen);
9203 			rmdir(DUMMY_SUBDIR);
9204 		} else
9205 		    if ((rc =
9206 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
9207 					   &fhlen)) == -1) {
9208 			remove(DUMMY_SUBDIR_FILE);
9209 			dm_handle_free(dhanp, dhlen);
9210 			rmdir(DUMMY_SUBDIR);
9211 		} else
9212 		    if (((rc =
9213 			  dm_set_region(sid, fhanp, fhlen, DM_NO_TOKEN, 1,
9214 					&region, &exactflag)) == -1)
9215 			||
9216 			((rc =
9217 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9218 					  &loc)) == -1)) {
9219 			dm_handle_free(fhanp, fhlen);
9220 			remove(DUMMY_SUBDIR_FILE);
9221 			dm_handle_free(dhanp, dhlen);
9222 			rmdir(DUMMY_SUBDIR);
9223 		}
9224 		if (rc == -1) {
9225 			DMLOG_PRINT(DMLVL_DEBUG,
9226 				    "Unable to set up variation! (errno = %d)\n",
9227 				    errno);
9228 			DMVAR_SKIP();
9229 		} else {
9230 			/* Variation */
9231 			DMLOG_PRINT(DMLVL_DEBUG,
9232 				    "%s(DM_AT_PMANR with region)\n",
9233 				    szFuncName);
9234 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9235 					     DM_AT_PMANR, &loc, sizeof(buf),
9236 					     buf, &rlen);
9237 			DMLOG_PRINT(DMLVL_DEBUG,
9238 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9239 				    rlen);
9240 			if (rc == 0) {
9241 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9242 				LogDirAttrs(buf, DM_AT_PMANR);
9243 				if (entry != NULL) {
9244 					if (entry->dt_pmanreg == DM_TRUE) {
9245 						DMLOG_PRINT(DMLVL_DEBUG,
9246 							    "%s passed with expected rc = %d\n",
9247 							    szFuncName, 0);
9248 						DMVAR_PASS();
9249 					} else {
9250 						DMLOG_PRINT(DMLVL_ERR,
9251 							    "%s failed with expected rc = %d but pmanreg NOT same (%d vs %d)\n",
9252 							    szFuncName, 0,
9253 							    entry->dt_pmanreg,
9254 							    DM_TRUE);
9255 						DMVAR_FAIL();
9256 					}
9257 				} else {
9258 					DMLOG_PRINT(DMLVL_ERR,
9259 						    "%s failed with expected rc = %d but unable to find entry %s",
9260 						    szFuncName, 0, DUMMY_FILE);
9261 					DMVAR_FAIL();
9262 				}
9263 			} else {
9264 				DMLOG_PRINT(DMLVL_ERR,
9265 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9266 					    szFuncName, rc, errno);
9267 				DMVAR_FAIL();
9268 			}
9269 
9270 			/* Variation clean up */
9271 			rc = remove(DUMMY_SUBDIR_FILE);
9272 			rc |= rmdir(DUMMY_SUBDIR);
9273 			if (rc == -1) {
9274 				DMLOG_PRINT(DMLVL_DEBUG,
9275 					    "Unable to clean up variation! (errno = %d)\n",
9276 					    errno);
9277 			}
9278 			dm_handle_free(dhanp, dhlen);
9279 			dm_handle_free(fhanp, fhlen);
9280 		}
9281 	}
9282 
9283 	/*
9284 	 * TEST    : dm_get_dirattrs - DM_AT_PMANR without region
9285 	 * EXPECTED: rc = 0
9286 	 */
9287 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 15)) {
9288 		void *dhanp;
9289 		size_t dhlen;
9290 		dm_attrloc_t loc;
9291 		char buf[ATTR_LISTLEN];
9292 		size_t rlen;
9293 
9294 		/* Variation set up */
9295 		memset(buf, 0, ATTR_LISTLEN);
9296 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9297 		rc |= dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN, &loc);
9298 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9299 			/* No clean up */
9300 		} else
9301 		    if ((rc =
9302 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9303 					   &dhlen)) == -1) {
9304 			rmdir(DUMMY_SUBDIR);
9305 		} else if ((rc = system(command)) == -1) {
9306 			dm_handle_free(dhanp, dhlen);
9307 			rmdir(DUMMY_SUBDIR);
9308 		} else
9309 		    if ((rc =
9310 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9311 					 &loc)) == -1) {
9312 			remove(DUMMY_SUBDIR_FILE);
9313 			dm_handle_free(dhanp, dhlen);
9314 			rmdir(DUMMY_SUBDIR);
9315 		}
9316 		if (rc == -1) {
9317 			DMLOG_PRINT(DMLVL_DEBUG,
9318 				    "Unable to set up variation! (errno = %d)\n",
9319 				    errno);
9320 			DMVAR_SKIP();
9321 		} else {
9322 			/* Variation */
9323 			DMLOG_PRINT(DMLVL_DEBUG,
9324 				    "%s(DM_AT_PMANR without region)\n",
9325 				    szFuncName);
9326 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9327 					     DM_AT_PMANR, &loc, sizeof(buf),
9328 					     buf, &rlen);
9329 			DMLOG_PRINT(DMLVL_DEBUG,
9330 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9331 				    rlen);
9332 			if (rc == 0) {
9333 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9334 				LogDirAttrs(buf, DM_AT_PMANR);
9335 				if (entry != NULL) {
9336 					if (entry->dt_pmanreg == DM_FALSE) {
9337 						DMLOG_PRINT(DMLVL_DEBUG,
9338 							    "%s passed with expected rc = %d\n",
9339 							    szFuncName, 0);
9340 						DMVAR_PASS();
9341 					} else {
9342 						DMLOG_PRINT(DMLVL_ERR,
9343 							    "%s failed with expected rc = %d but pmanreg NOT same (%d vs %d)\n",
9344 							    szFuncName, 0,
9345 							    entry->dt_pmanreg,
9346 							    DM_FALSE);
9347 						DMVAR_FAIL();
9348 					}
9349 				} else {
9350 					DMLOG_PRINT(DMLVL_ERR,
9351 						    "%s failed with expected rc = %d but unable to find entry %s",
9352 						    szFuncName, 0, DUMMY_FILE);
9353 					DMVAR_FAIL();
9354 				}
9355 			} else {
9356 				DMLOG_PRINT(DMLVL_ERR,
9357 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9358 					    szFuncName, rc, errno);
9359 				DMVAR_FAIL();
9360 			}
9361 
9362 			/* Variation clean up */
9363 			rc = remove(DUMMY_SUBDIR_FILE);
9364 			rc |= rmdir(DUMMY_SUBDIR);
9365 			if (rc == -1) {
9366 				DMLOG_PRINT(DMLVL_DEBUG,
9367 					    "Unable to clean up variation! (errno = %d)\n",
9368 					    errno);
9369 			}
9370 			dm_handle_free(dhanp, dhlen);
9371 		}
9372 	}
9373 
9374 	/*
9375 	 * TEST    : dm_get_dirattrs - DM_AT_PATTR with DM attribute
9376 	 * EXPECTED: rc = 0
9377 	 */
9378 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 16)) {
9379 		void *dhanp, *fhanp;
9380 		size_t dhlen, fhlen;
9381 		dm_attrloc_t loc;
9382 		char buf[ATTR_LISTLEN];
9383 		size_t rlen;
9384 		dm_attrname_t attrname;
9385 		char attrbuf[ATTR_VALUELEN];
9386 
9387 		/* Variation set up */
9388 		memset(buf, 0, ATTR_LISTLEN);
9389 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
9390 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
9391 		memcpy(attrbuf, ATTR_VALUE, ATTR_VALUELEN);
9392 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9393 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9394 			/* No clean up */
9395 		} else
9396 		    if ((rc =
9397 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9398 					   &dhlen)) == -1) {
9399 			rmdir(DUMMY_SUBDIR);
9400 		} else if ((rc = system(command)) == -1) {
9401 			dm_handle_free(dhanp, dhlen);
9402 			rmdir(DUMMY_SUBDIR);
9403 		} else
9404 		    if ((rc =
9405 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
9406 					   &fhlen)) == -1) {
9407 			remove(DUMMY_SUBDIR_FILE);
9408 			dm_handle_free(dhanp, dhlen);
9409 			rmdir(DUMMY_SUBDIR);
9410 		} else
9411 		    if (((rc =
9412 			  dm_set_dmattr(sid, fhanp, fhlen, DM_NO_TOKEN,
9413 					&attrname, 0, sizeof(attrbuf),
9414 					attrbuf)) == -1)
9415 			||
9416 			((rc =
9417 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9418 					  &loc)) == -1)) {
9419 			dm_handle_free(fhanp, fhlen);
9420 			remove(DUMMY_SUBDIR_FILE);
9421 			dm_handle_free(dhanp, dhlen);
9422 			rmdir(DUMMY_SUBDIR);
9423 		}
9424 		if (rc == -1) {
9425 			DMLOG_PRINT(DMLVL_DEBUG,
9426 				    "Unable to set up variation! (errno = %d)\n",
9427 				    errno);
9428 			DMVAR_SKIP();
9429 		} else {
9430 			/* Variation */
9431 			DMLOG_PRINT(DMLVL_DEBUG,
9432 				    "%s(DM_AT_PATTR with DM attr)\n",
9433 				    szFuncName);
9434 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9435 					     DM_AT_PATTR, &loc, sizeof(buf),
9436 					     buf, &rlen);
9437 			DMLOG_PRINT(DMLVL_DEBUG,
9438 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9439 				    rlen);
9440 			if (rc == 0) {
9441 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9442 				LogDirAttrs(buf, DM_AT_PATTR);
9443 				if (entry != NULL) {
9444 					if (entry->dt_pers == DM_TRUE) {
9445 						DMLOG_PRINT(DMLVL_DEBUG,
9446 							    "%s passed with expected rc = %d\n",
9447 							    szFuncName, 0);
9448 						DMVAR_PASS();
9449 					} else {
9450 						DMLOG_PRINT(DMLVL_ERR,
9451 							    "%s failed with expected rc = %d but pers NOT same (%d vs %d)\n",
9452 							    szFuncName, 0,
9453 							    entry->dt_pers,
9454 							    DM_TRUE);
9455 						DMVAR_FAIL();
9456 					}
9457 				} else {
9458 					DMLOG_PRINT(DMLVL_ERR,
9459 						    "%s failed with expected rc = %d but unable to find entry %s",
9460 						    szFuncName, 0, DUMMY_FILE);
9461 					DMVAR_FAIL();
9462 				}
9463 			} else {
9464 				DMLOG_PRINT(DMLVL_ERR,
9465 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9466 					    szFuncName, rc, errno);
9467 				DMVAR_FAIL();
9468 			}
9469 
9470 			/* Variation clean up */
9471 			rc = remove(DUMMY_SUBDIR_FILE);
9472 			rc |= rmdir(DUMMY_SUBDIR);
9473 			if (rc == -1) {
9474 				DMLOG_PRINT(DMLVL_DEBUG,
9475 					    "Unable to clean up variation! (errno = %d)\n",
9476 					    errno);
9477 			}
9478 			dm_handle_free(dhanp, dhlen);
9479 			dm_handle_free(fhanp, fhlen);
9480 		}
9481 	}
9482 
9483 	/*
9484 	 * TEST    : dm_get_dirattrs - DM_AT_PATTR without DM attribute
9485 	 * EXPECTED: rc = 0
9486 	 */
9487 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 17)) {
9488 		void *dhanp;
9489 		size_t dhlen;
9490 		dm_attrloc_t loc;
9491 		char buf[ATTR_LISTLEN];
9492 		size_t rlen;
9493 
9494 		/* Variation set up */
9495 		memset(buf, 0, ATTR_LISTLEN);
9496 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9497 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9498 			/* No clean up */
9499 		} else
9500 		    if ((rc =
9501 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9502 					   &dhlen)) == -1) {
9503 			rmdir(DUMMY_SUBDIR);
9504 		} else if ((rc = system(command)) == -1) {
9505 			dm_handle_free(dhanp, dhlen);
9506 			rmdir(DUMMY_SUBDIR);
9507 		} else
9508 		    if ((rc =
9509 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9510 					 &loc)) == -1) {
9511 			remove(DUMMY_SUBDIR_FILE);
9512 			dm_handle_free(dhanp, dhlen);
9513 			rmdir(DUMMY_SUBDIR);
9514 		}
9515 		if (rc == -1) {
9516 			DMLOG_PRINT(DMLVL_DEBUG,
9517 				    "Unable to set up variation! (errno = %d)\n",
9518 				    errno);
9519 			DMVAR_SKIP();
9520 		} else {
9521 			/* Variation */
9522 			DMLOG_PRINT(DMLVL_DEBUG,
9523 				    "%s(DM_AT_PATTR without DM attr)\n",
9524 				    szFuncName);
9525 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9526 					     DM_AT_PATTR, &loc, sizeof(buf),
9527 					     buf, &rlen);
9528 			DMLOG_PRINT(DMLVL_DEBUG,
9529 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9530 				    rlen);
9531 			if (rc == 0) {
9532 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9533 				LogDirAttrs(buf, DM_AT_PATTR);
9534 				if (entry != NULL) {
9535 					if (entry->dt_pers == DM_FALSE) {
9536 						DMLOG_PRINT(DMLVL_DEBUG,
9537 							    "%s passed with expected rc = %d\n",
9538 							    szFuncName, 0);
9539 						DMVAR_PASS();
9540 					} else {
9541 						DMLOG_PRINT(DMLVL_ERR,
9542 							    "%s failed with expected rc = %d but pers NOT same (%d vs %d)\n",
9543 							    szFuncName, 0,
9544 							    entry->dt_pers,
9545 							    DM_FALSE);
9546 						DMVAR_FAIL();
9547 					}
9548 				} else {
9549 					DMLOG_PRINT(DMLVL_ERR,
9550 						    "%s failed with expected rc = %d but unable to find entry %s",
9551 						    szFuncName, 0, DUMMY_FILE);
9552 					DMVAR_FAIL();
9553 				}
9554 			} else {
9555 				DMLOG_PRINT(DMLVL_ERR,
9556 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9557 					    szFuncName, rc, errno);
9558 				DMVAR_FAIL();
9559 			}
9560 
9561 			/* Variation clean up */
9562 			rc = remove(DUMMY_SUBDIR_FILE);
9563 			rc |= rmdir(DUMMY_SUBDIR);
9564 			if (rc == -1) {
9565 				DMLOG_PRINT(DMLVL_DEBUG,
9566 					    "Unable to clean up variation! (errno = %d)\n",
9567 					    errno);
9568 			}
9569 			dm_handle_free(dhanp, dhlen);
9570 		}
9571 	}
9572 
9573 	/*
9574 	 * TEST    : dm_get_dirattrs - DM_AT_DTIME with DM attribute
9575 	 * EXPECTED: rc = 0
9576 	 */
9577 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 18)) {
9578 		void *dhanp, *fhanp;
9579 		size_t dhlen, fhlen;
9580 		dm_attrloc_t loc;
9581 		char buf[ATTR_LISTLEN];
9582 		size_t rlen;
9583 		dm_attrname_t attrname;
9584 		char attrbuf[ATTR_VALUELEN];
9585 		struct stat statfs;
9586 
9587 		/* Variation set up */
9588 		memset(buf, 0, ATTR_LISTLEN);
9589 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
9590 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
9591 		memcpy(attrbuf, ATTR_VALUE, ATTR_VALUELEN);
9592 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9593 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9594 			/* No clean up */
9595 		} else
9596 		    if ((rc =
9597 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9598 					   &dhlen)) == -1) {
9599 			rmdir(DUMMY_SUBDIR);
9600 		} else if ((rc = system(command)) == -1) {
9601 			dm_handle_free(dhanp, dhlen);
9602 			rmdir(DUMMY_SUBDIR);
9603 		} else
9604 		    if ((rc =
9605 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
9606 					   &fhlen)) == -1) {
9607 			remove(DUMMY_SUBDIR_FILE);
9608 			dm_handle_free(dhanp, dhlen);
9609 			rmdir(DUMMY_SUBDIR);
9610 		} else if (((rc = stat(DUMMY_SUBDIR_FILE, &statfs)) == -1) ||
9611 			   ((rc =
9612 			     dm_set_dmattr(sid, fhanp, fhlen, DM_NO_TOKEN,
9613 					   &attrname, 0, sizeof(attrbuf),
9614 					   attrbuf)) == -1)
9615 			   ||
9616 			   ((rc =
9617 			     dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9618 					     &loc)) == -1)) {
9619 			dm_handle_free(fhanp, fhlen);
9620 			remove(DUMMY_SUBDIR_FILE);
9621 			dm_handle_free(dhanp, dhlen);
9622 			rmdir(DUMMY_SUBDIR);
9623 		}
9624 		if (rc == -1) {
9625 			DMLOG_PRINT(DMLVL_DEBUG,
9626 				    "Unable to set up variation! (errno = %d)\n",
9627 				    errno);
9628 			DMVAR_SKIP();
9629 		} else {
9630 			/* Variation */
9631 			DMLOG_PRINT(DMLVL_DEBUG,
9632 				    "%s(DM_AT_DTIME with DM attr)\n",
9633 				    szFuncName);
9634 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9635 					     DM_AT_DTIME, &loc, sizeof(buf),
9636 					     buf, &rlen);
9637 			DMLOG_PRINT(DMLVL_DEBUG,
9638 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9639 				    rlen);
9640 			if (rc == 0) {
9641 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9642 				LogDirAttrs(buf, DM_AT_DTIME);
9643 				if (entry != NULL) {
9644 					if (entry->dt_dtime == statfs.st_ctime) {
9645 						DMLOG_PRINT(DMLVL_DEBUG,
9646 							    "%s passed with expected rc = %d\n",
9647 							    szFuncName, 0);
9648 						DMVAR_PASS();
9649 					} else {
9650 						DMLOG_PRINT(DMLVL_ERR,
9651 							    "%s failed with expected rc = %d but dtime NOT same (%d vs %d)\n",
9652 							    szFuncName, 0,
9653 							    entry->dt_dtime,
9654 							    statfs.st_ctime);
9655 						DMVAR_FAIL();
9656 					}
9657 				} else {
9658 					DMLOG_PRINT(DMLVL_ERR,
9659 						    "%s failed with expected rc = %d but unable to find entry %s",
9660 						    szFuncName, 0, DUMMY_FILE);
9661 					DMVAR_FAIL();
9662 				}
9663 			} else {
9664 				DMLOG_PRINT(DMLVL_ERR,
9665 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9666 					    szFuncName, rc, errno);
9667 				DMVAR_FAIL();
9668 			}
9669 
9670 			/* Variation clean up */
9671 			rc = remove(DUMMY_SUBDIR_FILE);
9672 			rc |= rmdir(DUMMY_SUBDIR);
9673 			if (rc == -1) {
9674 				DMLOG_PRINT(DMLVL_DEBUG,
9675 					    "Unable to clean up variation! (errno = %d)\n",
9676 					    errno);
9677 			}
9678 			dm_handle_free(dhanp, dhlen);
9679 			dm_handle_free(fhanp, fhlen);
9680 		}
9681 	}
9682 
9683 	/*
9684 	 * TEST    : dm_get_dirattrs - DM_AT_DTIME without DM attribute
9685 	 * EXPECTED: rc = 0
9686 	 *
9687 	 * This variation uncovered XFS BUG #25 (dtime updated without any DM
9688 	 * attributes)
9689 	 */
9690 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 19)) {
9691 		void *dhanp;
9692 		size_t dhlen;
9693 		dm_attrloc_t loc;
9694 		char buf[ATTR_LISTLEN];
9695 		size_t rlen;
9696 		struct stat statfs;
9697 
9698 		/* Variation set up */
9699 		memset(buf, 0, ATTR_LISTLEN);
9700 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9701 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9702 			/* No clean up */
9703 		} else
9704 		    if ((rc =
9705 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9706 					   &dhlen)) == -1) {
9707 			rmdir(DUMMY_SUBDIR);
9708 		} else if ((rc = system(command)) == -1) {
9709 			dm_handle_free(dhanp, dhlen);
9710 			rmdir(DUMMY_SUBDIR);
9711 		} else if (((rc = stat(DUMMY_SUBDIR_FILE, &statfs)) == -1) ||
9712 			   ((rc =
9713 			     dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9714 					     &loc)) == -1)) {
9715 			remove(DUMMY_SUBDIR_FILE);
9716 			dm_handle_free(dhanp, dhlen);
9717 			rmdir(DUMMY_SUBDIR);
9718 		}
9719 		if (rc == -1) {
9720 			DMLOG_PRINT(DMLVL_DEBUG,
9721 				    "Unable to set up variation! (errno = %d)\n",
9722 				    errno);
9723 			DMVAR_SKIP();
9724 		} else {
9725 			/* Variation */
9726 			DMLOG_PRINT(DMLVL_DEBUG,
9727 				    "%s(DM_AT_DTIME without DM attr)\n",
9728 				    szFuncName);
9729 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9730 					     DM_AT_DTIME, &loc, sizeof(buf),
9731 					     buf, &rlen);
9732 			DMLOG_PRINT(DMLVL_DEBUG,
9733 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9734 				    rlen);
9735 			if (rc == 0) {
9736 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
9737 				LogDirAttrs(buf, DM_AT_DTIME);
9738 				if (entry != NULL) {
9739 					if (entry->dt_dtime != statfs.st_ctime) {
9740 						DMLOG_PRINT(DMLVL_DEBUG,
9741 							    "%s passed with expected rc = %d\n",
9742 							    szFuncName, 0);
9743 						DMVAR_PASS();
9744 					} else {
9745 						DMLOG_PRINT(DMLVL_ERR,
9746 							    "%s failed with expected rc = %d but dtime same (%d vs %d)\n",
9747 							    szFuncName, 0,
9748 							    entry->dt_dtime,
9749 							    statfs.st_ctime);
9750 						DMVAR_FAIL();
9751 					}
9752 				} else {
9753 					DMLOG_PRINT(DMLVL_ERR,
9754 						    "%s failed with expected rc = %d but unable to find entry %s",
9755 						    szFuncName, 0, DUMMY_FILE);
9756 					DMVAR_FAIL();
9757 				}
9758 			} else {
9759 				DMLOG_PRINT(DMLVL_ERR,
9760 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9761 					    szFuncName, rc, errno);
9762 				DMVAR_FAIL();
9763 			}
9764 
9765 			/* Variation clean up */
9766 			rc = remove(DUMMY_SUBDIR_FILE);
9767 			rc |= rmdir(DUMMY_SUBDIR);
9768 			if (rc == -1) {
9769 				DMLOG_PRINT(DMLVL_DEBUG,
9770 					    "Unable to clean up variation! (errno = %d)\n",
9771 					    errno);
9772 			}
9773 			dm_handle_free(dhanp, dhlen);
9774 		}
9775 	}
9776 
9777 	/*
9778 	 * TEST    : dm_get_dirattrs - DM_AT_CFLAG with no change
9779 	 * EXPECTED: rc = 0
9780 	 */
9781 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 20)) {
9782 		void *dhanp;
9783 		size_t dhlen;
9784 		dm_attrloc_t loc;
9785 		char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
9786 		size_t rlen;
9787 
9788 		/* Variation set up */
9789 		memset(buf1, 0, ATTR_LISTLEN);
9790 		memset(buf2, 0, ATTR_LISTLEN);
9791 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9792 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9793 			/* No clean up */
9794 		} else
9795 		    if ((rc =
9796 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9797 					   &dhlen)) == -1) {
9798 			rmdir(DUMMY_SUBDIR);
9799 		} else if ((rc = system(command)) == -1) {
9800 			dm_handle_free(dhanp, dhlen);
9801 			rmdir(DUMMY_SUBDIR);
9802 		} else
9803 		    if (((rc =
9804 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9805 					  &loc)) == -1)
9806 			||
9807 			((rc =
9808 			  dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9809 					  DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
9810 					  &rlen)) == -1)
9811 			||
9812 			((rc =
9813 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9814 					  &loc)) == -1)) {
9815 			remove(DUMMY_SUBDIR_FILE);
9816 			dm_handle_free(dhanp, dhlen);
9817 			rmdir(DUMMY_SUBDIR);
9818 		}
9819 		if (rc == -1) {
9820 			DMLOG_PRINT(DMLVL_DEBUG,
9821 				    "Unable to set up variation! (errno = %d)\n",
9822 				    errno);
9823 			DMVAR_SKIP();
9824 		} else {
9825 			/* Variation */
9826 			DMLOG_PRINT(DMLVL_DEBUG,
9827 				    "%s(DM_AT_CFLAG with no change)\n",
9828 				    szFuncName);
9829 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9830 					     DM_AT_CFLAG, &loc, sizeof(buf2),
9831 					     buf2, &rlen);
9832 			DMLOG_PRINT(DMLVL_DEBUG,
9833 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9834 				    rlen);
9835 			if (rc == 0) {
9836 				dm_stat_t *entry1 =
9837 				    GetDirEntry(buf1, DUMMY_FILE);
9838 				dm_stat_t *entry2 =
9839 				    GetDirEntry(buf2, DUMMY_FILE);
9840 				LogDirAttrs(buf2, DM_AT_CFLAG);
9841 				if ((entry1 != NULL) && (entry2 != NULL)) {
9842 					if (entry1->dt_change ==
9843 					    entry2->dt_change) {
9844 						DMLOG_PRINT(DMLVL_DEBUG,
9845 							    "%s passed with expected rc = %d\n",
9846 							    szFuncName, 0);
9847 						DMVAR_PASS();
9848 					} else {
9849 						DMLOG_PRINT(DMLVL_ERR,
9850 							    "%s failed with expected rc = %d but change not same (%d vs %d)\n",
9851 							    szFuncName, 0,
9852 							    entry1->dt_change,
9853 							    entry2->dt_change);
9854 						DMVAR_FAIL();
9855 					}
9856 				} else {
9857 					DMLOG_PRINT(DMLVL_ERR,
9858 						    "%s failed with expected rc = %d but unable to find entry %s",
9859 						    szFuncName, 0, DUMMY_FILE);
9860 					DMVAR_FAIL();
9861 				}
9862 			} else {
9863 				DMLOG_PRINT(DMLVL_ERR,
9864 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9865 					    szFuncName, rc, errno);
9866 				DMVAR_FAIL();
9867 			}
9868 
9869 			/* Variation clean up */
9870 			rc = remove(DUMMY_SUBDIR_FILE);
9871 			rc |= rmdir(DUMMY_SUBDIR);
9872 			if (rc == -1) {
9873 				DMLOG_PRINT(DMLVL_DEBUG,
9874 					    "Unable to clean up variation! (errno = %d)\n",
9875 					    errno);
9876 			}
9877 			dm_handle_free(dhanp, dhlen);
9878 		}
9879 	}
9880 
9881 	/*
9882 	 * TEST    : dm_get_dirattrs - DM_AT_CFLAG with data change
9883 	 * EXPECTED: rc = 0
9884 	 */
9885 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 21)) {
9886 		int fd;
9887 		void *dhanp;
9888 		size_t dhlen;
9889 		dm_attrloc_t loc;
9890 		char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
9891 		size_t rlen;
9892 
9893 		/* Variation set up */
9894 		memset(buf1, 0, ATTR_LISTLEN);
9895 		memset(buf2, 0, ATTR_LISTLEN);
9896 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
9897 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
9898 			/* No clean up */
9899 		} else
9900 		    if ((rc =
9901 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
9902 					   &dhlen)) == -1) {
9903 			rmdir(DUMMY_SUBDIR);
9904 		} else if ((rc = system(command)) == -1) {
9905 			dm_handle_free(dhanp, dhlen);
9906 			rmdir(DUMMY_SUBDIR);
9907 		} else if ((fd = open(DUMMY_SUBDIR_FILE, O_RDWR | O_CREAT,
9908 				      DUMMY_FILE_RW_MODE)) == -1) {
9909 			remove(DUMMY_SUBDIR_FILE);
9910 			dm_handle_free(dhanp, dhlen);
9911 			rmdir(DUMMY_SUBDIR);
9912 		} else
9913 		    if (((rc =
9914 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9915 					  &loc)) == -1)
9916 			||
9917 			((rc =
9918 			  dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9919 					  DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
9920 					  &rlen)) == -1)
9921 			||
9922 			((rc =
9923 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
9924 					  &loc)) == -1)
9925 			||
9926 			((rc =
9927 			  (write(fd, DUMMY_STRING, DUMMY_STRLEN) !=
9928 			   DUMMY_STRLEN ? -1 : 0) == 1))) {
9929 			close(fd);
9930 			remove(DUMMY_SUBDIR_FILE);
9931 			dm_handle_free(dhanp, dhlen);
9932 			rmdir(DUMMY_SUBDIR);
9933 		}
9934 		if (fd == -1 || rc == -1) {
9935 			DMLOG_PRINT(DMLVL_DEBUG,
9936 				    "Unable to set up variation! (errno = %d)\n",
9937 				    errno);
9938 			DMVAR_SKIP();
9939 		} else {
9940 			/* Variation */
9941 			DMLOG_PRINT(DMLVL_DEBUG,
9942 				    "%s(DM_AT_CFLAG with data change)\n",
9943 				    szFuncName);
9944 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
9945 					     DM_AT_CFLAG, &loc, sizeof(buf2),
9946 					     buf2, &rlen);
9947 			DMLOG_PRINT(DMLVL_DEBUG,
9948 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
9949 				    rlen);
9950 			if (rc == 0) {
9951 				dm_stat_t *entry1 =
9952 				    GetDirEntry(buf1, DUMMY_FILE);
9953 				dm_stat_t *entry2 =
9954 				    GetDirEntry(buf2, DUMMY_FILE);
9955 				LogDirAttrs(buf2, DM_AT_CFLAG);
9956 				if ((entry1 != NULL) && (entry2 != NULL)) {
9957 					if (entry1->dt_change !=
9958 					    entry2->dt_change) {
9959 						DMLOG_PRINT(DMLVL_DEBUG,
9960 							    "%s passed with expected rc = %d\n",
9961 							    szFuncName, 0);
9962 						DMVAR_PASS();
9963 					} else {
9964 						DMLOG_PRINT(DMLVL_ERR,
9965 							    "%s failed with expected rc = %d but change same (%d vs %d)\n",
9966 							    szFuncName, 0,
9967 							    entry1->dt_change,
9968 							    entry2->dt_change);
9969 						DMVAR_FAIL();
9970 					}
9971 				} else {
9972 					DMLOG_PRINT(DMLVL_ERR,
9973 						    "%s failed with expected rc = %d but unable to find entry %s",
9974 						    szFuncName, 0, DUMMY_FILE);
9975 					DMVAR_FAIL();
9976 				}
9977 			} else {
9978 				DMLOG_PRINT(DMLVL_ERR,
9979 					    "%s failed with unexpected rc = %d (errno = %d)\n",
9980 					    szFuncName, rc, errno);
9981 				DMVAR_FAIL();
9982 			}
9983 
9984 			/* Variation clean up */
9985 			rc = remove(DUMMY_SUBDIR_FILE);
9986 			rc |= rmdir(DUMMY_SUBDIR);
9987 			if (rc == -1) {
9988 				DMLOG_PRINT(DMLVL_DEBUG,
9989 					    "Unable to clean up variation! (errno = %d)\n",
9990 					    errno);
9991 			}
9992 			dm_handle_free(dhanp, dhlen);
9993 		}
9994 	}
9995 
9996 	/*
9997 	 * TEST    : dm_get_dirattrs - DM_AT_CFLAG with metadata change
9998 	 * EXPECTED: rc = 0
9999 	 */
10000 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 22)) {
10001 		void *dhanp;
10002 		size_t dhlen;
10003 		dm_attrloc_t loc;
10004 		char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
10005 		size_t rlen;
10006 
10007 		/* Variation set up */
10008 		memset(buf1, 0, ATTR_LISTLEN);
10009 		memset(buf2, 0, ATTR_LISTLEN);
10010 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10011 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10012 			/* No clean up */
10013 		} else
10014 		    if ((rc =
10015 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10016 					   &dhlen)) == -1) {
10017 			rmdir(DUMMY_SUBDIR);
10018 		} else if ((rc = system(command)) == -1) {
10019 			dm_handle_free(dhanp, dhlen);
10020 			rmdir(DUMMY_SUBDIR);
10021 		} else
10022 		    if (((rc =
10023 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10024 					  &loc)) == -1)
10025 			||
10026 			((rc =
10027 			  dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10028 					  DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
10029 					  &rlen)) == -1)
10030 			||
10031 			((rc =
10032 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10033 					  &loc)) == -1)
10034 			||
10035 			((rc =
10036 			  chown(DUMMY_SUBDIR_FILE, DUMMY_UID,
10037 				DUMMY_GID)) == -1)) {
10038 			remove(DUMMY_SUBDIR_FILE);
10039 			dm_handle_free(dhanp, dhlen);
10040 			rmdir(DUMMY_SUBDIR);
10041 		}
10042 		if (rc == -1) {
10043 			DMLOG_PRINT(DMLVL_DEBUG,
10044 				    "Unable to set up variation! (errno = %d)\n",
10045 				    errno);
10046 			DMVAR_SKIP();
10047 		} else {
10048 			/* Variation */
10049 			DMLOG_PRINT(DMLVL_DEBUG,
10050 				    "%s(DM_AT_CFLAG with metadata change)\n",
10051 				    szFuncName);
10052 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10053 					     DM_AT_CFLAG, &loc, sizeof(buf2),
10054 					     buf2, &rlen);
10055 			DMLOG_PRINT(DMLVL_DEBUG,
10056 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
10057 				    rlen);
10058 			if (rc == 0) {
10059 				dm_stat_t *entry1 =
10060 				    GetDirEntry(buf1, DUMMY_FILE);
10061 				dm_stat_t *entry2 =
10062 				    GetDirEntry(buf2, DUMMY_FILE);
10063 				LogDirAttrs(buf2, DM_AT_CFLAG);
10064 				if ((entry1 != NULL) && (entry2 != NULL)) {
10065 					if (entry1->dt_change !=
10066 					    entry2->dt_change) {
10067 						DMLOG_PRINT(DMLVL_DEBUG,
10068 							    "%s passed with expected rc = %d\n",
10069 							    szFuncName, 0);
10070 						DMVAR_PASS();
10071 					} else {
10072 						DMLOG_PRINT(DMLVL_ERR,
10073 							    "%s failed with expected rc = %d but change same (%d vs %d)\n",
10074 							    szFuncName, 0,
10075 							    entry1->dt_change,
10076 							    entry2->dt_change);
10077 						DMVAR_FAIL();
10078 					}
10079 				} else {
10080 					DMLOG_PRINT(DMLVL_ERR,
10081 						    "%s failed with expected rc = %d but unable to find entry %s",
10082 						    szFuncName, 0, DUMMY_FILE);
10083 					DMVAR_FAIL();
10084 				}
10085 			} else {
10086 				DMLOG_PRINT(DMLVL_ERR,
10087 					    "%s failed with unexpected rc = %d (errno = %d)\n",
10088 					    szFuncName, rc, errno);
10089 				DMVAR_FAIL();
10090 			}
10091 
10092 			/* Variation clean up */
10093 			rc = remove(DUMMY_SUBDIR_FILE);
10094 			rc |= rmdir(DUMMY_SUBDIR);
10095 			if (rc == -1) {
10096 				DMLOG_PRINT(DMLVL_DEBUG,
10097 					    "Unable to clean up variation! (errno = %d)\n",
10098 					    errno);
10099 			}
10100 			dm_handle_free(dhanp, dhlen);
10101 		}
10102 	}
10103 
10104 	/*
10105 	 * TEST    : dm_get_dirattrs - DM_AT_CFLAG with DM attribute change
10106 	 * EXPECTED: rc = 0
10107 	 */
10108 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 23)) {
10109 		void *dhanp, *fhanp;
10110 		size_t dhlen, fhlen;
10111 		dm_attrloc_t loc;
10112 		char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
10113 		size_t rlen;
10114 		dm_attrname_t attrname;
10115 
10116 		/* Variation set up */
10117 		memset(buf1, 0, ATTR_LISTLEN);
10118 		memset(buf2, 0, ATTR_LISTLEN);
10119 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
10120 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
10121 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10122 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10123 			/* No clean up */
10124 		} else
10125 		    if ((rc =
10126 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10127 					   &dhlen)) == -1) {
10128 			rmdir(DUMMY_SUBDIR);
10129 		} else if ((rc = system(command)) == -1) {
10130 			dm_handle_free(dhanp, dhlen);
10131 			rmdir(DUMMY_SUBDIR);
10132 		} else
10133 		    if ((rc =
10134 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
10135 					   &fhlen)) == -1) {
10136 			remove(DUMMY_SUBDIR_FILE);
10137 			dm_handle_free(dhanp, dhlen);
10138 			rmdir(DUMMY_SUBDIR);
10139 		} else
10140 		    if (((rc =
10141 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10142 					  &loc)) == -1)
10143 			||
10144 			((rc =
10145 			  dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10146 					  DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
10147 					  &rlen)) == -1)
10148 			||
10149 			((rc =
10150 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10151 					  &loc)) == -1)
10152 			||
10153 			((rc =
10154 			  dm_set_dmattr(sid, fhanp, fhlen, DM_NO_TOKEN,
10155 					&attrname, 0, 0, NULL)) == -1)) {
10156 			dm_handle_free(fhanp, fhlen);
10157 			remove(DUMMY_SUBDIR_FILE);
10158 			dm_handle_free(dhanp, dhlen);
10159 			rmdir(DUMMY_SUBDIR);
10160 		}
10161 		if (rc == -1) {
10162 			DMLOG_PRINT(DMLVL_DEBUG,
10163 				    "Unable to set up variation! (errno = %d)\n",
10164 				    errno);
10165 			DMVAR_SKIP();
10166 		} else {
10167 			/* Variation */
10168 			DMLOG_PRINT(DMLVL_DEBUG,
10169 				    "%s(DM_AT_CFLAG with DM attr change)\n",
10170 				    szFuncName);
10171 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10172 					     DM_AT_CFLAG, &loc, sizeof(buf2),
10173 					     buf2, &rlen);
10174 			DMLOG_PRINT(DMLVL_DEBUG,
10175 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
10176 				    rlen);
10177 			if (rc == 0) {
10178 				dm_stat_t *entry1 =
10179 				    GetDirEntry(buf1, DUMMY_FILE);
10180 				dm_stat_t *entry2 =
10181 				    GetDirEntry(buf2, DUMMY_FILE);
10182 				LogDirAttrs(buf2, DM_AT_CFLAG);
10183 				if ((entry1 != NULL) && (entry2 != NULL)) {
10184 					if (entry1->dt_change !=
10185 					    entry2->dt_change) {
10186 						DMLOG_PRINT(DMLVL_DEBUG,
10187 							    "%s passed with expected rc = %d\n",
10188 							    szFuncName, 0);
10189 						DMVAR_PASS();
10190 					} else {
10191 						DMLOG_PRINT(DMLVL_ERR,
10192 							    "%s failed with expected rc = %d but change same (%d vs %d)\n",
10193 							    szFuncName, 0,
10194 							    entry1->dt_change,
10195 							    entry2->dt_change);
10196 						DMVAR_FAIL();
10197 					}
10198 				} else {
10199 					DMLOG_PRINT(DMLVL_ERR,
10200 						    "%s failed with expected rc = %d but unable to find entry %s",
10201 						    szFuncName, 0, DUMMY_FILE);
10202 					DMVAR_FAIL();
10203 				}
10204 			} else {
10205 				DMLOG_PRINT(DMLVL_ERR,
10206 					    "%s failed with unexpected rc = %d (errno = %d)\n",
10207 					    szFuncName, rc, errno);
10208 				DMVAR_FAIL();
10209 			}
10210 
10211 			/* Variation clean up */
10212 			rc = remove(DUMMY_SUBDIR_FILE);
10213 			rc |= rmdir(DUMMY_SUBDIR);
10214 			if (rc == -1) {
10215 				DMLOG_PRINT(DMLVL_DEBUG,
10216 					    "Unable to clean up variation! (errno = %d)\n",
10217 					    errno);
10218 			}
10219 			dm_handle_free(dhanp, dhlen);
10220 			dm_handle_free(fhanp, fhlen);
10221 		}
10222 	}
10223 
10224 	/*
10225 	 * TEST    : dm_get_dirattrs - DM_AT_CFLAG with non-DM attribute change
10226 	 * EXPECTED: rc = 0
10227 	 */
10228 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 23)) {
10229 		void *dhanp, *fhanp;
10230 		size_t dhlen, fhlen;
10231 		dm_attrloc_t loc;
10232 		char buf1[ATTR_LISTLEN], buf2[ATTR_LISTLEN];
10233 		size_t rlen;
10234 		dm_attrname_t attrname;
10235 
10236 		/* Variation set up */
10237 		memset(buf1, 0, ATTR_LISTLEN);
10238 		memset(buf2, 0, ATTR_LISTLEN);
10239 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
10240 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
10241 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10242 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10243 			/* No clean up */
10244 		} else
10245 		    if ((rc =
10246 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10247 					   &dhlen)) == -1) {
10248 			rmdir(DUMMY_SUBDIR);
10249 		} else if ((rc = system(command)) == -1) {
10250 			dm_handle_free(dhanp, dhlen);
10251 			rmdir(DUMMY_SUBDIR);
10252 		} else
10253 		    if ((rc =
10254 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp,
10255 					   &fhlen)) == -1) {
10256 			remove(DUMMY_SUBDIR_FILE);
10257 			dm_handle_free(dhanp, dhlen);
10258 			rmdir(DUMMY_SUBDIR);
10259 		} else
10260 		    if (((rc =
10261 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10262 					  &loc)) == -1)
10263 			||
10264 			((rc =
10265 			  dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10266 					  DM_AT_CFLAG, &loc, sizeof(buf1), buf1,
10267 					  &rlen)) == -1)
10268 			||
10269 			((rc =
10270 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10271 					  &loc)) == -1)
10272 			||
10273 			((rc =
10274 			  setxattr(DUMMY_SUBDIR_FILE, NON_DM_ATTR_NAME,
10275 				   NON_DM_ATTR_VALUE, sizeof(NON_DM_ATTR_VALUE),
10276 				   0)) == -1)) {
10277 			dm_handle_free(fhanp, fhlen);
10278 			remove(DUMMY_SUBDIR_FILE);
10279 			dm_handle_free(dhanp, dhlen);
10280 			rmdir(DUMMY_SUBDIR);
10281 		}
10282 		if (rc == -1) {
10283 			DMLOG_PRINT(DMLVL_DEBUG,
10284 				    "Unable to set up variation! (errno = %d)\n",
10285 				    errno);
10286 			DMVAR_SKIP();
10287 		} else {
10288 			/* Variation */
10289 			DMLOG_PRINT(DMLVL_DEBUG,
10290 				    "%s(DM_AT_CFLAG with non-DM attr change)\n",
10291 				    szFuncName);
10292 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10293 					     DM_AT_CFLAG, &loc, sizeof(buf2),
10294 					     buf2, &rlen);
10295 			DMLOG_PRINT(DMLVL_DEBUG,
10296 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
10297 				    rlen);
10298 			if (rc == 0) {
10299 				dm_stat_t *entry1 =
10300 				    GetDirEntry(buf1, DUMMY_FILE);
10301 				dm_stat_t *entry2 =
10302 				    GetDirEntry(buf2, DUMMY_FILE);
10303 				LogDirAttrs(buf2, DM_AT_CFLAG);
10304 				if ((entry1 != NULL) && (entry2 != NULL)) {
10305 					if (entry1->dt_change !=
10306 					    entry2->dt_change) {
10307 						DMLOG_PRINT(DMLVL_DEBUG,
10308 							    "%s passed with expected rc = %d\n",
10309 							    szFuncName, 0);
10310 						DMVAR_PASS();
10311 					} else {
10312 						DMLOG_PRINT(DMLVL_ERR,
10313 							    "%s failed with expected rc = %d but change same (%d vs %d)\n",
10314 							    szFuncName, 0,
10315 							    entry1->dt_change,
10316 							    entry2->dt_change);
10317 						DMVAR_FAIL();
10318 					}
10319 				} else {
10320 					DMLOG_PRINT(DMLVL_ERR,
10321 						    "%s failed with expected rc = %d but unable to find entry %s",
10322 						    szFuncName, 0, DUMMY_FILE);
10323 					DMVAR_FAIL();
10324 				}
10325 			} else {
10326 				DMLOG_PRINT(DMLVL_ERR,
10327 					    "%s failed with unexpected rc = %d (errno = %d)\n",
10328 					    szFuncName, rc, errno);
10329 				DMVAR_FAIL();
10330 			}
10331 
10332 			/* Variation clean up */
10333 			rc = remove(DUMMY_SUBDIR_FILE);
10334 			rc |= rmdir(DUMMY_SUBDIR);
10335 			if (rc == -1) {
10336 				DMLOG_PRINT(DMLVL_DEBUG,
10337 					    "Unable to clean up variation! (errno = %d)\n",
10338 					    errno);
10339 			}
10340 			dm_handle_free(dhanp, dhlen);
10341 			dm_handle_free(fhanp, fhlen);
10342 		}
10343 	}
10344 
10345 	/*
10346 	 * TEST    : dm_get_dirattrs - DM_AT_STAT
10347 	 * EXPECTED: rc = 0
10348 	 */
10349 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 24)) {
10350 		void *dhanp;
10351 		size_t dhlen;
10352 		dm_attrloc_t loc;
10353 		char buf[ATTR_LISTLEN];
10354 		size_t rlen;
10355 		struct stat statfs;
10356 		int varStatus;
10357 
10358 		/* Variation set up */
10359 		memset(buf, 0, ATTR_LISTLEN);
10360 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10361 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10362 			/* No clean up */
10363 		} else
10364 		    if ((rc =
10365 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10366 					   &dhlen)) == -1) {
10367 			rmdir(DUMMY_SUBDIR);
10368 		} else if ((rc = system(command)) == -1) {
10369 			dm_handle_free(dhanp, dhlen);
10370 			rmdir(DUMMY_SUBDIR);
10371 		} else
10372 		    if (((rc =
10373 			  dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10374 					  &loc)) == -1)
10375 			|| ((rc = stat(DUMMY_SUBDIR_FILE, &statfs)) == -1)) {
10376 			remove(DUMMY_SUBDIR_FILE);
10377 			dm_handle_free(dhanp, dhlen);
10378 			rmdir(DUMMY_SUBDIR);
10379 		}
10380 		if (rc == -1) {
10381 			DMLOG_PRINT(DMLVL_DEBUG,
10382 				    "Unable to set up variation! (errno = %d)\n",
10383 				    errno);
10384 			DMVAR_SKIP();
10385 		} else {
10386 			/* Variation */
10387 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_STAT)\n",
10388 				    szFuncName);
10389 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10390 					     DM_AT_STAT, &loc, sizeof(buf), buf,
10391 					     &rlen);
10392 			DMLOG_PRINT(DMLVL_DEBUG,
10393 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
10394 				    rlen);
10395 			if (rc == 0) {
10396 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
10397 				LogDirAttrs(buf, DM_AT_STAT);
10398 				if (entry != NULL) {
10399 					varStatus = DMSTAT_PASS;
10400 					DMLOG_PRINT(DMLVL_DEBUG,
10401 						    "%s returned expected rc = %d\n",
10402 						    szFuncName, rc);
10403 					if (statfs.st_dev != entry->dt_dev) {
10404 						DMLOG_PRINT(DMLVL_ERR,
10405 							    "%s failed with nonmatching dev (%lld vs %lld)\n",
10406 							    szFuncName,
10407 							    statfs.st_dev,
10408 							    entry->dt_dev);
10409 						varStatus = DMSTAT_FAIL;
10410 					}
10411 					if (statfs.st_ino != entry->dt_ino) {
10412 						DMLOG_PRINT(DMLVL_ERR,
10413 							    "%s failed with nonmatching ino (%lld vs %lld)\n",
10414 							    szFuncName,
10415 							    statfs.st_ino,
10416 							    entry->dt_ino);
10417 						varStatus = DMSTAT_FAIL;
10418 					}
10419 					if (statfs.st_mode != entry->dt_mode) {
10420 						DMLOG_PRINT(DMLVL_ERR,
10421 							    "%s failed with nonmatching mode (%d vs %d)\n",
10422 							    szFuncName,
10423 							    statfs.st_mode,
10424 							    entry->dt_mode);
10425 						varStatus = DMSTAT_FAIL;
10426 					}
10427 					if (statfs.st_nlink != entry->dt_nlink) {
10428 						DMLOG_PRINT(DMLVL_ERR,
10429 							    "%s failed with nonmatching nlink (%d vs %d)\n",
10430 							    szFuncName,
10431 							    statfs.st_nlink,
10432 							    entry->dt_nlink);
10433 						varStatus = DMSTAT_FAIL;
10434 					}
10435 					if (statfs.st_uid != entry->dt_uid) {
10436 						DMLOG_PRINT(DMLVL_ERR,
10437 							    "%s failed with nonmatching uid (%d vs %d)\n",
10438 							    szFuncName,
10439 							    statfs.st_uid,
10440 							    entry->dt_uid);
10441 						varStatus = DMSTAT_FAIL;
10442 					}
10443 					if (statfs.st_gid != entry->dt_gid) {
10444 						DMLOG_PRINT(DMLVL_ERR,
10445 							    "%s failed with nonmatching gid (%d vs %d)\n",
10446 							    szFuncName,
10447 							    statfs.st_gid,
10448 							    entry->dt_gid);
10449 						varStatus = DMSTAT_FAIL;
10450 					}
10451 					if (statfs.st_rdev != entry->dt_rdev) {
10452 						DMLOG_PRINT(DMLVL_ERR,
10453 							    "%s failed with nonmatching rdev (%lld vs %lld)\n",
10454 							    szFuncName,
10455 							    statfs.st_rdev,
10456 							    entry->dt_rdev);
10457 						varStatus = DMSTAT_FAIL;
10458 					}
10459 					if (statfs.st_size != entry->dt_size) {
10460 						DMLOG_PRINT(DMLVL_ERR,
10461 							    "%s failed with nonmatching size (%lld vs %lld)\n",
10462 							    szFuncName,
10463 							    statfs.st_size,
10464 							    entry->dt_size);
10465 						varStatus = DMSTAT_FAIL;
10466 					}
10467 					if (statfs.st_atime != entry->dt_atime) {
10468 						DMLOG_PRINT(DMLVL_ERR,
10469 							    "%s failed with nonmatching atime (%d vs %d)\n",
10470 							    szFuncName,
10471 							    statfs.st_atime,
10472 							    entry->dt_atime);
10473 						varStatus = DMSTAT_FAIL;
10474 					}
10475 					if (statfs.st_mtime != entry->dt_mtime) {
10476 						DMLOG_PRINT(DMLVL_ERR,
10477 							    "%s failed with nonmatching mtime (%d vs %d)\n",
10478 							    szFuncName,
10479 							    statfs.st_mtime,
10480 							    entry->dt_mtime);
10481 						varStatus = DMSTAT_FAIL;
10482 					}
10483 					if (statfs.st_ctime != entry->dt_ctime) {
10484 						DMLOG_PRINT(DMLVL_ERR,
10485 							    "%s failed with nonmatching ctime (%d vs %d)\n",
10486 							    szFuncName,
10487 							    statfs.st_ctime,
10488 							    entry->dt_ctime);
10489 						varStatus = DMSTAT_FAIL;
10490 					}
10491 					if (statfs.st_blksize !=
10492 					    entry->dt_blksize) {
10493 						DMLOG_PRINT(DMLVL_ERR,
10494 							    "%s failed with nonmatching blksize (%d vs %d)\n",
10495 							    szFuncName,
10496 							    statfs.st_blksize,
10497 							    entry->dt_blksize);
10498 						varStatus = DMSTAT_FAIL;
10499 					}
10500 					if (statfs.st_blocks !=
10501 					    entry->dt_blocks) {
10502 						DMLOG_PRINT(DMLVL_ERR,
10503 							    "%s failed with nonmatching blocks (%lld vs %lld)\n",
10504 							    szFuncName,
10505 							    statfs.st_blocks,
10506 							    entry->dt_blocks);
10507 						varStatus = DMSTAT_FAIL;
10508 					}
10509 				} else {
10510 					DMLOG_PRINT(DMLVL_ERR,
10511 						    "%s failed with expected rc = %d but unable to find entry %s",
10512 						    szFuncName, 0, DUMMY_FILE);
10513 					varStatus = DMSTAT_FAIL;
10514 				}
10515 			} else {
10516 				DMLOG_PRINT(DMLVL_ERR,
10517 					    "%s failed with unexpected rc = %d (errno = %d)\n",
10518 					    szFuncName, rc, errno);
10519 				varStatus = DMSTAT_FAIL;
10520 			}
10521 			DMVAR_END(varStatus);
10522 
10523 			/* Variation clean up */
10524 			rc = remove(DUMMY_SUBDIR_FILE);
10525 			rc |= rmdir(DUMMY_SUBDIR);
10526 			if (rc == -1) {
10527 				DMLOG_PRINT(DMLVL_DEBUG,
10528 					    "Unable to clean up variation! (errno = %d)\n",
10529 					    errno);
10530 			}
10531 			dm_handle_free(dhanp, dhlen);
10532 		}
10533 	}
10534 
10535 	/*
10536 	 * TEST    : dm_get_dirattrs - DM_AT_STAT returned over two calls
10537 	 * EXPECTED: rc = 1, 0
10538 	 */
10539 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 25)) {
10540 		void *dhanp;
10541 		size_t dhlen;
10542 		dm_attrloc_t loc;
10543 		char buf1[2 * ATTR_SMALLLEN];
10544 		char buf2[ATTR_SMALLLEN + 1];
10545 		size_t rlen1, rlen2;
10546 		dm_stat_t *entry;
10547 		int rc1, rc2;
10548 		int varStatus;
10549 		int num;
10550 
10551 		/* Variation set up */
10552 		memset(buf1, 0, sizeof(buf1));
10553 		memset(buf2, 0, sizeof(buf2));
10554 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10555 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10556 			/* No clean up */
10557 		} else
10558 		    if ((rc =
10559 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10560 					   &dhlen)) == -1) {
10561 			rmdir(DUMMY_SUBDIR);
10562 		} else if ((rc = system(command)) == -1) {
10563 			dm_handle_free(dhanp, dhlen);
10564 			rmdir(DUMMY_SUBDIR);
10565 		} else
10566 		    if ((rc =
10567 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10568 					 &loc)) == -1) {
10569 			remove(DUMMY_SUBDIR_FILE);
10570 			dm_handle_free(dhanp, dhlen);
10571 			rmdir(DUMMY_SUBDIR);
10572 		}
10573 		if (rc == -1) {
10574 			DMLOG_PRINT(DMLVL_DEBUG,
10575 				    "Unable to set up variation! (errno = %d)\n",
10576 				    errno);
10577 			DMVAR_SKIP();
10578 		} else {
10579 			/* Variation */
10580 			DMLOG_PRINT(DMLVL_DEBUG,
10581 				    "%s(DM_AT_STAT over two calls)\n",
10582 				    szFuncName);
10583 			rc1 =
10584 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10585 					    DM_AT_STAT, &loc, sizeof(buf1),
10586 					    buf1, &rlen1);
10587 			DMLOG_PRINT(DMLVL_DEBUG,
10588 				    "1st call: rc %d, rlen %d, loc %llx\n", rc1,
10589 				    rlen1, loc);
10590 			rc2 =
10591 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10592 					    DM_AT_STAT, &loc, sizeof(buf2),
10593 					    buf2, &rlen2);
10594 			DMLOG_PRINT(DMLVL_DEBUG,
10595 				    "2nd call: rc %d, rlen %d, loc %llx\n", rc2,
10596 				    rlen2, loc);
10597 			varStatus = DMSTAT_PASS;
10598 			if (rc1 == 1) {
10599 				if (((num = GetNumDirEntry(buf1)) == 2)
10600 				    && (rlen1 >= 2 * MIN_ENTRYLEN)) {
10601 					DMLOG_PRINT(DMLVL_DEBUG,
10602 						    "1st call attrs:\n");
10603 					LogDirAttrs(buf1, DM_AT_STAT);
10604 					if (((entry =
10605 					      GetDirEntry(buf1,
10606 							  CURRENT_DIR)) != NULL)
10607 					    &&
10608 					    ((entry =
10609 					      GetDirEntry(buf1,
10610 							  PARENT_DIR)) !=
10611 					     NULL)) {
10612 						DMLOG_PRINT(DMLVL_DEBUG,
10613 							    "%s 1st call returned expected rc = %d and %d entries %s and %s in buffer\n",
10614 							    szFuncName, rc1,
10615 							    num, CURRENT_DIR,
10616 							    PARENT_DIR);
10617 					} else {
10618 						DMLOG_PRINT(DMLVL_ERR,
10619 							    "%s 1st call returned expected rc = %d but entries %s and/or %s not in buffer\n",
10620 							    szFuncName, rc1,
10621 							    CURRENT_DIR,
10622 							    PARENT_DIR);
10623 						varStatus = DMSTAT_FAIL;
10624 					}
10625 				} else {
10626 					DMLOG_PRINT(DMLVL_ERR,
10627 						    "%s 1st call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
10628 						    szFuncName, rc1, rlen1,
10629 						    num);
10630 					varStatus = DMSTAT_FAIL;
10631 				}
10632 			} else {
10633 				DMLOG_PRINT(DMLVL_ERR,
10634 					    "%s 1st call returned unexpected rc = %d\n",
10635 					    szFuncName, rc1);
10636 				varStatus = DMSTAT_FAIL;
10637 			}
10638 			if (rc2 == 0) {
10639 				if (((num = GetNumDirEntry(buf2)) == 1)
10640 				    && (rlen2 >= MIN_ENTRYLEN)) {
10641 					DMLOG_PRINT(DMLVL_DEBUG,
10642 						    "2nd call attrs:\n");
10643 					LogDirAttrs(buf2, DM_AT_STAT);
10644 					if ((entry =
10645 					     GetDirEntry(buf2,
10646 							 DUMMY_FILE)) != NULL) {
10647 						DMLOG_PRINT(DMLVL_DEBUG,
10648 							    "%s 2nd call returned expected rc = %d and %d entry %s in buffer\n",
10649 							    szFuncName, rc2,
10650 							    num, DUMMY_FILE);
10651 					} else {
10652 						DMLOG_PRINT(DMLVL_ERR,
10653 							    "%s 2nd call returned expected rc = %d but entry %s not in buffer\n",
10654 							    szFuncName, rc2,
10655 							    DUMMY_FILE);
10656 						varStatus = DMSTAT_FAIL;
10657 					}
10658 				} else {
10659 					DMLOG_PRINT(DMLVL_ERR,
10660 						    "%s 2nd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
10661 						    szFuncName, rc2, rlen2,
10662 						    num);
10663 					varStatus = DMSTAT_FAIL;
10664 				}
10665 			} else {
10666 				DMLOG_PRINT(DMLVL_ERR,
10667 					    "%s 2nd call returned unexpected rc = %d\n",
10668 					    szFuncName, rc2);
10669 				varStatus = DMSTAT_FAIL;
10670 			}
10671 			DMVAR_END(varStatus);
10672 
10673 			/* Variation clean up */
10674 			rc = remove(DUMMY_SUBDIR_FILE);
10675 			rc |= rmdir(DUMMY_SUBDIR);
10676 			if (rc == -1) {
10677 				DMLOG_PRINT(DMLVL_DEBUG,
10678 					    "Unable to clean up variation! (errno = %d)\n",
10679 					    errno);
10680 			}
10681 			dm_handle_free(dhanp, dhlen);
10682 		}
10683 	}
10684 
10685 	/*
10686 	 * TEST    : dm_get_dirattrs - DM_AT_STAT returned over three calls,
10687 	 *              third buffer too small
10688 	 * EXPECTED: rc = 1, 1, 1
10689 	 */
10690 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 26)) {
10691 		void *dhanp;
10692 		size_t dhlen;
10693 		dm_attrloc_t loc;
10694 		char buf1[ATTR_SMALLLEN];
10695 		char buf2[ATTR_SMALLLEN];
10696 		char buf3[ATTR_SMALLLEN / 2];
10697 		size_t rlen1, rlen2, rlen3;
10698 		dm_stat_t *entry;
10699 		int rc1, rc2, rc3;
10700 		int varStatus;
10701 		int num;
10702 
10703 		/* Variation set up */
10704 		memset(buf1, 0, sizeof(buf1));
10705 		memset(buf2, 0, sizeof(buf2));
10706 		memset(buf3, 0, sizeof(buf3));
10707 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10708 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10709 			/* No clean up */
10710 		} else
10711 		    if ((rc =
10712 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10713 					   &dhlen)) == -1) {
10714 			rmdir(DUMMY_SUBDIR);
10715 		} else if ((rc = system(command)) == -1) {
10716 			dm_handle_free(dhanp, dhlen);
10717 			rmdir(DUMMY_SUBDIR);
10718 		} else
10719 		    if ((rc =
10720 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10721 					 &loc)) == -1) {
10722 			remove(DUMMY_SUBDIR_FILE);
10723 			dm_handle_free(dhanp, dhlen);
10724 			rmdir(DUMMY_SUBDIR);
10725 		}
10726 		if (rc == -1) {
10727 			DMLOG_PRINT(DMLVL_DEBUG,
10728 				    "Unable to set up variation! (errno = %d)\n",
10729 				    errno);
10730 			DMVAR_SKIP();
10731 		} else {
10732 			/* Variation */
10733 			DMLOG_PRINT(DMLVL_DEBUG,
10734 				    "%s(DM_AT_STAT over three calls, third buf too small)\n",
10735 				    szFuncName);
10736 			rc1 =
10737 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10738 					    DM_AT_STAT, &loc, sizeof(buf1),
10739 					    buf1, &rlen1);
10740 			DMLOG_PRINT(DMLVL_DEBUG,
10741 				    "1st call: rc %d, rlen %d, loc %llx\n", rc1,
10742 				    rlen1, loc);
10743 			rc2 =
10744 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10745 					    DM_AT_STAT, &loc, sizeof(buf2),
10746 					    buf2, &rlen2);
10747 			DMLOG_PRINT(DMLVL_DEBUG,
10748 				    "2nd call: rc %d, rlen %d, loc %llx\n", rc2,
10749 				    rlen2, loc);
10750 			rc3 =
10751 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10752 					    DM_AT_STAT, &loc, sizeof(buf3),
10753 					    buf3, &rlen3);
10754 			DMLOG_PRINT(DMLVL_DEBUG,
10755 				    "3rd call: rc %d, rlen %d, loc %llx\n", rc3,
10756 				    rlen3, loc);
10757 			varStatus = DMSTAT_PASS;
10758 			if (rc1 == 1) {
10759 				if (((num = GetNumDirEntry(buf1)) == 1)
10760 				    && (rlen1 >= MIN_ENTRYLEN)) {
10761 					DMLOG_PRINT(DMLVL_DEBUG,
10762 						    "1st call attrs:\n");
10763 					LogDirAttrs(buf1, DM_AT_STAT);
10764 					if ((entry =
10765 					     GetDirEntry(buf1,
10766 							 CURRENT_DIR)) !=
10767 					    NULL) {
10768 						DMLOG_PRINT(DMLVL_DEBUG,
10769 							    "%s 1st call returned expected rc = %d and %d entry %s in buffer\n",
10770 							    szFuncName, rc1,
10771 							    num, CURRENT_DIR);
10772 					} else {
10773 						DMLOG_PRINT(DMLVL_ERR,
10774 							    "%s 1st call returned expected rc = %d but entry %s not in buffer\n",
10775 							    szFuncName, rc1,
10776 							    CURRENT_DIR);
10777 						varStatus = DMSTAT_FAIL;
10778 					}
10779 				} else {
10780 					DMLOG_PRINT(DMLVL_ERR,
10781 						    "%s 1st call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
10782 						    szFuncName, rc1, rlen1,
10783 						    num);
10784 					varStatus = DMSTAT_FAIL;
10785 				}
10786 			} else {
10787 				DMLOG_PRINT(DMLVL_ERR,
10788 					    "%s 1st call returned unexpected rc = %d\n",
10789 					    szFuncName, rc1);
10790 				varStatus = DMSTAT_FAIL;
10791 			}
10792 			if (rc2 == 1) {
10793 				if (((num = GetNumDirEntry(buf2)) == 1)
10794 				    && (rlen2 >= MIN_ENTRYLEN)) {
10795 					DMLOG_PRINT(DMLVL_DEBUG,
10796 						    "2nd call attrs:\n");
10797 					LogDirAttrs(buf2, DM_AT_STAT);
10798 					if ((entry =
10799 					     GetDirEntry(buf2,
10800 							 PARENT_DIR)) != NULL) {
10801 						DMLOG_PRINT(DMLVL_DEBUG,
10802 							    "%s 2nd call returned expected rc = %d and %d entry %s in buffer\n",
10803 							    szFuncName, rc2,
10804 							    num, PARENT_DIR);
10805 					} else {
10806 						DMLOG_PRINT(DMLVL_ERR,
10807 							    "%s 2nd call returned expected rc = %d but entry %s not in buffer\n",
10808 							    szFuncName, rc2,
10809 							    PARENT_DIR);
10810 						varStatus = DMSTAT_FAIL;
10811 					}
10812 				} else {
10813 					DMLOG_PRINT(DMLVL_ERR,
10814 						    "%s 2nd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
10815 						    szFuncName, rc2, rlen2,
10816 						    num);
10817 					varStatus = DMSTAT_FAIL;
10818 				}
10819 			} else {
10820 				DMLOG_PRINT(DMLVL_ERR,
10821 					    "%s 2nd call returned unexpected rc = %d\n",
10822 					    szFuncName, rc2);
10823 				varStatus = DMSTAT_FAIL;
10824 			}
10825 			if (rc3 == 1) {
10826 				if (rlen3 == 0) {
10827 					DMLOG_PRINT(DMLVL_DEBUG,
10828 						    "%s 3rd call returned expected rc = %d and empty buffer\n",
10829 						    szFuncName, rc3);
10830 				} else {
10831 					DMLOG_PRINT(DMLVL_ERR,
10832 						    "%s 3rd call returned expected rc = %d but unexpected rlen = %d\n",
10833 						    szFuncName, rc3, rlen3);
10834 					varStatus = DMSTAT_FAIL;
10835 				}
10836 			} else {
10837 				DMLOG_PRINT(DMLVL_ERR,
10838 					    "%s 3rd call returned unexpected rc = %d\n",
10839 					    szFuncName, rc3);
10840 				varStatus = DMSTAT_FAIL;
10841 			}
10842 			DMVAR_END(varStatus);
10843 
10844 			/* Variation clean up */
10845 			rc = remove(DUMMY_SUBDIR_FILE);
10846 			rc |= rmdir(DUMMY_SUBDIR);
10847 			if (rc == -1) {
10848 				DMLOG_PRINT(DMLVL_DEBUG,
10849 					    "Unable to clean up variation! (errno = %d)\n",
10850 					    errno);
10851 			}
10852 			dm_handle_free(dhanp, dhlen);
10853 		}
10854 	}
10855 
10856 	/*
10857 	 * TEST    : dm_get_dirattrs - DM_AT_STAT returned over three calls
10858 	 * EXPECTED: rc = 1, 1, 0
10859 	 */
10860 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 27)) {
10861 		void *dhanp;
10862 		size_t dhlen;
10863 		dm_attrloc_t loc;
10864 		char buf1[ATTR_SMALLLEN];
10865 		char buf2[ATTR_SMALLLEN];
10866 		char buf3[ATTR_SMALLLEN];
10867 		size_t rlen1, rlen2, rlen3;
10868 		dm_stat_t *entry;
10869 		int rc1, rc2, rc3;
10870 		int varStatus;
10871 		int num;
10872 
10873 		/* Variation set up */
10874 		memset(buf1, 0, sizeof(buf1));
10875 		memset(buf2, 0, sizeof(buf2));
10876 		memset(buf3, 0, sizeof(buf3));
10877 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
10878 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
10879 			/* No clean up */
10880 		} else
10881 		    if ((rc =
10882 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
10883 					   &dhlen)) == -1) {
10884 			rmdir(DUMMY_SUBDIR);
10885 		} else if ((rc = system(command)) == -1) {
10886 			dm_handle_free(dhanp, dhlen);
10887 			rmdir(DUMMY_SUBDIR);
10888 		} else
10889 		    if ((rc =
10890 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
10891 					 &loc)) == -1) {
10892 			remove(DUMMY_SUBDIR_FILE);
10893 			dm_handle_free(dhanp, dhlen);
10894 			rmdir(DUMMY_SUBDIR);
10895 		}
10896 		if (rc == -1) {
10897 			DMLOG_PRINT(DMLVL_DEBUG,
10898 				    "Unable to set up variation! (errno = %d)\n",
10899 				    errno);
10900 			DMVAR_SKIP();
10901 		} else {
10902 			/* Variation */
10903 			DMLOG_PRINT(DMLVL_DEBUG,
10904 				    "%s(DM_AT_STAT over three calls)\n",
10905 				    szFuncName);
10906 			rc1 =
10907 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10908 					    DM_AT_STAT, &loc, sizeof(buf1),
10909 					    buf1, &rlen1);
10910 			DMLOG_PRINT(DMLVL_DEBUG,
10911 				    "1st call: rc %d, rlen %d, loc %llx\n", rc1,
10912 				    rlen1, loc);
10913 			rc2 =
10914 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10915 					    DM_AT_STAT, &loc, sizeof(buf2),
10916 					    buf2, &rlen2);
10917 			DMLOG_PRINT(DMLVL_DEBUG,
10918 				    "2nd call: rc %d, rlen %d, loc %llx\n", rc2,
10919 				    rlen2, loc);
10920 			rc3 =
10921 			    dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
10922 					    DM_AT_STAT, &loc, sizeof(buf3),
10923 					    buf3, &rlen3);
10924 			DMLOG_PRINT(DMLVL_DEBUG,
10925 				    "3rd call: rc %d, rlen %d, loc %llx\n", rc3,
10926 				    rlen3, loc);
10927 			varStatus = DMSTAT_PASS;
10928 			if (rc1 == 1) {
10929 				if (((num = GetNumDirEntry(buf1)) == 1)
10930 				    && (rlen1 >= MIN_ENTRYLEN)) {
10931 					DMLOG_PRINT(DMLVL_DEBUG,
10932 						    "1st call attrs:\n");
10933 					LogDirAttrs(buf1, DM_AT_STAT);
10934 					if ((entry =
10935 					     GetDirEntry(buf1,
10936 							 CURRENT_DIR)) !=
10937 					    NULL) {
10938 						DMLOG_PRINT(DMLVL_DEBUG,
10939 							    "%s 1st call returned expected rc = %d and %d entry %s in buffer\n",
10940 							    szFuncName, rc1,
10941 							    num, CURRENT_DIR);
10942 					} else {
10943 						DMLOG_PRINT(DMLVL_ERR,
10944 							    "%s 1st call returned expected rc = %d but entry %s not in buffer\n",
10945 							    szFuncName, rc1,
10946 							    CURRENT_DIR);
10947 						varStatus = DMSTAT_FAIL;
10948 					}
10949 				} else {
10950 					DMLOG_PRINT(DMLVL_ERR,
10951 						    "%s 1st call returned expected rc = %d but unexpected rlen = %d\n and/or number of entries in buffer %d",
10952 						    szFuncName, rc1, rlen1,
10953 						    num);
10954 					varStatus = DMSTAT_FAIL;
10955 				}
10956 			} else {
10957 				DMLOG_PRINT(DMLVL_ERR,
10958 					    "%s 1st call returned unexpected rc = %d\n",
10959 					    szFuncName, rc1);
10960 				varStatus = DMSTAT_FAIL;
10961 			}
10962 			if (rc2 == 1) {
10963 				if (((num = GetNumDirEntry(buf2)) == 1)
10964 				    && (rlen2 >= MIN_ENTRYLEN)) {
10965 					DMLOG_PRINT(DMLVL_DEBUG,
10966 						    "2nd call attrs:\n");
10967 					LogDirAttrs(buf2, DM_AT_STAT);
10968 					if ((entry =
10969 					     GetDirEntry(buf2,
10970 							 PARENT_DIR)) != NULL) {
10971 						DMLOG_PRINT(DMLVL_DEBUG,
10972 							    "%s 2nd call returned expected rc = %d and %d entry %s in buffer\n",
10973 							    szFuncName, rc2,
10974 							    num, PARENT_DIR);
10975 					} else {
10976 						DMLOG_PRINT(DMLVL_ERR,
10977 							    "%s 2nd call returned expected rc = %d but entry %s not in buffer\n",
10978 							    szFuncName, rc2,
10979 							    PARENT_DIR);
10980 						varStatus = DMSTAT_FAIL;
10981 					}
10982 				} else {
10983 					DMLOG_PRINT(DMLVL_ERR,
10984 						    "%s 2nd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
10985 						    szFuncName, rc2, rlen2,
10986 						    num);
10987 					varStatus = DMSTAT_FAIL;
10988 				}
10989 			} else {
10990 				DMLOG_PRINT(DMLVL_ERR,
10991 					    "%s 2nd call returned unexpected rc = %d\n",
10992 					    szFuncName, rc2);
10993 				varStatus = DMSTAT_FAIL;
10994 			}
10995 			if (rc3 == 0) {
10996 				if (((num = GetNumDirEntry(buf3)) == 1)
10997 				    && (rlen3 >= MIN_ENTRYLEN)) {
10998 					DMLOG_PRINT(DMLVL_DEBUG,
10999 						    "3rd call attrs:\n");
11000 					LogDirAttrs(buf3, DM_AT_STAT);
11001 					if ((entry =
11002 					     GetDirEntry(buf3,
11003 							 DUMMY_FILE)) != NULL) {
11004 						DMLOG_PRINT(DMLVL_DEBUG,
11005 							    "%s 3rd call returned expected rc = %d and %d entry %s in buffer\n",
11006 							    szFuncName, rc3,
11007 							    num, DUMMY_FILE);
11008 					} else {
11009 						DMLOG_PRINT(DMLVL_ERR,
11010 							    "%s 3rd call returned expected rc = %d but entry %s not in buffer\n",
11011 							    szFuncName, rc3,
11012 							    DUMMY_FILE);
11013 						varStatus = DMSTAT_FAIL;
11014 					}
11015 				} else {
11016 					DMLOG_PRINT(DMLVL_ERR,
11017 						    "%s 3rd call returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11018 						    szFuncName, rc3, rlen3,
11019 						    num);
11020 					varStatus = DMSTAT_FAIL;
11021 				}
11022 			} else {
11023 				DMLOG_PRINT(DMLVL_ERR,
11024 					    "%s 3rd call returned unexpected rc = %d\n",
11025 					    szFuncName, rc3);
11026 				varStatus = DMSTAT_FAIL;
11027 			}
11028 			DMVAR_END(varStatus);
11029 
11030 			/* Variation clean up */
11031 			rc = remove(DUMMY_SUBDIR_FILE);
11032 			rc |= rmdir(DUMMY_SUBDIR);
11033 			if (rc == -1) {
11034 				DMLOG_PRINT(DMLVL_DEBUG,
11035 					    "Unable to clean up variation! (errno = %d)\n",
11036 					    errno);
11037 			}
11038 			dm_handle_free(dhanp, dhlen);
11039 		}
11040 	}
11041 
11042 	/*
11043 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11044 	 *              returned from jfs_readdir > files fit in buffer)
11045 	 * EXPECTED: rc = 1
11046 	 */
11047 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 28)) {
11048 		void *dhanp;
11049 		size_t dhlen;
11050 		dm_attrloc_t loc;
11051 		char buf[ATTR_SMALLLEN * (DIRENTS_FILES - 1)];
11052 		size_t rlen;
11053 		dm_stat_t *entry;
11054 		int varStatus;
11055 		int i;
11056 		char *filename;
11057 		int num;
11058 
11059 		/* Variation set up */
11060 		memset(buf, 0, sizeof(buf));
11061 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11062 			/* No clean up */
11063 		} else
11064 		    if ((rc =
11065 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11066 					   &dhlen)) == -1) {
11067 			rmdir(DUMMY_SUBDIR);
11068 		} else {
11069 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11070 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11071 					DUMMY_SUBDIR_FILE, i);
11072 				rc = system(command);
11073 			}
11074 			if ((rc == -1) ||
11075 			    ((rc =
11076 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11077 					      &loc)) == -1)) {
11078 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11079 				rc = system(command);
11080 			}
11081 		}
11082 		if (rc == -1) {
11083 			DMLOG_PRINT(DMLVL_DEBUG,
11084 				    "Unable to set up variation! (errno = %d)\n",
11085 				    errno);
11086 			DMVAR_SKIP();
11087 		} else {
11088 			/* Variation */
11089 			DMLOG_PRINT(DMLVL_DEBUG,
11090 				    "%s(DM_AT_STAT with %d files)\n",
11091 				    szFuncName, DIRENTS_FILES - 1);
11092 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11093 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11094 					     &rlen);
11095 			DMLOG_PRINT(DMLVL_DEBUG,
11096 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11097 				    rlen);
11098 			varStatus = DMSTAT_PASS;
11099 			if (rc == 1) {
11100 				if (((num =
11101 				      GetNumDirEntry(buf)) == DIRENTS_FILES - 1)
11102 				    && (rlen >=
11103 					(DIRENTS_FILES - 1) * MIN_ENTRYLEN)) {
11104 					filename = strchr(command, '/') + 1;
11105 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11106 					LogDirAttrs(buf, DM_AT_STAT);
11107 					if ((entry =
11108 					     GetDirEntry(buf,
11109 							 filename)) == NULL) {
11110 						if (((entry =
11111 						      GetLastDirEntry(buf)) !=
11112 						     NULL)
11113 						    && (entry->dt_compname.
11114 							vd_length > 0)) {
11115 							DMLOG_PRINT(DMLVL_DEBUG,
11116 								    "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
11117 								    szFuncName,
11118 								    rc, num,
11119 								    filename);
11120 						} else {
11121 							DMLOG_PRINT(DMLVL_ERR,
11122 								    "%s returned expected rc = %d but empty entry in buffer\n",
11123 								    szFuncName,
11124 								    rc,
11125 								    filename);
11126 							varStatus = DMSTAT_FAIL;
11127 						}
11128 					} else {
11129 						DMLOG_PRINT(DMLVL_ERR,
11130 							    "%s returned expected rc = %d but entry %s in buffer\n",
11131 							    szFuncName, rc,
11132 							    filename);
11133 						varStatus = DMSTAT_FAIL;
11134 					}
11135 				} else {
11136 					DMLOG_PRINT(DMLVL_ERR,
11137 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11138 						    szFuncName, rc, rlen, num);
11139 					varStatus = DMSTAT_FAIL;
11140 				}
11141 			} else {
11142 				DMLOG_PRINT(DMLVL_ERR,
11143 					    "%s returned unexpected rc = %d\n",
11144 					    szFuncName, rc);
11145 				varStatus = DMSTAT_FAIL;
11146 			}
11147 			DMVAR_END(varStatus);
11148 
11149 			/* Variation clean up */
11150 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11151 			rc = system(command);
11152 			if (rc == -1) {
11153 				DMLOG_PRINT(DMLVL_DEBUG,
11154 					    "Unable to clean up variation! (errno = %d)\n",
11155 					    errno);
11156 			}
11157 			dm_handle_free(dhanp, dhlen);
11158 		}
11159 	}
11160 
11161 	/*
11162 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11163 	 *              returned from jfs_readdir > files fit in buffer)
11164 	 * EXPECTED: rc = 1
11165 	 */
11166 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 29)) {
11167 		void *dhanp;
11168 		size_t dhlen;
11169 		dm_attrloc_t loc;
11170 		char buf[ATTR_SMALLLEN * DIRENTS_FILES];
11171 		size_t rlen;
11172 		dm_stat_t *entry;
11173 		int varStatus;
11174 		int i;
11175 		char *filename;
11176 		int num;
11177 
11178 		/* Variation set up */
11179 		memset(buf, 0, sizeof(buf));
11180 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11181 			/* No clean up */
11182 		} else
11183 		    if ((rc =
11184 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11185 					   &dhlen)) == -1) {
11186 			rmdir(DUMMY_SUBDIR);
11187 		} else {
11188 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11189 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11190 					DUMMY_SUBDIR_FILE, i);
11191 				rc = system(command);
11192 			}
11193 			if ((rc == -1) ||
11194 			    ((rc =
11195 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11196 					      &loc)) == -1)) {
11197 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11198 				rc = system(command);
11199 			}
11200 		}
11201 		if (rc == -1) {
11202 			DMLOG_PRINT(DMLVL_DEBUG,
11203 				    "Unable to set up variation! (errno = %d)\n",
11204 				    errno);
11205 			DMVAR_SKIP();
11206 		} else {
11207 			/* Variation */
11208 			DMLOG_PRINT(DMLVL_DEBUG,
11209 				    "%s(DM_AT_STAT with %d files)\n",
11210 				    szFuncName, DIRENTS_FILES);
11211 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11212 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11213 					     &rlen);
11214 			DMLOG_PRINT(DMLVL_DEBUG,
11215 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11216 				    rlen);
11217 			varStatus = DMSTAT_PASS;
11218 			if (rc == 1) {
11219 				if (((num =
11220 				      GetNumDirEntry(buf)) == DIRENTS_FILES)
11221 				    && (rlen >= DIRENTS_FILES * MIN_ENTRYLEN)) {
11222 					filename = strchr(command, '/') + 1;
11223 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11224 					LogDirAttrs(buf, DM_AT_STAT);
11225 					if ((entry =
11226 					     GetDirEntry(buf,
11227 							 filename)) == NULL) {
11228 						if (((entry =
11229 						      GetLastDirEntry(buf)) !=
11230 						     NULL)
11231 						    && (entry->dt_compname.
11232 							vd_length > 0)) {
11233 							DMLOG_PRINT(DMLVL_DEBUG,
11234 								    "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
11235 								    szFuncName,
11236 								    rc, num,
11237 								    filename);
11238 						} else {
11239 							DMLOG_PRINT(DMLVL_ERR,
11240 								    "%s returned expected rc = %d but empty entry in buffer\n",
11241 								    szFuncName,
11242 								    rc,
11243 								    filename);
11244 							varStatus = DMSTAT_FAIL;
11245 						}
11246 					} else {
11247 						DMLOG_PRINT(DMLVL_ERR,
11248 							    "%s returned expected rc = %d but entry %s in buffer\n",
11249 							    szFuncName, rc,
11250 							    filename);
11251 						varStatus = DMSTAT_FAIL;
11252 					}
11253 				} else {
11254 					DMLOG_PRINT(DMLVL_ERR,
11255 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11256 						    szFuncName, rc, rlen, num);
11257 					varStatus = DMSTAT_FAIL;
11258 				}
11259 			} else {
11260 				DMLOG_PRINT(DMLVL_ERR,
11261 					    "%s returned unexpected rc = %d\n",
11262 					    szFuncName, rc);
11263 				varStatus = DMSTAT_FAIL;
11264 			}
11265 			DMVAR_END(varStatus);
11266 
11267 			/* Variation clean up */
11268 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11269 			rc = system(command);
11270 			if (rc == -1) {
11271 				DMLOG_PRINT(DMLVL_DEBUG,
11272 					    "Unable to clean up variation! (errno = %d)\n",
11273 					    errno);
11274 			}
11275 			dm_handle_free(dhanp, dhlen);
11276 		}
11277 	}
11278 
11279 	/*
11280 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11281 	 *              returned from jfs_readdir > files fit in buffer)
11282 	 * EXPECTED: rc = 1
11283 	 */
11284 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 30)) {
11285 		void *dhanp;
11286 		size_t dhlen;
11287 		dm_attrloc_t loc;
11288 		char buf[ATTR_SMALLLEN * (DIRENTS_FILES + 1)];
11289 		size_t rlen;
11290 		dm_stat_t *entry;
11291 		int varStatus;
11292 		int i;
11293 		char *filename;
11294 		int num;
11295 
11296 		/* Variation set up */
11297 		memset(buf, 0, sizeof(buf));
11298 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11299 			/* No clean up */
11300 		} else
11301 		    if ((rc =
11302 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11303 					   &dhlen)) == -1) {
11304 			rmdir(DUMMY_SUBDIR);
11305 		} else {
11306 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11307 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11308 					DUMMY_SUBDIR_FILE, i);
11309 				rc = system(command);
11310 			}
11311 			if ((rc == -1) ||
11312 			    ((rc =
11313 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11314 					      &loc)) == -1)) {
11315 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11316 				rc = system(command);
11317 			}
11318 		}
11319 		if (rc == -1) {
11320 			DMLOG_PRINT(DMLVL_DEBUG,
11321 				    "Unable to set up variation! (errno = %d)\n",
11322 				    errno);
11323 			DMVAR_SKIP();
11324 		} else {
11325 			/* Variation */
11326 			DMLOG_PRINT(DMLVL_DEBUG,
11327 				    "%s(DM_AT_STAT with %d files)\n",
11328 				    szFuncName, DIRENTS_FILES + 1);
11329 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11330 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11331 					     &rlen);
11332 			DMLOG_PRINT(DMLVL_DEBUG,
11333 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11334 				    rlen);
11335 			varStatus = DMSTAT_PASS;
11336 			if (rc == 1) {
11337 				if (((num =
11338 				      GetNumDirEntry(buf)) == DIRENTS_FILES + 1)
11339 				    && (rlen >=
11340 					(DIRENTS_FILES + 1) * MIN_ENTRYLEN)) {
11341 					filename = strchr(command, '/') + 1;
11342 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11343 					LogDirAttrs(buf, DM_AT_STAT);
11344 					if ((entry =
11345 					     GetDirEntry(buf,
11346 							 filename)) == NULL) {
11347 						if (((entry =
11348 						      GetLastDirEntry(buf)) !=
11349 						     NULL)
11350 						    && (entry->dt_compname.
11351 							vd_length > 0)) {
11352 							DMLOG_PRINT(DMLVL_DEBUG,
11353 								    "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
11354 								    szFuncName,
11355 								    rc, num,
11356 								    filename);
11357 						} else {
11358 							DMLOG_PRINT(DMLVL_ERR,
11359 								    "%s returned expected rc = %d but empty entry in buffer\n",
11360 								    szFuncName,
11361 								    rc,
11362 								    filename);
11363 							varStatus = DMSTAT_FAIL;
11364 						}
11365 					} else {
11366 						DMLOG_PRINT(DMLVL_ERR,
11367 							    "%s returned expected rc = %d but entry %s in buffer\n",
11368 							    szFuncName, rc,
11369 							    filename);
11370 						varStatus = DMSTAT_FAIL;
11371 					}
11372 				} else {
11373 					DMLOG_PRINT(DMLVL_ERR,
11374 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11375 						    szFuncName, rc, rlen, num);
11376 					varStatus = DMSTAT_FAIL;
11377 				}
11378 			} else {
11379 				DMLOG_PRINT(DMLVL_ERR,
11380 					    "%s returned unexpected rc = %d\n",
11381 					    szFuncName, rc);
11382 				varStatus = DMSTAT_FAIL;
11383 			}
11384 			DMVAR_END(varStatus);
11385 
11386 			/* Variation clean up */
11387 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11388 			rc = system(command);
11389 			if (rc == -1) {
11390 				DMLOG_PRINT(DMLVL_DEBUG,
11391 					    "Unable to clean up variation! (errno = %d)\n",
11392 					    errno);
11393 			}
11394 			dm_handle_free(dhanp, dhlen);
11395 		}
11396 	}
11397 
11398 	/*
11399 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11400 	 *              returned from jfs_readdir > files fit in buffer)
11401 	 * EXPECTED: rc = 1
11402 	 */
11403 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 31)) {
11404 		void *dhanp;
11405 		size_t dhlen;
11406 		dm_attrloc_t loc;
11407 		char buf[ATTR_SMALLLEN * ((2 * DIRENTS_FILES) - 1)];
11408 		size_t rlen;
11409 		dm_stat_t *entry;
11410 		int varStatus;
11411 		int i;
11412 		char *filename;
11413 		int num;
11414 
11415 		/* Variation set up */
11416 		memset(buf, 0, sizeof(buf));
11417 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11418 			/* No clean up */
11419 		} else
11420 		    if ((rc =
11421 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11422 					   &dhlen)) == -1) {
11423 			rmdir(DUMMY_SUBDIR);
11424 		} else {
11425 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11426 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11427 					DUMMY_SUBDIR_FILE, i);
11428 				rc = system(command);
11429 			}
11430 			if ((rc == -1) ||
11431 			    ((rc =
11432 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11433 					      &loc)) == -1)) {
11434 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11435 				rc = system(command);
11436 			}
11437 		}
11438 		if (rc == -1) {
11439 			DMLOG_PRINT(DMLVL_DEBUG,
11440 				    "Unable to set up variation! (errno = %d)\n",
11441 				    errno);
11442 			DMVAR_SKIP();
11443 		} else {
11444 			/* Variation */
11445 			DMLOG_PRINT(DMLVL_DEBUG,
11446 				    "%s(DM_AT_STAT with %d files)\n",
11447 				    szFuncName, (2 * DIRENTS_FILES) - 1);
11448 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11449 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11450 					     &rlen);
11451 			DMLOG_PRINT(DMLVL_DEBUG,
11452 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11453 				    rlen);
11454 			varStatus = DMSTAT_PASS;
11455 			if (rc == 1) {
11456 				if (((num =
11457 				      GetNumDirEntry(buf)) ==
11458 				     (2 * DIRENTS_FILES) - 1)
11459 				    && (rlen >=
11460 					((2 * DIRENTS_FILES) -
11461 					 1) * MIN_ENTRYLEN)) {
11462 					filename = strchr(command, '/') + 1;
11463 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11464 					LogDirAttrs(buf, DM_AT_STAT);
11465 					if ((entry =
11466 					     GetDirEntry(buf,
11467 							 filename)) == NULL) {
11468 						if (((entry =
11469 						      GetLastDirEntry(buf)) !=
11470 						     NULL)
11471 						    && (entry->dt_compname.
11472 							vd_length > 0)) {
11473 							DMLOG_PRINT(DMLVL_DEBUG,
11474 								    "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
11475 								    szFuncName,
11476 								    rc, num,
11477 								    filename);
11478 						} else {
11479 							DMLOG_PRINT(DMLVL_ERR,
11480 								    "%s returned expected rc = %d but empty entry in buffer\n",
11481 								    szFuncName,
11482 								    rc,
11483 								    filename);
11484 							varStatus = DMSTAT_FAIL;
11485 						}
11486 					} else {
11487 						DMLOG_PRINT(DMLVL_ERR,
11488 							    "%s returned expected rc = %d but entry %s in buffer\n",
11489 							    szFuncName, rc,
11490 							    filename);
11491 						varStatus = DMSTAT_FAIL;
11492 					}
11493 				} else {
11494 					DMLOG_PRINT(DMLVL_ERR,
11495 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11496 						    szFuncName, rc, rlen, num);
11497 					varStatus = DMSTAT_FAIL;
11498 				}
11499 			} else {
11500 				DMLOG_PRINT(DMLVL_ERR,
11501 					    "%s returned unexpected rc = %d\n",
11502 					    szFuncName, rc);
11503 				varStatus = DMSTAT_FAIL;
11504 			}
11505 			DMVAR_END(varStatus);
11506 
11507 			/* Variation clean up */
11508 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11509 			rc = system(command);
11510 			if (rc == -1) {
11511 				DMLOG_PRINT(DMLVL_DEBUG,
11512 					    "Unable to clean up variation! (errno = %d)\n",
11513 					    errno);
11514 			}
11515 			dm_handle_free(dhanp, dhlen);
11516 		}
11517 	}
11518 
11519 	/*
11520 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11521 	 *              returned from jfs_readdir > files fit in buffer)
11522 	 * EXPECTED: rc = 1
11523 	 */
11524 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 32)) {
11525 		void *dhanp;
11526 		size_t dhlen;
11527 		dm_attrloc_t loc;
11528 		char buf[ATTR_SMALLLEN * (2 * DIRENTS_FILES)];
11529 		size_t rlen;
11530 		dm_stat_t *entry;
11531 		int varStatus;
11532 		int i;
11533 		char *filename;
11534 		int num;
11535 
11536 		/* Variation set up */
11537 		memset(buf, 0, sizeof(buf));
11538 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11539 			/* No clean up */
11540 		} else
11541 		    if ((rc =
11542 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11543 					   &dhlen)) == -1) {
11544 			rmdir(DUMMY_SUBDIR);
11545 		} else {
11546 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11547 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11548 					DUMMY_SUBDIR_FILE, i);
11549 				rc = system(command);
11550 			}
11551 			if ((rc == -1) ||
11552 			    ((rc =
11553 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11554 					      &loc)) == -1)) {
11555 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11556 				rc = system(command);
11557 			}
11558 		}
11559 		if (rc == -1) {
11560 			DMLOG_PRINT(DMLVL_DEBUG,
11561 				    "Unable to set up variation! (errno = %d)\n",
11562 				    errno);
11563 			DMVAR_SKIP();
11564 		} else {
11565 			/* Variation */
11566 			DMLOG_PRINT(DMLVL_DEBUG,
11567 				    "%s(DM_AT_STAT with %d files)\n",
11568 				    szFuncName, 2 * DIRENTS_FILES);
11569 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11570 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11571 					     &rlen);
11572 			DMLOG_PRINT(DMLVL_DEBUG,
11573 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11574 				    rlen);
11575 			varStatus = DMSTAT_PASS;
11576 			if (rc == 1) {
11577 				if (((num =
11578 				      GetNumDirEntry(buf)) == 2 * DIRENTS_FILES)
11579 				    && (rlen >=
11580 					(2 * DIRENTS_FILES) * MIN_ENTRYLEN)) {
11581 					filename = strchr(command, '/') + 1;
11582 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11583 					LogDirAttrs(buf, DM_AT_STAT);
11584 					if ((entry =
11585 					     GetDirEntry(buf,
11586 							 filename)) == NULL) {
11587 						if (((entry =
11588 						      GetLastDirEntry(buf)) !=
11589 						     NULL)
11590 						    && (entry->dt_compname.
11591 							vd_length > 0)) {
11592 							DMLOG_PRINT(DMLVL_DEBUG,
11593 								    "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
11594 								    szFuncName,
11595 								    rc, num,
11596 								    filename);
11597 						} else {
11598 							DMLOG_PRINT(DMLVL_ERR,
11599 								    "%s returned expected rc = %d but empty entry in buffer\n",
11600 								    szFuncName,
11601 								    rc,
11602 								    filename);
11603 							varStatus = DMSTAT_FAIL;
11604 						}
11605 					} else {
11606 						DMLOG_PRINT(DMLVL_ERR,
11607 							    "%s returned expected rc = %d but entry %s in buffer\n",
11608 							    szFuncName, rc,
11609 							    filename);
11610 						varStatus = DMSTAT_FAIL;
11611 					}
11612 				} else {
11613 					DMLOG_PRINT(DMLVL_ERR,
11614 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11615 						    szFuncName, rc, rlen, num);
11616 					varStatus = DMSTAT_FAIL;
11617 				}
11618 			} else {
11619 				DMLOG_PRINT(DMLVL_ERR,
11620 					    "%s returned unexpected rc = %d\n",
11621 					    szFuncName, rc);
11622 				varStatus = DMSTAT_FAIL;
11623 			}
11624 			DMVAR_END(varStatus);
11625 
11626 			/* Variation clean up */
11627 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11628 			rc = system(command);
11629 			if (rc == -1) {
11630 				DMLOG_PRINT(DMLVL_DEBUG,
11631 					    "Unable to clean up variation! (errno = %d)\n",
11632 					    errno);
11633 			}
11634 			dm_handle_free(dhanp, dhlen);
11635 		}
11636 	}
11637 
11638 	/*
11639 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11640 	 *              returned from jfs_readdir > files fit in buffer)
11641 	 * EXPECTED: rc = 1
11642 	 */
11643 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 33)) {
11644 		void *dhanp;
11645 		size_t dhlen;
11646 		dm_attrloc_t loc;
11647 		char buf[ATTR_SMALLLEN * ((2 * DIRENTS_FILES) + 1)];
11648 		size_t rlen;
11649 		dm_stat_t *entry;
11650 		int varStatus;
11651 		int i;
11652 		char *filename;
11653 		int num;
11654 
11655 		/* Variation set up */
11656 		memset(buf, 0, sizeof(buf));
11657 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11658 			/* No clean up */
11659 		} else
11660 		    if ((rc =
11661 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11662 					   &dhlen)) == -1) {
11663 			rmdir(DUMMY_SUBDIR);
11664 		} else {
11665 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11666 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11667 					DUMMY_SUBDIR_FILE, i);
11668 				rc = system(command);
11669 			}
11670 			if ((rc == -1) ||
11671 			    ((rc =
11672 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11673 					      &loc)) == -1)) {
11674 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11675 				rc = system(command);
11676 			}
11677 		}
11678 		if (rc == -1) {
11679 			DMLOG_PRINT(DMLVL_DEBUG,
11680 				    "Unable to set up variation! (errno = %d)\n",
11681 				    errno);
11682 			DMVAR_SKIP();
11683 		} else {
11684 			/* Variation */
11685 			DMLOG_PRINT(DMLVL_DEBUG,
11686 				    "%s(DM_AT_STAT with %d files)\n",
11687 				    szFuncName, (2 * DIRENTS_FILES) + 1);
11688 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11689 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11690 					     &rlen);
11691 			DMLOG_PRINT(DMLVL_DEBUG,
11692 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11693 				    rlen);
11694 			varStatus = DMSTAT_PASS;
11695 			if (rc == 1) {
11696 				if (((num =
11697 				      GetNumDirEntry(buf)) ==
11698 				     (2 * DIRENTS_FILES) + 1)
11699 				    && (rlen >=
11700 					((2 * DIRENTS_FILES) +
11701 					 1) * MIN_ENTRYLEN)) {
11702 					filename = strchr(command, '/') + 1;
11703 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11704 					LogDirAttrs(buf, DM_AT_STAT);
11705 					if ((entry =
11706 					     GetDirEntry(buf,
11707 							 filename)) == NULL) {
11708 						if (((entry =
11709 						      GetLastDirEntry(buf)) !=
11710 						     NULL)
11711 						    && (entry->dt_compname.
11712 							vd_length > 0)) {
11713 							DMLOG_PRINT(DMLVL_DEBUG,
11714 								    "%s returned expected rc = %d, expected number of entries in buffer %d, and neither entry %s nor empty entry in buffer\n",
11715 								    szFuncName,
11716 								    rc, num,
11717 								    filename);
11718 						} else {
11719 							DMLOG_PRINT(DMLVL_ERR,
11720 								    "%s returned expected rc = %d but empty entry in buffer\n",
11721 								    szFuncName,
11722 								    rc,
11723 								    filename);
11724 							varStatus = DMSTAT_FAIL;
11725 						}
11726 					} else {
11727 						DMLOG_PRINT(DMLVL_ERR,
11728 							    "%s returned expected rc = %d but entry %s in buffer\n",
11729 							    szFuncName, rc,
11730 							    filename);
11731 						varStatus = DMSTAT_FAIL;
11732 					}
11733 				} else {
11734 					DMLOG_PRINT(DMLVL_ERR,
11735 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11736 						    szFuncName, rc, rlen, num);
11737 					varStatus = DMSTAT_FAIL;
11738 				}
11739 			} else {
11740 				DMLOG_PRINT(DMLVL_ERR,
11741 					    "%s returned unexpected rc = %d\n",
11742 					    szFuncName, rc);
11743 				varStatus = DMSTAT_FAIL;
11744 			}
11745 			DMVAR_END(varStatus);
11746 
11747 			/* Variation clean up */
11748 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11749 			rc = system(command);
11750 			if (rc == -1) {
11751 				DMLOG_PRINT(DMLVL_DEBUG,
11752 					    "Unable to clean up variation! (errno = %d)\n",
11753 					    errno);
11754 			}
11755 			dm_handle_free(dhanp, dhlen);
11756 		}
11757 	}
11758 
11759 	/*
11760 	 * TEST    : dm_get_dirattrs - DM_AT_STAT with one buffer (files
11761 	 *              returned from jfs_readdir < files fit in buffer)
11762 	 * EXPECTED: rc = 0
11763 	 */
11764 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 34)) {
11765 		void *dhanp;
11766 		size_t dhlen;
11767 		dm_attrloc_t loc;
11768 		char buf[ATTR_BIGLISTLEN];
11769 		size_t rlen;
11770 		dm_stat_t *entry;
11771 		int varStatus;
11772 		int i;
11773 		char *filename;
11774 		int num;
11775 
11776 		/* Variation set up */
11777 		memset(buf, 0, sizeof(buf));
11778 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11779 			/* No clean up */
11780 		} else
11781 		    if ((rc =
11782 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11783 					   &dhlen)) == -1) {
11784 			rmdir(DUMMY_SUBDIR);
11785 		} else {
11786 			for (i = 0; i < NUM_FILES && rc == 0; i++) {
11787 				sprintf(command, "cp %s %s.%3.3d", DUMMY_TMP,
11788 					DUMMY_SUBDIR_FILE, i);
11789 				rc = system(command);
11790 			}
11791 			if ((rc == -1) ||
11792 			    ((rc =
11793 			      dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11794 					      &loc)) == -1)) {
11795 				sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11796 				rc = system(command);
11797 			}
11798 		}
11799 		if (rc == -1) {
11800 			DMLOG_PRINT(DMLVL_DEBUG,
11801 				    "Unable to set up variation! (errno = %d)\n",
11802 				    errno);
11803 			DMVAR_SKIP();
11804 		} else {
11805 			/* Variation */
11806 			DMLOG_PRINT(DMLVL_DEBUG,
11807 				    "%s(DM_AT_STAT with %d files)\n",
11808 				    szFuncName, NUM_FILES + 2);
11809 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11810 					     DM_AT_STAT, &loc, sizeof(buf), buf,
11811 					     &rlen);
11812 			DMLOG_PRINT(DMLVL_DEBUG,
11813 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11814 				    rlen);
11815 			varStatus = DMSTAT_PASS;
11816 			if (rc == 0) {
11817 				if (((num =
11818 				      GetNumDirEntry(buf)) == NUM_FILES + 2)
11819 				    && (rlen >=
11820 					(NUM_FILES + 2) * MIN_ENTRYLEN)) {
11821 					filename = strchr(command, '/') + 1;
11822 					DMLOG_PRINT(DMLVL_DEBUG, "attrs:\n");
11823 					LogDirAttrs(buf, DM_AT_STAT);
11824 					if ((entry =
11825 					     GetDirEntry(buf,
11826 							 filename)) != NULL) {
11827 						DMLOG_PRINT(DMLVL_DEBUG,
11828 							    "%s returned expected rc = %d, expected number of entries in buffer %d, and entry %s in buffer\n",
11829 							    szFuncName, rc, num,
11830 							    filename);
11831 					} else {
11832 						DMLOG_PRINT(DMLVL_ERR,
11833 							    "%s returned expected rc = %d but entry %s not in buffer\n",
11834 							    szFuncName, rc,
11835 							    filename);
11836 						varStatus = DMSTAT_FAIL;
11837 					}
11838 				} else {
11839 					DMLOG_PRINT(DMLVL_ERR,
11840 						    "%s returned expected rc = %d but unexpected rlen = %d and/or number of entries in buffer %d\n",
11841 						    szFuncName, rc, rlen, num);
11842 					varStatus = DMSTAT_FAIL;
11843 				}
11844 			} else {
11845 				DMLOG_PRINT(DMLVL_ERR,
11846 					    "%s returned unexpected rc = %d\n",
11847 					    szFuncName, rc);
11848 				varStatus = DMSTAT_FAIL;
11849 			}
11850 			DMVAR_END(varStatus);
11851 
11852 			/* Variation clean up */
11853 			sprintf(command, "rm -rf %s", DUMMY_SUBDIR);
11854 			rc = system(command);
11855 			if (rc == -1) {
11856 				DMLOG_PRINT(DMLVL_DEBUG,
11857 					    "Unable to clean up variation! (errno = %d)\n",
11858 					    errno);
11859 			}
11860 			dm_handle_free(dhanp, dhlen);
11861 		}
11862 	}
11863 
11864 	/*
11865 	 * TEST    : dm_get_dirattrs - DM_AT_HANDLE with link
11866 	 * EXPECTED: rc = 0
11867 	 */
11868 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 35)) {
11869 		void *dhanp, *fhanp1, *fhanp2;
11870 		size_t dhlen, fhlen1, fhlen2;
11871 		dm_attrloc_t loc;
11872 		char buf[ATTR_LISTLEN];
11873 		size_t rlen;
11874 
11875 		/* Variation set up */
11876 		memset(buf, 0, ATTR_LISTLEN);
11877 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
11878 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
11879 			/* No clean up */
11880 		} else
11881 		    if ((rc =
11882 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
11883 					   &dhlen)) == -1) {
11884 			rmdir(DUMMY_SUBDIR);
11885 		} else if ((rc = system(command)) == -1) {
11886 			dm_handle_free(dhanp, dhlen);
11887 			rmdir(DUMMY_SUBDIR);
11888 		} else
11889 		    if ((rc =
11890 			 dm_path_to_handle(DUMMY_SUBDIR_FILE, &fhanp1,
11891 					   &fhlen1)) == -1) {
11892 			remove(DUMMY_SUBDIR_FILE);
11893 			dm_handle_free(dhanp, dhlen);
11894 			rmdir(DUMMY_SUBDIR);
11895 		} else if ((rc = link(DUMMY_SUBDIR_FILE, DUMMY_SUBDIR_LINK)) ==
11896 			   -1) {
11897 			dm_handle_free(fhanp1, fhlen1);
11898 			remove(DUMMY_SUBDIR_FILE);
11899 			dm_handle_free(dhanp, dhlen);
11900 			rmdir(DUMMY_SUBDIR);
11901 		} else
11902 		    if ((rc =
11903 			 dm_path_to_handle(DUMMY_SUBDIR_LINK, &fhanp2,
11904 					   &fhlen2)) == -1) {
11905 			unlink(DUMMY_SUBDIR_LINK);
11906 			dm_handle_free(fhanp1, fhlen1);
11907 			remove(DUMMY_SUBDIR_FILE);
11908 			dm_handle_free(dhanp, dhlen);
11909 			rmdir(DUMMY_SUBDIR);
11910 		} else
11911 		    if ((rc =
11912 			 dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
11913 					 &loc)) == -1) {
11914 			dm_handle_free(fhanp2, fhlen2);
11915 			unlink(DUMMY_SUBDIR_LINK);
11916 			dm_handle_free(fhanp1, fhlen1);
11917 			remove(DUMMY_SUBDIR_FILE);
11918 			dm_handle_free(dhanp, dhlen);
11919 			rmdir(DUMMY_SUBDIR);
11920 		}
11921 		if (rc == -1) {
11922 			DMLOG_PRINT(DMLVL_DEBUG,
11923 				    "Unable to set up variation! (errno = %d)\n",
11924 				    errno);
11925 			DMVAR_SKIP();
11926 		} else {
11927 			/* Variation */
11928 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_AT_HANDLE with link)\n",
11929 				    szFuncName);
11930 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
11931 					     DM_AT_HANDLE, &loc, sizeof(buf),
11932 					     buf, &rlen);
11933 			DMLOG_PRINT(DMLVL_DEBUG,
11934 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
11935 				    rlen);
11936 			if (rc == 0) {
11937 				dm_stat_t *entry1 =
11938 				    GetDirEntry(buf, DUMMY_FILE);
11939 				dm_stat_t *entry2 =
11940 				    GetDirEntry(buf, DUMMY_LINK);
11941 				LogDirAttrs(buf, DM_AT_HANDLE);
11942 				if (entry1 != NULL) {
11943 					if (dm_handle_cmp
11944 					    (fhanp1, fhlen1,
11945 					     DM_GET_VALUE(entry1, dt_handle,
11946 							  void *),
11947 					     DM_GET_LEN(entry1,
11948 							dt_handle)) == 0) {
11949 						if (entry2 != NULL) {
11950 							if (dm_handle_cmp
11951 							    (fhanp2, fhlen2,
11952 							     DM_GET_VALUE
11953 							     (entry2, dt_handle,
11954 							      void *),
11955 							     DM_GET_LEN(entry2,
11956 									dt_handle))
11957 							    == 0) {
11958 								DMLOG_PRINT
11959 								    (DMLVL_DEBUG,
11960 								     "%s passed with expected rc = %d\n",
11961 								     szFuncName,
11962 								     0);
11963 								DMVAR_PASS();
11964 							} else {
11965 								DMLOG_PRINT
11966 								    (DMLVL_ERR,
11967 								     "%s failed with expected rc = %d but link handles NOT same\n",
11968 								     szFuncName,
11969 								     0);
11970 								DMVAR_FAIL();
11971 							}
11972 						} else {
11973 							DMLOG_PRINT(DMLVL_ERR,
11974 								    "%s failed with expected rc = %d but unable to find entry %s",
11975 								    szFuncName,
11976 								    0,
11977 								    DUMMY_LINK);
11978 							DMVAR_FAIL();
11979 						}
11980 					} else {
11981 						DMLOG_PRINT(DMLVL_ERR,
11982 							    "%s failed with expected rc = %d but file handles NOT same\n",
11983 							    szFuncName, 0);
11984 						DMVAR_FAIL();
11985 					}
11986 				} else {
11987 					DMLOG_PRINT(DMLVL_ERR,
11988 						    "%s failed with expected rc = %d but unable to find entry %s",
11989 						    szFuncName, 0, DUMMY_FILE);
11990 					DMVAR_FAIL();
11991 				}
11992 			} else {
11993 				DMLOG_PRINT(DMLVL_ERR,
11994 					    "%s failed with unexpected rc = %d (errno = %d)\n",
11995 					    szFuncName, rc, errno);
11996 				DMVAR_FAIL();
11997 			}
11998 
11999 			/* Variation clean up */
12000 			rc = remove(DUMMY_SUBDIR_FILE);
12001 			rc |= remove(DUMMY_SUBDIR_LINK);
12002 			rc |= rmdir(DUMMY_SUBDIR);
12003 			if (rc == -1) {
12004 				DMLOG_PRINT(DMLVL_DEBUG,
12005 					    "Unable to clean up variation! (errno = %d)\n",
12006 					    errno);
12007 			}
12008 			dm_handle_free(dhanp, dhlen);
12009 			dm_handle_free(fhanp1, fhlen1);
12010 			dm_handle_free(fhanp2, fhlen2);
12011 		}
12012 	}
12013 
12014 	/*
12015 	 * TEST    : dm_get_dirattrs - DM_AT_EMASK (verify no handle)
12016 	 * EXPECTED: rc = 0
12017 	 *
12018 	 * This variation uncovered XFS BUG #28 (handle returned when
12019 	 * DM_AT_HANDLE not set in mask)
12020 	 */
12021 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 36)) {
12022 		void *dhanp;
12023 		size_t dhlen;
12024 		dm_attrloc_t loc;
12025 		char buf[ATTR_LISTLEN];
12026 		size_t rlen;
12027 
12028 		/* Variation set up */
12029 		memset(buf, 0, ATTR_LISTLEN);
12030 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
12031 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
12032 			/* No clean up */
12033 		} else
12034 		    if ((rc =
12035 			 dm_path_to_handle(DUMMY_SUBDIR, &dhanp,
12036 					   &dhlen)) == -1) {
12037 			rmdir(DUMMY_SUBDIR);
12038 		} else if (((rc = system(command)) == -1) ||
12039 			   ((rc =
12040 			     dm_init_attrloc(sid, dhanp, dhlen, DM_NO_TOKEN,
12041 					     &loc)) == -1)) {
12042 			dm_handle_free(dhanp, dhlen);
12043 			rmdir(DUMMY_SUBDIR);
12044 		}
12045 		if (rc == -1) {
12046 			DMLOG_PRINT(DMLVL_DEBUG,
12047 				    "Unable to set up variation! (errno = %d)\n",
12048 				    errno);
12049 			DMVAR_SKIP();
12050 		} else {
12051 			/* Variation */
12052 			DMLOG_PRINT(DMLVL_DEBUG, "%s(~DM_AT_HANDLE)\n",
12053 				    szFuncName);
12054 			rc = dm_get_dirattrs(sid, dhanp, dhlen, DM_NO_TOKEN,
12055 					     DM_AT_ALL_DIRATTRS &
12056 					     (~DM_AT_HANDLE), &loc, sizeof(buf),
12057 					     buf, &rlen);
12058 			DMLOG_PRINT(DMLVL_DEBUG,
12059 				    "call: rc %d, loc %lld, rlen %d\n", rc, loc,
12060 				    rlen);
12061 			if (rc == 0) {
12062 				dm_stat_t *entry = GetDirEntry(buf, DUMMY_FILE);
12063 				LogDirAttrs(buf, DM_AT_ALL_DIRATTRS);
12064 				if (entry != NULL) {
12065 					if ((entry->dt_handle.vd_offset == 0)
12066 					    && (entry->dt_handle.vd_length ==
12067 						0)) {
12068 						DMLOG_PRINT(DMLVL_DEBUG,
12069 							    "%s passed with expected rc = %d\n",
12070 							    szFuncName, 0);
12071 						DMVAR_PASS();
12072 					} else {
12073 						DMLOG_PRINT(DMLVL_ERR,
12074 							    "%s failed with expected rc = %d but handle non-zero (offset %d, length %d)\n",
12075 							    szFuncName, 0,
12076 							    entry->dt_handle.
12077 							    vd_offset,
12078 							    entry->dt_handle.
12079 							    vd_length);
12080 						DMVAR_FAIL();
12081 					}
12082 				} else {
12083 					DMLOG_PRINT(DMLVL_ERR,
12084 						    "%s failed with expected rc = %d but unable to find entry %s",
12085 						    szFuncName, 0, DUMMY_FILE);
12086 					DMVAR_FAIL();
12087 				}
12088 			} else {
12089 				DMLOG_PRINT(DMLVL_ERR,
12090 					    "%s failed with unexpected rc = %d (errno = %d)\n",
12091 					    szFuncName, rc, errno);
12092 				DMVAR_FAIL();
12093 			}
12094 
12095 			/* Variation clean up */
12096 			rc = remove(DUMMY_SUBDIR_FILE);
12097 			rc |= rmdir(DUMMY_SUBDIR);
12098 			if (rc == -1) {
12099 				DMLOG_PRINT(DMLVL_DEBUG,
12100 					    "Unable to clean up variation! (errno = %d)\n",
12101 					    errno);
12102 			}
12103 			dm_handle_free(dhanp, dhlen);
12104 		}
12105 	}
12106 
12107 	/*
12108 	 * TEST    : dm_get_dirattrs - fs handle
12109 	 * EXPECTED: rc = -1, errno = EINVAL
12110 	 */
12111 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 37)) {
12112 		void *hanp;
12113 		size_t hlen;
12114 		dm_attrloc_t loc;
12115 		char buf[ATTR_LISTLEN];
12116 		size_t rlen;
12117 
12118 		/* Variation set up */
12119 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12120 		if ((rc = system(command)) == -1) {
12121 			/* No clean up */
12122 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12123 			   == -1) {
12124 			remove(DUMMY_FILE);
12125 		}
12126 		if (rc == -1) {
12127 			DMLOG_PRINT(DMLVL_DEBUG,
12128 				    "Unable to set up variation! (errno = %d)\n",
12129 				    errno);
12130 			DMVAR_SKIP();
12131 		} else {
12132 			/* Variation */
12133 			DMLOG_PRINT(DMLVL_DEBUG, "%s(fs handle)\n", szFuncName);
12134 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
12135 					     DM_AT_EMASK, &loc, sizeof(buf),
12136 					     buf, &rlen);
12137 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12138 
12139 			/* Variation clean up */
12140 			rc = remove(DUMMY_FILE);
12141 			if (rc == -1) {
12142 				DMLOG_PRINT(DMLVL_DEBUG,
12143 					    "Unable to clean up variation! (errno = %d)\n",
12144 					    errno);
12145 			}
12146 			dm_handle_free(hanp, hlen);
12147 		}
12148 	}
12149 
12150 	/*
12151 	 * TEST    : dm_get_dirattrs - DM_NO_SESSION sid
12152 	 * EXPECTED: rc = -1, errno = EINVAL
12153 	 */
12154 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 38)) {
12155 		void *hanp;
12156 		size_t hlen;
12157 		dm_attrloc_t loc;
12158 		char buf[ATTR_LISTLEN];
12159 		size_t rlen;
12160 
12161 		/* Variation set up */
12162 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_SUBDIR_FILE);
12163 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
12164 			/* No clean up */
12165 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
12166 			   == -1) {
12167 			rmdir(DUMMY_SUBDIR);
12168 		} else
12169 		    if (((rc =
12170 			  dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
12171 					  &loc)) == -1)
12172 			|| ((rc = system(command)) == -1)) {
12173 			dm_handle_free(hanp, hlen);
12174 			rmdir(DUMMY_SUBDIR);
12175 		}
12176 		if (rc == -1) {
12177 			DMLOG_PRINT(DMLVL_DEBUG,
12178 				    "Unable to set up variation! (errno = %d)\n",
12179 				    errno);
12180 			DMVAR_SKIP();
12181 		} else {
12182 			/* Variation */
12183 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
12184 				    szFuncName);
12185 			rc = dm_get_dirattrs(DM_NO_SESSION, hanp, hlen,
12186 					     DM_NO_TOKEN, DM_AT_EMASK, &loc,
12187 					     sizeof(buf), buf, &rlen);
12188 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12189 
12190 			/* Variation clean up */
12191 			rc = remove(DUMMY_SUBDIR_FILE);
12192 			rc |= rmdir(DUMMY_SUBDIR);
12193 			if (rc == -1) {
12194 				DMLOG_PRINT(DMLVL_DEBUG,
12195 					    "Unable to clean up variation! (errno = %d)\n",
12196 					    errno);
12197 			}
12198 			dm_handle_free(hanp, hlen);
12199 		}
12200 	}
12201 
12202 	/*
12203 	 * TEST    : dm_get_dirattrs - global handle
12204 	 * EXPECTED: rc = -1, errno = EBADF
12205 	 */
12206 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 39)) {
12207 		void *hanp;
12208 		size_t hlen;
12209 		dm_attrloc_t loc;
12210 		char buf[ATTR_LISTLEN];
12211 		size_t rlen;
12212 
12213 		/* Variation set up */
12214 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
12215 			/* No clean up */
12216 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
12217 			   == -1) {
12218 			rmdir(DUMMY_SUBDIR);
12219 		} else
12220 		    if ((rc =
12221 			 dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
12222 					 &loc)) == -1) {
12223 			dm_handle_free(hanp, hlen);
12224 			rmdir(DUMMY_SUBDIR);
12225 		}
12226 		if (rc == -1) {
12227 			DMLOG_PRINT(DMLVL_DEBUG,
12228 				    "Unable to set up variation! (errno = %d)\n",
12229 				    errno);
12230 			DMVAR_SKIP();
12231 		} else {
12232 			/* Variation */
12233 			DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n",
12234 				    szFuncName);
12235 			rc = dm_get_dirattrs(sid, DM_GLOBAL_HANP,
12236 					     DM_GLOBAL_HLEN, DM_NO_TOKEN,
12237 					     DM_AT_EMASK, &loc, sizeof(buf),
12238 					     buf, &rlen);
12239 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
12240 
12241 			/* Variation clean up */
12242 			rc = rmdir(DUMMY_SUBDIR);
12243 			if (rc == -1) {
12244 				DMLOG_PRINT(DMLVL_DEBUG,
12245 					    "Unable to clean up variation! (errno = %d)\n",
12246 					    errno);
12247 			}
12248 			dm_handle_free(hanp, hlen);
12249 		}
12250 	}
12251 
12252 	/*
12253 	 * TEST    : dm_get_dirattrs - invalidated hanp
12254 	 * EXPECTED: rc = -1, errno = EBADF
12255 	 */
12256 	if (DMVAR_EXEC(GET_DIRATTRS_BASE + 40)) {
12257 		void *hanp;
12258 		size_t hlen;
12259 		dm_attrloc_t loc;
12260 		char buf[ATTR_LISTLEN];
12261 		size_t rlen;
12262 
12263 		/* Variation set up */
12264 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
12265 			/* No clean up */
12266 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
12267 			   == -1) {
12268 			rmdir(DUMMY_SUBDIR);
12269 		} else
12270 		    if ((rc =
12271 			 dm_init_attrloc(sid, hanp, hlen, DM_NO_TOKEN,
12272 					 &loc)) == -1) {
12273 			dm_handle_free(hanp, hlen);
12274 			rmdir(DUMMY_SUBDIR);
12275 		} else if ((rc = rmdir(DUMMY_SUBDIR)) == -1) {
12276 			dm_handle_free(hanp, hlen);
12277 		}
12278 		if (rc == -1) {
12279 			DMLOG_PRINT(DMLVL_DEBUG,
12280 				    "Unable to set up variation! (errno = %d)\n",
12281 				    errno);
12282 			DMVAR_SKIP();
12283 		} else {
12284 			/* Variation */
12285 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalidated hanp)\n",
12286 				    szFuncName);
12287 			rc = dm_get_dirattrs(sid, hanp, hlen, DM_NO_TOKEN,
12288 					     DM_AT_EMASK, &loc, sizeof(buf),
12289 					     buf, &rlen);
12290 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
12291 
12292 			/* Variation clean up */
12293 			dm_handle_free(hanp, hlen);
12294 		}
12295 	}
12296 
12297 	szFuncName = "dm_set_inherit";
12298 
12299 	/*
12300 	 * TEST    : dm_set_inherit - invalid sid
12301 	 * EXPECTED: rc = -1, errno = EINVAL
12302 	 */
12303 	if (DMVAR_EXEC(SET_INHERIT_BASE + 1)) {
12304 		int fd;
12305 		void *hanp;
12306 		size_t hlen;
12307 		dm_attrname_t attrname;
12308 
12309 		/* Variation set up */
12310 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12311 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12312 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12313 		if ((rc = system(command)) == -1) {
12314 			/* No clean up */
12315 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12316 			remove(DUMMY_FILE);
12317 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12318 			   == -1) {
12319 			close(fd);
12320 			remove(DUMMY_FILE);
12321 		}
12322 		if (fd == -1 || rc == -1) {
12323 			DMLOG_PRINT(DMLVL_DEBUG,
12324 				    "Unable to set up variation! (errno = %d)\n",
12325 				    errno);
12326 			DMVAR_SKIP();
12327 		} else {
12328 			/* Variation */
12329 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
12330 				    szFuncName);
12331 			rc = dm_set_inherit(INVALID_ADDR, hanp, hlen,
12332 					    DM_NO_TOKEN, &attrname, 0);
12333 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12334 
12335 			/* Variation clean up */
12336 			rc = close(fd);
12337 			rc |= remove(DUMMY_FILE);
12338 			if (rc == -1) {
12339 				DMLOG_PRINT(DMLVL_DEBUG,
12340 					    "Unable to clean up variation! (errno = %d)\n",
12341 					    errno);
12342 			}
12343 			dm_handle_free(hanp, hlen);
12344 		}
12345 	}
12346 
12347 	/*
12348 	 * TEST    : dm_set_inherit - invalid hanp
12349 	 * EXPECTED: rc = -1, errno = EFAULT
12350 	 */
12351 	if (DMVAR_EXEC(SET_INHERIT_BASE + 2)) {
12352 		int fd;
12353 		void *hanp;
12354 		size_t hlen;
12355 		dm_attrname_t attrname;
12356 
12357 		/* Variation set up */
12358 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12359 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12360 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12361 		if ((rc = system(command)) == -1) {
12362 			/* No clean up */
12363 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12364 			remove(DUMMY_FILE);
12365 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12366 			   == -1) {
12367 			close(fd);
12368 			remove(DUMMY_FILE);
12369 		}
12370 		if (fd == -1 || rc == -1) {
12371 			DMLOG_PRINT(DMLVL_DEBUG,
12372 				    "Unable to set up variation! (errno = %d)\n",
12373 				    errno);
12374 			DMVAR_SKIP();
12375 		} else {
12376 			/* Variation */
12377 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
12378 				    szFuncName);
12379 			rc = dm_set_inherit(sid, (void *)INVALID_ADDR, hlen,
12380 					    DM_NO_TOKEN, &attrname, 0);
12381 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
12382 
12383 			/* Variation clean up */
12384 			rc = close(fd);
12385 			rc |= remove(DUMMY_FILE);
12386 			if (rc == -1) {
12387 				DMLOG_PRINT(DMLVL_DEBUG,
12388 					    "Unable to clean up variation! (errno = %d)\n",
12389 					    errno);
12390 			}
12391 			dm_handle_free(hanp, hlen);
12392 		}
12393 	}
12394 
12395 	/*
12396 	 * TEST    : dm_set_inherit - invalid hlen
12397 	 * EXPECTED: rc = -1, errno = EBADF
12398 	 */
12399 	if (DMVAR_EXEC(SET_INHERIT_BASE + 3)) {
12400 		int fd;
12401 		void *hanp;
12402 		size_t hlen;
12403 		dm_attrname_t attrname;
12404 
12405 		/* Variation set up */
12406 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12407 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12408 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12409 		if ((rc = system(command)) == -1) {
12410 			/* No clean up */
12411 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12412 			remove(DUMMY_FILE);
12413 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12414 			   == -1) {
12415 			close(fd);
12416 			remove(DUMMY_FILE);
12417 		}
12418 		if (fd == -1 || rc == -1) {
12419 			DMLOG_PRINT(DMLVL_DEBUG,
12420 				    "Unable to set up variation! (errno = %d)\n",
12421 				    errno);
12422 			DMVAR_SKIP();
12423 		} else {
12424 			/* Variation */
12425 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
12426 				    szFuncName);
12427 			rc = dm_set_inherit(sid, hanp, INVALID_ADDR,
12428 					    DM_NO_TOKEN, &attrname, 0);
12429 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
12430 
12431 			/* Variation clean up */
12432 			rc = close(fd);
12433 			rc |= remove(DUMMY_FILE);
12434 			if (rc == -1) {
12435 				DMLOG_PRINT(DMLVL_DEBUG,
12436 					    "Unable to clean up variation! (errno = %d)\n",
12437 					    errno);
12438 			}
12439 			dm_handle_free(hanp, hlen);
12440 		}
12441 	}
12442 
12443 	/*
12444 	 * TEST    : dm_set_inherit - invalid token
12445 	 * EXPECTED: rc = -1, errno = EINVAL
12446 	 */
12447 	if (DMVAR_EXEC(SET_INHERIT_BASE + 4)) {
12448 		int fd;
12449 		void *hanp;
12450 		size_t hlen;
12451 		dm_attrname_t attrname;
12452 
12453 		/* Variation set up */
12454 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12455 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12456 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12457 		if ((rc = system(command)) == -1) {
12458 			/* No clean up */
12459 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12460 			remove(DUMMY_FILE);
12461 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12462 			   == -1) {
12463 			close(fd);
12464 			remove(DUMMY_FILE);
12465 		}
12466 		if (fd == -1 || rc == -1) {
12467 			DMLOG_PRINT(DMLVL_DEBUG,
12468 				    "Unable to set up variation! (errno = %d)\n",
12469 				    errno);
12470 			DMVAR_SKIP();
12471 		} else {
12472 			/* Variation */
12473 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
12474 				    szFuncName);
12475 			rc = dm_set_inherit(sid, hanp, hlen, INVALID_ADDR,
12476 					    &attrname, 0);
12477 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12478 
12479 			/* Variation clean up */
12480 			rc = close(fd);
12481 			rc |= remove(DUMMY_FILE);
12482 			if (rc == -1) {
12483 				DMLOG_PRINT(DMLVL_DEBUG,
12484 					    "Unable to clean up variation! (errno = %d)\n",
12485 					    errno);
12486 			}
12487 			dm_handle_free(hanp, hlen);
12488 		}
12489 	}
12490 
12491 	/*
12492 	 * TEST    : dm_set_inherit - invalid attrnamep
12493 	 * EXPECTED: rc = -1, errno = EFAULT
12494 	 */
12495 	if (DMVAR_EXEC(SET_INHERIT_BASE + 5)) {
12496 		int fd;
12497 		void *hanp;
12498 		size_t hlen;
12499 		dm_attrname_t attrname;
12500 
12501 		/* Variation set up */
12502 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12503 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12504 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12505 		if ((rc = system(command)) == -1) {
12506 			/* No clean up */
12507 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12508 			remove(DUMMY_FILE);
12509 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12510 			   == -1) {
12511 			close(fd);
12512 			remove(DUMMY_FILE);
12513 		}
12514 		if (fd == -1 || rc == -1) {
12515 			DMLOG_PRINT(DMLVL_DEBUG,
12516 				    "Unable to set up variation! (errno = %d)\n",
12517 				    errno);
12518 			DMVAR_SKIP();
12519 		} else {
12520 			/* Variation */
12521 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
12522 				    szFuncName);
12523 			rc = dm_set_inherit(sid, hanp, hlen, DM_NO_TOKEN,
12524 					    (dm_attrname_t *) INVALID_ADDR, 0);
12525 			DMVAR_ENDFAILEXP(szFuncName, -1, rc,
12526 					 persInheritAttr ? EFAULT : ENOSYS);
12527 
12528 			/* Variation clean up */
12529 			rc = close(fd);
12530 			rc |= remove(DUMMY_FILE);
12531 			if (rc == -1) {
12532 				DMLOG_PRINT(DMLVL_DEBUG,
12533 					    "Unable to clean up variation! (errno = %d)\n",
12534 					    errno);
12535 			}
12536 			dm_handle_free(hanp, hlen);
12537 		}
12538 	}
12539 
12540 	/*
12541 	 * TEST    : dm_set_inherit - DM_NO_SESSION sid
12542 	 * EXPECTED: rc = -1, errno = EINVAL
12543 	 */
12544 	if (DMVAR_EXEC(SET_INHERIT_BASE + 6)) {
12545 		int fd;
12546 		void *hanp;
12547 		size_t hlen;
12548 		dm_attrname_t attrname;
12549 
12550 		/* Variation set up */
12551 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12552 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12553 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12554 		if ((rc = system(command)) == -1) {
12555 			/* No clean up */
12556 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12557 			remove(DUMMY_FILE);
12558 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12559 			   == -1) {
12560 			close(fd);
12561 			remove(DUMMY_FILE);
12562 		}
12563 		if (fd == -1 || rc == -1) {
12564 			DMLOG_PRINT(DMLVL_DEBUG,
12565 				    "Unable to set up variation! (errno = %d)\n",
12566 				    errno);
12567 			DMVAR_SKIP();
12568 		} else {
12569 			/* Variation */
12570 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
12571 				    szFuncName);
12572 			rc = dm_set_inherit(DM_NO_SESSION, hanp, hlen,
12573 					    DM_NO_TOKEN, &attrname, 0);
12574 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12575 
12576 			/* Variation clean up */
12577 			rc = close(fd);
12578 			rc |= remove(DUMMY_FILE);
12579 			if (rc == -1) {
12580 				DMLOG_PRINT(DMLVL_DEBUG,
12581 					    "Unable to clean up variation! (errno = %d)\n",
12582 					    errno);
12583 			}
12584 			dm_handle_free(hanp, hlen);
12585 		}
12586 	}
12587 
12588 	/*
12589 	 * TEST    : dm_set_inherit - global handle
12590 	 * EXPECTED: rc = -1, errno = EBADF
12591 	 */
12592 	if (DMVAR_EXEC(SET_INHERIT_BASE + 7)) {
12593 		dm_attrname_t attrname;
12594 
12595 		/* Variation set up */
12596 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12597 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12598 
12599 		/* Variation */
12600 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
12601 		rc = dm_set_inherit(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
12602 				    DM_NO_TOKEN, &attrname, 0);
12603 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
12604 
12605 		/* Variation clean up */
12606 	}
12607 
12608 	/*
12609 	 * TEST    : dm_set_inherit - file handle
12610 	 * EXPECTED: rc = -1, errno = EINVAL
12611 	 */
12612 	if (DMVAR_EXEC(SET_INHERIT_BASE + 8)) {
12613 		int fd;
12614 		void *hanp;
12615 		size_t hlen;
12616 		dm_attrname_t attrname;
12617 
12618 		/* Variation set up */
12619 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12620 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12621 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12622 		if ((rc = system(command)) == -1) {
12623 			/* No clean up */
12624 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12625 			remove(DUMMY_FILE);
12626 		} else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
12627 			   -1) {
12628 			close(fd);
12629 			remove(DUMMY_FILE);
12630 		}
12631 		if (fd == -1 || rc == -1) {
12632 			DMLOG_PRINT(DMLVL_DEBUG,
12633 				    "Unable to set up variation! (errno = %d)\n",
12634 				    errno);
12635 			DMVAR_SKIP();
12636 		} else {
12637 			/* Variation */
12638 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
12639 				    szFuncName);
12640 			rc = dm_set_inherit(sid, hanp, hlen, DM_NO_TOKEN,
12641 					    &attrname, 0);
12642 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12643 
12644 			/* Variation clean up */
12645 			rc = close(fd);
12646 			rc |= remove(DUMMY_FILE);
12647 			if (rc == -1) {
12648 				DMLOG_PRINT(DMLVL_DEBUG,
12649 					    "Unable to clean up variation! (errno = %d)\n",
12650 					    errno);
12651 			}
12652 			dm_handle_free(hanp, hlen);
12653 		}
12654 	}
12655 
12656 	/*
12657 	 * TEST    : dm_set_inherit - directory handle
12658 	 * EXPECTED: rc = -1, errno = EINVAL
12659 	 */
12660 	if (DMVAR_EXEC(SET_INHERIT_BASE + 9)) {
12661 		void *hanp;
12662 		size_t hlen;
12663 		dm_attrname_t attrname;
12664 
12665 		/* Variation set up */
12666 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12667 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12668 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
12669 			/* No clean up */
12670 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
12671 			   == -1) {
12672 			rmdir(DUMMY_SUBDIR);
12673 		}
12674 		if (rc == -1) {
12675 			DMLOG_PRINT(DMLVL_DEBUG,
12676 				    "Unable to set up variation! (errno = %d)\n",
12677 				    errno);
12678 			DMVAR_SKIP();
12679 		} else {
12680 			/* Variation */
12681 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
12682 				    szFuncName);
12683 			rc = dm_set_inherit(sid, hanp, hlen, DM_NO_TOKEN,
12684 					    &attrname, 0);
12685 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12686 
12687 			/* Variation clean up */
12688 			rc = rmdir(DUMMY_SUBDIR);
12689 			if (rc == -1) {
12690 				DMLOG_PRINT(DMLVL_DEBUG,
12691 					    "Unable to clean up variation! (errno = %d)\n",
12692 					    errno);
12693 			}
12694 			dm_handle_free(hanp, hlen);
12695 		}
12696 	}
12697 
12698 	szFuncName = "dm_clear_inherit";
12699 
12700 	/*
12701 	 * TEST    : dm_clear_inherit - invalid sid
12702 	 * EXPECTED: rc = -1, errno = EINVAL
12703 	 */
12704 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 1)) {
12705 		int fd;
12706 		void *hanp;
12707 		size_t hlen;
12708 		dm_attrname_t attrname;
12709 
12710 		/* Variation set up */
12711 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12712 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12713 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12714 		if ((rc = system(command)) == -1) {
12715 			/* No clean up */
12716 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12717 			remove(DUMMY_FILE);
12718 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12719 			   == -1) {
12720 			close(fd);
12721 			remove(DUMMY_FILE);
12722 		}
12723 		if (fd == -1 || rc == -1) {
12724 			DMLOG_PRINT(DMLVL_DEBUG,
12725 				    "Unable to set up variation! (errno = %d)\n",
12726 				    errno);
12727 			DMVAR_SKIP();
12728 		} else {
12729 			/* Variation */
12730 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
12731 				    szFuncName);
12732 			rc = dm_clear_inherit(INVALID_ADDR, hanp, hlen,
12733 					      DM_NO_TOKEN, &attrname);
12734 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12735 
12736 			/* Variation clean up */
12737 			rc = close(fd);
12738 			rc |= remove(DUMMY_FILE);
12739 			if (rc == -1) {
12740 				DMLOG_PRINT(DMLVL_DEBUG,
12741 					    "Unable to clean up variation! (errno = %d)\n",
12742 					    errno);
12743 			}
12744 			dm_handle_free(hanp, hlen);
12745 		}
12746 	}
12747 
12748 	/*
12749 	 * TEST    : dm_clear_inherit - invalid hanp
12750 	 * EXPECTED: rc = -1, errno = EFAULT
12751 	 */
12752 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 2)) {
12753 		int fd;
12754 		void *hanp;
12755 		size_t hlen;
12756 		dm_attrname_t attrname;
12757 
12758 		/* Variation set up */
12759 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12760 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12761 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12762 		if ((rc = system(command)) == -1) {
12763 			/* No clean up */
12764 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12765 			remove(DUMMY_FILE);
12766 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12767 			   == -1) {
12768 			close(fd);
12769 			remove(DUMMY_FILE);
12770 		}
12771 		if (fd == -1 || rc == -1) {
12772 			DMLOG_PRINT(DMLVL_DEBUG,
12773 				    "Unable to set up variation! (errno = %d)\n",
12774 				    errno);
12775 			DMVAR_SKIP();
12776 		} else {
12777 			/* Variation */
12778 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
12779 				    szFuncName);
12780 			rc = dm_clear_inherit(sid, (void *)INVALID_ADDR, hlen,
12781 					      DM_NO_TOKEN, &attrname);
12782 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
12783 
12784 			/* Variation clean up */
12785 			rc = close(fd);
12786 			rc |= remove(DUMMY_FILE);
12787 			if (rc == -1) {
12788 				DMLOG_PRINT(DMLVL_DEBUG,
12789 					    "Unable to clean up variation! (errno = %d)\n",
12790 					    errno);
12791 			}
12792 			dm_handle_free(hanp, hlen);
12793 		}
12794 	}
12795 
12796 	/*
12797 	 * TEST    : dm_clear_inherit - invalid hlen
12798 	 * EXPECTED: rc = -1, errno = EBADF
12799 	 */
12800 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 3)) {
12801 		int fd;
12802 		void *hanp;
12803 		size_t hlen;
12804 		dm_attrname_t attrname;
12805 
12806 		/* Variation set up */
12807 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12808 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12809 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12810 		if ((rc = system(command)) == -1) {
12811 			/* No clean up */
12812 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12813 			remove(DUMMY_FILE);
12814 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12815 			   == -1) {
12816 			close(fd);
12817 			remove(DUMMY_FILE);
12818 		}
12819 		if (fd == -1 || rc == -1) {
12820 			DMLOG_PRINT(DMLVL_DEBUG,
12821 				    "Unable to set up variation! (errno = %d)\n",
12822 				    errno);
12823 			DMVAR_SKIP();
12824 		} else {
12825 			/* Variation */
12826 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
12827 				    szFuncName);
12828 			rc = dm_clear_inherit(sid, hanp, INVALID_ADDR,
12829 					      DM_NO_TOKEN, &attrname);
12830 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
12831 
12832 			/* Variation clean up */
12833 			rc = close(fd);
12834 			rc |= remove(DUMMY_FILE);
12835 			if (rc == -1) {
12836 				DMLOG_PRINT(DMLVL_DEBUG,
12837 					    "Unable to clean up variation! (errno = %d)\n",
12838 					    errno);
12839 			}
12840 			dm_handle_free(hanp, hlen);
12841 		}
12842 	}
12843 
12844 	/*
12845 	 * TEST    : dm_clear_inherit - invalid token
12846 	 * EXPECTED: rc = -1, errno = EINVAL
12847 	 */
12848 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 4)) {
12849 		int fd;
12850 		void *hanp;
12851 		size_t hlen;
12852 		dm_attrname_t attrname;
12853 
12854 		/* Variation set up */
12855 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12856 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12857 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12858 		if ((rc = system(command)) == -1) {
12859 			/* No clean up */
12860 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12861 			remove(DUMMY_FILE);
12862 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12863 			   == -1) {
12864 			close(fd);
12865 			remove(DUMMY_FILE);
12866 		}
12867 		if (fd == -1 || rc == -1) {
12868 			DMLOG_PRINT(DMLVL_DEBUG,
12869 				    "Unable to set up variation! (errno = %d)\n",
12870 				    errno);
12871 			DMVAR_SKIP();
12872 		} else {
12873 			/* Variation */
12874 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
12875 				    szFuncName);
12876 			rc = dm_clear_inherit(sid, hanp, hlen, INVALID_ADDR,
12877 					      &attrname);
12878 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12879 
12880 			/* Variation clean up */
12881 			rc = close(fd);
12882 			rc |= remove(DUMMY_FILE);
12883 			if (rc == -1) {
12884 				DMLOG_PRINT(DMLVL_DEBUG,
12885 					    "Unable to clean up variation! (errno = %d)\n",
12886 					    errno);
12887 			}
12888 			dm_handle_free(hanp, hlen);
12889 		}
12890 	}
12891 
12892 	/*
12893 	 * TEST    : dm_clear_inherit - invalid attrnamep
12894 	 * EXPECTED: rc = -1, errno = EFAULT
12895 	 */
12896 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 5)) {
12897 		int fd;
12898 		void *hanp;
12899 		size_t hlen;
12900 		dm_attrname_t attrname;
12901 
12902 		/* Variation set up */
12903 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12904 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12905 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12906 		if ((rc = system(command)) == -1) {
12907 			/* No clean up */
12908 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12909 			remove(DUMMY_FILE);
12910 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12911 			   == -1) {
12912 			close(fd);
12913 			remove(DUMMY_FILE);
12914 		}
12915 		if (fd == -1 || rc == -1) {
12916 			DMLOG_PRINT(DMLVL_DEBUG,
12917 				    "Unable to set up variation! (errno = %d)\n",
12918 				    errno);
12919 			DMVAR_SKIP();
12920 		} else {
12921 			/* Variation */
12922 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid attrnamep)\n",
12923 				    szFuncName);
12924 			rc = dm_clear_inherit(sid, hanp, hlen, DM_NO_TOKEN,
12925 					      (dm_attrname_t *) INVALID_ADDR);
12926 			DMVAR_ENDFAILEXP(szFuncName, -1, rc,
12927 					 persInheritAttr ? EFAULT : ENOSYS);
12928 
12929 			/* Variation clean up */
12930 			rc = close(fd);
12931 			rc |= remove(DUMMY_FILE);
12932 			if (rc == -1) {
12933 				DMLOG_PRINT(DMLVL_DEBUG,
12934 					    "Unable to clean up variation! (errno = %d)\n",
12935 					    errno);
12936 			}
12937 			dm_handle_free(hanp, hlen);
12938 		}
12939 	}
12940 
12941 	/*
12942 	 * TEST    : dm_clear_inherit - DM_NO_SESSION sid
12943 	 * EXPECTED: rc = -1, errno = EINVAL
12944 	 */
12945 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 6)) {
12946 		int fd;
12947 		void *hanp;
12948 		size_t hlen;
12949 		dm_attrname_t attrname;
12950 
12951 		/* Variation set up */
12952 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12953 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12954 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
12955 		if ((rc = system(command)) == -1) {
12956 			/* No clean up */
12957 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
12958 			remove(DUMMY_FILE);
12959 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
12960 			   == -1) {
12961 			close(fd);
12962 			remove(DUMMY_FILE);
12963 		}
12964 		if (fd == -1 || rc == -1) {
12965 			DMLOG_PRINT(DMLVL_DEBUG,
12966 				    "Unable to set up variation! (errno = %d)\n",
12967 				    errno);
12968 			DMVAR_SKIP();
12969 		} else {
12970 			/* Variation */
12971 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
12972 				    szFuncName);
12973 			rc = dm_clear_inherit(DM_NO_SESSION, hanp, hlen,
12974 					      DM_NO_TOKEN, &attrname);
12975 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
12976 
12977 			/* Variation clean up */
12978 			rc = close(fd);
12979 			rc |= remove(DUMMY_FILE);
12980 			if (rc == -1) {
12981 				DMLOG_PRINT(DMLVL_DEBUG,
12982 					    "Unable to clean up variation! (errno = %d)\n",
12983 					    errno);
12984 			}
12985 			dm_handle_free(hanp, hlen);
12986 		}
12987 	}
12988 
12989 	/*
12990 	 * TEST    : dm_clear_inherit - global handle
12991 	 * EXPECTED: rc = -1, errno = EBADF
12992 	 */
12993 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 7)) {
12994 		dm_attrname_t attrname;
12995 
12996 		/* Variation set up */
12997 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
12998 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
12999 
13000 		/* Variation */
13001 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
13002 		rc = dm_clear_inherit(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
13003 				      DM_NO_TOKEN, &attrname);
13004 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
13005 
13006 		/* Variation clean up */
13007 	}
13008 
13009 	/*
13010 	 * TEST    : dm_clear_inherit - file handle
13011 	 * EXPECTED: rc = -1, errno = EINVAL
13012 	 */
13013 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 8)) {
13014 		int fd;
13015 		void *hanp;
13016 		size_t hlen;
13017 		dm_attrname_t attrname;
13018 
13019 		/* Variation set up */
13020 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
13021 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
13022 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13023 		if ((rc = system(command)) == -1) {
13024 			/* No clean up */
13025 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13026 			remove(DUMMY_FILE);
13027 		} else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
13028 			   -1) {
13029 			close(fd);
13030 			remove(DUMMY_FILE);
13031 		}
13032 		if (fd == -1 || rc == -1) {
13033 			DMLOG_PRINT(DMLVL_DEBUG,
13034 				    "Unable to set up variation! (errno = %d)\n",
13035 				    errno);
13036 			DMVAR_SKIP();
13037 		} else {
13038 			/* Variation */
13039 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
13040 				    szFuncName);
13041 			rc = dm_clear_inherit(sid, hanp, hlen, DM_NO_TOKEN,
13042 					      &attrname);
13043 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13044 
13045 			/* Variation clean up */
13046 			rc = close(fd);
13047 			rc |= remove(DUMMY_FILE);
13048 			if (rc == -1) {
13049 				DMLOG_PRINT(DMLVL_DEBUG,
13050 					    "Unable to clean up variation! (errno = %d)\n",
13051 					    errno);
13052 			}
13053 			dm_handle_free(hanp, hlen);
13054 		}
13055 	}
13056 
13057 	/*
13058 	 * TEST    : dm_clear_inherit - directory handle
13059 	 * EXPECTED: rc = -1, errno = EINVAL
13060 	 */
13061 	if (DMVAR_EXEC(CLEAR_INHERIT_BASE + 9)) {
13062 		void *hanp;
13063 		size_t hlen;
13064 		dm_attrname_t attrname;
13065 
13066 		/* Variation set up */
13067 		memset(attrname.an_chars, 0, DM_ATTR_NAME_SIZE);
13068 		memcpy(attrname.an_chars, ATTR_NAME, DM_ATTR_NAME_SIZE);
13069 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
13070 			/* No clean up */
13071 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
13072 			   == -1) {
13073 			rmdir(DUMMY_SUBDIR);
13074 		}
13075 		if (rc == -1) {
13076 			DMLOG_PRINT(DMLVL_DEBUG,
13077 				    "Unable to set up variation! (errno = %d)\n",
13078 				    errno);
13079 			DMVAR_SKIP();
13080 		} else {
13081 			/* Variation */
13082 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
13083 				    szFuncName);
13084 			rc = dm_clear_inherit(sid, hanp, hlen, DM_NO_TOKEN,
13085 					      &attrname);
13086 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13087 
13088 			/* Variation clean up */
13089 			rc = rmdir(DUMMY_SUBDIR);
13090 			if (rc == -1) {
13091 				DMLOG_PRINT(DMLVL_DEBUG,
13092 					    "Unable to clean up variation! (errno = %d)\n",
13093 					    errno);
13094 			}
13095 			dm_handle_free(hanp, hlen);
13096 		}
13097 	}
13098 
13099 	szFuncName = "dm_getall_inherit";
13100 
13101 	/*
13102 	 * TEST    : dm_getall_inherit - invalid sid
13103 	 * EXPECTED: rc = -1, errno = EINVAL
13104 	 */
13105 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 1)) {
13106 		int fd;
13107 		void *hanp;
13108 		size_t hlen;
13109 		dm_inherit_t inheritbuf;
13110 		u_int nelem;
13111 
13112 		/* Variation set up */
13113 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13114 		if ((rc = system(command)) == -1) {
13115 			/* No clean up */
13116 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13117 			remove(DUMMY_FILE);
13118 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
13119 			   == -1) {
13120 			close(fd);
13121 			remove(DUMMY_FILE);
13122 		}
13123 		if (fd == -1 || rc == -1) {
13124 			DMLOG_PRINT(DMLVL_DEBUG,
13125 				    "Unable to set up variation! (errno = %d)\n",
13126 				    errno);
13127 			DMVAR_SKIP();
13128 		} else {
13129 			/* Variation */
13130 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid sid)\n",
13131 				    szFuncName);
13132 			rc = dm_getall_inherit(INVALID_ADDR, hanp, hlen,
13133 					       DM_NO_TOKEN, 1, &inheritbuf,
13134 					       &nelem);
13135 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13136 
13137 			/* Variation clean up */
13138 			rc = close(fd);
13139 			rc |= remove(DUMMY_FILE);
13140 			if (rc == -1) {
13141 				DMLOG_PRINT(DMLVL_DEBUG,
13142 					    "Unable to clean up variation! (errno = %d)\n",
13143 					    errno);
13144 			}
13145 			dm_handle_free(hanp, hlen);
13146 		}
13147 	}
13148 
13149 	/*
13150 	 * TEST    : dm_getall_inherit - invalid hanp
13151 	 * EXPECTED: rc = -1, errno = EFAULT
13152 	 */
13153 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 2)) {
13154 		int fd;
13155 		void *hanp;
13156 		size_t hlen;
13157 		dm_inherit_t inheritbuf;
13158 		u_int nelem;
13159 
13160 		/* Variation set up */
13161 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13162 		if ((rc = system(command)) == -1) {
13163 			/* No clean up */
13164 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13165 			remove(DUMMY_FILE);
13166 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
13167 			   == -1) {
13168 			close(fd);
13169 			remove(DUMMY_FILE);
13170 		}
13171 		if (fd == -1 || rc == -1) {
13172 			DMLOG_PRINT(DMLVL_DEBUG,
13173 				    "Unable to set up variation! (errno = %d)\n",
13174 				    errno);
13175 			DMVAR_SKIP();
13176 		} else {
13177 			/* Variation */
13178 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hanp)\n",
13179 				    szFuncName);
13180 			rc = dm_getall_inherit(sid, (void *)INVALID_ADDR, hlen,
13181 					       DM_NO_TOKEN, 1, &inheritbuf,
13182 					       &nelem);
13183 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EFAULT);
13184 
13185 			/* Variation clean up */
13186 			rc = close(fd);
13187 			rc |= remove(DUMMY_FILE);
13188 			if (rc == -1) {
13189 				DMLOG_PRINT(DMLVL_DEBUG,
13190 					    "Unable to clean up variation! (errno = %d)\n",
13191 					    errno);
13192 			}
13193 			dm_handle_free(hanp, hlen);
13194 		}
13195 	}
13196 
13197 	/*
13198 	 * TEST    : dm_getall_inherit - invalid hlen
13199 	 * EXPECTED: rc = -1, errno = EBADF
13200 	 */
13201 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 3)) {
13202 		int fd;
13203 		void *hanp;
13204 		size_t hlen;
13205 		dm_inherit_t inheritbuf;
13206 		u_int nelem;
13207 
13208 		/* Variation set up */
13209 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13210 		if ((rc = system(command)) == -1) {
13211 			/* No clean up */
13212 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13213 			remove(DUMMY_FILE);
13214 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
13215 			   == -1) {
13216 			close(fd);
13217 			remove(DUMMY_FILE);
13218 		}
13219 		if (fd == -1 || rc == -1) {
13220 			DMLOG_PRINT(DMLVL_DEBUG,
13221 				    "Unable to set up variation! (errno = %d)\n",
13222 				    errno);
13223 			DMVAR_SKIP();
13224 		} else {
13225 			/* Variation */
13226 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid hlen)\n",
13227 				    szFuncName);
13228 			rc = dm_getall_inherit(sid, hanp, INVALID_ADDR,
13229 					       DM_NO_TOKEN, 1, &inheritbuf,
13230 					       &nelem);
13231 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
13232 
13233 			/* Variation clean up */
13234 			rc = close(fd);
13235 			rc |= remove(DUMMY_FILE);
13236 			if (rc == -1) {
13237 				DMLOG_PRINT(DMLVL_DEBUG,
13238 					    "Unable to clean up variation! (errno = %d)\n",
13239 					    errno);
13240 			}
13241 			dm_handle_free(hanp, hlen);
13242 		}
13243 	}
13244 
13245 	/*
13246 	 * TEST    : dm_getall_inherit - invalid token
13247 	 * EXPECTED: rc = -1, errno = EINVAL
13248 	 */
13249 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 4)) {
13250 		int fd;
13251 		void *hanp;
13252 		size_t hlen;
13253 		dm_inherit_t inheritbuf;
13254 		u_int nelem;
13255 
13256 		/* Variation set up */
13257 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13258 		if ((rc = system(command)) == -1) {
13259 			/* No clean up */
13260 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13261 			remove(DUMMY_FILE);
13262 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
13263 			   == -1) {
13264 			close(fd);
13265 			remove(DUMMY_FILE);
13266 		}
13267 		if (fd == -1 || rc == -1) {
13268 			DMLOG_PRINT(DMLVL_DEBUG,
13269 				    "Unable to set up variation! (errno = %d)\n",
13270 				    errno);
13271 			DMVAR_SKIP();
13272 		} else {
13273 			/* Variation */
13274 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid token)\n",
13275 				    szFuncName);
13276 			rc = dm_getall_inherit(sid, hanp, hlen, INVALID_ADDR, 1,
13277 					       &inheritbuf, &nelem);
13278 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13279 
13280 			/* Variation clean up */
13281 			rc = close(fd);
13282 			rc |= remove(DUMMY_FILE);
13283 			if (rc == -1) {
13284 				DMLOG_PRINT(DMLVL_DEBUG,
13285 					    "Unable to clean up variation! (errno = %d)\n",
13286 					    errno);
13287 			}
13288 			dm_handle_free(hanp, hlen);
13289 		}
13290 	}
13291 
13292 	/*
13293 	 * TEST    : dm_getall_inherit - invalid inheritbufp
13294 	 * EXPECTED: rc = -1, errno = EFAULT
13295 	 */
13296 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 5)) {
13297 		int fd;
13298 		void *hanp;
13299 		size_t hlen;
13300 		u_int nelem;
13301 
13302 		/* Variation set up */
13303 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13304 		if ((rc = system(command)) == -1) {
13305 			/* No clean up */
13306 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13307 			remove(DUMMY_FILE);
13308 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
13309 			   == -1) {
13310 			close(fd);
13311 			remove(DUMMY_FILE);
13312 		}
13313 		if (fd == -1 || rc == -1) {
13314 			DMLOG_PRINT(DMLVL_DEBUG,
13315 				    "Unable to set up variation! (errno = %d)\n",
13316 				    errno);
13317 			DMVAR_SKIP();
13318 		} else {
13319 			/* Variation */
13320 			DMLOG_PRINT(DMLVL_DEBUG, "%s(invalid inheritbufp)\n",
13321 				    szFuncName);
13322 			rc = dm_getall_inherit(sid, hanp, hlen, DM_NO_TOKEN, 1,
13323 					       (dm_inherit_t *) INVALID_ADDR,
13324 					       &nelem);
13325 			DMVAR_ENDFAILEXP(szFuncName, -1, rc,
13326 					 persInheritAttr ? EFAULT : ENOSYS);
13327 
13328 			/* Variation clean up */
13329 			rc = close(fd);
13330 			rc |= remove(DUMMY_FILE);
13331 			if (rc == -1) {
13332 				DMLOG_PRINT(DMLVL_DEBUG,
13333 					    "Unable to clean up variation! (errno = %d)\n",
13334 					    errno);
13335 			}
13336 			dm_handle_free(hanp, hlen);
13337 		}
13338 	}
13339 
13340 	/*
13341 	 * TEST    : dm_getall_inherit - DM_NO_SESSION sid
13342 	 * EXPECTED: rc = -1, errno = EINVAL
13343 	 */
13344 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 6)) {
13345 		int fd;
13346 		void *hanp;
13347 		size_t hlen;
13348 		dm_inherit_t inheritbuf;
13349 		u_int nelem;
13350 
13351 		/* Variation set up */
13352 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13353 		if ((rc = system(command)) == -1) {
13354 			/* No clean up */
13355 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13356 			remove(DUMMY_FILE);
13357 		} else if ((rc = dm_path_to_fshandle(DUMMY_FILE, &hanp, &hlen))
13358 			   == -1) {
13359 			close(fd);
13360 			remove(DUMMY_FILE);
13361 		}
13362 		if (fd == -1 || rc == -1) {
13363 			DMLOG_PRINT(DMLVL_DEBUG,
13364 				    "Unable to set up variation! (errno = %d)\n",
13365 				    errno);
13366 			DMVAR_SKIP();
13367 		} else {
13368 			/* Variation */
13369 			DMLOG_PRINT(DMLVL_DEBUG, "%s(DM_NO_SESSION sid)\n",
13370 				    szFuncName);
13371 			rc = dm_getall_inherit(DM_NO_SESSION, hanp, hlen,
13372 					       DM_NO_TOKEN, 1, &inheritbuf,
13373 					       &nelem);
13374 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13375 
13376 			/* Variation clean up */
13377 			rc = close(fd);
13378 			rc |= remove(DUMMY_FILE);
13379 			if (rc == -1) {
13380 				DMLOG_PRINT(DMLVL_DEBUG,
13381 					    "Unable to clean up variation! (errno = %d)\n",
13382 					    errno);
13383 			}
13384 			dm_handle_free(hanp, hlen);
13385 		}
13386 	}
13387 
13388 	/*
13389 	 * TEST    : dm_getall_inherit - global handle
13390 	 * EXPECTED: rc = -1, errno = EBADF
13391 	 */
13392 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 7)) {
13393 		dm_inherit_t inheritbuf;
13394 		u_int nelem;
13395 
13396 		/* Variation set up */
13397 
13398 		/* Variation */
13399 		DMLOG_PRINT(DMLVL_DEBUG, "%s(global handle)\n", szFuncName);
13400 		rc = dm_getall_inherit(sid, DM_GLOBAL_HANP, DM_GLOBAL_HLEN,
13401 				       DM_NO_TOKEN, 1, &inheritbuf, &nelem);
13402 		DMVAR_ENDFAILEXP(szFuncName, -1, rc, EBADF);
13403 
13404 		/* Variation clean up */
13405 	}
13406 
13407 	/*
13408 	 * TEST    : dm_getall_inherit - file handle
13409 	 * EXPECTED: rc = -1, errno = EINVAL
13410 	 */
13411 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 8)) {
13412 		int fd;
13413 		void *hanp;
13414 		size_t hlen;
13415 		dm_inherit_t inheritbuf;
13416 		u_int nelem;
13417 
13418 		/* Variation set up */
13419 		sprintf(command, "cp %s %s", DUMMY_TMP, DUMMY_FILE);
13420 		if ((rc = system(command)) == -1) {
13421 			/* No clean up */
13422 		} else if ((fd = open(DUMMY_FILE, O_RDWR)) == -1) {
13423 			remove(DUMMY_FILE);
13424 		} else if ((rc = dm_path_to_handle(DUMMY_FILE, &hanp, &hlen)) ==
13425 			   -1) {
13426 			close(fd);
13427 			remove(DUMMY_FILE);
13428 		}
13429 		if (fd == -1 || rc == -1) {
13430 			DMLOG_PRINT(DMLVL_DEBUG,
13431 				    "Unable to set up variation! (errno = %d)\n",
13432 				    errno);
13433 			DMVAR_SKIP();
13434 		} else {
13435 			/* Variation */
13436 			DMLOG_PRINT(DMLVL_DEBUG, "%s(file handle)\n",
13437 				    szFuncName);
13438 			rc = dm_getall_inherit(sid, hanp, hlen, DM_NO_TOKEN, 1,
13439 					       &inheritbuf, &nelem);
13440 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13441 
13442 			/* Variation clean up */
13443 			rc = close(fd);
13444 			rc |= remove(DUMMY_FILE);
13445 			if (rc == -1) {
13446 				DMLOG_PRINT(DMLVL_DEBUG,
13447 					    "Unable to clean up variation! (errno = %d)\n",
13448 					    errno);
13449 			}
13450 			dm_handle_free(hanp, hlen);
13451 		}
13452 	}
13453 
13454 	/*
13455 	 * TEST    : dm_getall_inherit - directory handle
13456 	 * EXPECTED: rc = -1, errno = EINVAL
13457 	 */
13458 	if (DMVAR_EXEC(GETALL_INHERIT_BASE + 9)) {
13459 		void *hanp;
13460 		size_t hlen;
13461 		dm_inherit_t inheritbuf;
13462 		u_int nelem;
13463 
13464 		/* Variation set up */
13465 		if ((rc = mkdir(DUMMY_SUBDIR, DUMMY_DIR_RW_MODE)) == -1) {
13466 			/* No clean up */
13467 		} else if ((rc = dm_path_to_handle(DUMMY_SUBDIR, &hanp, &hlen))
13468 			   == -1) {
13469 			rmdir(DUMMY_SUBDIR);
13470 		}
13471 		if (rc == -1) {
13472 			DMLOG_PRINT(DMLVL_DEBUG,
13473 				    "Unable to set up variation! (errno = %d)\n",
13474 				    errno);
13475 			DMVAR_SKIP();
13476 		} else {
13477 			/* Variation */
13478 			DMLOG_PRINT(DMLVL_DEBUG, "%s(dir handle)\n",
13479 				    szFuncName);
13480 			rc = dm_getall_inherit(sid, hanp, hlen, DM_NO_TOKEN, 1,
13481 					       &inheritbuf, &nelem);
13482 			DMVAR_ENDFAILEXP(szFuncName, -1, rc, EINVAL);
13483 
13484 			/* Variation clean up */
13485 			rc = rmdir(DUMMY_SUBDIR);
13486 			if (rc == -1) {
13487 				DMLOG_PRINT(DMLVL_DEBUG,
13488 					    "Unable to clean up variation! (errno = %d)\n",
13489 					    errno);
13490 			}
13491 			dm_handle_free(hanp, hlen);
13492 		}
13493 	}
13494 
13495 	rc = dm_destroy_session(sid);
13496 	if (rc == -1) {
13497 		DMLOG_PRINT(DMLVL_ERR,
13498 			    "dm_destroy_session failed! (rc = %d, errno = %d)\n",
13499 			    rc, errno);
13500 	}
13501 
13502 	remove(DUMMY_TMP);
13503 
13504 	DMLOG_STOP();
13505 
13506 	tst_exit();
13507 }
13508