strlist_xti.c 593 B

12345678910111213141516171819202122232425262728
  1. #include "unpxti.h"
  2. #include <stropts.h>
  3. int
  4. main(int argc, char *argv[])
  5. {
  6. int fd, i, nmods;
  7. struct str_list list;
  8. if (argc != 2)
  9. err_quit("usage: a.out <pathname>");
  10. fd = T_open(argv[1], O_RDWR, NULL);
  11. if (isastream(fd) == 0)
  12. err_quit("%s is not a stream", argv[1]);
  13. list.sl_nmods = nmods = Ioctl(fd, I_LIST, (void *) 0);
  14. printf("%d modules\n", nmods);
  15. list.sl_modlist = Calloc(nmods, sizeof(struct str_mlist));
  16. Ioctl(fd, I_LIST, &list);
  17. for (i = 1; i <= nmods; i++)
  18. printf(" %s: %s\n", (i == nmods) ? "driver" : "module",
  19. list.sl_modlist++);
  20. exit(0);
  21. }