10 #include <sys/mount.h>
12 #include <sys/statvfs.h>
14 #include "test_driver.h"
19 * ################################################
21 * # These allow all of the different commands #
22 * # to be called with the same format #
23 * ################################################
26 int test_do_setdebug(int argc, char **argv)
31 DBG(2, fprintf(outfp, "Invalid number of args (%d) for setdebug\n",
36 level = atoi(argv[0]);
39 DBG(2, fprintf(outfp, "Invalid debug level %d\n", level));
47 int test_do_printline(int argc, char **argv)
53 DBG(2, fprintf(outfp, "Invalid number of args (%d) for printline\n",
68 int test_do_setoutput(int argc, char **argv)
73 fprintf(outfp, "Invalid number of args (%d) for setoutput\n",
78 newfp = fopen(argv[0], "w");
80 fprintf(outfp, "Unable to open new output file %s\n", argv[0]);
92 int test_do_fillbuff(int argc, char **argv)
96 int size, type, index, offset;
101 "fillbuff requires a value, a type, a size, an offset, and the target buffer\n"));
102 fprintf(stderr, "fillbuff requires 5 args, you gave %d\n", argc);
106 offset = get_obj(argv[3]);
108 DBG(2, fprintf(outfp, "Do not understand offset %s\n", argv[3]));
112 index = get_obj(argv[4]);
114 DBG(2, fprintf(outfp, "Can't find buffer at %s\n", argv[4]));
117 buf = (char *)(buflist[index]->buf)+offset;
119 DBG(4, fprintf(outfp, "Buffer start is at %p\n", (void *)buflist[index]));
122 size = get_obj(argv[2]);
124 DBG(2, fprintf(outfp, "Unable to understand size %s\n", argv[2]));
128 if ( (!strcmp(typestr, "UINT")) || (!strcmp(typestr, "SINT")) ){
129 int val = get_obj(argv[0]);
132 if (val < 0) { /* FIX THIS */
133 DBG(2, fprintf(outfp, "Can't understand value %s\n", argv[0]));
136 DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %x\n",
137 size, buf, *((int *)valptr)));
138 memcpy(buf, valptr, size);
140 } else if (!strcmp(typestr,"STR")) {
143 DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %s\n",
144 size, buf, (char *)valptr));
145 memcpy(buf, valptr, size);
146 } else if (!strcmp(typestr, "PTR")) {
148 int index = get_obj(argv[0]);
150 DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[0]));
154 val = (unsigned long)buflist[index]->buf;
156 DBG(4, fprintf(outfp, "Copying %d bytes from %p. Val is %p\n",
158 memcpy(buf, valptr, size);
160 DBG(2, fprintf(outfp, "Unknown type %s. Valid types are UINT, STR, and PTR\n",
162 fprintf(stderr, "Unknown type %s. Valid types are UINT, STR, and PTR\n",
177 void print_partial(char *buf, int offset, int len, int type)
181 if (type == STR_TYPE) {
182 sprintf(output, "%s%s", output, (char *)(buf+offset));
183 DBG(4, fprintf(outfp, "Printing str %s\n", (char *)(buf+offset)));
185 if (type == SHORT_TYPE) {
186 for (i = 0; i < len; i+= 2) {
187 short *ibuf = (short *)(buf + offset + i);
188 sprintf(output, "%s%#04x ", output, *ibuf);
189 DBG(4, fprintf(outfp, "Printing short %#04x\n", *ibuf));
191 } else if (type == CHAR_TYPE) {
192 for (i = 0; i < len; i++) {
193 short *ibuf = (short *)(buf+offset+i);
194 sprintf(output, "%s%#02x ", output, (*ibuf & 0x00ff));
195 DBG(4, fprintf(outfp, "Printing char %c\n", (*ibuf & 0x00ff)));
197 } else if (type == INT_TYPE) {
198 for (i = 0; i < len; i+= 4) {
199 int *ibuf = (int *)(buf + offset + i);
200 sprintf(output, "%s%#08x ", output, *ibuf);
201 DBG(4, fprintf(outfp, "Printing int %#08x\n", *ibuf));
204 for (i = 0; i < len; i += 8) {
205 unsigned long *lbuf = (unsigned long *)(buf + offset +i);
206 sprintf(output, "%s%#08lx ", output, *lbuf);
207 DBG(4, fprintf(outfp, "Printing int %#016lx\n", *lbuf));
213 int test_do_printbuf(int argc, char **argv)
215 int index, i, type, offset, len;
216 struct buf_t *buf_st;
219 struct var_mapping *mobj;
221 if (argv[0][0] == '$') {
222 if (argv[0][1] == '$') {
223 sprintf(output, "\n%#010x", (unsigned int)last_ret_val);
225 } else if (!strcmp("errno", &argv[0][1])) {
226 sprintf(output, "\n%#010x", my_errno);
231 mobj = get_map(argv[0]);
233 DBG(2, fprintf(outfp, "Can't get var at %s\n", argv[0]));
237 if (mobj->type == UINT)
238 sprintf(output, "\n%#010x", mobj->obj);
239 else if (mobj->type == SINT)
240 sprintf(output, "%d", mobj->obj);
241 else if ((mobj->type == STR) || (mobj->type == PTR)) {
244 buf_st = buflist[index];
245 DBG(2, fprintf(outfp, "buf_st is %p:\n", (void *)buf_st));
247 DBG(2, fprintf(outfp, "buf %s:\n", argv[0]));
248 if (mobj->type == STR) {
249 sprintf(output, "\n%s", (char *)buf);
251 sprintf(output,"%s\n", output);
252 DBG(2, fprintf(outfp, "buf_st->len is %d, buf is %p\n", buf_st->len, buf));
254 for (i = 0; i < buf_st->len/4; i++)
255 DBG(2, fprintf(outfp, "%#x ", ((int *)buf)[i]));
256 sprintf(output, "%s%#x ", output, ((int *)buf)[i]);
260 for (i = 1; i < argc; i++) {
261 offset = get_obj(argv[i++]);
262 len = get_obj(argv[i++]);
263 if ((offset < 0) || (len < 0)) {
264 DBG(2, fprintf(outfp, "Invalid offset (%s) or len (%s)\n",
265 argv[i-2], argv[i-1]));
269 if (!strcmp("STR", typestr))
271 else if (!strcmp("INT", typestr))
273 else if (!strcmp("SHORT", typestr))
275 else if (!strcmp("CHAR", typestr))
277 else if (!strcmp("LONG", typestr))
280 DBG(2, fprintf(outfp, "Unable to understand type %s\n",
284 print_partial(buf, offset, len, type);
288 DBG(3, fprintf(outfp, "output: %s \n", output));
292 int test_do_mount(int argc, char **argv)
295 DBG(2, fprintf(outfp, "Invalid number of args (%d) for test_do_mount\n",
300 DBG(4, fprintf(outfp, "Calling mount with from %s and to %s\n",
302 last_ret_val = sysio_mount(argv[0], argv[1]);
308 int test_do_clear(int argc, char **argv)
314 DBG(2, fprintf(outfp, "Invalid number of args (%d) for clear\n",
318 index = get_obj(argv[0]);
320 fprintf(outfp, "Unable to locate buffer %s\n",
324 buf = buflist[index];
325 bzero(buf->buf, buf->len);
330 int test_do_list(int argc, char **argv)
334 if ((argc) && (argc != 1)) {
335 DBG(2, fprintf(outfp, "Invalid number of args (%d) for list\n",
340 DBG(5,fprintf(outfp, "In test_do_list with args %p\n", (void *)argv));
342 buf = getcwd(NULL, 0);
343 DBG(4, fprintf(outfp, "Calling list with dir of %s\n", buf));
344 last_ret_val = sysio_list(buf);
351 return sysio_list(*argv);
355 * Initlizes sysio library. Will use default initlization
356 * unless arguments are given
358 int test_do_init(int argc, char **argv)
363 int mflags, rsize, msize;
365 DBG(2, fprintf(outfp, "Invalid number of args (%d) for init\n",
370 rdriver = get_str(argv[0]);
371 rsize = strlen(rdriver)+1;
373 DBG(2, fprintf(outfp, "%s too long for root driver\n", rdriver));
376 bzero(root_driver, 75);
377 memcpy(root_driver, rdriver, rsize);
379 mpath = get_str(argv[1]);
380 msize = strlen(mpath)+1;
382 DBG(2, fprintf(outfp, "%s too long for mount path\n", mpath));
386 memcpy(mntpath, mpath, msize);
388 mflags = get_obj(argv[2]);
390 DBG(2, fprintf(outfp, "Invalid flags argument %s\n", argv[2]));
395 DBG(5, fprintf(outfp, "In test_do_init\n"));
397 DBG(3, fprintf(outfp, "initializing\n"));
398 return initilize_sysio();
403 * Returns 1 if the machine is big-endian, 0
406 int get_endian(int argc, char **argv)
410 if ((argc) || (argv)) {
411 DBG(2, fprintf(outfp, "Expected no args for test_do_endian\n"));
415 if(*(char *)&x == 1) {
416 /* little-endian, return 0 */
419 /* big endian, return 1 */
426 int do_setbuf(int argc, char **argv)
428 int val, size, index, offset;
432 DBG(2, fprintf(outfp, "Need val, size, buffer, and offset for setbuf\n"));
435 val = get_obj(argv[0]);
437 DBG(2, fprintf(outfp, "Unable to understand val of %s\n",
442 size = get_obj(argv[1]);
444 DBG(2, fprintf(outfp, "Size of %s is invalid\n", argv[1]));
448 index = get_obj(argv[2]);
450 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
455 buf = buflist[index]->buf;
457 offset = get_obj(argv[3]);
460 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[3]));
464 buf = (void *)((char *)buf +offset);
466 memset(buf, val, size);
472 int get_sizeof(int argc, char **argv)
478 DBG(2, fprintf(outfp, "Number of args (%d) invalid for sizeof\n",
485 if (!strcmp(type, "char"))
487 else if (!strcmp(type, "int"))
489 else if (!strcmp(type, "long"))
491 else if (!strcmp(type, "flock"))
492 size = sizeof(struct flock);
493 else if (!strcmp(type, "stat"))
494 size = sizeof(struct stat);
495 else if (!strcmp(type, "statvfs"))
496 size = sizeof(struct statvfs);
497 else if (!strcmp(type, "iovec"))
498 size = sizeof(struct iovec);
499 else if (!strcmp(type, "xtvec"))
500 size = sizeof(struct xtvec);
504 DBG(2, fprintf(outfp, "Size is %d\n", size));
511 int test_do_exit(int argc, char **argv)
517 * If argc is given, need to return the value of
518 * the passed in variable
520 val = get_obj(argv[0]);
529 DBG(3, printf("Exiting with %d from %s\n", val, argv[0]));
536 int get_buffer(int argc, char **argv)
541 if (argc == 1) /* Just put size, not alignment */
544 align = get_obj(argv[1]);
546 DBG(2, fprintf(outfp, "Number of args (%d) invalid for alloc\n",
551 size = get_obj(argv[0]);
553 DBG(2, fprintf(outfp, "Invalid size %s\n", argv[0]));
557 DBG(3, fprintf(outfp, "Getting buffer of size %d and aligned at %d\n",
559 buf = (struct buf_t *)malloc(sizeof(struct buf_t));
560 buf->buf = alloc_buff32(size, align);
563 DBG(3, fprintf(outfp, "Your buffer (%p) (%p) is at index %d\n",
564 (void *)buf, buf->buf, next));
568 last_ret_val = next-1;
572 int free_buffer(int argc, char **argv)
575 char *name = argv[0];
578 DBG(2, fprintf(outfp, "Number of args (%d) invalid for free\n",
584 * Assume that there is one arg and it
585 * is a variable name which maps to an
586 * index into the buffer array
588 index = get_obj(name);
590 DBG(2, fprintf(outfp, "Can't find buffer %s\n",
594 DBG(4, fprintf(outfp, "Freeing buffer at index %d\n", index));
595 free(buflist[index]);
601 int cmp_bufs(int argc, char **argv)
603 int res, index1, index2;
607 fprintf(outfp, "Need two buffers to compare\n");
611 index1 = get_obj(argv[0]);
613 fprintf(outfp, "Unable to locate buffer %s\n",
617 buf1 = buflist[index1]->buf;
619 index2 = get_obj(argv[1]);
621 fprintf(outfp, "Unable to locate buffer %s\n",
626 buf2 = buflist[index2]->buf;
627 last_ret_val = strcmp(buf1, buf2);
629 DBG(3, fprintf(outfp, "strcmp returned %d\n", res));
633 int test_do_chdir(int argc, char **argv)
636 DBG(2, fprintf(outfp, "Number of args (%d) invalid for chdir\n",
641 return sysio_chdir(argv[0]);
645 int test_do_chmod(int argc, char **argv)
648 DBG(2, fprintf(outfp, "Number of args (%d) invalid for chmod\n",
653 return sysio_chmod(argv[0], argv[1]);
656 int test_do_chown(int argc, char **argv)
659 DBG(2, fprintf(outfp, "Number of args (%d) invalid for chown\n",
664 return sysio_chown(argv[0], argv[1]);
667 int test_do_open(int argc, char **argv)
669 char *name = argv[0];
673 flags = get_obj(argv[1]);
675 if (name[0] == '$') {
676 int index = get_obj(name);
679 DBG(2, fprintf(outfp, "Unable to find buffer at %s\n",
684 name = buflist[index]->buf;
687 DBG(4, fprintf(outfp, "Opening file %s with flags %d\n", name, flags));
689 return sysio_open(name, flags);
691 return sysio_open3(name, flags, argv[2]);
693 DBG(2, fprintf(outfp, "Invalid number of arguments (%d)\n", argc));
700 int test_do_close(int argc, char **argv)
703 char *name = argv[0];
706 DBG(2, fprintf(outfp, "Number of args (%d) invalid for close\n",
712 * Assume that there is one arg and it
713 * is a variable name which maps to a file
718 DBG(2, fprintf(outfp, "Unable to map var %s to anything\n", name));
726 int test_do_dup(int argc, char **argv)
729 char *var_name = argv[0];
732 DBG(2, fprintf(outfp, "Number of args (%d) invalid for dup\n",
738 fd = get_obj(var_name);
740 DBG(2, fprintf(outfp, "Unable to map var %s to any file\n", var_name));
744 last_ret_val = dup(fd);
751 int test_do_dup2(int argc, char **argv)
754 char *var_name1 = argv[0];
755 char *var_name2 = argv[1];
758 DBG(2, fprintf(outfp, "Number of args (%d) invalid for dup2\n",
763 fd1 = get_obj(var_name1);
765 DBG(2, fprintf(outfp, "Unable to map var %s to any file\n", var_name1));
769 fd2 = get_obj(var_name2);
771 DBG(2, fprintf(outfp, "Unable to map var %s to any file\n", var_name2));
775 last_ret_val = dup2(fd1, fd2);
782 struct cmd_map fcntl_cmds[] = {
783 { "F_DUPFD", F_DUPFD, 3 },
784 { "F_GETFD", F_GETFD, 2 },
785 { "F_SETFD", F_SETFD, 3 },
786 { "F_GETFL", F_GETFL, 2 },
787 { "F_SETFL", F_SETFL, 3 },
788 { "F_SETLK", F_SETLK, 3 },
789 { "F_SETLKW", F_SETLKW, 3 },
790 { "F_GETLK", F_GETLK, 3 },
791 #if defined __USE_BSD || defined __USE_XOPEN2K
792 { "F_GETOWN", F_GETOWN, 2 },
793 { "F_SETOWN", F_SETOWN, 3 },
796 { "F_GETSIG", F_GETSIG, 2 },
797 { "F_SETSIG", F_SETSIG, 3 },
798 { "F_SETLEASE", F_SETLEASE, 3},
799 { "F_GETLEASE", F_GETLEASE, 2},
800 { "F_NOTIFY", F_NOTIFY, 3} ,
805 struct cmd_map* get_cmd(char *cmd_name, int argc)
809 while (fcntl_cmds[i].cmd_name) {
810 if (!strcmp(fcntl_cmds[i].cmd_name, cmd_name)) {
811 if (fcntl_cmds[i].num_args == argc)
812 return &fcntl_cmds[i];
821 int test_do_fcntl(int argc, char **argv)
828 * get_cmd translates a symbolic command into
829 * into its numerical equivalent. It also
830 * verifies that the number of args is the
831 * correct number for the command. It returns
834 cmd = get_cmd(argv[1], argc);
836 DBG(2, fprintf(outfp, "Unable to get command %s\n", argv[1]));
840 fd = get_obj(argv[0]);
842 DBG(2, fprintf(outfp, "Unable to map %s to file descriptor \n", argv[0]));
847 last_ret_val = sysio_fcntl(fd, cmd, argv[2]);
849 last_ret_val = sysio_fcntl(fd, cmd, NULL);
850 DBG(4, fprintf(outfp, "Got return value of %d\n", (int)last_ret_val));
857 int test_do_fstat(int argc, char **argv)
863 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) for fstat\n",
868 fd = get_obj(argv[0]);
871 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
876 index = get_obj(argv[1]);
878 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
883 buf = buflist[index]->buf;
885 last_ret_val = sysio_fstat(fd, buf);
892 int test_do_lstat(int argc, char **argv)
894 char *name = argv[0];
899 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) for lstat\n",
904 index = get_obj(argv[1]);
906 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
911 buf = buflist[index]->buf;
914 return sysio_lstat(name, buf);
917 int test_do_fsync(int argc, char **argv)
922 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to fsync\n", argc));
927 fd = get_obj(argv[0]);
930 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
935 last_ret_val = fsync(fd);
943 int test_do_fdatasync(int argc, char **argv)
948 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to fdatasync\n", argc));
953 fd = get_obj(argv[0]);
956 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
961 last_ret_val = fdatasync(fd);
969 int test_do_ftruncate(int argc, char **argv)
975 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ftruncate\n", argc));
980 fd = get_obj(argv[0]);
983 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
988 length = (off_t)get_obj(argv[1]);
990 DBG(3, fprintf(outfp, "Setting file %d to %d\n", fd, (int) length));
992 last_ret_val = ftruncate(fd, length);
999 int test_do_getcwd(int argc, char **argv)
1005 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to getcwd\n", argc));
1006 return INVALID_ARGS;
1009 index = get_obj(argv[0]);
1011 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
1016 buf = buflist[index]->buf;
1018 size = get_obj(argv[1]);
1020 DBG(4, fprintf(outfp, "Getting cwd with buffer size of %d\n", size));
1023 if (!getcwd(buf, size)) {
1025 if (errno == ERANGE) {
1026 DBG(2, fprintf(outfp, "Need a bigger buffer!\n"));
1033 DBG(3, fprintf(outfp, "cwd: %s\n", buf));
1039 int test_do_lseek(int argc, char **argv)
1046 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to lseek\n", argc));
1047 return INVALID_ARGS;
1051 fd = get_obj(argv[0]);
1054 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
1059 offset = (off_t)get_obj(argv[1]);
1060 whence = get_obj(argv[2]);
1063 DBG(2, fprintf(outfp, "Not familiar with whence of %s\n",
1065 return INVALID_ARGS;
1068 last_ret_val = lseek(fd, offset, whence);
1075 int test_do_getdirentries(int argc, char **argv)
1081 struct var_mapping *base_map;
1084 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to getdirentries\n", argc));
1085 return INVALID_ARGS;
1088 fd = get_obj(argv[0]);
1091 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
1096 bufindex = get_obj(argv[1]);
1099 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
1104 buf = buflist[bufindex]->buf;
1106 nbytes = get_obj(argv[2]);
1109 DBG(2, fprintf(outfp, "I don't understand %s\n",
1111 return INVALID_ARGS;
1114 base_map = get_map(argv[3]);
1116 DBG(3, fprintf(outfp, "Resetting basep\n"));
1118 * Assume that this is the first getdirentries call
1119 * and we need to setup the base pointer
1123 basep = base_map->obj;
1125 DBG(3, fprintf(outfp, "basep is (starting) %d\n", (int) basep));
1126 last_ret_val = sysio_getdirentries(fd, buf, nbytes, &basep);
1128 base_map->obj = basep;
1130 store_result(argv[3]+1, basep);
1131 DBG(3, fprintf(outfp, "basep is (ending) %d\n", (int) basep));
1138 int test_do_mkdir(int argc, char **argv)
1141 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to mkdir\n", argc));
1142 return INVALID_ARGS;
1146 return sysio_mkdir(argv[0], argv[1]);
1149 int test_do_creat(int argc, char **argv)
1152 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to creat\n", argc));
1153 return INVALID_ARGS;
1157 return sysio_creat(argv[0], argv[1]);
1160 int test_do_stat(int argc, char **argv)
1167 fprintf(outfp, "Invalid number of arguments (%d) for stat\n",
1173 index = get_obj(argv[1]);
1175 fprintf(outfp, "Unable to find buffer assocated with %s\n",
1179 buf = buflist[index]->buf;
1182 str = get_str(argv[0]);
1183 return sysio_stat(str, buf);
1186 int test_do_statvfs(int argc, char **argv)
1192 fprintf(outfp, "Invalid number of arguments (%d) for statvfs\n",
1198 index = get_obj(argv[1]);
1200 fprintf(outfp, "Unable to find buffer assocated with %s\n",
1204 buf = buflist[index]->buf;
1207 return sysio_statvfs(argv[0], buf);
1210 int test_do_fstatvfs(int argc, char **argv)
1216 fprintf(outfp, "Invalid number of arguments (%d) for fstatvfs\n",
1222 fd = get_obj(argv[0]);
1225 fprintf(outfp, "Unable to find file assocated with %s\n",
1230 index = get_obj(argv[1]);
1232 fprintf(outfp, "Unable to find buffer assocated with %s\n",
1236 buf = buflist[index]->buf;
1239 return sysio_fstatvfs(fd, buf);
1242 int test_do_truncate(int argc, char **argv)
1247 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to truncate\n", argc));
1248 return INVALID_ARGS;
1251 length = (off_t)get_obj(argv[1]);
1253 DBG(3, fprintf(outfp, "Setting file %s to %d\n", argv[0], (int) length));
1255 last_ret_val = truncate(argv[0], length);
1262 int test_do_rmdir(int argc, char **argv)
1266 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to rmdir\n", argc));
1267 return INVALID_ARGS;
1270 DBG(3, fprintf(outfp, "Removing dir %s\n", argv[0]));
1272 last_ret_val = rmdir(argv[0]);
1279 int test_do_symlink(int argc, char **argv)
1282 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to symlink\n", argc));
1283 return INVALID_ARGS;
1286 DBG(3, fprintf(outfp, "Linking %s to %s\n", argv[0], argv[1]));
1288 last_ret_val = symlink(argv[0], argv[1]);
1292 my_perror("symlink");
1301 struct cmd_map ioctl_cmds[] = {
1303 { "BLKROSET", BLKROSET, 3 },
1304 { "BLKROGET", BLKROGET, 3 },
1305 { "BLKRRPART", BLKRRPART, 3 },
1306 { "BLKGETSIZE", BLKGETSIZE, 3 },
1307 { "BLKRASET", BLKRASET, 3 },
1308 { "BLKRAGET", BLKRAGET, 3 },
1309 { "BLKSECTSET", BLKSECTSET, 3 },
1310 { "BLKSECTGET", BLKSECTGET, 3 },
1311 { "BLKSSZGET", BLKSSZGET, 3 },
1312 { "BLKGETLASTSECT", BLKGETLASTSECT, 3 },
1313 { "BLKSETLASTSECT", BLKSETLASTSECT, 3 },
1314 { "BLKBSZGET", BLKBSZGET, 3 },
1315 { "BLKBSZSET", BLKBSZSET, 3 },
1316 { "FIBMAP", FIBMAP, 3 },
1317 { "FIGETBSZ", FIGETBSZ, 3},
1322 int get_ioctl_cmd(char *cmd)
1326 while (ioctl_cmds[i].cmd_name != NULL) {
1327 if (strcmp(ioctl_cmds[i].cmd_name, cmd))
1330 return ioctl_cmds[i].cmd;
1336 int test_do_ioctl(int argc, char **argv)
1341 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ioctl\n", argc));
1342 return INVALID_ARGS;
1346 fd = get_obj(argv[0]);
1348 DBG(2, fprintf(outfp, "Unable to find file %s\n", argv[0]));
1352 cmd = get_ioctl_cmd(argv[1]);
1354 DBG(2, fprintf(outfp, "Do not understand command %s\n", argv[1]));
1355 return INVALID_ARGS;
1358 DBG(3, fprintf(outfp, "Executing command %s\n", argv[1]));
1360 last_ret_val = ioctl(fd, cmd, argv[2]);
1369 int test_do_unlink(int argc, char **argv)
1372 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to unlink\n", argc));
1373 return INVALID_ARGS;
1376 DBG(4, fprintf(outfp, "Unlinking %s\n", argv[0]));
1378 last_ret_val = unlink(argv[0]);
1381 my_perror("unlink");
1387 int test_do_umask(int argc, char **argv)
1392 DBG(2, fprintf(outfp, "Incorrect number of args (%d) for umask\n", argc));
1393 return INVALID_ARGS;
1396 last_ret_val = old_mask = sysio_umask(argv[0]);
1398 DBG(3, fprintf(outfp, "Previous umask was %o\n", old_mask));
1404 int test_do_iowait(int argc, char **argv)
1410 DBG(2, fprintf(outfp, "Incorrect amount of args (%d) for iowait\n", argc));
1411 return INVALID_ARGS;
1414 err = get_obj(argv[0]);
1416 DBG(2, fprintf(outfp, "Cannot find ioid at %s\n", argv[0]));
1422 last_ret_val = iowait(ioid);
1424 if (last_ret_val < 0) {
1425 my_perror("iowait");
1432 int test_do_iodone(int argc, char **argv)
1438 DBG(2, fprintf(outfp, "Incorrect amount of args (%d) for iodone\n", argc));
1439 return INVALID_ARGS;
1442 err = get_obj(argv[0]);
1444 DBG(2, fprintf(outfp, "Cannot find ioid at %s\n", argv[0]));
1449 last_ret_val = iowait(ioid);
1450 if (last_ret_val < 0) {
1451 my_perror("iodone");
1460 int test_do_ipread(int argc, char **argv)
1462 int fd, index, count, offset;
1466 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipread\n", argc));
1467 return INVALID_ARGS;
1470 fd = get_obj(argv[0]);
1472 DBG(2, fprintf(outfp, "Unable to find file at %s\n", argv[0]));
1476 index = get_obj(argv[1]);
1478 DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[1]));
1482 buf = buflist[index]->buf;
1484 count = get_obj(argv[2]);
1486 DBG(2, fprintf(outfp, "Do not understand count %s\n", argv[2]));
1487 return INVALID_ARGS;
1490 offset = get_obj(argv[3]);
1492 DBG(2, fprintf(outfp, "Unable to understand offset of %s\n", argv[3]));
1493 return INVALID_ARGS;
1496 last_ret_val = (long)ipread(fd, buf, count, offset);
1497 if (last_ret_val < 0) {
1498 my_perror("ipread");
1506 int test_do_iread(int argc, char **argv)
1508 int fd, index, count;
1512 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iread\n", argc));
1513 return INVALID_ARGS;
1516 fd = get_obj(argv[0]);
1518 DBG(2, fprintf(outfp, "Unable to find file at %s\n", argv[0]));
1522 index = get_obj(argv[1]);
1524 DBG(2, fprintf(outfp, "Unable to find buffer at %s\n", argv[1]));
1528 buf = buflist[index]->buf;
1530 count = get_obj(argv[2]);
1532 DBG(2, fprintf(outfp, "Do not understand count %s\n", argv[2]));
1533 return INVALID_ARGS;
1536 last_ret_val = (long) iread(fd, buf, count);
1537 if (last_ret_val < 0) {
1547 int test_do_ipreadv(int argc, char **argv)
1549 int fd, count, index;
1555 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipreadv\n", argc));
1556 return INVALID_ARGS;
1559 fd = get_obj(argv[0]);
1562 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1566 index = get_obj(argv[1]);
1569 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1573 buf = buflist[index]->buf;
1575 iov = (struct iovec *)buf;
1576 count = get_obj(argv[2]);
1579 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
1580 return INVALID_ARGS;
1583 offset = get_obj(argv[3]);
1585 DBG(2, fprintf(outfp, "Unable to understand offset value %s\n", argv[3]));
1586 return INVALID_ARGS;
1589 DBG(3, fprintf(outfp, "ipreadv(fd: %d vector:{iov_base: %p iov_len %d} count: %d offset: %d\n",
1590 fd, iov->iov_base, (int)iov->iov_len, count, (int) offset));
1592 last_ret_val = (long) ipreadv(fd, iov, count, offset);
1593 if (last_ret_val < 0)
1594 my_perror("ipreadv");
1602 int test_do_preadv(int argc, char **argv)
1604 int fd, count, index;
1610 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to preadv\n", argc));
1611 return INVALID_ARGS;
1614 fd = get_obj(argv[0]);
1617 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1621 index = get_obj(argv[1]);
1624 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1628 buf = buflist[index]->buf;
1630 iov = (struct iovec *)buf;
1631 count = get_obj(argv[2]);
1634 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
1635 return INVALID_ARGS;
1638 offset = get_obj(argv[3]);
1640 DBG(2, fprintf(outfp, "Unable to understand offset value %s\n", argv[3]));
1641 return INVALID_ARGS;
1644 DBG(3, fprintf(outfp, "preadv(fd: %d vector:{iov_base: %p iov_len %d} count: %d offset: %d\n",
1645 fd, iov->iov_base, (int) iov->iov_len, count, (int) offset));
1647 last_ret_val = preadv(fd, iov, count, offset);
1649 if (last_ret_val < 0)
1650 my_perror("preadv");
1657 int test_do_pread(int argc, char **argv)
1659 int fd, count, index, numbytes, offset;
1663 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to pread\n", argc));
1664 return INVALID_ARGS;
1668 fd = get_obj(argv[0]);
1671 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
1676 index = get_obj(argv[1]);
1679 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
1684 buf = buflist[index]->buf;
1686 count = get_obj(argv[2]);
1688 DBG(2, fprintf(outfp, "Unable to understand count of %s\n", argv[1]));
1689 return INVALID_ARGS;
1692 offset = get_obj(argv[3]);
1694 DBG(2, fprintf(outfp, "Unable to understand offset of %s\n", argv[2]));
1695 return INVALID_ARGS;
1699 last_ret_val = numbytes = (int) pread(fd, buf, count, offset);
1701 DBG(4, fprintf(outfp, "Read %d bytes out of %d starting at offset %x\n",
1702 numbytes, count, offset));
1703 DBG(3, fprintf(outfp, "Got %s\n", buf));
1710 int test_do_ireadv(int argc, char **argv)
1712 int fd, count, index;
1717 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ireadv\n", argc));
1718 return INVALID_ARGS;
1721 fd = get_obj(argv[0]);
1724 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1728 index = get_obj(argv[1]);
1731 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1735 buf = buflist[index]->buf;
1737 iov = (struct iovec *)buf;
1738 count = get_obj(argv[2]);
1741 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
1742 return INVALID_ARGS;
1745 DBG(3, fprintf(outfp, "ireadv (fd: %d, vector:{ iov_base: %p iov_len %d }, count: %d\n",
1746 fd, iov->iov_base, (int)iov->iov_len, count));
1748 last_ret_val = (long) ireadv(fd, iov, count);
1749 if (last_ret_val < 0)
1750 my_perror("ireadv");
1757 int test_do_readv(int argc, char **argv)
1759 int fd, count, index;
1764 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to readv\n", argc));
1765 return INVALID_ARGS;
1768 fd = get_obj(argv[0]);
1771 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1775 index = get_obj(argv[1]);
1778 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1782 buf = buflist[index]->buf;
1784 iov = (struct iovec *)buf;
1785 count = get_obj(argv[2]);
1788 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
1789 return INVALID_ARGS;
1792 DBG(3, fprintf(outfp, "ireadv (fd: %d, vector:{ iov_base: %p iov_len %d }, count: %d\n",
1793 fd, iov->iov_base, (int)iov->iov_len, count));
1795 last_ret_val = readv(fd, iov, count);
1796 if (last_ret_val < 0)
1804 int test_do_read(int argc, char **argv)
1806 int fd, count, index, numbytes=0;
1810 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to read\n", argc));
1811 return INVALID_ARGS;
1815 fd = get_obj(argv[0]);
1818 DBG(2, fprintf(outfp, "Unable to find file assocated with %s\n",
1823 index = get_obj(argv[1]);
1827 DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n",
1832 buf = buflist[index]->buf;
1834 count = get_obj(argv[2]);
1836 if ( (argc == 4) && (!strcmp(argv[3], "delay")) ){
1838 /* Wait a little while for input */
1839 for (i=0; i < count; i++) {
1841 numbytes += (int) read(fd, buf, 1);
1842 last_ret_val = numbytes;
1846 last_ret_val = numbytes = (int) read(fd, buf, count);
1850 DBG(3, fprintf(outfp, "Read %d bytes out of %d\n", numbytes, count));
1851 DBG(3, fprintf(outfp, "Got %s\n", buf));
1857 int test_do_ipwritev(int argc, char **argv)
1859 int fd, count, index, offset;
1864 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipwritev\n", argc));
1865 return INVALID_ARGS;
1868 fd = get_obj(argv[0]);
1871 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1875 index = get_obj(argv[1]);
1878 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1882 buf = buflist[index]->buf;
1884 iov = (struct iovec *)buf;
1886 count = get_obj(argv[2]);
1888 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
1889 return INVALID_ARGS;
1892 offset = get_obj(argv[3]);
1894 DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3]));
1895 return INVALID_ARGS;
1898 DBG(3, fprintf(outfp,
1899 "ipwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d, offset: %d\n",
1900 fd, iov->iov_base, (int)iov->iov_len, count, offset));
1902 last_ret_val = (long) ipwritev(fd, iov, count, offset);
1904 if (last_ret_val < 0)
1905 my_perror("ipwritev");
1911 int test_do_ipwrite(int argc, char **argv)
1913 int fd, count, index, offset;
1917 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ipwrite\n", argc));
1918 return INVALID_ARGS;
1921 fd = get_obj(argv[0]);
1924 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1928 index = get_obj(argv[1]);
1931 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1935 buf = buflist[index]->buf;
1937 count = get_obj(argv[2]);
1939 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
1940 return INVALID_ARGS;
1943 offset = get_obj(argv[3]);
1945 DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3]));
1946 return INVALID_ARGS;
1949 last_ret_val = (long) ipwrite(fd, buf, count, offset);
1950 if (last_ret_val < 0)
1951 my_perror("ipwrite");
1958 int test_do_pwritev(int argc, char **argv)
1960 int fd, count, index, offset;
1965 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to pwritev\n", argc));
1966 return INVALID_ARGS;
1969 fd = get_obj(argv[0]);
1972 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
1976 index = get_obj(argv[1]);
1979 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
1983 buf = buflist[index]->buf;
1985 iov = (struct iovec *)buf;
1987 count = get_obj(argv[2]);
1989 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
1990 return INVALID_ARGS;
1993 offset = get_obj(argv[3]);
1995 DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3]));
1996 return INVALID_ARGS;
2000 DBG(3, fprintf(outfp,
2001 "pwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d, offset: %d\n",
2002 fd, iov->iov_base, (int)iov->iov_len, count, offset));
2004 last_ret_val = (long) pwritev(fd, iov, count, offset);
2005 if (last_ret_val < 0)
2006 my_perror("ipwritev");
2013 int test_do_pwrite(int argc, char **argv)
2015 int fd, count, index, offset;
2019 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to pwrite\n", argc));
2020 return INVALID_ARGS;
2023 fd = get_obj(argv[0]);
2026 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2030 index = get_obj(argv[1]);
2033 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2037 buf = buflist[index]->buf;
2039 count = get_obj(argv[2]);
2041 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
2042 return INVALID_ARGS;
2045 offset = get_obj(argv[3]);
2047 DBG(2, fprintf(outfp, "Unable to understand offset %s\n", argv[3]));
2048 return INVALID_ARGS;
2051 last_ret_val = pwrite(fd, buf, count, offset);
2053 if (last_ret_val < 0)
2054 my_perror("pwrite");
2061 int test_do_iwritev(int argc, char **argv)
2063 int fd, count, index;
2068 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwritev\n", argc));
2069 return INVALID_ARGS;
2072 fd = get_obj(argv[0]);
2075 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2079 index = get_obj(argv[1]);
2082 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2086 buf = buflist[index]->buf;
2088 iov = (struct iovec *)buf;
2090 count = get_obj(argv[2]);
2092 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
2093 return INVALID_ARGS;
2096 DBG(3, fprintf(outfp, "iwritev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d\n",
2097 fd, iov->iov_base, (int)iov->iov_len, count));
2099 last_ret_val = (long) iwritev(fd, iov, count);
2101 if (last_ret_val < 0)
2102 my_perror("iwritev");
2108 int test_do_iwrite(int argc, char **argv)
2110 int fd, count, index;
2114 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwrite\n", argc));
2115 return INVALID_ARGS;
2118 fd = get_obj(argv[0]);
2121 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2125 index = get_obj(argv[1]);
2128 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2132 buf = buflist[index]->buf;
2134 count = get_obj(argv[2]);
2136 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
2137 return INVALID_ARGS;
2140 last_ret_val = (long) iwrite(fd, buf, count);
2142 if (last_ret_val < 0)
2143 my_perror("iwrite");
2150 int test_do_write(int argc, char **argv)
2152 int fd, count, index, err;
2156 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to write\n", argc));
2157 return INVALID_ARGS;
2160 fd = get_obj(argv[0]);
2163 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2167 index = get_obj(argv[1]);
2170 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2174 buf = buflist[index]->buf;
2176 count = get_obj(argv[2]);
2178 DBG(2, fprintf(outfp, "Unable to understand count %s\n", argv[2]));
2179 return INVALID_ARGS;
2182 DBG(4, fprintf(outfp, "Writing out %d bytes (%s) using fd of %x\n",
2184 err = write(fd, buf, count);
2196 int test_do_writev(int argc, char **argv)
2198 int fd, count, index;
2203 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to writev\n", argc));
2204 return INVALID_ARGS;
2207 fd = get_obj(argv[0]);
2210 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2211 return INVALID_ARGS;
2214 index = get_obj(argv[1]);
2217 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2221 buf = buflist[index]->buf;
2223 iov = (struct iovec *)buf;
2224 count = get_obj(argv[2]);
2227 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2228 return INVALID_ARGS;
2231 DBG(3, fprintf(outfp, "writev(fd: %d, vector: { iov_base: %p iov_len %d }, count: %d\n",
2232 fd, iov->iov_base, (int)iov->iov_len, count));
2234 last_ret_val = writev(fd, iov, count);
2235 if (last_ret_val < 0)
2236 my_perror("writev");
2243 int test_do_mknod(int argc, char **argv)
2248 DBG(2, fprintf(outfp, "Invalid number of args (%d) for mknod\n", argc));
2249 return INVALID_ARGS;
2252 dev = get_obj(argv[2]);
2254 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2255 return INVALID_ARGS;
2260 return sysio_mknod(argv[0], argv[1], (dev_t) dev);
2263 int test_do_umount(int argc, char **argv)
2268 DBG(2, fprintf(outfp, "Invalid number (%d) of args for umount\n", argc));
2269 return INVALID_ARGS;
2272 err = umount(argv[0]);
2274 my_perror("umount");
2283 int test_do_init_iovec(int argc, char **argv)
2285 int iov_index, buf_index;
2286 int offset, len, pos;
2287 struct iovec *iov_ptr;
2291 DBG(2, fprintf(outfp, "Need buffer, offset, len, array pos, and iov pointer\n"));
2292 return INVALID_ARGS;
2295 if ((buf_index = get_obj(argv[0])) < 0) {
2296 DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[0]));
2299 base_ptr = buflist[buf_index]->buf;
2301 if ((offset = get_obj(argv[1])) < 0) {
2302 DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[1]));
2306 if ((len = get_obj(argv[2])) < 0) {
2307 DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[2]));
2311 if ((pos = get_obj(argv[3])) < 0) {
2312 DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[3]));
2316 if ((iov_index = get_obj(argv[4])) < 0) {
2317 DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[4]));
2320 iov_ptr = (struct iovec *)(buflist[iov_index]->buf);
2322 iov_ptr[pos].iov_len = len;
2323 iov_ptr[pos].iov_base = (void *)(base_ptr + offset);
2325 DBG(3, fprintf(outfp, "iov_ptr.len is %d and base is %p\n",
2326 (int)iov_ptr[pos].iov_len, iov_ptr[pos].iov_base));
2334 int test_do_init_xtvec(int argc, char **argv)
2337 int offset, len, pos;
2338 struct xtvec *xtv_ptr;
2341 DBG(2, fprintf(outfp, "Need offset, len, array pos, and xtv pointer\n"));
2342 return INVALID_ARGS;
2345 if ((offset = get_obj(argv[0])) < 0) {
2346 DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[0]));
2350 if ((len = get_obj(argv[1])) < 0) {
2351 DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[1]));
2355 if ((pos = get_obj(argv[2])) < 0) {
2356 DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[2]));
2360 if ((xtv_index = get_obj(argv[3])) < 0) {
2361 DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[3]));
2364 xtv_ptr = (struct xtvec *)(buflist[xtv_index]->buf);
2366 xtv_ptr[pos].xtv_len = len;
2367 xtv_ptr[pos].xtv_off = offset;
2369 DBG(3, fprintf(outfp, "xtv_ptr.len is %d and offset is %d\n",
2370 (int)xtv_ptr[pos].xtv_len, (int)xtv_ptr[pos].xtv_off));
2378 int test_do_writex(int argc, char **argv)
2380 int fd, iov_count, xtv_count,index;
2386 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to writex\n", argc));
2387 return INVALID_ARGS;
2390 fd = get_obj(argv[0]);
2393 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2394 return INVALID_ARGS;
2397 index = get_obj(argv[1]);
2400 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2404 buf = buflist[index]->buf;
2406 iov = (struct iovec *)buf;
2407 iov_count = get_obj(argv[2]);
2409 if (iov_count < 0) {
2410 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2411 return INVALID_ARGS;
2414 index = get_obj(argv[3]);
2417 DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3]));
2421 buf = buflist[index]->buf;
2423 xtv = (struct xtvec *)buf;
2424 xtv_count = get_obj(argv[4]);
2426 if (xtv_count < 0) {
2427 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4]));
2428 return INVALID_ARGS;
2431 DBG(3, fprintf(outfp, "writex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n",
2432 fd, (void *)iov, iov_count, (void *)xtv, xtv_count));
2434 last_ret_val = writex(fd, iov, iov_count, xtv, xtv_count);
2435 if (last_ret_val < 0)
2436 my_perror("writex");
2444 int test_do_iwritex(int argc, char **argv)
2446 int fd, iov_count, xtv_count,index;
2452 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwritex\n", argc));
2453 return INVALID_ARGS;
2456 fd = get_obj(argv[0]);
2459 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2460 return INVALID_ARGS;
2463 index = get_obj(argv[1]);
2466 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2470 buf = buflist[index]->buf;
2472 iov = (struct iovec *)buf;
2473 iov_count = get_obj(argv[2]);
2475 if (iov_count < 0) {
2476 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2477 return INVALID_ARGS;
2480 index = get_obj(argv[3]);
2483 DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3]));
2487 buf = buflist[index]->buf;
2489 xtv = (struct xtvec *)buf;
2490 xtv_count = get_obj(argv[4]);
2492 if (xtv_count < 0) {
2493 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4]));
2494 return INVALID_ARGS;
2497 DBG(3, fprintf(outfp, "iwritex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n",
2498 fd, (void *)iov, iov_count, (void *)xtv, xtv_count));
2500 last_ret_val = (long) iwritex(fd, iov, iov_count, xtv, xtv_count);
2501 if (last_ret_val < 0)
2502 my_perror("iwritex");
2510 int test_do_readx(int argc, char **argv)
2512 int fd, iov_count, xtv_count,index;
2518 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to readx\n", argc));
2519 return INVALID_ARGS;
2522 fd = get_obj(argv[0]);
2525 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2526 return INVALID_ARGS;
2529 index = get_obj(argv[1]);
2532 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2536 buf = buflist[index]->buf;
2538 iov = (struct iovec *)buf;
2539 iov_count = get_obj(argv[2]);
2541 if (iov_count < 0) {
2542 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2543 return INVALID_ARGS;
2546 index = get_obj(argv[3]);
2549 DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3]));
2553 buf = buflist[index]->buf;
2555 xtv = (struct xtvec *)buf;
2556 xtv_count = get_obj(argv[4]);
2558 if (xtv_count < 0) {
2559 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4]));
2560 return INVALID_ARGS;
2563 DBG(3, fprintf(outfp, "readx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n",
2564 fd, (void *)iov, iov_count, (void *)xtv, xtv_count));
2566 last_ret_val = readx(fd, iov, iov_count, xtv, xtv_count);
2567 if (last_ret_val < 0)
2576 int test_do_ireadx(int argc, char **argv)
2578 int fd, iov_count, xtv_count,index;
2584 DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ireadx\n", argc));
2585 return INVALID_ARGS;
2588 fd = get_obj(argv[0]);
2591 DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0]));
2592 return INVALID_ARGS;
2595 index = get_obj(argv[1]);
2598 DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1]));
2602 buf = buflist[index]->buf;
2604 iov = (struct iovec *)buf;
2605 iov_count = get_obj(argv[2]);
2607 if (iov_count < 0) {
2608 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2609 return INVALID_ARGS;
2612 index = get_obj(argv[3]);
2615 DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3]));
2619 buf = buflist[index]->buf;
2621 xtv = (struct xtvec *)buf;
2622 xtv_count = get_obj(argv[4]);
2624 if (xtv_count < 0) {
2625 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4]));
2626 return INVALID_ARGS;
2629 DBG(3, fprintf(outfp, "ireadx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n",
2630 fd, (void *)iov, iov_count, (void *)xtv, xtv_count));
2632 last_ret_val = (long) ireadx(fd, iov, iov_count, xtv, xtv_count);
2633 if (last_ret_val < 0)
2634 my_perror("ireadx");
2642 int do_checkbuf(int argc, char **argv)
2644 int size, val, index, i, offset;
2648 DBG(2, fprintf(outfp, "Need buffer, val, and offset for checkbuf\n"));
2649 return INVALID_ARGS;
2652 index = get_obj(argv[0]);
2655 DBG(2, fprintf(outfp, "Unable to find buf described by %s\n", argv[0]));
2659 buf = (int *)buflist[index]->buf;
2662 size = get_obj(argv[1]);
2665 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[1]));
2666 return INVALID_ARGS;
2669 val = get_obj(argv[2]);
2672 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2]));
2673 return INVALID_ARGS;
2677 offset = get_obj(argv[3]);
2680 DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[3]));
2681 return INVALID_ARGS;
2685 ref_buf = (int *)malloc(size);
2686 memset((void *)ref_buf, val, size);
2689 buf = (int *)((char *)buf + offset);
2690 for (i=0; (unsigned)i < size/sizeof(int); i++) {
2691 if (buf[i] != ref_buf[i]) {
2692 DBG(2, fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x\n",
2693 i, buf[i], ref_buf[i]));
2694 fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x (val was %d)\n",
2695 i, buf[i], ref_buf[i], val);