511 */
512 (void) mdb_vnode2path(vp, path, MAXPATHLEN);
513
514 /*
515 * A common problem is that device pathnames are prefixed with
516 * /dev/../devices/. We just clean those up slightly:
517 * /dev/../devices/<mumble> --> /devices/<mumble>
518 * /dev/pts/../../devices/<mumble> --> /devices/<mumble>
519 */
520 if (strncmp("/dev/../devices/", path, strlen("/dev/../devices/")) == 0)
521 strcpy(path, path + 7);
522
523 if (strncmp("/dev/pts/../../devices/", path,
524 strlen("/dev/pts/../../devices/")) == 0)
525 strcpy(path, path + 14);
526
527 return (0);
528 }
529
530 const struct fs_type {
531 int type;
532 const char *name;
533 } fs_types[] = {
534 { VNON, "NON" },
535 { VREG, "REG" },
536 { VDIR, "DIR" },
537 { VBLK, "BLK" },
538 { VCHR, "CHR" },
539 { VLNK, "LNK" },
540 { VFIFO, "FIFO" },
541 { VDOOR, "DOOR" },
542 { VPROC, "PROC" },
543 { VSOCK, "SOCK" },
544 { VPORT, "PORT" },
545 { VBAD, "BAD" }
546 };
547
548 #define NUM_FS_TYPES (sizeof (fs_types) / sizeof (struct fs_type))
549
550 struct pfiles_cbdata {
551 int opt_p;
930 const char *type;
931 char path[MAXPATHLEN];
932 uintptr_t top_vnodep, realvpp;
933 char fsname[_ST_FSTYPSZ];
934 int err, i;
935
936 cb->fd++;
937
938 if (addr == NULL) {
939 return (WALK_NEXT);
940 }
941
942 top_vnodep = realvpp = (uintptr_t)f->f_vnode;
943
944 if (mdb_vread(&v, sizeof (v), realvpp) == -1) {
945 mdb_warn("failed to read vnode");
946 return (DCMD_ERR);
947 }
948
949 type = "?";
950 for (i = 0; i <= NUM_FS_TYPES; i++) {
951 if (fs_types[i].type == v.v_type)
952 type = fs_types[i].name;
953 }
954
955 do {
956 uintptr_t next_realvpp;
957
958 err = next_realvp(realvpp, &layer_vn, &next_realvpp);
959 if (next_realvpp != NULL)
960 realvpp = next_realvpp;
961
962 } while (err == REALVP_CONTINUE);
963
964 if (err == REALVP_ERR) {
965 mdb_warn("failed to do realvp() for %p", realvpp);
966 return (DCMD_ERR);
967 }
968
969 if (read_fsname((uintptr_t)layer_vn.v_vfsp, fsname) == -1)
970 return (DCMD_ERR);
971
972 mdb_printf("%4d %4s %?0p ", myfd, type, top_vnodep);
|
511 */
512 (void) mdb_vnode2path(vp, path, MAXPATHLEN);
513
514 /*
515 * A common problem is that device pathnames are prefixed with
516 * /dev/../devices/. We just clean those up slightly:
517 * /dev/../devices/<mumble> --> /devices/<mumble>
518 * /dev/pts/../../devices/<mumble> --> /devices/<mumble>
519 */
520 if (strncmp("/dev/../devices/", path, strlen("/dev/../devices/")) == 0)
521 strcpy(path, path + 7);
522
523 if (strncmp("/dev/pts/../../devices/", path,
524 strlen("/dev/pts/../../devices/")) == 0)
525 strcpy(path, path + 14);
526
527 return (0);
528 }
529
530 const struct fs_type {
531 vtype_t type;
532 const char *name;
533 } fs_types[] = {
534 { VNON, "NON" },
535 { VREG, "REG" },
536 { VDIR, "DIR" },
537 { VBLK, "BLK" },
538 { VCHR, "CHR" },
539 { VLNK, "LNK" },
540 { VFIFO, "FIFO" },
541 { VDOOR, "DOOR" },
542 { VPROC, "PROC" },
543 { VSOCK, "SOCK" },
544 { VPORT, "PORT" },
545 { VBAD, "BAD" }
546 };
547
548 #define NUM_FS_TYPES (sizeof (fs_types) / sizeof (struct fs_type))
549
550 struct pfiles_cbdata {
551 int opt_p;
930 const char *type;
931 char path[MAXPATHLEN];
932 uintptr_t top_vnodep, realvpp;
933 char fsname[_ST_FSTYPSZ];
934 int err, i;
935
936 cb->fd++;
937
938 if (addr == NULL) {
939 return (WALK_NEXT);
940 }
941
942 top_vnodep = realvpp = (uintptr_t)f->f_vnode;
943
944 if (mdb_vread(&v, sizeof (v), realvpp) == -1) {
945 mdb_warn("failed to read vnode");
946 return (DCMD_ERR);
947 }
948
949 type = "?";
950 for (i = 0; i < NUM_FS_TYPES; i++) {
951 if (fs_types[i].type == v.v_type) {
952 type = fs_types[i].name;
953 break;
954 }
955 }
956
957 do {
958 uintptr_t next_realvpp;
959
960 err = next_realvp(realvpp, &layer_vn, &next_realvpp);
961 if (next_realvpp != NULL)
962 realvpp = next_realvpp;
963
964 } while (err == REALVP_CONTINUE);
965
966 if (err == REALVP_ERR) {
967 mdb_warn("failed to do realvp() for %p", realvpp);
968 return (DCMD_ERR);
969 }
970
971 if (read_fsname((uintptr_t)layer_vn.v_vfsp, fsname) == -1)
972 return (DCMD_ERR);
973
974 mdb_printf("%4d %4s %?0p ", myfd, type, top_vnodep);
|