1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268
|
/*
* dnode.c - Solaris node reading functions for lsof
*/
/*
* Copyright 1994 Purdue Research Foundation, West Lafayette, Indiana
* 47907. All rights reserved.
*
* Written by Victor A. Abell
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. Neither the authors nor Purdue University are responsible for any
* consequences of the use of this software.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Credit to the authors and Purdue
* University must appear in documentation and sources.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 4. This notice may not be removed or altered.
*/
#ifndef lint
static char copyright[] =
"@(#) Copyright 1994 Purdue Research Foundation.\nAll rights reserved.\n";
#endif
#include "common.h"
#if solaris >= 110000
# include <sys/fs/sdev_impl.h>
#endif /* solaris>=110000 */
#undef fs_bsize
#include <sys/fs/ufs_inode.h>
#if solaris >= 110000 && defined(HAS_LIBCTF)
/*
* Sockfs support for Solaris 11 via libctf
*/
/*
* Sockfs internal structure definitions
*
* The structure definitions may look like kernel structures, but they are
* not. They have been defined to have member names that duplicate those
* used by the kernel that are of interest to lsof. Member values are
* obtained via the CTF library, libctf.
*
* Robert Byrnes developed the CTF library access code and contributed it
* to lsof.
*/
struct soaddr { /* sadly, CTF doesn't grok this
* structure */
struct sockaddr *soa_sa; /* address */
t_uscalar_t soa_len; /* length in bytes */
t_uscalar_t soa_maxlen; /* maximum length */
};
typedef struct sotpi_info {
dev_t sti_dev; /* sonode device */
struct soaddr sti_laddr; /* local address */
struct soaddr sti_faddr; /* peer address */
struct so_ux_addr sti_ux_laddr; /* bound local address */
struct so_ux_addr sti_ux_faddr; /* bound peer address */
t_scalar_t sti_serv_type; /* service type */
} sotpi_info_t;
/*
* CTF definitions for sockfs
*/
static int Sockfs_ctfs = 0; /* CTF initialization status for
* sockfs */
# if defined(_LP64)
# define SOCKFS_MOD_FORMAT "/kernel/%s/genunix"
# else /* !defined(_LP64) */
# define SOCKFS_MOD_FORMAT "/kernel/fs/sockfs"
# endif /* defined(_LP64) */
/* sockfs module pathname template to
* which the kernel's instruction type
* set is added for CTF access */
/*
* Sockfs access definitions and structures
*/
# define SOADDR_TYPE_NAME "soaddr"
static CTF_member_t soaddr_members[] = {CTF_MEMBER(soa_sa),
# define MX_soa_sa 0
CTF_MEMBER(soa_len),
# define MX_soa_len 1
CTF_MEMBER(soa_maxlen),
# define MX_soa_maxlen 2
{NULL, 0}};
# define SOTPI_INFO_TYPE_NAME "sotpi_info_t"
static CTF_member_t sotpi_info_members[] = {CTF_MEMBER(sti_dev),
# define MX_sti_dev 0
CTF_MEMBER(sti_laddr),
# define MX_sti_laddr 1
CTF_MEMBER(sti_faddr),
# define MX_sti_faddr 2
CTF_MEMBER(sti_ux_laddr),
# define MX_sti_ux_laddr 3
CTF_MEMBER(sti_ux_faddr),
# define MX_sti_ux_faddr 4
CTF_MEMBER(sti_serv_type),
# define MX_sti_serv_type 5
{NULL, 0}};
/*
* CTF sockfs request table
*/
static CTF_request_t Sockfs_requests[] = {
{SOTPI_INFO_TYPE_NAME, sotpi_info_members}, {NULL, NULL}};
/*
* Sockfs function prototypes
*/
static int read_nsti(struct lsof_context *ctx, struct sonode *so,
sotpi_info_t *stpi);
#endif /* solaris>=110000 && defined(HAS_LIBCTF) */
#if defined(HAS_ZFS) && defined(HAS_LIBCTF)
/*
* ZFS support via libctf
*/
/*
* ZFS internal structure definitions
*
* The structure definitions may look like kernel structures, but they are
* not. They have been defined to have member names that duplicate those
* used by the kernel that are of interest to lsof. Member values are
* obtained via the CTF library, libctf.
*
* Robert Byrnes developed the CTF library access code and contributed it
* to lsof.
*/
typedef struct zfsvfs {
vfs_t *z_vfs; /* pointer to VFS */
} zfsvfs_t;
typedef struct znode_phys {
uint64_t zp_size; /* file size (ZFS below 5) */
uint64_t zp_links; /* links (ZFS below 5) */
} znode_phys_t;
typedef struct znode {
zfsvfs_t *z_zfsvfs; /* pointer to associated vfs */
vnode_t *z_vnode; /* pointer to associated vnode */
uint64_t z_id; /* node ID */
znode_phys_t *z_phys; /* pointer to persistent znode (ZFS
* below 5) */
uint64_t z_links; /* links (ZFS 5 and above) */
uint64_t z_size; /* file size (ZFS 5 and above) */
} znode_t;
/*
* CTF definitions for ZFS
*/
static int ZFS_ctfs = 0; /* CTF initialization status for ZFS */
# if defined(_LP64)
# define ZFS_MOD_FORMAT "/kernel/fs/%s/zfs"
# else /* !defined(_LP64) */
# define ZFS_MOD_FORMAT "/kernel/fs/zfs"
# endif /* defined(_LP64) */
/* ZFS module pathname template to
* which the kernel's instruction type
* set is added for CTF access */
/*
* ZFS access definitions and structures
*/
# define ZNODE_TYPE_NAME "znode_t"
static CTF_member_t znode_members[] = {CTF_MEMBER(z_zfsvfs),
# define MX_z_zfsvfs 0
CTF_MEMBER(z_vnode),
# define MX_z_vnode 1
CTF_MEMBER(z_id),
# define MX_z_id 2
CTF_MEMBER(z_link_node),
# define MX_z_link_node 3
CTF_MEMBER(z_phys),
# define MX_z_phys 4
CTF_MEMBER(z_links),
# define MX_z_links 5
CTF_MEMBER(z_size),
# define MX_z_size 6
{NULL, 0}};
# define ZNODE_PHYS_TYPE_NAME "znode_phys_t"
static CTF_member_t znode_phys_members[] = {CTF_MEMBER(zp_size),
# define MX_zp_size 0
CTF_MEMBER(zp_links),
# define MX_zp_links 1
{NULL, 0}};
# define ZFSVFS_TYPE_NAME "zfsvfs_t"
static CTF_member_t zfsvfs_members[] = {CTF_MEMBER(z_vfs),
# define MX_z_vfs 0
{NULL, 0}};
/*
* CTF ZFS request table
*/
static CTF_request_t ZFS_requests[] = {
{ZNODE_TYPE_NAME, znode_members},
{ZNODE_PHYS_TYPE_NAME, znode_phys_members},
{ZFSVFS_TYPE_NAME, zfsvfs_members},
{NULL, NULL}};
/*
* Missing members exceptions -- i.e., CTF_getmem won't consider it
* an error if any of these members are undefined.
*/
typedef struct CTF_exception {
char *tynm; /* type name */
char *memnm; /* member name */
} CTF_exception_t;
static CTF_exception_t CTF_exceptions[] = {{ZNODE_TYPE_NAME, "z_phys"},
{ZNODE_TYPE_NAME, "z_links"},
{ZNODE_TYPE_NAME, "z_size"},
{NULL, NULL}};
/*
* ZFS function prototypes
*/
static int read_nzn(struct lsof_context *ctx, KA_T na, KA_T nza, znode_t *z);
static int read_nznp(struct lsof_context *ctx, KA_T nza, KA_T nzpa,
znode_phys_t *zp);
static int read_nzvfs(struct lsof_context *ctx, KA_T nza, KA_T nzva,
zfsvfs_t *zv);
#endif /* defined(HAS_ZFS) && defined(HAS_LIBCTF) */
static struct l_dev *finddev(struct lsof_context *ctx, dev_t *dev, dev_t *rdev,
int flags);
/*
* Finddev() "look-in " flags
*/
#define LOOKDEV_TAB 0x01 /* look in device table */
#define LOOKDEV_CLONE 0x02 /* look in Clone table */
#define LOOKDEV_PSEUDO 0x04 /* look in Pseudo table */
#define LOOKDEV_ALL (LOOKDEV_TAB | LOOKDEV_CLONE | LOOKDEV_PSEUDO)
/* look all places */
/*
* SAM-FS definitions
*/
#define SAMFS_NMA_MSG "(limited SAM-FS info)"
/*
* Voptab definitions
*/
typedef struct build_v_optab {
char *dnm; /* drive_NL name */
char *fsys; /* file system type name */
int nty; /* node type index (i.e., N_*) */
} build_v_optab_t;
static build_v_optab_t Build_v_optab[] = {
{"auvops", "autofs", N_AUTO},
{"avops", "afs", N_AFS},
{"afsops", "afs", N_AFS},
{"ctfsadir", NULL, N_CTFSADIR},
{"ctfsbund", NULL, N_CTFSBUND},
{"ctfscdir", NULL, N_CTFSCDIR},
{"ctfsctl", NULL, N_CTFSCTL},
{"ctfsevt", NULL, N_CTFSEVT},
{"ctfslate", NULL, N_CTFSLATE},
{"ctfsroot", NULL, N_CTFSROOT},
{"ctfsstat", NULL, N_CTFSSTAT},
{"ctfssym", NULL, N_CTFSSYM},
{"ctfstdir", NULL, N_CTFSTDIR},
{"ctfstmpl", NULL, N_CTFSTMPL},
#if defined(HASCACHEFS)
{"cvops", NULL, N_CACHE},
#endif /* defined(HASCACHEFS) */
{"devops", "devfs", N_DEV},
{"doorops", NULL, N_DOOR},
{"fdops", "fd", N_FD},
{"fd_ops", "fd", N_FD},
{"fvops", "fifofs", N_FIFO},
{"hvops", "hsfs", N_HSFS},
{"lvops", "lofs", N_LOFS},
{"mntops", "mntfs", N_MNT},
{"mvops", "mvfs", N_MVFS},
{"n3vops", NULL, N_NFS},
#if solaris >= 100000
{"n4vops", NULL, N_NFS4},
#else /* solaris<100000 */
{"n4vops", NULL, N_NFS},
#endif /* solaris>=100000 */
{"nmvops", "namefs", N_NM},
{"nvops", NULL, N_NFS},
{"pdvops", "pcfs", N_PCFS},
{"pfvops", "pcfs", N_PCFS},
{"portvops", NULL, N_PORT},
{"prvops", "proc", N_PROC},
{"sam1vops", NULL, N_SAMFS},
{"sam2vops", NULL, N_SAMFS},
{"sam3vops", NULL, N_SAMFS},
{"sam4vops", NULL, N_SAMFS},
{"sckvops", "sockfs", N_SOCK},
{"devipnetops", "sdevfs", N_SDEV},
{"devnetops", "sdevfs", N_SDEV},
{"devptsops", "sdevfs", N_SDEV},
{"devvtops", "sdevfs", N_SDEV},
{"socketvops", "sockfs", N_SOCK},
{"sdevops", "sdevfs", N_SDEV},
{"shvops", "sharedfs", N_SHARED},
{"sncavops", "sockfs", N_SOCK},
{"stpivops", "sockfs", N_SOCK},
{"spvops", "specfs", N_REGLR},
{"tvops", "tmpfs", N_TMP},
{"uvops", "ufs", N_REGLR},
{"vvfclops", "vxfs", N_VXFS},
{"vvfops", "vxfs", N_VXFS},
{"vvfcops", "vxfs", N_VXFS},
{"vvops", "vxfs", N_VXFS},
{"vvops_p", "vxfs", N_VXFS},
{"zfsdops", "zfs", N_ZFS},
{"zfseops", "zfs", N_ZFS},
{"zfsfops", "zfs", N_ZFS},
{"zfsshops", "zfs", N_ZFS},
{"zfssymops", "zfs", N_ZFS},
{"zfsxdops", "zfs", N_ZFS},
{NULL, NULL, 0} /* table end */
};
typedef struct v_optab {
char *fsys; /* file system type name */
int fx; /* Fsinfo[] index (-1 if none) */
int nty; /* node type index (i.e., N_*) */
KA_T v_op; /* vnodeops address */
struct v_optab *next; /* next entry */
} v_optab_t;
static v_optab_t **FxToVoptab = (v_optab_t **)NULL;
/* table to convert file system index
* to Voptab address[] -- built by
* build_Voptab() */
static v_optab_t **Voptab = (v_optab_t **)NULL;
/* table to convert vnode v_op
* addresses to file system name and
* node type -- built by build_Voptab()
* and addressed through the HASHVOP()
* macro */
#define VOPHASHBINS \
256 /* number of Voptab[] hash bins -- \
* MUST BE A POWER OF TWO! */
/*
* Local function prototypes
*/
static void build_Voptab(struct lsof_context *ctx);
static enum lsof_lock_mode isvlocked(struct lsof_context *ctx,
struct vnode *va);
static int readinode(struct lsof_context *ctx, KA_T ia, struct inode *i);
static void read_mi(struct lsof_context *ctx, KA_T s, dev_t *dev, caddr_t so,
int *so_st, KA_T *so_ad, struct l_dev **sdp);
#if solaris >= 20500
# if solaris >= 20600
static int read_nan(struct lsof_context *ctx, KA_T na, KA_T aa,
struct fnnode *rn);
static int read_nson(struct lsof_context *ctx, KA_T na, KA_T sa,
struct sonode *sn);
static int read_nusa(struct lsof_context *ctx, struct soaddr *so,
struct sockaddr_un *ua);
# else /* solaris<20600 */
static int read_nan(struct lsof_context *ctx, KA_T na, KA_T aa,
struct autonode *a);
# endif /* solaris>=20600 */
static int idoorkeep(struct lsof_context *ctx, struct door_node *d);
static int read_ndn(struct lsof_context *ctx, KA_T na, KA_T da,
struct door_node *d);
#endif /* solaris>=20500 */
#if solaris >= 110000
static int read_nsdn(struct lsof_context *ctx, KA_T na, KA_T sa,
struct sdev_node *sdn, struct vattr *sdva);
#endif /* solaris>=110000 */
static int read_nfn(struct lsof_context *ctx, KA_T na, KA_T fa,
struct fifonode *f);
static int read_nhn(struct lsof_context *ctx, KA_T na, KA_T ha,
struct hsnode *h);
static int read_nin(struct lsof_context *ctx, KA_T na, KA_T ia,
struct inode *i);
static int read_nmn(struct lsof_context *ctx, KA_T na, KA_T ia,
struct mvfsnode *m);
static int read_npn(struct lsof_context *ctx, KA_T na, KA_T pa,
struct pcnode *p);
static int read_nrn(struct lsof_context *ctx, KA_T na, KA_T ra,
struct rnode *r);
#if solaris >= 100000
static int read_nctfsn(struct lsof_context *ctx, int ty, KA_T na, KA_T ca,
char *cn);
static int read_nprtn(struct lsof_context *ctx, KA_T na, KA_T ra, port_t *p);
static int read_nrn4(struct lsof_context *ctx, KA_T na, KA_T ra,
struct rnode4 *r);
#endif /* solaris>=100000 */
static int read_nsn(struct lsof_context *ctx, KA_T na, KA_T sa,
struct snode *s);
static int read_ntn(struct lsof_context *ctx, KA_T na, KA_T ta,
struct tmpnode *t);
static int read_nvn(struct lsof_context *ctx, KA_T na, KA_T va,
struct vnode *v);
#if defined(HASPROCFS)
static int read_npi(struct lsof_context *ctx, KA_T na, struct vnode *v,
struct pid *pids);
#endif /* defined(HASPROCFS) */
static char *ent_fa(KA_T *a1, KA_T *a2, char *d, int *len);
static int is_socket(struct lsof_context *ctx, struct vnode *v);
static int read_cni(struct lsof_context *ctx, struct snode *s, struct vnode *rv,
struct vnode *v, struct snode *rs, struct dev_info *di,
char *din, int dinl);
#if defined(HASCACHEFS)
static int read_ncn(struct lsof_context *ctx, KA_T na, KA_T ca,
struct cnode *cn);
#endif /* defined(HASCACHEFS) */
static int read_nln(struct lsof_context *ctx, KA_T na, KA_T la,
struct lnode *ln);
static int read_nnn(struct lsof_context *ctx, KA_T na, KA_T nna,
struct namenode *n);
#if solaris < 100000
static void savesockmod(struct so_so *so, struct so_so *sop, int *so_st);
#else /* solaris>=100000 */
static int read_ndvn(struct lsof_context *ctx, KA_T na, KA_T da,
struct dv_node *dv, dev_t *dev, unsigned char *devs);
#endif /* solaris<100000 */
/*
* Local static values
*/
static KA_T Spvops = (KA_T)0; /* specfs vnodeops address -- saved
* by build_Voptab() */
static KA_T Vvops[VXVOP_NUM]; /* addresses of:
* vx_fcl_dnodeops_p (VXVOP_FCL)
* fdd_vnops (VXVOP_FDD)
* fdd_chain_vnops (VXVOP_FDDCH),
* vx_vnodeops (VXVOP_REG)
* vx_vnodeops_p (VXVOP_REG_P)
* -- saved by build_Voptab() */
/*
* Local macros
*
* GETVOPS() -- get direct or indirect *vnodeops address
*
* HASHVOP() -- hash the vnode's v_op address
*/
#if defined(VOPNAME_OPEN) && solaris >= 100000
# define GETVOPS(name, nl, ops) \
if (get_Nl_value(ctx, name, nl, &ops) < 0) \
ops = (KA_T)0; \
else if (kread(ctx, ops, (char *)&ops, sizeof(ops))) \
ops = (KA_T)0
#else /* !defined(VOPNAME_OPEN) || solaris<100000 */
# define GETVOPS(name, nl, ops) \
if (get_Nl_value(ctx, name, nl, &ops) < 0) \
ops = (KA_T)0
#endif /* defined(VOPNAME_OPEN) && solaris>=100000 */
#define HASHVOP(ka) \
((int)((((ka & 0x1fffffff) * 31415) >> 3) & (VOPHASHBINS - 1)))
/*
* build_Voptab() -- build Voptab[]
*/
static void build_Voptab(struct lsof_context *ctx) {
build_v_optab_t *bp; /* Build_v_optab[] pointer */
int fx; /* temporary file system type index */
int h; /* hash index */
int i, j; /* temporary indexes */
KA_T ka; /* temporary kernel address */
v_optab_t *nv, *vp, *vpp; /* Voptab[] working pointers */
int vv = 0; /* number of Vvops[] addresses that
* have been located */
/*
* If Voptab[] is allocated, return; otherwise allocate space for Voptab[]
* and FxToVoptab[] amd fill them.
*/
if (Voptab)
return;
/*
* During first call, allocate space for Voptab[] and FxToVoptab[].
*/
if (!(Voptab =
(v_optab_t **)calloc((MALLOC_S)VOPHASHBINS, sizeof(v_optab_t)))) {
(void)fprintf(stderr, "%s: no space for Voptab\n", Pn);
Error(ctx);
}
if (!(FxToVoptab =
(v_optab_t **)calloc((MALLOC_S)Fsinfomax, sizeof(v_optab_t *)))) {
(void)fprintf(stderr, "%s: no space for FxToVoptab\n", Pn);
Error(ctx);
}
for (i = 0; i < VXVOP_NUM; i++) {
Vvops[i] = (KA_T)NULL;
}
/*
* Use Build_v_optab[] to build Voptab[].
*/
for (bp = Build_v_optab; bp->dnm; bp++) {
/*
* Get the kernel address for the symbol. Do nothing if it can't
* be determined.
*/
GETVOPS(bp->dnm, Drive_Nl, ka);
if (!ka)
continue;
/*
* Check the Voptab[] for the address.
*/
h = HASHVOP(ka);
for (vp = Voptab[h], vpp = (v_optab_t *)NULL; vp; vp = vp->next) {
if (vp->v_op == ka)
break;
vpp = vp;
}
if (vp) {
/*
* Ignore duplicates.
*/
continue;
}
/*
* No Voptab[] entry was found, so allocate space for a new
* v_optab_t structure, determine its file system type index,
* fill it and link it to the Voptab[].
*/
if (!(nv = (v_optab_t *)malloc((MALLOC_S)sizeof(v_optab_t)))) {
(void)fprintf(stderr, "%s: out of Voptab space at: %s\n", Pn,
bp->dnm);
Error(ctx);
}
nv->fsys = bp->fsys;
nv->fx = -1;
nv->nty = bp->nty;
nv->next = (v_optab_t *)NULL;
nv->v_op = ka;
if (bp->fsys) {
for (i = 0; i < Fsinfomax; i++) {
if (!strcmp(bp->fsys, Fsinfo[i])) {
nv->fx = i;
break;
}
}
}
if (!Voptab[h])
Voptab[h] = nv;
else
vpp->next = nv;
/*
* Handle special v_op addresses:
*
* special vnode ops;
* VxFS ops.
*/
if (!Spvops) {
if (!strcmp(bp->dnm, "spvops"))
Spvops = ka;
}
for (i = 0; (i < VXVOP_NUM) && (vv < VXVOP_NUM); i++) {
if (Vvops[i])
continue;
switch (i) {
case VXVOP_FCL:
if (!strcmp(bp->dnm, "vvfclops")) {
Vvops[i] = ka;
vv++;
}
break;
case VXVOP_FDD:
if (!strcmp(bp->dnm, "vvfops")) {
Vvops[i] = ka;
vv++;
}
break;
case VXVOP_FDDCH:
if (!strcmp(bp->dnm, "vvfcops")) {
Vvops[i] = ka;
vv++;
}
break;
case VXVOP_REG:
if (!strcmp(bp->dnm, "vvops")) {
Vvops[i] = ka;
vv++;
}
break;
case VXVOP_REG_P:
if (!strcmp(bp->dnm, "vvops_p")) {
Vvops[i] = ka;
vv++;
}
break;
}
}
}
/*
* Link Voptab[] entries to FxToVoptab[] entries.
*/
for (h = 0; h < VOPHASHBINS; h++) {
for (vp = Voptab[h]; vp; vp = vp->next) {
if (!vp->fsys)
continue;
if (((fx = vp->fx) >= 0) && (fx < Fsinfomax)) {
if (!FxToVoptab[fx])
FxToVoptab[fx] = vp;
continue;
}
for (i = 0; i < Fsinfomax; i++) {
if (!strcmp(Fsinfo[i], vp->fsys)) {
vp->fx = i;
if (!FxToVoptab[i])
FxToVoptab[i] = vp;
break;
}
}
}
}
}
#if defined(HAS_LIBCTF)
/*
* CTF_getmem() -- get CTF members
*/
int CTF_getmem(struct lsof_context *ctx, /* context*/
ctf_file_t *f, /* CTF file handle */
const char *mod, /* module name */
const char *ty, /* type */
CTF_member_t *mem) /* member table */
{
int err; /* error flag */
ctf_id_t id; /* CTF ID */
CTF_member_t *mp; /* member pointer */
CTF_exception_t *xp; /* exception table pointer */
int xs; /* exception status */
/*
* Look up the type.
*/
if ((id = ctf_lookup_by_name(f, ty)) == CTF_ERR) {
(void)fprintf(stderr, "%s: ctf_lookup_by_name: %s: %s: %s\n", Pn, mod,
ty, ctf_errmsg(ctf_errno(f)));
return (1);
}
/*
* Get member offsets.
*/
if (ctf_member_iter(f, id, CTF_memCB, mem) == CTF_ERR) {
(void)fprintf(stderr, "%s: ctf_member_iter: %s: %s: %s\n", Pn, mod, ty,
ctf_errmsg(ctf_errno(f)));
return (1);
}
/*
* Examine members.
*/
for (err = 0, mp = mem; mp->m_name; mp++) {
if (mp->m_offset == CTF_MEMBER_UNDEF) {
/*
* Check for an undefined member exception. Report an error if
* no exception is found.
*/
for (xp = CTF_exceptions, xs = 0; xp->tynm; xp++) {
if (!strcmp(xp->tynm, ty) && !strcmp(xp->memnm, mp->m_name)) {
xs = 1;
break;
}
}
if (!xs) {
(void)fprintf(
stderr,
"%s: getmembers: %s: %s: %s: struct member undefined\n", Pn,
mod, ty, mp->m_name);
err = 1;
}
} else {
/*
* Convert bit offsets to byte offsets.
*/
if ((mp->m_offset % NBBY) != 0) {
(void)fprintf(
stderr,
"%s: getmembers: %s: %s: %s: struct member is bit field\n",
Pn, mod, ty, mp->m_name);
err = 1;
} else
mp->m_offset /= NBBY;
}
}
return (err);
}
/*
* CTF_init - initialize CTF library access
*/
void CTF_init(struct lsof_context *ctx, /* context */
int *i, /* initialization status */
char *t, /* kernel module template */
CTF_request_t *r) /* CTF requests */
{
int err; /* error status */
ctf_file_t *f; /* CTF file info handle */
# if defined(_LP64)
static char isa[256 + 1]; /* kernel instruction set name */
static int isas = 0; /* isa[] status */
# endif /* defined(_LP64) */
char kernmod[MAXPATHLEN]; /* kernel module pathname */
char *kmp; /* kernel module path name pointer */
static char pfn[256 + 1]; /* system platform name */
static int pfns = 0; /* pfn[] status: -1 = request failed
* 0 = none requested
* >0 = available */
char pfxkernmod[MAXPATHLEN]; /* prefixed kernel module name */
struct stat sb; /* stat(2) buffer */
if (*i)
return;
# if defined(_LP64)
/*
* If CTF access hasn't been initialized and a 64 bit kernel is in use,
* determine the name of the kernel's instruction set, and construct the
* pathname of the kernel module, using the supplied template.
*/
if (!isas) {
if (sysinfo(SI_ARCHITECTURE_K, isa, sizeof(isa) - 1) == -1) {
(void)fprintf(stderr, "%s: sysinfo: %s\n", Pn, strerror(errno));
Error(ctx);
}
isas = 1;
isa[sizeof(isa) - 1] = '\0';
}
(void)snprintf(kernmod, sizeof(kernmod) - 1, t, isa);
kernmod[sizeof(kernmod) - 1] = '\0';
# else /* !defined(_LP64) */
/*
* If CTF access hasn't been initialized and a 32 bit kernel is in use, the
* supplied template is the module path name.
*/
(void)strncpy(kernmod, t, sizeof(kernmod) - 1);
# endif /* defined(_LP64) */
kernmod[sizeof(kernmod) - 1] = '\0';
kmp = kernmod;
if (statsafely(ctx, kmp, &sb)) {
/*
* The module at the specified path does not exist or is inaccessible.
*
* Get the platform name and construct a prefix from it for module path
* name and see if that exists and is accessible.
*
* If it is, let CTF_init() use it; otherwise let CTF_init() fail on
* the specified path.
*/
if (pfns >= 0) {
if (!pfns)
pfns = sysinfo(SI_MACHINE, pfn, sizeof(pfn) - 1);
if (pfns > 0) {
pfn[sizeof(pfn) - 1] = '\0';
(void)snprintf(pfxkernmod, sizeof(pfxkernmod) - 1,
"/platform/%s/%s", pfn,
(kernmod[0] == '/') ? &kernmod[1] : kernmod);
pfxkernmod[sizeof(pfxkernmod) - 1] = '\0';
if (!stat(pfxkernmod, &sb))
kmp = pfxkernmod;
}
}
}
/*
* Open the module file and read its CTF info.
*/
if ((f = ctf_open(kmp, &err)) == NULL) {
(void)fprintf(stderr, "%s: ctf_open: %s: %s\n", Pn, kmp,
ctf_errmsg(err));
Error(ctx);
}
for (err = 0; r->name; r++) {
if (CTF_getmem(ctx, f, kmp, r->name, r->mem))
err = 1;
}
(void)ctf_close(f);
if (err)
Error(ctx);
*i = 1;
}
/*
* CTF_memCB() - Callback function for ctf_member_iter()
*/
int CTF_memCB(const char *name, /* structure member name */
ctf_id_t id, /* CTF ID */
ulong_t offset, /* member offset */
void *arg) /* member table */
{
CTF_member_t *mp;
/*
* Check for members of interest and record their offsets.
*/
for (mp = (CTF_member_t *)arg; mp->m_name; mp++) {
if (!strcmp(name, mp->m_name)) {
mp->m_offset = offset;
break;
}
}
return (0);
}
#endif /* defined(HAS_LIBCTF) */
/*
* ent_fa() - enter fattach addresses in NAME column addition
*/
static char *ent_fa(KA_T *a1, /* first fattach address (NULL OK) */
KA_T *a2, /* second fattach address */
char *d, /* direction ("->" or "<-") */
int *len) /* returned description length */
{
static char buf[1024];
size_t bufl = sizeof(buf);
char tbuf[32];
/*
* Form the fattach description.
*/
if (!a1)
#if solaris < 20600
(void)snpf(buf, bufl, "(FA:%s%s)", d, print_kptr(*a2, (char *)NULL, 0));
#else /* solaris>=20600 */
(void)snpf(buf, bufl, "(FA:%s%s)", d, print_kptr(*a2, (char *)NULL, 0));
#endif /* solaris<20600 */
else
#if solaris < 20600
(void)snpf(buf, bufl, "(FA:%s%s%s)",
print_kptr(*a1, tbuf, sizeof(tbuf)), d,
print_kptr(*a2, (char *)NULL, 0));
#else /* solaris>=20600 */
(void)snpf(buf, bufl, "(FA:%s%s%s)",
print_kptr(*a1, tbuf, sizeof(tbuf)), d,
print_kptr(*a2, (char *)NULL, 0));
#endif /* solaris<20600 */
*len = (int)strlen(buf);
return (buf);
}
/*
* is_socket() - is the stream a socket?
*/
static int is_socket(struct lsof_context *ctx, /* context */
struct vnode *v) /* vnode pointer */
{
char *cp, *ep, *pf;
int i, j, len, n, pfl;
major_t maj;
minor_t min;
static struct tcpudp {
int ds;
major_t maj;
minor_t min;
char *proto;
} tcpudp[] = {
{0, 0, 0, "tcp"},
{0, 0, 0, "udp"},
#if defined(HASIPv6)
{0, 0, 0, "tcp6"},
{0, 0, 0, "udp6"},
#endif /* defined(HASIPv6) */
};
#define NTCPUDP (sizeof(tcpudp) / sizeof(struct tcpudp))
static int tcpudps = 0;
if (!v->v_stream)
return (0);
maj = (major_t)GET_MAJ_DEV(v->v_rdev);
min = (minor_t)GET_MIN_DEV(v->v_rdev);
/*
* Fill in tcpudp[], as required.
*/
if (!tcpudps) {
#if solaris < 80000
pf = "/devices/pseudo/clone";
#else /* solaris>=80000 */
pf = "/devices/pseudo/";
#endif /* solaris<80000 */
for (i = n = 0, pfl = (int)strlen(pf); (i < Ndev) && (n < NTCPUDP);
i++) {
if (strncmp(Devtp[i].name, pf, pfl) ||
!(ep = strrchr((cp = &Devtp[i].name[pfl]), ':')) ||
(strncmp(++ep, "tcp", 3) && strncmp(ep, "udp", 3)))
continue;
#if solaris < 80000
if (*(ep + 3))
#else /* solaris>=80000 */
len = (*(ep + 3) == '6') ? 4 : 3;
if (*(ep + len) || ((cp + len) >= ep) || strncmp(cp, ep, len))
#endif /* solaris<80000 */
continue;
for (j = 0; j < NTCPUDP; j++) {
if (!tcpudp[j].ds && !strcmp(ep, tcpudp[j].proto)) {
tcpudp[j].ds = 1;
tcpudp[j].maj = (major_t)GET_MAJ_DEV(Devtp[i].rdev);
tcpudp[j].min = (minor_t)GET_MIN_DEV(Devtp[i].rdev);
n++;
break;
}
}
}
tcpudps = n ? 1 : -1;
}
/*
* Check for known IPv[46] TCP or UDP device.
*/
for (i = 0; (i < NTCPUDP) && (tcpudps > 0); i++) {
if (tcpudp[i].ds
#if solaris < 80000
&& (maj == tcpudp[i].min)
#else /* solaris>=80000 */
&& (maj == tcpudp[i].maj)
#endif /* solaris<80000 */
) {
process_socket(ctx, (KA_T)v->v_stream, tcpudp[i].proto);
return (1);
}
}
return (0);
}
/*
* isvlocked() - is Solaris vnode locked?
*/
static enum lsof_lock_mode isvlocked(struct lsof_context *ctx, /* context */
struct vnode *va) /* local vnode address */
{
#if solaris < 20500
struct filock f;
KA_T ff;
KA_T fp;
#endif /* solaris<20500 */
int i, l;
#if solaris >= 20300
struct lock_descriptor ld;
KA_T lf;
KA_T lp;
# if solaris < 20500
# define LOCK_END ld.info.li_sleep.sli_flock.l_len
# define LOCK_FLAGS ld.flags
# define LOCK_NEXT ld.next
# define LOCK_OWNER ld.owner.pid
# define LOCK_START ld.start
# define LOCK_TYPE ld.type
# else /* solaris>=20500 */
# define LOCK_END ld.l_flock.l_len
# define LOCK_FLAGS ld.l_state
# define LOCK_NEXT ld.l_next
# define LOCK_OWNER ld.l_flock.l_pid
# define LOCK_START ld.l_start
# define LOCK_TYPE ld.l_type
# endif /* solaris<20500 */
#endif /* solaris>=20300 */
if (va->v_filocks == NULL)
return LSOF_LOCK_NONE;
#if solaris < 20500
# if solaris > 20300 || \
(solaris == 20300 && defined(P101318) && P101318 >= 45)
if (Ntype == N_NFS)
# endif /* solaris>20300 || (solaris==20300 && defined(P101318) && \
P101318>=45) */
{
ff = fp = (KA_T)va->v_filocks;
i = 0;
do {
if (kread(ctx, fp, (char *)&f, sizeof(f)))
return LSOF_LOCK_NONE;
i++;
if (f.set.l_pid != (pid_t)Lp->pid)
continue;
if (f.set.l_whence == 0 && f.set.l_start == 0 &&
f.set.l_len == MAXEND)
l = 1;
else
l = 0;
switch (f.set.l_type & (F_RDLCK | F_WRLCK)) {
case F_RDLCK:
return l ? LSOF_LOCK_READ_FULL : LSOF_LOCK_READ_PARTIAL;
case F_WRLCK:
return l ? LSOF_LOCK_WRITE_FULL : LSOF_LOCK_WRITE_PARTIAL;
case F_RDLCK | F_WRLCK:
return LSOF_LOCK_READ_WRITE;
default:
return LSOF_LOCK_SOLARIS_NFS;
}
} while ((fp = (KA_T)f.next) && (fp != ff) && (i < 10000));
}
#endif /* solaris<20500 */
#if solaris >= 20300
lf = lp = (KA_T)va->v_filocks;
i = 0;
do {
if (kread(ctx, lp, (char *)&ld, sizeof(ld)))
return LSOF_LOCK_NONE;
i++;
if (!(LOCK_FLAGS & ACTIVE_LOCK) || LOCK_OWNER != (pid_t)Lp->pid)
continue;
if (LOCK_START == 0 && (LOCK_END == 0
# if solaris < 20500
|| LOCK_END == MAXEND
# else /* solaris>=20500 */
|| LOCK_END == MAXEND
# endif /* solaris<20500 */
))
l = 1;
else
l = 0;
switch (LOCK_TYPE) {
case F_RDLCK:
return l ? LSOF_LOCK_READ_FULL : LSOF_LOCK_READ_PARTIAL;
case F_WRLCK:
return l ? LSOF_LOCK_WRITE_FULL : LSOF_LOCK_WRITE_PARTIAL;
case (F_RDLCK | F_WRLCK):
return LSOF_LOCK_READ_WRITE;
default:
/* It was 'L' since 1997, dunno what is it */
return LSOF_LOCK_UNKNOWN;
}
} while ((lp = (KA_T)LOCK_NEXT) && (lp != lf) && (i < 10000));
return LSOF_LOCK_NONE;
#endif /* solaris>=20300 */
}
/*
* finddev() - look up device by device number
*/
static struct l_dev *finddev(struct lsof_context *ctx, /* context */
dev_t *dev, /* device */
dev_t *rdev, /* raw device */
int flags) /* look flags -- see LOOKDEV_* symbol
* definitions */
{
struct clone *c;
struct l_dev *dp;
struct pseudo *p;
if (!Sdev)
readdev(ctx, 0);
/*
* Search device table for match.
*/
#if defined(HASDCACHE)
finddev_again:
#endif /* defined(HASDCACHE) */
if (flags & LOOKDEV_TAB) {
if ((dp = lkupdev(ctx, dev, rdev, 0, 0)))
return (dp);
}
/*
* Search for clone.
*/
if ((flags & LOOKDEV_CLONE) && Clone) {
for (c = Clone; c; c = c->next) {
if (GET_MAJ_DEV(*rdev) == GET_MIN_DEV(c->cd.rdev)) {
#if defined(HASDCACHE)
if (DCunsafe && !c->cd.v && !vfy_dev(ctx, &c->cd))
goto finddev_again;
#endif /* defined(HASDCACHE) */
return (&c->cd);
}
}
}
/*
* Search for pseudo device match on major device only.
*/
if ((flags & LOOKDEV_PSEUDO) && Pseudo) {
for (p = Pseudo; p; p = p->next) {
if (GET_MAJ_DEV(*rdev) == GET_MAJ_DEV(p->pd.rdev)) {
#if defined(HASDCACHE)
if (DCunsafe && !p->pd.v && !vfy_dev(ctx, &p->pd))
goto finddev_again;
#endif /* defined(HASDCACHE) */
return (&p->pd);
}
}
}
return ((struct l_dev *)NULL);
}
#if solaris >= 20500
/*
* idoorkeep() -- identify door keeper process
*/
static int idoorkeep(struct lsof_context *ctx, /* context */
struct door_node *d) /* door's node */
{
char buf[1024];
size_t bufl = sizeof(buf);
struct proc dp;
struct pid dpid;
/*
* Get the proc structure and its pid structure for the door target.
*/
if (!d->door_target ||
kread(ctx, (KA_T)d->door_target, (char *)&dp, sizeof(dp)))
return (0);
if (!dp.p_pidp || kread(ctx, (KA_T)dp.p_pidp, (char *)&dpid, sizeof(dpid)))
return (0);
/*
* Form a description of the door.
*
* Put the description in the NAME column addition field. If there's
* already something there, allocate more space and add the door description
* to it.
*/
if (Lp->pid == (int)dpid.pid_id)
(void)snpf(buf, bufl, "(this PID's door)");
else {
(void)snpf(buf, bufl, "(door to %.64s[%ld])", dp.p_user.u_comm,
(long)dpid.pid_id);
}
(void)add_nma(ctx, buf, (int)strlen(buf));
return (1);
}
#endif /* solaris>=20500 */
/*
* process_node() - process vnode
*/
void process_node(struct lsof_context *ctx, /* context */
KA_T va) /* vnode kernel space address */
{
#if defined(HASCACHEFS)
struct cnode cn;
#endif /* defined(HASCACHEFS) */
dev_t dev, rdev, trdev;
unsigned char devs = 0;
unsigned char fxs = 0;
unsigned char ins = 0;
unsigned char kvs = 0;
unsigned char nns = 0;
unsigned char pnl = 0;
unsigned char rdevs = 0;
unsigned char rvs = 0;
unsigned char rfxs = 0;
unsigned char sdns = 0;
unsigned char tdef;
unsigned char trdevs = 0;
unsigned char unix_sock = 0;
struct dev_info di;
char din[DINAMEL];
char *ep;
struct fifonode f;
char *fa = (char *)NULL;
int fal;
static int ft = 1;
struct vnode fv, rv;
int fx, rfx;
struct hsnode h;
struct inode i;
int j;
KA_T ka, vka;
struct lnode lo;
struct vfs kv, rkv;
int len, llc, nl, snl, sepl;
struct mvfsnode m;
struct namenode nn;
struct l_vfs *nvfs, *vfs;
struct pcnode pc;
struct pcfs pcfs;
struct rnode r;
KA_T realvp = (KA_T)NULL;
struct snode rs;
struct snode s;
char fd[FDLEN];
#if solaris >= 110000
char *nm, *sep;
size_t nmrl, tl;
struct sdev_node sdn;
struct vattr sdva;
sotpi_info_t sti;
int stis = 0;
#endif /* solaris>=110000 */
struct l_dev *sdp = (struct l_dev *)NULL;
size_t sz;
struct tmpnode t;
char tbuf[128], *ty, ubuf[128];
int tbufx;
enum vtype type;
struct sockaddr_un ua;
static struct vnode *v = (struct vnode *)NULL;
KA_T vs;
int vty = 0;
int vty_tmp;
#if solaris >= 20500
# if solaris >= 20600
struct fnnode fnn;
struct pairaddr {
short f;
unsigned short p;
} * pa;
KA_T peer;
struct sonode so;
KA_T soa, sona;
# else /* solaris<20600 */
struct autonode au;
# endif /* solaris>=20600 */
struct door_node dn;
int dns = 0;
#endif /* solaris >=20500 */
#if solaris < 100000
KA_T so_ad[2];
struct so_so soso;
int so_st = 0;
#else /* solaris>=100000 */
union {
ctfs_adirnode_t adir;
ctfs_bunode_t bun;
ctfs_cdirnode_t cdir;
ctfs_ctlnode_t ctl;
ctfs_evnode_t ev;
ctfs_latenode_t late;
ctfs_rootnode_t root;
ctfs_symnode_t sym;
ctfs_tdirnode_t tdir;
ctfs_tmplnode_t tmpl;
} ctfs;
dev_t dv_dev;
struct dv_node dv;
unsigned char dv_devs = 0;
unsigned char dvs = 0;
port_t pn;
struct rnode4 r4;
#endif /* solaris<100000 */
#if defined(HASPROCFS)
struct procfsid *pfi;
struct pid pids;
#endif /* defined(HASPROCFS) */
#if defined(HAS_AFS)
struct afsnode an;
#endif /* defined(HAS_AFS) */
#if defined(HASVXFS)
struct l_ino vx;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
vfs_t zgvfs;
unsigned char zns = 0;
znode_t zn;
zfsvfs_t zvfs;
#endif /* defined(HAS_ZFS) */
/*
* Do first-time only operations.
*/
#if solaris < 100000
so_ad[0] = so_ad[1] = (KA_T)0;
#endif /* solaris<100000 */
if (ft) {
(void)build_Voptab(ctx);
ft = 0;
}
/*
* Read the vnode.
*/
if (!va) {
enter_nm(ctx, "no vnode address");
return;
}
if (!v) {
/*
* Allocate space for the vnode or AFS vcache structure.
*/
#if defined(HAS_AFS)
v = alloc_vcache();
#else /* !defined(HAS_AFS) */
v = (struct vnode *)malloc(sizeof(struct vnode));
#endif /* defined(HAS_AFS) */
if (!v) {
(void)fprintf(stderr, "%s: can't allocate %s space\n", Pn,
#if defined(HAS_AFS)
"vcache"
#else /* !defined(HAS_AFS) */
"vnode"
#endif /* defined(HAS_AFS) */
);
Error(ctx);
}
}
if (readvnode(ctx, va, v)) {
enter_nm(ctx, Namech);
return;
}
#if defined(HASNCACHE)
Lf->na = va;
#endif /* defined(HASNCACHE) */
#if defined(HASFSTRUCT)
Lf->fna = va;
Lf->fsv |= FSV_NI;
#endif /* defined(HASFSTRUCT) */
#if defined(HASLFILEADD) && defined(HAS_V_PATH)
Lf->V_path = (KA_T)v->v_path;
#endif /* defined(HASLFILEADD) && defined(HAS_V_PATH) */
vs = (KA_T)v->v_stream;
/*
* Check for a Solaris socket.
*/
if (is_socket(ctx, v))
return;
/*
* Obtain the Solaris virtual file system structure.
*/
if ((ka = (KA_T)v->v_vfsp)) {
if (kread(ctx, ka, (char *)&kv, sizeof(kv))) {
vka = va;
vfs_read_error:
(void)snpf(Namech, Namechl - 1, "vnode at %s: can't read vfs: %s",
print_kptr(vka, tbuf, sizeof(tbuf)),
print_kptr(ka, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return;
}
kvs = 1;
} else
kvs = 0;
/*
* Derive the virtual file system structure's device number from
* its file system ID for NFS and High Sierra file systems.
*/
if (kvs && ((fx = kv.vfs_fstype - 1) >= 0) && (fx < Fsinfomax)) {
fxs = 1;
if (strcmp(Fsinfo[fx], "nfs") == 0 || strcmp(Fsinfo[fx], "nfs3") == 0 ||
strcmp(Fsinfo[fx], "hsfs") == 0)
kv.vfs_dev = (dev_t)kv.vfs_fsid.val[0];
} else {
fx = -1;
fxs = 0;
}
/*
* Determine the Solaris vnode type.
*/
if ((Ntype = vop2ty(ctx, v, fx)) < 0) {
if (v->v_type == VFIFO) {
vty = N_REGLR;
Ntype = N_FIFO;
} else if (vs) {
Ntype = vty = N_STREAM;
Lf->is_stream = 1;
}
if (Ntype < 0) {
(void)snpf(Namech, Namechl - 1,
"unknown file system type%s%s%s, v_op: %s",
fxs ? " (" : "", fxs ? Fsinfo[fx] : "", fxs ? ")" : "",
print_kptr((KA_T)v->v_op, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return;
}
} else {
vty = Ntype;
if (v->v_type == VFIFO)
Ntype = N_FIFO;
else if (vs && Ntype != N_SOCK) {
Ntype = vty = N_STREAM;
Lf->is_stream = 1;
}
}
/*
* See if this Solaris node has been fattach'ed to another node.
* If it has, read the namenode, and enter the node addresses in
* the NAME column addition.
*
* See if it's covering a socket as well and process accordingly.
*/
if (vty == N_NM) {
if (read_nnn(ctx, va, (KA_T)v->v_data, &nn))
return;
nns = 1;
if (nn.nm_mountpt)
#if solaris >= 20500
fa = ent_fa(
(KA_T *)((Ntype == N_FIFO || v->v_type == VDOOR) ? NULL : &va),
(KA_T *)&nn.nm_mountpt, "->", &fal);
#else /* solaris<20500 */
fa = ent_fa((KA_T *)((Ntype == N_FIFO) ? NULL : &va),
(KA_T *)&nn.nm_mountpt, "->", &fal);
#endif /* solaris>=20500 */
if (Ntype != N_FIFO && nn.nm_filevp &&
!kread(ctx, (KA_T)nn.nm_filevp, (char *)&rv, sizeof(rv))) {
rvs = 1;
if ((ka = (KA_T)rv.v_vfsp) &&
!kread(ctx, ka, (char *)&rkv, sizeof(rkv)) &&
((rfx = rkv.vfs_fstype - 1) >= 0) && (rfx < Fsinfomax)) {
rfxs = 1;
} else {
rfx = fx;
rfxs = fxs;
}
#if defined(HASNCACHE)
Lf->na = (KA_T)nn.nm_filevp;
#endif /* defined(HASNCACHE) */
if (is_socket(ctx, &rv))
return;
}
}
if (Selinet && Ntype != N_SOCK)
return;
/*
* See if this Solaris node is served by spec_vnodeops.
*/
if (Spvops && Spvops == (KA_T)v->v_op)
Ntype = N_SPEC;
/*
* Determine the Solaris lock state.
*/
Lf->lock = isvlocked(ctx, v);
/*
* Establish the Solaris local virtual file system structure.
*/
if (!(ka = (KA_T)v->v_vfsp) || !kvs)
vfs = (struct l_vfs *)NULL;
else if (!(vfs = readvfs(ctx, ka, &kv, v))) {
vka = va;
goto vfs_read_error;
}
/*
* Read the afsnode, autonode, cnode, door_node, fifonode, fnnode, lnode,
* inode, pcnode, rnode, snode, tmpnode, znode, etc.
*/
switch (Ntype) {
case N_SPEC:
/*
* A N_SPEC node is a node that resides in in an underlying file system
* type -- e.g. NFS, HSFS. Its vnode points to an snode. Subsequent
* node structures are implied by the underlying node type.
*/
if (read_nsn(ctx, va, (KA_T)v->v_data, &s))
return;
realvp = (KA_T)s.s_realvp;
if (!realvp && s.s_commonvp) {
if (read_cni(ctx, &s, &rv, v, &rs, &di, din, sizeof(din)) == 1)
return;
if (!rv.v_stream) {
if (din[0]) {
(void)snpf(Namech, Namechl, "COMMON: %s", din);
Namech[Namechl - 1] = '\0';
Lf->is_com = 1;
}
break;
}
}
if (!realvp) {
/*
* If the snode lacks a real vnode (and also lacks a common vnode),
* it's original type is N_STREAM or N_REGLR, and it has a stream
* pointer, get the module names.
*/
if ((vty == N_STREAM || vty == N_REGLR) && vs) {
Lf->is_stream = 1;
vty = N_STREAM;
#if solaris < 100000
read_mi(ctx, vs, (dev_t *)&s.s_dev, (caddr_t)&soso, &so_st,
so_ad, &sdp);
#else /* solaris>=100000 */
read_mi(ctx, vs, (dev_t *)&s.s_dev, NULL, NULL, NULL, &sdp);
#endif /* solaris<100000 */
vs = (KA_T)NULL;
}
}
break;
#if defined(HAS_AFS)
case N_AFS:
if (readafsnode(ctx, va, v, &an))
return;
break;
#endif /* defined(HAS_AFS) */
#if solaris >= 20500
case N_AUTO:
# if solaris < 20600
if (read_nan(ctx, va, (KA_T)v->v_data, &au))
# else /* solaris>=20600 */
if (read_nan(ctx, va, (KA_T)v->v_data, &fnn))
# endif /* solaris<20600 */
return;
break;
# if solaris >= 100000
case N_DEV:
if (read_ndvn(ctx, va, (KA_T)v->v_data, &dv, &dv_dev, &dv_devs))
return;
dvs = 1;
break;
# endif /* solaris>=100000 */
case N_DOOR:
if (read_ndn(ctx, va, (KA_T)v->v_data, &dn))
return;
dns = 1;
break;
#endif /* solaris>=20500 */
#if defined(HASCACHEFS)
case N_CACHE:
if (read_ncn(ctx, va, (KA_T)v->v_data, &cn))
return;
break;
#endif /* defined(HASCACHEFS) */
#if solaris >= 100000
case N_CTFSADIR:
case N_CTFSBUND:
case N_CTFSCDIR:
case N_CTFSCTL:
case N_CTFSEVT:
case N_CTFSLATE:
case N_CTFSROOT:
case N_CTFSSTAT:
case N_CTFSSYM:
case N_CTFSTDIR:
case N_CTFSTMPL:
if (read_nctfsn(ctx, Ntype, va, (KA_T)v->v_data, (char *)&ctfs))
return;
break;
#endif /* solaris>=100000 */
#if solaris >= 20600
case N_SOCK:
sona = (KA_T)v->v_data;
if (read_nson(ctx, va, sona, &so))
return;
break;
#endif /* solaris>=20600 */
case N_MNT:
/* Information comes from the l_vfs structure. */
break;
case N_MVFS:
if (read_nmn(ctx, va, (KA_T)v->v_data, &m))
return;
break;
case N_NFS:
if (read_nrn(ctx, va, (KA_T)v->v_data, &r))
return;
break;
#if solaris >= 100000
case N_NFS4:
if (read_nrn4(ctx, va, (KA_T)v->v_data, &r4))
return;
break;
#endif /* solaris>=100000 */
case N_NM:
if (nns)
realvp = (KA_T)nn.nm_filevp;
#if defined(HASNCACHE)
Lf->na = (KA_T)nn.nm_filevp;
#endif /* defined(HASNCACHE) */
break;
case N_FD:
break; /* no successor node */
case N_FIFO:
/*
* Solaris FIFO vnodes are usually linked to a fifonode. One
* exception is a FIFO vnode served by nm_vnodeops; it is linked
* to a namenode, and the namenode points to the fifonode.
*
* Non-pipe fifonodes are linked to a vnode thorough fn_realvp.
*/
if (vty == N_NM && nns) {
if (nn.nm_filevp) {
if (read_nfn(ctx, va, (KA_T)nn.nm_filevp, &f))
return;
realvp = (KA_T)NULL;
vty = N_FIFO;
} else {
(void)snpf(Namech, Namechl - 1,
"FIFO namenode at %s: no fifonode pointer",
print_kptr((KA_T)v->v_data, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
return;
}
} else {
if (read_nfn(ctx, va, (KA_T)v->v_data, &f))
return;
realvp = (KA_T)f.fn_realvp;
}
if (!realvp) {
Lf->inode = (INODETYPE)(nns ? nn.nm_vattr.va_nodeid : f.fn_ino);
#if solaris >= 80000 /* Solaris 8 and above hack! */
# if defined(_LP64)
if (Lf->inode >= (unsigned long)0xbaddcafebaddcafe)
# else /* !defined(_LP64) */
if (Lf->inode >= (unsigned long)0xbaddcafe)
# endif /* defined(_LP64) */
Lf->inp_ty = 0;
else
#endif /* solaris>=80000 Solaris 8 and above hack! */
Lf->inp_ty = 1;
enter_dev_ch(ctx, print_kptr((KA_T)v->v_data, (char *)NULL, 0));
if (f.fn_flag & ISPIPE) {
(void)snpf(tbuf, sizeof(tbuf), "PIPE");
tbufx = (int)strlen(tbuf);
} else
tbufx = 0;
#if solaris < 20500
if (f.fn_mate) {
(void)snpf(&tbuf[tbufx], sizeof(tbuf) - tbufx, "->%s",
print_kptr((KA_T)f.fn_mate, (char *)NULL, 0));
tbufx = (int)strlen(tbuf);
}
#else /* solaris>=20500 */
if (f.fn_dest) {
(void)snpf(&tbuf[tbufx], sizeof(tbuf) - tbufx, "->%s",
print_kptr((KA_T)f.fn_dest, (char *)NULL, 0));
tbufx = (int)strlen(tbuf);
}
#endif /* solaris<20500 */
if (tbufx)
(void)add_nma(ctx, tbuf, tbufx);
break;
}
break;
case N_HSFS:
if (read_nhn(ctx, va, (KA_T)v->v_data, &h))
return;
break;
case N_LOFS:
llc = 0;
do {
rvs = 0;
if (read_nln(ctx, va, llc ? (KA_T)rv.v_data : (KA_T)v->v_data,
&lo)) {
return;
}
if (!(realvp = (KA_T)lo.lo_vp)) {
(void)snpf(Namech, Namechl - 1, "lnode at %s: no real vnode",
print_kptr((KA_T)v->v_data, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return;
}
if (read_nvn(ctx, (KA_T)v->v_data, (KA_T)realvp, &rv))
return;
rvs = 1;
llc++;
if ((ka = (KA_T)rv.v_vfsp) &&
!kread(ctx, ka, (char *)&rkv, sizeof(rkv)) &&
((rfx = rkv.vfs_fstype - 1) >= 0) && (rfx < Fsinfomax)) {
rfxs = 1;
} else {
rfx = fx;
rfxs = fxs;
}
if (((vty_tmp = vop2ty(ctx, &rv, rfx)) == N_LOFS) && (llc > 1000)) {
(void)snpf(Namech, Namechl - 1, "lnode at %s: loop > 1000",
print_kptr((KA_T)v->v_data, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return;
}
} while (vty_tmp == N_LOFS);
break;
case N_PCFS:
if (read_npn(ctx, va, (KA_T)v->v_data, &pc))
return;
break;
#if solaris >= 100000
case N_PORT:
if (read_nprtn(ctx, va, (KA_T)v->v_data, &pn))
return;
break;
#endif /* solaris>=100000 */
#if defined(HASPROCFS)
case N_PROC:
if (read_npi(ctx, va, v, &pids))
return;
break;
#endif /* defined(HASPROCFS) */
#if solaris >= 110000
case N_SDEV:
if (read_nsdn(ctx, va, (KA_T)v->v_data, &sdn, &sdva))
return;
sdns = 1;
break;
#endif /* solaris>=110000 */
case N_SAMFS:
(void)add_nma(ctx, SAMFS_NMA_MSG, (int)strlen(SAMFS_NMA_MSG));
break;
case N_SHARED:
break; /* No more sharedfs information is available. */
case N_STREAM:
if (read_nsn(ctx, va, (KA_T)v->v_data, &s))
return;
if (vs) {
Lf->is_stream = 1;
#if solaris < 100000
read_mi(ctx, vs, (dev_t *)&s.s_dev, (caddr_t)&soso, &so_st, so_ad,
&sdp);
#else /* solaris>=100000 */
read_mi(ctx, vs, (dev_t *)&s.s_dev, NULL, NULL, NULL, &sdp);
#endif /* solaris<100000 */
vs = (KA_T)NULL;
}
break;
case N_TMP:
if (read_ntn(ctx, va, (KA_T)v->v_data, &t))
return;
break;
#if defined(HASVXFS)
case N_VXFS:
if (read_vxnode(ctx, va, v, vfs, fx, &vx, Vvops))
return;
break;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
case N_ZFS:
if (read_nzn(ctx, va, (KA_T)v->v_data, &zn))
return;
zns = 1;
break;
#endif /* defined(HAS_ZFS) */
case N_REGLR:
default:
if (read_nin(ctx, va, (KA_T)v->v_data, &i))
return;
ins = 1;
}
/*
* If the node has a real vnode pointer, follow it.
*/
if (realvp) {
if (rvs) {
*v = rv;
fx = rfx;
fxs = rfxs;
} else {
if (read_nvn(ctx, (KA_T)v->v_data, (KA_T)realvp, v))
return;
else {
#if defined(HASNCACHE)
Lf->na = (KA_T)realvp;
#endif /* defined(HASNCACHE) */
if ((ka = (KA_T)v->v_vfsp) &&
!kread(ctx, ka, (char *)&kv, sizeof(kv))) {
kvs = 1;
}
if (kvs && ((fx = kv.vfs_fstype - 1) >= 0) &&
(fx < Fsinfomax)) {
fxs = 1;
}
}
}
/*
* If the original vnode type is N_STREAM, if there is a stream
* pointer and if there is no sdev_node, get the module names.
*/
if (vty == N_STREAM && vs && !sdns) {
Lf->is_stream = 1;
#if solaris < 100000
read_mi(ctx, vs, (dev_t *)&s.s_dev, (caddr_t)&soso, &so_st, so_ad,
&sdp);
#else /* solaris>=100000 */
read_mi(ctx, vs, (dev_t *)&s.s_dev, NULL, NULL, NULL, &sdp);
#endif /* solaris<100000 */
vs = (KA_T)NULL;
}
/*
* Get the real vnode's type.
*/
if ((vty = vop2ty(ctx, v, fx)) < 0) {
if (Ntype != N_FIFO && vs)
vty = N_STREAM;
else {
#if solaris < 100000
(void)snpf(Namech, Namechl - 1,
"unknown file system type, v_op: %s",
print_kptr((KA_T)v->v_op, (char *)NULL, 0));
#else /* solaris>=100000 */
(void)snpf(Namech, Namechl - 1,
"unknown file system type (%s), v_op: %s",
fxs ? Fsinfo[fx] : "unknown",
print_kptr((KA_T)v->v_op, (char *)NULL, 0));
#endif /* solaris<100000 */
Namech[Namechl - 1] = '\0';
}
}
if (Ntype == N_NM || Ntype == N_AFS)
Ntype = vty;
/*
* Base further processing on the "real" vnode.
*/
Lf->lock = isvlocked(ctx, v);
switch (vty) {
#if defined(HAS_AFS)
case N_AFS:
if (readafsnode(ctx, va, v, &an))
return;
break;
#endif /* defined(HAS_AFS) */
#if solaris >= 20500
case N_AUTO:
# if solaris < 20600
if (read_nan(ctx, va, (KA_T)v->v_data, &au))
# else /* solaris>=20600 */
if (read_nan(ctx, va, (KA_T)v->v_data, &fnn))
# endif /* solaris<20600 */
return;
break;
# if solaris >= 100000
case N_DEV:
if (read_ndvn(ctx, va, (KA_T)v->v_data, &dv, &dv_dev, &dv_devs))
return;
dvs = 1;
break;
# endif /* solaris>=100000 */
case N_DOOR:
# if solaris < 20600
if (read_ndn(ctx, realvp, (KA_T)v->v_data, &dn))
# else /* solaris>=20600 */
if (read_ndn(ctx, va, (KA_T)v->v_data, &dn))
# endif /* solaris<20500 */
return;
dns = 1;
break;
#endif /* solaris>=20500 */
#if defined(HASCACHEFS)
case N_CACHE:
if (read_ncn(ctx, va, (KA_T)v->v_data, &cn))
return;
break;
#endif /* defined(HASCACHEFS) */
#if solaris >= 100000
case N_CTFSADIR:
case N_CTFSBUND:
case N_CTFSCDIR:
case N_CTFSCTL:
case N_CTFSEVT:
case N_CTFSLATE:
case N_CTFSROOT:
case N_CTFSSTAT:
case N_CTFSSYM:
case N_CTFSTDIR:
case N_CTFSTMPL:
if (read_nctfsn(ctx, vty, va, (KA_T)v->v_data, (char *)&ctfs))
return;
break;
#endif /* solaris>=100000 */
case N_HSFS:
if (read_nhn(ctx, va, (KA_T)v->v_data, &h))
return;
break;
case N_MNT:
/* Information comes from the l_vfs structure. */
break;
case N_MVFS:
if (read_nmn(ctx, va, (KA_T)v->v_data, &m))
return;
break;
case N_NFS:
if (read_nrn(ctx, va, (KA_T)v->v_data, &r))
return;
break;
#if solaris >= 100000
case N_NFS4:
if (read_nrn4(ctx, va, (KA_T)v->v_data, &r4))
return;
break;
#endif /* solaris>=100000 */
case N_NM:
if (read_nnn(ctx, va, (KA_T)v->v_data, &nn))
return;
nns = 1;
break;
#if solaris >= 100000
case N_PORT:
if (read_nprtn(ctx, va, (KA_T)v->v_data, &pn))
return;
break;
#endif /* solaris>=100000 */
case N_PCFS:
if (read_npn(ctx, va, (KA_T)v->v_data, &pc))
return;
break;
case N_SAMFS:
(void)add_nma(ctx, SAMFS_NMA_MSG, (int)strlen(SAMFS_NMA_MSG));
#if solaris >= 110000
case N_SDEV:
if (read_nsdn(ctx, va, (KA_T)v->v_data, &sdn, &sdva))
return;
if (Lf->is_stream) {
/*
* This stream's real node is an sdev_node, so it's not really
* a stream. Reverse prior stream settings.
*/
Lf->is_stream = 0;
Namech[0] = '\0';
}
sdns = 1;
break;
#endif /* solaris>=110000 */
break;
#if solaris >= 20600
case N_SOCK:
sona = (KA_T)v->v_data;
if (read_nson(ctx, va, sona, &so))
return;
break;
#endif /* solaris>=20600 */
case N_STREAM:
if (vs) {
Lf->is_stream = 1;
#if solaris < 100000
read_mi(ctx, vs, (dev_t *)&s.s_dev, (caddr_t)&soso, &so_st,
so_ad, &sdp);
#else /* solaris>=100000 */
read_mi(ctx, vs, (dev_t *)&s.s_dev, NULL, NULL, NULL, &sdp);
#endif /* solaris<100000 */
vs = (KA_T)NULL;
}
break;
case N_TMP:
if (read_ntn(ctx, va, (KA_T)v->v_data, &t))
return;
break;
#if defined(HASVXFS)
case N_VXFS:
if (read_vxnode(ctx, va, v, vfs, fx, &vx, Vvops))
return;
break;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
case N_ZFS:
if (read_nzn(ctx, va, (KA_T)v->v_data, &zn))
return;
zns = 1;
break;
#endif /* defined(HAS_ZFS) */
case N_REGLR:
default:
if (read_nin(ctx, va, (KA_T)v->v_data, &i))
return;
ins = 1;
}
/*
* If this is a Solaris loopback node, use the "real" node type.
*/
if (Ntype == N_LOFS)
Ntype = vty;
}
/*
* Get device and type for printing.
*/
switch (((Ntype == N_FIFO) || (vty == N_SDEV)) ? vty : Ntype) {
#if defined(HAS_AFS)
case N_AFS:
dev = an.dev;
devs = 1;
break;
#endif /* defined(HAS_AFS) */
#if solaris >= 20500
case N_AUTO:
if (kvs) {
dev = (dev_t)kv.vfs_fsid.val[0];
devs = 1;
}
break;
# if solaris >= 100000
case N_DEV:
if (dv_devs) {
dev = dv_dev;
devs = 1;
} else if (vfs) {
dev = vfs->dev;
devs = 1;
}
rdev = v->v_rdev;
rdevs = 1;
break;
# endif /* solaris>=100000 */
case N_DOOR:
# if solaris < 20600
if (kvs) {
dev = (dev_t)kv.vfs_fsid.val[0];
devs = 1;
}
# else /* solaris>=20600 */
if (nns) {
dev = (dev_t)nn.nm_vattr.va_fsid;
devs = 1;
} else if (dns) {
dev = (dev_t)dn.door_index;
devs = 1;
}
# endif /* solaris<20600 */
break;
#endif /* solaris>=20500 */
#if defined(HASCACHEFS)
case N_CACHE:
#endif /* defined(HASCACHEFS) */
case N_HSFS:
case N_PCFS:
if (kvs) {
dev = kv.vfs_dev;
devs = 1;
}
break;
#if solaris >= 100000
case N_CTFSADIR:
case N_CTFSBUND:
case N_CTFSCDIR:
case N_CTFSCTL:
case N_CTFSEVT:
case N_CTFSLATE:
case N_CTFSROOT:
case N_CTFSSTAT:
case N_CTFSSYM:
case N_CTFSTDIR:
case N_CTFSTMPL:
if (kvs) {
dev = kv.vfs_dev;
devs = 1;
}
break;
#endif /* solaris>=100000 */
case N_FD:
if (kvs) {
dev = kv.vfs_dev;
devs = 1;
}
if ((v->v_type == VCHR) || (v->v_type == VBLK)) {
rdev = v->v_rdev;
rdevs = 1;
}
break;
case N_MNT:
#if defined(CVFS_DEVSAVE)
if (vfs) {
dev = vfs->dev;
devs = 1;
}
#endif /* defined(CVFS_DEVSAVE) */
break;
case N_MVFS:
#if defined(CVFS_DEVSAVE)
if (vfs) {
dev = vfs->dev;
devs = 1;
}
#endif /* defined(CVFS_DEVSAVE) */
break;
case N_NFS:
dev = r.r_attr.va_fsid;
devs = 1;
break;
#if solaris >= 100000
case N_NFS4:
dev = r4.r_attr.va_fsid;
devs = 1;
break;
#endif /* solaris>=100000 */
case N_NM:
if (nns) {
dev = (dev_t)nn.nm_vattr.va_fsid;
devs = 1;
} else
enter_dev_ch(ctx, " NMFS");
break;
#if solaris >= 100000
case N_PORT:
if (kvs) {
dev = kv.vfs_dev;
devs = 1;
}
break;
#endif /* solaris>=100000 */
#if defined(HASPROCFS)
case N_PROC:
if (kvs) {
dev = kv.vfs_dev;
devs = 1;
}
break;
#endif /* defined(HASPROCFS) */
case N_SAMFS:
if ((v->v_type == VCHR) || (v->v_type == VBLK)) {
rdev = v->v_rdev;
rdevs = 1;
} else if (vfs) {
dev = vfs->dev;
devs = 1;
}
break;
#if solaris >= 110000
case N_SDEV:
if (sdns) {
if (v->v_type == VDIR) {
dev = v->v_rdev;
devs = 1;
} else {
rdev = v->v_rdev;
rdevs = 1;
}
}
break;
#endif /* solaris>=110000 */
case N_SHARED:
if (vfs) {
dev = vfs->dev;
devs = 1;
}
break;
#if solaris >= 20600
case N_SOCK:
if (so.so_family == AF_UNIX)
/*
* Process an AF_UNIX socket node.
*/
# if solaris >= 110000
{
/*
* Process a Solaris >= 11 AF_UNIX socket node:
*
* Get its sotpi_info_t structure;
*/
if (read_nsti(ctx, &so, &sti))
return;
/*
* Get its device numbers. If they are located, start the NAME
* column with the device name, followed by "->".
*/
nm = Namech;
nmrl = Namechl - 1;
Namech[Namechl - 1] = '\0';
if (!sdp)
sdp = finddev(ctx, &DevDev, &sti.sti_dev, LOOKDEV_ALL);
if (sdp) {
dev = DevDev;
rdev = v->v_rdev;
trdev = sdp->rdev;
devs = rdevs = trdevs = 1;
Lf->inode = (INODETYPE)sdp->inode;
Lf->inp_ty = 1;
(void)snpf(nm, nmrl, "%s", sdp->name);
tl = strlen(nm);
nm += tl;
nmrl -= tl;
sep = "->";
} else {
devs = rdevs = trdevs = 0;
sep = "";
}
/*
* Add the socket node's address to the NAME column.
*/
sepl = strlen(sep);
if (sona && ((nmrl - sepl) > 0)) {
(void)snpf(nm, nmrl, "%s%s", sep,
print_kptr(sona, (char *)NULL, 0));
tl = strlen(nm);
nm += tl;
nmrl -= tl;
}
/*
* Add the service type to the NAME column.
*/
switch (sti.sti_serv_type) {
case T_CLTS:
ty = "dgram";
break;
case T_COTS:
ty = "stream";
break;
case T_COTS_ORD:
ty = "stream-ord";
break;
default:
ty = (char *)NULL;
}
if (ty && (nmrl > 1)) {
(void)snpf(nm, nmrl, " %s", ty);
tl = strlen(nm);
nm += tl;
nmrl -= tl;
}
/*
* Add the vnode and connected addresses to the NAME column,
* as indicated by the socket node state.
*/
if ((so.so_state & SS_ISBOUND) && (nmrl > 36) &&
(sti.sti_ux_laddr.soua_magic == SOU_MAGIC_EXPLICIT)) {
(void)snpf(nm, nmrl, " Vn=%s",
print_kptr((KA_T)sti.sti_ux_laddr.soua_vp,
(char *)NULL, 0));
tl = strlen(nm);
nm += tl;
nmrl -= tl;
}
if ((so.so_state & SS_ISCONNECTED) && (nmrl > 38) &&
(sti.sti_ux_faddr.soua_magic == SOU_MAGIC_EXPLICIT)) {
(void)snpf(nm, nmrl, " Conn=%s ",
print_kptr((KA_T)sti.sti_ux_faddr.soua_vp,
(char *)NULL, 0));
tl = strlen(nm);
nm += tl;
nmrl -= tl;
}
/*
* Put local and connected UNIX addresses in the NAME column, if
* they exist and as indicated by the socket node's state.
*/
if ((so.so_state & SS_ISBOUND) &&
((len = read_nusa(ctx, &sti.sti_laddr, &ua)) > 0) &&
(nmrl > (len + 5))) {
if (Sfile && is_file_named(ctx, ua.sun_path, Ntype, VSOCK, 0))
Lf->sf |= SELNM;
if (len > nmrl)
len = nmrl;
if (len > 0) {
ua.sun_path[len] = '\0';
(void)snpf(nm, nmrl, " Lcl=%s", ua.sun_path);
tl = strlen(nm);
nm += tl;
nmrl -= tl;
}
}
if ((so.so_state & SS_ISCONNECTED) &&
((len = read_nusa(ctx, &sti.sti_faddr, &ua)) > 0) &&
(nmrl > (len + 5))) {
if (Sfile && is_file_named(ctx, ua.sun_path, Ntype, VSOCK, 0))
Lf->sf |= SELNM;
if (len > nmrl)
len = nmrl;
if (len > 0) {
ua.sun_path[len] = '\0';
(void)snpf(nm, nmrl, " Rem=%s", ua.sun_path);
tl = strlen(nm);
nm += tl;
nmrl -= tl;
}
}
} else {
/*
* Process Solaris >= 11 AF_INET, AF_INET6 and AF_ROUTE VSOCK
* nodes.
*/
switch (so.so_family) {
case AF_INET:
case AF_INET6:
case AF_ROUTE:
if (process_VSOCK(ctx, (KA_T)va, v, &so))
return;
}
}
# else /* solaris<110000 */
{
/*
* Process an AF_UNIX socket node for Solaris < 11:
* Locate its device numbers;
* Enter the sonode address as the device (netstat's local
* address);
* Get a non-NULL local sockaddr_un and enter it in Namech;
* Get a non-NULL foreign sockaddr_un and enter it in Namech;
* Check for matches on sockaddr_un.sun_path names.
*/
if (!sdp)
sdp = finddev(&DevDev,
# if solaris < 100000
&so.so_vnode.v_rdev,
# else /* solaris>=100000 */
&so.so_dev,
# endif /* solaris<100000 */
LOOKDEV_ALL);
if (sdp) {
dev = DevDev;
# if solaris < 100000
rdev = so.so_vnode.v_rdev;
# else /* solaris>=100000 */
rdev = so.so_dev;
# endif /* solaris<100000 */
trdev = sdp->rdev;
devs = rdevs = trdevs = 1;
Lf->inode = (INODETYPE)sdp->inode;
Lf->inp_ty = 1;
(void)snpf(Namech, Namechl - 1, "%s", sdp->name);
Namech[Namechl - 1] = '\0';
} else
devs = 0;
nl = snl = (int)strlen(Namech);
if ((len = read_nusa(&so.so_laddr, &ua))) {
if (Sfile && is_file_named(ctx, ua.sun_path, Ntype, VSOCK, 0))
Lf->sf |= SELNM;
sepl = Namech[0] ? 2 : 0;
if (len > (Namechl - nl - sepl - 1))
len = Namechl - nl - sepl - 1;
if (len > 0) {
ua.sun_path[len] = '\0';
(void)snpf(&Namech[nl], Namechl - nl, "%s%s",
sepl ? "->" : "", ua.sun_path);
nl += (len + sepl);
}
}
if ((len = read_nusa(&so.so_faddr, &ua))) {
if (Sfile && is_file_named(ctx, ua.sun_path, Ntype, VSOCK, 0))
Lf->sf |= SELNM;
sepl = Namech[0] ? 2 : 0;
if (len > (Namechl - nl - sepl - 1))
len = Namechl - nl - sepl - 1;
if (len > 0) {
ua.sun_path[len] = 0;
(void)snpf(&Namech[nl], Namechl - nl, "%s%s",
sepl ? "->" : "", ua.sun_path);
nl += (len + sepl);
}
}
if ((nl == snl)
# if defined(HASSOUXSOUA)
&& so.so_ux_laddr.soua_magic == SOU_MAGIC_IMPLICIT
# else /* !defined(HASSOUXSOUA) */
&& so.so_ux_laddr.sou_magic == SOU_MAGIC_IMPLICIT
# endif /* defined(HASSOUXSOUA) */
) {
/*
* There are no addresses; this must be a socket pair.
* Print its identity.
*/
pa = (struct pairaddr *)&ua;
if (!(peer = (KA_T)((int)pa->p)))
# if defined(HASSOUXSOUA)
peer = (KA_T)so.so_ux_laddr.soua_vp;
# else /* !defined(HASSOUXSOUA) */
peer = (KA_T)so.so_ux_laddr.sou_vp;
# endif /* defined(HASSOUXSOUA) */
if (peer)
(void)snpf(ubuf, sizeof(ubuf), "(socketpair: %s)",
print_kptr(peer, (char *)NULL, 0));
else
(void)snpf(ubuf, sizeof(ubuf), "(socketpair)");
len = (int)strlen(ubuf);
sepl = Namech[0] ? 2 : 0;
if (len > (Namechl - nl - sepl - 1))
len = Namechl - nl - sepl - 1;
if (len > 0) {
(void)snpf(&Namech[nl], Namechl - nl, "%s%s",
sepl ? "->" : "", ubuf);
nl += (len + sepl);
}
}
/*
* Add the local and foreign addresses, ala `netstat -f unix` to
* the name.
*/
# if defined(HASSOUXSOUA)
soa = (KA_T)so.so_ux_faddr.soua_vp;
# else /* !defined(HASSOUXSOUA) */
soa = (KA_T)so.so_ux_faddr.sou_vp;
# endif /* defined(HASSOUXSOUA) */
(void)snpf(ubuf, sizeof(ubuf), "%s(%s%s%s)", Namech[0] ? " " : "",
print_kptr((KA_T)v->v_data, (char *)NULL, 0),
soa ? "->" : "",
soa ? print_kptr(soa, tbuf, sizeof(tbuf)) : "");
len = (int)strlen(ubuf);
if (len <= (Namechl - nl - 1)) {
(void)snpf(&Namech[nl], Namechl - nl, "%s", ubuf);
nl += len;
}
/*
* If there is a bound vnode, add its address to the name.
*/
if (so.so_ux_bound_vp) {
(void)snpf(
ubuf, sizeof(ubuf), "%s(Vnode=%s)", Namech[0] ? " " : "",
print_kptr((KA_T)so.so_ux_bound_vp, (char *)NULL, 0));
len = (int)strlen(ubuf);
if (len <= (Namechl - nl - 1)) {
(void)snpf(&Namech[nl], Namechl - nl, "%s", ubuf);
nl += len;
}
}
}
# endif /* solaris>=110000 */
break;
#endif /* solaris>=20600 */
case N_SPEC:
#if solaris < 100000
if (((Ntype = vty) == N_STREAM) && so_st) {
if (Funix)
Lf->sf |= SELUNX;
unix_sock = 1;
if (so_ad[0]) {
if (sdp) {
if (vfs) {
dev = vfs->dev;
devs = 1;
}
rdev = sdp->rdev;
rdevs = 1;
Lf->inode = (INODETYPE)sdp->inode;
Lf->inp_ty = 1;
(void)snpf(ubuf, sizeof(ubuf), "(%s%s%s)",
print_kptr(so_ad[0], (char *)NULL, 0),
so_ad[1] ? "->" : "",
so_ad[1]
? print_kptr(so_ad[1], tbuf, sizeof(tbuf))
: "");
} else {
enter_dev_ch(print_kptr(so_ad[0], (char *)NULL, 0));
if (so_ad[1])
(void)snpf(ubuf, sizeof(ubuf), "(->%s)",
print_kptr(so_ad[1], (char *)NULL, 0));
}
if (!Lf->nma &&
(Lf->nma = (char *)malloc((int)strlen(ubuf) + 1))) {
(void)snpf(Lf->nma, (int)strlen(ubuf) + 1, "%s", ubuf);
}
} else if (soso.lux_dev.addr.tu_addr.ino) {
if (vfs) {
dev = vfs->dev;
devs = 1;
}
rdev = soso.lux_dev.addr.tu_addr.dev;
rdevs = 1;
} else {
int dc, dl, dr;
# if solaris < 20400
dl = (soso.lux_dev.addr.tu_addr.dev >> 16) & 0xffff;
dr = (soso.rux_dev.addr.tu_addr.dev >> 16) & 0xffff;
# else /* solaris>=20400 */
dl = soso.lux_dev.addr.tu_addr.dev & 0xffff;
dr = soso.rux_dev.addr.tu_addr.dev & 0xffff;
# endif /* solaris<20400 */
dc = (dl << 16) | dr;
enter_dev_ch(print_kptr((KA_T)dc, (char *)NULL, 0));
devs = 0;
}
if (soso.laddr.buf && soso.laddr.len == sizeof(ua)) {
if (kread(ctx, (KA_T)soso.laddr.buf, (char *)&ua, sizeof(ua)) ==
0) {
ua.sun_path[sizeof(ua.sun_path) - 1] = '\0';
if (ua.sun_path[0]) {
if (Sfile &&
is_file_named(ctx, ua.sun_path, Ntype, type, 0))
Lf->sf |= SELNM;
len = (int)strlen(ua.sun_path);
nl = (int)strlen(Namech);
sepl = Namech[0] ? 2 : 0;
if (len > (Namechl - nl - sepl - 1))
len = Namechl - nl - sepl - 1;
if (len > 0) {
ua.sun_path[len] = '\0';
(void)snpf(&Namech[nl], Namechl - nl, "%s%s",
sepl ? "->" : "", ua.sun_path);
}
}
}
}
} else
#endif /* solaris<100000 */
{
if (vfs) {
dev = vfs->dev;
devs = 1;
}
rdev = s.s_dev;
rdevs = 1;
}
break;
case N_STREAM:
if (vfs) {
dev = vfs->dev;
devs = 1;
}
rdev = s.s_dev;
rdevs = 1;
break;
case N_TMP:
dev = t.tn_attr.va_fsid;
devs = 1;
break;
#if defined(HASVXFS)
case N_VXFS:
dev = vx.dev;
devs = vx.dev_def;
if ((v->v_type == VCHR) || (v->v_type == VBLK)) {
rdev = vx.rdev;
rdevs = vx.rdev_def;
}
break;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
case N_ZFS:
if (zns) {
if (!read_nzvfs(ctx, (KA_T)v->v_data, (KA_T)zn.z_zfsvfs, &zvfs) &&
zvfs.z_vfs &&
!kread(ctx, (KA_T)zvfs.z_vfs, (char *)&zgvfs, sizeof(zgvfs))) {
dev = zgvfs.vfs_dev;
devs = 1;
}
}
if ((v->v_type == VCHR) || (v->v_type == VBLK)) {
rdev = v->v_rdev;
rdevs = 1;
}
break;
#endif /* defined(HAS_ZFS) */
default:
if (ins) {
dev = i.i_dev;
devs = 1;
} else if (nns) {
dev = nn.nm_vattr.va_fsid;
devs = 1;
} else if (vfs) {
dev = vfs->dev;
devs = 1;
}
if ((v->v_type == VCHR) || (v->v_type == VBLK)) {
rdev = v->v_rdev;
rdevs = 1;
}
}
type = v->v_type;
if (devs && vfs && !vfs->dir) {
(void)completevfs(ctx, vfs, &dev);
#if defined(HAS_AFS)
if (vfs->dir && (Ntype == N_AFS || vty == N_AFS) && !AFSVfsp)
AFSVfsp = (KA_T)v->v_vfsp;
#endif /* defined(HAS_AFS) */
}
/*
* Obtain the inode number.
*/
switch (vty) {
#if defined(HAS_AFS)
case N_AFS:
if (an.ino_st) {
Lf->inode = (INODETYPE)an.inode;
Lf->inp_ty = 1;
}
break;
#endif /* defined(HAS_AFS) */
#if solaris >= 20500
case N_AUTO:
# if solaris < 20600
Lf->inode = (INODETYPE)au.an_nodeid;
# else /* solaris>=20600 */
Lf->inode = (INODETYPE)fnn.fn_nodeid;
# endif /* solaris<20600 */
Lf->inp_ty = 1;
break;
# if solaris >= 100000
case N_DEV:
if (dvs) {
Lf->inode = (INODETYPE)dv.dv_ino;
Lf->inp_ty = 1;
}
break;
# endif /* solaris>=100000 */
case N_DOOR:
if (nns && (Lf->inode = (INODETYPE)nn.nm_vattr.va_nodeid)) {
Lf->inp_ty = 1;
break;
}
if (dns) {
if ((Lf->inode = (INODETYPE)dn.door_index))
Lf->inp_ty = 1;
}
break;
#endif /* solaris>=20500 */
#if defined(HASCACHEFS)
case N_CACHE:
Lf->inode = (INODETYPE)cn.c_fileno;
Lf->inp_ty = 1;
break;
#endif /* defined(HASCACHEFS) */
#if solaris >= 100000
case N_CTFSADIR:
case N_CTFSBUND:
case N_CTFSCDIR:
case N_CTFSCTL:
case N_CTFSEVT:
case N_CTFSLATE:
case N_CTFSROOT:
case N_CTFSSTAT:
case N_CTFSSYM:
case N_CTFSTDIR:
case N_CTFSTMPL:
/* Method of computing CTFS inode not known. */
break;
#endif /* solaris>=10000 */
case N_FD:
if (v->v_type == VDIR)
Lf->inode = (INODETYPE)2;
else
Lf->inode = (INODETYPE)(GET_MIN_DEV(v->v_rdev) * 100);
Lf->inp_ty = 1;
break;
case N_HSFS:
Lf->inode = (INODETYPE)h.hs_nodeid;
Lf->inp_ty = 1;
break;
case N_MNT:
#if defined(HASFSINO)
if (vfs) {
Lf->inode = vfs->fs_ino;
Lf->inp_ty = 1;
}
#endif /* defined(HASFSINO) */
break;
case N_MVFS:
Lf->inode = (INODETYPE)m.m_ino;
Lf->inp_ty = 1;
break;
case N_NFS:
Lf->inode = (INODETYPE)r.r_attr.va_nodeid;
Lf->inp_ty = 1;
break;
#if solaris >= 100000
case N_NFS4:
Lf->inode = (INODETYPE)r4.r_attr.va_nodeid;
Lf->inp_ty = 1;
break;
#endif /* solaris>=100000 */
case N_NM:
Lf->inode = (INODETYPE)nn.nm_vattr.va_nodeid;
Lf->inp_ty = 1;
break;
#if defined(HASPROCFS)
case N_PROC:
/*
* The proc file system inode number is defined when the
* prnode is read.
*/
break;
#endif /* defined(HASPROCFS) */
case N_PCFS:
if (kvs && kv.vfs_data &&
!kread(ctx, (KA_T)kv.vfs_data, (char *)&pcfs, sizeof(pcfs))) {
#if solaris >= 70000
# if defined(HAS_PC_DIRENTPERSEC)
Lf->inode = (INODETYPE)pc_makenodeid(
pc.pc_eblkno, pc.pc_eoffset, pc.pc_entry.pcd_attr,
IS_FAT32(&pcfs)
? ltohs(pc.pc_entry.pcd_scluster_lo) |
(ltohs(pc.pc_entry.un.pcd_scluster_hi) << 16)
: ltohs(pc.pc_entry.pcd_scluster_lo),
pc_direntpersec(&pcfs));
# else /* !defined(HAS_PC_DIRENTPERSEC) */
Lf->inode = (INODETYPE)pc_makenodeid(
pc.pc_eblkno, pc.pc_eoffset, pc.pc_entry.pcd_attr,
IS_FAT32(&pcfs)
? ltohs(pc.pc_entry.pcd_scluster_lo) |
(ltohs(pc.pc_entry.un.pcd_scluster_hi) << 16)
: ltohs(pc.pc_entry.pcd_scluster_lo),
pcfs.pcfs_entps);
# endif /* defined(HAS_PC_DIRENTPERSEC) */
#else /* solaris<70000 */
Lf->inode = (INODETYPE)pc_makenodeid(pc.pc_eblkno, pc.pc_eoffset,
&pc.pc_entry, pcfs.pcfs_entps);
#endif /* solaris>=70000 */
Lf->inp_ty = 1;
}
break;
case N_REGLR:
if (nns) {
if ((Lf->inode = (INODETYPE)nn.nm_vattr.va_nodeid))
Lf->inp_ty = 1;
} else if (ins) {
if ((Lf->inode = (INODETYPE)i.i_number))
Lf->inp_ty = 1;
}
break;
case N_SAMFS:
break; /* No more SAM-FS information is available. */
#if solaris >= 110000
case N_SDEV:
if (sdns) {
Lf->inode = (INODETYPE)sdva.va_nodeid;
Lf->inp_ty = 1;
}
break;
#endif /* solaris>=110000 */
case N_SHARED:
(void)snpf(Lf->iproto, sizeof(Lf->iproto), "SHARED");
Lf->inp_ty = 2;
break;
case N_STREAM:
#if solaris < 100000
if (so_st && soso.lux_dev.addr.tu_addr.ino) {
if (Lf->inp_ty) {
nl = Lf->nma ? (int)strlen(Lf->nma) : 0;
(void)snpf(ubuf, sizeof(ubuf), "%s(Inode=%lu)", nl ? " " : "",
(unsigned long)soso.lux_dev.addr.tu_addr.ino);
len = nl + (int)strlen(ubuf) + 1;
if (Lf->nma)
Lf->nma = (char *)realloc(Lf->nma, len);
else
Lf->nma = (char *)malloc(len);
if (Lf->nma)
(void)snpf(&Lf->nma[nl], len - nl, "%s", ubuf);
} else {
Lf->inode = (INODETYPE)soso.lux_dev.addr.tu_addr.ino;
Lf->inp_ty = 1;
}
}
#endif /* solaris<100000 */
break;
case N_TMP:
Lf->inode = (INODETYPE)t.tn_attr.va_nodeid;
Lf->inp_ty = 1;
break;
#if defined(HASVXFS)
case N_VXFS:
if (vx.ino_def) {
Lf->inode = (INODETYPE)vx.ino;
Lf->inp_ty = 1;
} else if (type == VCHR)
pnl = 1;
break;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
case N_ZFS:
if (zns) {
Lf->inode = (INODETYPE)zn.z_id;
Lf->inp_ty = 1;
}
break;
#endif /* defined(HAS_ZFS) */
}
/*
* Obtain the file size.
*/
switch (Ntype) {
#if defined(HAS_AFS)
case N_AFS:
Lf->sz = (SZOFFTYPE)an.size;
Lf->sz_def = 1;
break;
#endif /* defined(HAS_AFS) */
#if solaris >= 20500
case N_AUTO:
# if solaris < 20600
Lf->sz = (SZOFFTYPE)au.an_size;
# else /* solaris >=20600 */
Lf->sz = (SZOFFTYPE)fnn.fn_size;
# endif /* solaris < 20600 */
Lf->sz_def = 1;
break;
#endif /* solaris>=20500 */
#if defined(HASCACHEFS)
case N_CACHE:
Lf->sz = (SZOFFTYPE)cn.c_size;
Lf->sz_def = 1;
break;
#endif /* defined(HASCACHEFS) */
#if solaris >= 100000
case N_CTFSADIR:
case N_CTFSBUND:
case N_CTFSCDIR:
case N_CTFSCTL:
case N_CTFSEVT:
case N_CTFSLATE:
case N_CTFSROOT:
case N_CTFSSTAT:
case N_CTFSSYM:
case N_CTFSTDIR:
case N_CTFSTMPL:
/* Method of computing CTFS size not known. */
break;
#endif /* solaris>=100000 */
case N_FD:
if (v->v_type == VDIR)
Lf->sz = (Unof + 2) * 16;
else
Lf->sz = (unsigned long)0;
Lf->sz_def = 1;
break;
#if solaris >= 20600
case N_SOCK:
break;
#endif /* solaris>=20600 */
case N_HSFS:
Lf->sz = (SZOFFTYPE)h.hs_dirent.ext_size;
Lf->sz_def = 1;
break;
case N_NM:
Lf->sz = (SZOFFTYPE)nn.nm_vattr.va_size;
Lf->sz_def = 1;
break;
#if solaris >= 100000
case N_DEV:
break;
#endif /* solaris>=100000 */
case N_DOOR:
case N_FIFO:
break;
case N_MNT:
#if defined(CVFS_SZSAVE)
if (vfs) {
Lf->sz = (SZOFFTYPE)vfs->size;
Lf->sz_def = 1;
} else
#endif /* defined(CVFS_SZSAVE) */
break;
case N_MVFS:
/* The location of file size isn't known. */
break;
case N_NFS:
if (!(type == VCHR || type == VBLK)) {
Lf->sz = (SZOFFTYPE)r.r_size;
Lf->sz_def = 1;
}
break;
#if solaris >= 100000
case N_NFS4:
if (!(type == VCHR || type == VBLK)) {
Lf->sz = (SZOFFTYPE)r4.r_size;
Lf->sz_def = 1;
}
break;
#endif /* solaris>=100000 */
case N_PCFS:
Lf->sz = (SZOFFTYPE)pc.pc_size;
Lf->sz_def = 1;
break;
#if solaris >= 100000
case N_PORT:
Lf->sz = (SZOFFTYPE)pn.port_curr;
Lf->sz_def = 1;
break;
#endif /* solaris>=100000 */
#if defined(HASPROCFS)
case N_PROC:
/*
* The proc file system size is defined when the
* prnode is read.
*/
break;
#endif /* defined(HASPROCFS) */
case N_REGLR:
if (type == VREG || type == VDIR) {
if (ins | nns) {
Lf->sz = (SZOFFTYPE)(nns ? nn.nm_vattr.va_size : i.i_size);
Lf->sz_def = 1;
}
}
break;
#if solaris >= 110000
case N_SDEV:
if (sdns) {
if (type == VREG || type == VDIR) {
Lf->sz = (SZOFFTYPE)sdva.va_size;
Lf->sz_def = 1;
}
}
break;
#endif /* solaris>=110000 */
case N_SAMFS:
break; /* No more SAM-FS information is available. */
case N_SHARED:
break; /* No more sharedfs information is available. */
case N_STREAM:
break;
case N_TMP:
Lf->sz = (SZOFFTYPE)t.tn_attr.va_size;
Lf->sz_def = 1;
break;
#if defined(HASVXFS)
case N_VXFS:
if (type == VREG || type == VDIR) {
Lf->sz = (SZOFFTYPE)vx.sz;
Lf->sz_def = vx.sz_def;
}
break;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
case N_ZFS:
if (zns) {
if (type == VREG || type == VDIR) {
Lf->sz = (SZOFFTYPE)zn.z_size;
Lf->sz_def = 1;
}
}
break;
#endif /* defined(HAS_ZFS) */
}
/*
* Record link count.
*/
switch (Ntype) {
#if defined(HAS_AFS)
case N_AFS:
Lf->nlink = an.nlink;
Lf->nlink_def = an.nlink_st;
break;
#endif /* defined(HAS_AFS) */
#if solaris >= 20500
case N_AUTO:
break;
# if defined(HASCACHEFS)
case N_CACHE:
Lf->nlink = (long)cn.c_attr.va_nlink;
Lf->nlink_def = 1;
break;
# endif /* defined(HASCACHEFS) */
#endif /* solaris>=20500 */
#if solaris >= 100000
case N_CTFSADIR:
case N_CTFSBUND:
case N_CTFSCDIR:
case N_CTFSCTL:
case N_CTFSEVT:
case N_CTFSLATE:
case N_CTFSROOT:
case N_CTFSSTAT:
case N_CTFSSYM:
case N_CTFSTDIR:
case N_CTFSTMPL:
/* Method of computing CTFS link count not known. */
break;
#endif /* solaris>=100000 */
case N_FD:
Lf->nlink = (v->v_type == VDIR) ? 2 : 1;
Lf->nlink_def = 1;
break;
#if solaris >= 20600
case N_SOCK: /* no link count */
break;
#endif /* solaris>=20600 */
case N_HSFS:
Lf->nlink = (long)h.hs_dirent.nlink;
Lf->nlink_def = 1;
break;
case N_NM:
Lf->nlink = (long)nn.nm_vattr.va_nlink;
Lf->nlink_def = 1;
break;
#if solaris >= 100000
case N_DEV:
if (dvs) {
Lf->nlink = (long)dv.dv_nlink;
Lf->nlink_def = 1;
}
break;
#endif /* solaris>=100000 */
case N_DOOR:
Lf->nlink = (long)v->v_count;
Lf->nlink_def = 1;
break;
case N_FIFO:
break;
case N_MNT:
#if defined(CVFS_NLKSAVE)
if (vfs) {
Lf->nlink = (long)vfs->nlink;
Lf->nlink_def = 1;
}
#endif /* defined(CVFS_NLKSAVE) */
break;
case N_MVFS: /* no link count */
break;
case N_NFS:
Lf->nlink = (long)r.r_attr.va_nlink;
Lf->nlink_def = 1;
break;
#if solaris >= 100000
case N_NFS4:
Lf->nlink = (long)r4.r_attr.va_nlink;
Lf->nlink_def = 1;
break;
#endif /* solaris>=100000 */
case N_PCFS:
break;
#if defined(HASPROCFS)
case N_PROC:
break;
#endif /* defined(HASPROCFS) */
case N_REGLR:
if (ins) {
Lf->nlink = (long)i.i_nlink;
Lf->nlink_def = 1;
}
break;
case N_SAMFS:
break; /* No more SAM-FS information is available. */
#if solaris >= 110000
case N_SDEV:
if (sdns) {
Lf->nlink = (long)sdva.va_nlink;
Lf->nlink_def = 1;
}
break;
#endif /* solaris>=110000 */
case N_SHARED:
break; /* No more sharedfs information is available. */
case N_STREAM:
break;
case N_TMP:
Lf->nlink = (long)t.tn_attr.va_nlink;
Lf->nlink_def = 1;
break;
#if defined(HASVXFS)
case N_VXFS:
Lf->nlink = vx.nl;
Lf->nlink_def = vx.nl_def;
break;
#endif /* defined(HASVXFS) */
#if defined(HAS_ZFS)
case N_ZFS:
if (zns) {
Lf->nlink = (long)MIN(zn.z_links, UINT32_MAX);
Lf->nlink_def = 1;
}
break;
#endif /* defined(HAS_ZFS) */
}
if (Nlink && Lf->nlink_def && (Lf->nlink < Nlink))
Lf->sf |= SELNLINK;
#if defined(HASVXFS)
/*
* Record a VxFS file.
*/
# if defined(HASVXFSDNLC)
Lf->is_vxfs = (Ntype == N_VXFS) ? 1 : 0;
# endif /* defined(HASVXFSDNLC) */
#endif /* defined(HASVXFS) */
/*
* Record an NFS selection.
*/
if (Fnfs) {
if ((Ntype == N_NFS) || (Ntype == N_NFS4))
Lf->sf |= SELNFS;
}
#if solaris >= 20500
/*
* If this is a Solaris 2.5 and greater autofs entry, save the autonode name
* (less than Solaris 2.6) or fnnode name (Solaris 2.6 and greater).
*/
if (Ntype == N_AUTO && !Namech[0]) {
# if solaris < 20600
if (au.an_name[0])
(void)snpf(Namech, Namechl - 1, "%s", au.an_name);
Namech[Namechl - 1] = '\0';
# else /* solaris>=20600 */
if (fnn.fn_name && (len = fnn.fn_namelen) > 0 && len < (Namechl - 1)) {
if (kread(ctx, (KA_T)fnn.fn_name, Namech, len))
Namech[0] = '\0';
else
Namech[len] = '\0';
}
# endif /* solaris<20600 */
}
/*
* If there is no local virtual file system pointer, or if its directory and
* file system names are NULL, and if there is a namenode, and if we're
* using the device number from it, see if its nm_mountpt vnode pointer
* leads to a local virtual file system structure with non-NULL directory
* and file system names. If it does, switch to that local virtual file
* system pointer.
*/
if (nns && (!vfs || (!vfs->dir && !vfs->fsname)) && devs &&
(dev == nn.nm_vattr.va_fsid) && nn.nm_mountpt) {
if (!readvnode(ctx, (KA_T)nn.nm_mountpt, &fv) && fv.v_vfsp) {
if ((nvfs = readvfs(ctx, (KA_T)fv.v_vfsp, (struct vfs *)NULL,
nn.nm_filevp)) &&
!nvfs->dir) {
(void)completevfs(ctx, nvfs, &dev);
}
# if defined(HASNCACHE)
if (nvfs && nvfs->dir && nvfs->fsname) {
fa = (char *)NULL;
vfs = nvfs;
}
# endif /* defined(HASNCACHE) */
}
}
# if defined(HASNCACHE)
/*
* If there's a namenode and its device and node number match this one,
* use the nm_mountpt's address for name cache lookups.
*/
if (nns && devs && (dev == nn.nm_vattr.va_fsid) && (Lf->inp_ty == 1) &&
(Lf->inode == (INODETYPE)nn.nm_vattr.va_nodeid))
Lf->na = (KA_T)nn.nm_mountpt;
# endif /* defined(HASNCACHE) */
#endif /* solaris>=20500 */
/*
* Save the file system names.
*/
if (vfs) {
Lf->fsdir = vfs->dir;
Lf->fsdev = vfs->fsname;
#if defined(HASMNTSTAT)
Lf->mnt_stat = vfs->mnt_stat;
#endif /* defined(HASMNTSTAT) */
if (!Lf->fsdir && !Lf->fsdev && kvs && fxs) {
/*
* The file system names are unknown.
*
* Set the file system device to the file system type and clear
* the doubtful device numbers.
*/
Lf->fsdev = Fsinfo[fx];
devs = 0;
rdevs = 0;
}
#if defined(HASFSINO)
else
Lf->fs_ino = vfs->fs_ino;
#endif /* defined(HASFSINO) */
}
/*
* Save the device numbers, and their states.
*
* Format the vnode type, and possibly the device name.
*/
switch (type) {
case VNON:
Lf->type = LSOF_FILE_VNODE_VNON;
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
break;
case VREG:
case VDIR:
Lf->type = (type == VREG) ? LSOF_FILE_VNODE_VREG : LSOF_FILE_VNODE_VDIR;
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
break;
case VBLK:
Lf->type = LSOF_FILE_VNODE_VBLK;
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
Ntype = N_BLK;
break;
case VCHR:
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
if (unix_sock) {
Lf->type = LSOF_FILE_UNIX;
break;
}
Lf->type = LSOF_FILE_VNODE_VCHR;
if (Lf->is_stream == 0 && Lf->is_com == 0)
Ntype = N_CHR;
break;
#if solaris >= 20500
case VDOOR:
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
Lf->type = LSOF_FILE_VNODE_VDOOR;
if (dns)
(void)idoorkeep(ctx, &dn);
break;
#endif /* solaris>=20500 */
case VLNK:
Lf->type = LSOF_FILE_VNODE_VLNK;
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
break;
#if solaris >= 100000
case VPORT:
Lf->type = LSOF_FILE_VNODE_VPORT;
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
break;
#endif /* solaris>=100000 */
#if solaris >= 20600
case VPROC:
/*
* The proc file system type is defined when the prnode is read.
*/
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
Lf->type = LSOF_FILE_NONE;
break;
#endif /* solaris>=20600 */
#if defined(HAS_VSOCK)
case VSOCK:
# if solaris >= 20600
if (so.so_family == AF_UNIX) {
Lf->type = LSOF_FILE_UNIX;
if (Funix)
Lf->sf |= SELUNX;
} else {
if (so.so_family == AF_INET) {
# if defined(HASIPv6)
Lf->type = LSOF_FILE_IPV4;
# else /* !defined(HASIPv6) */
Lf->type = LSOF_FILE_INET;
# endif /* defined(HASIPv6) */
(void)snpf(Namech, Namechl - 1, printsockty(so.so_type));
Namech[Namechl - 1] = '\0';
if (TcpStIn || UdpStIn || TcpStXn || UdpStXn)
Lf->sf |= SELEXCLF;
else if (Fnet && (FnetTy != 6))
Lf->sf |= SELNET;
}
# if defined(HASIPv6)
else if (so.so_family == AF_INET6) {
Lf->type = LSOF_FILE_IPV6;
(void)snpf(Namech, Namechl - 1, printsockty(so.so_type));
Namech[Namechl - 1] = '\0';
if (TcpStIn || UdpStIn || TcpStXn || UdpStXn)
Lf->sf |= SELEXCLF;
else if (Fnet && (FnetTy != 4))
Lf->sf |= SELNET;
}
# endif /* defined(HASIPv6) */
else {
Lf->type = LSOF_FILE_SOCKET;
(void)printunkaf(ctx, so.so_family, 0);
ep = endnm(ctx, &sz);
(void)snpf(ep, sz, ", %s", printsockty(so.so_type));
}
}
# endif /* solaris>=20600 */
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
break;
#endif /* defined(HAS_VSOCK) */
case VBAD:
Lf->type = LSOF_FILE_VNODE_VBAD;
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
break;
case VFIFO:
Lf->type = LSOF_FILE_VNODE_VFIFO;
if (!Lf->dev_ch || Lf->dev_ch[0] == '\0') {
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
}
break;
default:
Lf->dev = dev;
Lf->dev_def = devs;
Lf->rdev = rdev;
Lf->rdev_def = rdevs;
Lf->type = LSOF_FILE_UNKNOWN_RAW;
Lf->unknown_file_type_number = type;
}
Lf->ntype = Ntype;
/*
* If this a Solaris common vnode/snode void some information.
*/
if (Lf->is_com)
Lf->sz_def = Lf->inp_ty = 0;
/*
* If a file attach description remains, put it in the NAME column addition.
*/
if (fa)
(void)add_nma(ctx, fa, fal);
#if defined(HASBLKDEV)
/*
* If this is a VBLK file and it's missing an inode number, try to
* supply one.
*/
if ((Lf->inp_ty == 0) && (type == VBLK))
find_bl_ino(ctx);
#endif /* defined(HASBLKDEV) */
/*
* If this is a VCHR file and it's missing an inode number, try to
* supply one.
*/
if ((Lf->inp_ty == 0) && (type == VCHR)) {
find_ch_ino(ctx);
/*
* If the VCHR inode number still isn't known and this is a COMMON
* vnode file or a stream, or if a pseudo node ID lookup has been
* requested, see if an inode number can be derived from a pseudo
* or clone device node.
*
* If it can, save the pseudo or clone device for temporary
* use when searching for a match with a named file argument.
*/
if ((Lf->inp_ty == 0) && (Lf->is_com || Lf->is_stream || pnl) &&
(Clone || Pseudo)) {
if (!sdp) {
if (rdevs || devs) {
if (Lf->is_stream && !pnl)
sdp = finddev(ctx, devs ? &dev : &DevDev,
rdevs ? &rdev : &Lf->dev, LOOKDEV_CLONE);
else
sdp = finddev(ctx, devs ? &dev : &DevDev,
rdevs ? &rdev : &Lf->dev, LOOKDEV_PSEUDO);
if (!sdp)
sdp = finddev(ctx, devs ? &dev : &DevDev,
rdevs ? &rdev : &Lf->dev, LOOKDEV_ALL);
if (sdp) {
if (!rdevs) {
Lf->rdev = Lf->dev;
Lf->rdev_def = rdevs = 1;
}
if (!devs) {
Lf->dev = DevDev;
devs = Lf->dev_def = 1;
}
}
}
} else {
/*
* A local device structure has been located. Make sure
* that it's accompanied by device settings.
*/
if (!devs && vfs) {
dev = Lf->dev = vfs->dev;
devs = Lf->dev_def = 1;
}
if (!rdevs) {
Lf->rdev = rdev = sdp->rdev;
Lf->rdev_def = rdevs = 1;
}
}
if (sdp) {
/*
* Process the local device information.
*/
trdev = sdp->rdev;
Lf->inode = sdp->inode;
Lf->inp_ty = trdevs = 1;
if (!Namech[0] || Lf->is_com) {
(void)snpf(Namech, Namechl - 1, "%s", sdp->name);
Namech[Namechl - 1] = '\0';
}
if (Lf->is_com && !Lf->nma) {
len = (int)strlen("(COMMON)") + 1;
if (!(Lf->nma = (char *)malloc(len))) {
fd_to_string(Lf->fd_type, Lf->fd_num, fd);
(void)fprintf(
stderr,
"%s: no space for (COMMON): PID %d; FD %s\n", Pn,
Lp->pid, fd);
Error(ctx);
}
(void)snpf(Lf->nma, len, "(COMMON)");
}
}
}
}
/*
* Record stream status.
*/
if (Lf->inp_ty == 0 && Lf->is_stream && strcmp(Lf->iproto, "STR") == 0)
Lf->inp_ty = 2;
/*
* Test for specified file.
*/
#if defined(HASPROCFS)
if (Ntype == N_PROC) {
if (Procsrch) {
Procfind = 1;
Lf->sf |= SELNM;
} else {
for (pfi = Procfsid; pfi; pfi = pfi->next) {
if ((pfi->pid && pfi->pid == pids.pid_id)
# if defined(HASPINODEN)
|| (Lf->inp_ty == 1 && Lf->inode == pfi->inode)
# endif /* defined(HASPINODEN) */
) {
pfi->f = 1;
if (!Namech[0]) {
(void)snpf(Namech, Namechl - 1, "%s", pfi->nm);
Namech[Namechl - 1] = '\0';
}
Lf->sf |= SELNM;
break;
}
}
}
} else
#endif /* defined(HASPROCFS) */
{
if (Sfile) {
if (trdevs) {
rdev = Lf->rdev;
Lf->rdev = trdev;
tdef = Lf->rdev_def;
Lf->rdev_def = 1;
}
if (is_file_named(ctx, NULL, Ntype, type, 1))
Lf->sf |= SELNM;
if (trdevs) {
Lf->rdev = rdev;
Lf->rdev_def = tdef;
}
}
}
/*
* Enter name characters.
*/
if (Namech[0])
enter_nm(ctx, Namech);
}
/*
* read_cni() - read common snode information
*/
static int read_cni(struct lsof_context *ctx, /* context */
struct snode *s, /* starting snode */
struct vnode *rv, /* "real" vnode receiver */
struct vnode *v, /* starting vnode */
struct snode *rs, /* "real" snode receiver */
struct dev_info *di, /* dev_info structure receiver */
char *din, /* device info name receiver */
int dinl) /* sizeof(*din) */
{
char tbuf[32];
if (read_nvn(ctx, (KA_T)v->v_data, (KA_T)s->s_commonvp, rv))
return (1);
if (read_nsn(ctx, (KA_T)s->s_commonvp, (KA_T)rv->v_data, rs))
return (1);
*din = '\0';
if (rs->s_dip) {
if (kread(ctx, (KA_T)rs->s_dip, (char *)di, sizeof(struct dev_info))) {
(void)snpf(Namech, Namechl - 1,
"common snode at %s: no dev info: %s",
print_kptr((KA_T)rv->v_data, tbuf, sizeof(tbuf)),
print_kptr((KA_T)rs->s_dip, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
if (di->devi_name &&
kread(ctx, (KA_T)di->devi_name, din, dinl - 1) == 0)
din[dinl - 1] = '\0';
}
return (0);
}
/*
* readinode() - read inode
*/
static int readinode(struct lsof_context *ctx, /* context */
KA_T ia, /* inode kernel address */
struct inode *i) /* inode buffer */
{
if (kread(ctx, (KA_T)ia, (char *)i, sizeof(struct inode))) {
(void)snpf(Namech, Namechl - 1, "can't read inode at %s",
print_kptr((KA_T)ia, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if solaris >= 20500
/*
* read_ndn() - read node's door node
*/
static int read_ndn(struct lsof_context *ctx, /* context */
KA_T na, /* containing vnode's address */
KA_T da, /* door node's address */
struct door_node *dn) /* door node receiver */
{
char tbuf[32];
if (!da || kread(ctx, (KA_T)da, (char *)dn, sizeof(struct door_node))) {
(void)snpf(Namech, Namechl - 1, "vnode at %s: can't read door_node: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(da, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=20500 */
/*
* read_mi() - read stream's module information
*/
static void read_mi(struct lsof_context *ctx, /* context */
KA_T s, /* kernel stream pointer address */
dev_t *rdev, /* raw device pointer */
caddr_t so, /* so_so return (Solaris) */
int *so_st, /* so_so status */
KA_T *so_ad, /* so_so addresses */
struct l_dev **sdp) /* returned device pointer */
{
struct l_dev *dp;
int i, j, k, nl;
KA_T ka;
struct module_info mi;
char mn[STRNML];
struct stdata sd;
struct queue q;
struct qinit qi;
KA_T qp;
/*
* If there is no stream pointer, or we can't read the stream head,
* return.
*/
if (!s)
return;
if (kread(ctx, (KA_T)s, (char *)&sd, sizeof(sd))) {
(void)snpf(Namech, Namechl - 1, "can't read stream head: %s",
print_kptr(s, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return;
}
/*
* Follow the stream head to each of its queue structures, retrieving the
* module names from each queue's q_info->qi_minfo->mi_idname chain of
* structures. Separate each additional name from the previous one with
* "->".
*
* Ignore failures to read all but queue structure chain entries.
*
* Ignore module names that end in "head".
*/
k = 0;
Namech[0] = '\0';
if (!(dp = finddev(ctx, &DevDev, rdev, LOOKDEV_CLONE)))
dp = finddev(ctx, &DevDev, rdev, LOOKDEV_ALL);
if (dp) {
(void)snpf(Namech, Namechl - 1, "%s", dp->name);
Namech[Namechl - 1] = '\0';
k = (int)strlen(Namech);
*sdp = dp;
} else
(void)snpf(Lf->iproto, sizeof(Lf->iproto), "STR");
nl = sizeof(mn) - 1;
mn[nl] = '\0';
qp = (KA_T)sd.sd_wrq;
for (i = 0; qp && i < 20; i++, qp = (KA_T)q.q_next) {
if (!qp || kread(ctx, qp, (char *)&q, sizeof(q)))
break;
if ((ka = (KA_T)q.q_qinfo) == (KA_T)NULL ||
kread(ctx, ka, (char *)&qi, sizeof(qi)))
continue;
if ((ka = (KA_T)qi.qi_minfo) == (KA_T)NULL ||
kread(ctx, ka, (char *)&mi, sizeof(mi)))
continue;
if ((ka = (KA_T)mi.mi_idname) == (KA_T)NULL || kread(ctx, ka, mn, nl))
continue;
if ((j = (int)strlen(mn)) < 1)
continue;
if (j >= 4 && strcmp(&mn[j - 4], "head") == 0)
continue;
#if solaris < 100000
if (strcmp(mn, "sockmod") == 0) {
/*
* Save the Solaris sockmod device and inode numbers.
*/
if (so) {
struct so_so s;
if (!kread(ctx, (KA_T)q.q_ptr, (char *)&s, sizeof(s))) {
if (!(*so_st))
so_ad[0] = (KA_T)q.q_ptr;
else
so_ad[1] = (KA_T)q.q_ptr;
(void)savesockmod(&s, (struct so_so *)so, so_st);
}
}
}
#endif /* solaris<100000 */
if (k) {
if ((k + 2) > (Namechl - 1))
break;
(void)snpf(&Namech[k], Namechl - k, "->");
k += 2;
}
if ((k + j) > (Namechl - 1))
break;
(void)snpf(&Namech[k], Namechl - k, "%s", mn);
k += j;
}
}
#if solaris >= 20500
/*
* read_nan(na, ca, cn) - read node's autofs node
*/
static int read_nan(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T aa, /* autofs node address */
# if solaris < 20600
struct autonode *rn) /* autofs node receiver */
# else /* solaris>=20600 */
struct fnnode *rn) /* autofs node receiver */
# endif /* solaris<20600 */
{
char tbuf[32];
# if solaris < 20600
if (!aa || kread(ctx, (KA_T)aa, (char *)rn, sizeof(struct autonode)))
# else /* solaris>=20600 */
if (!aa || kread(ctx, (KA_T)aa, (char *)rn, sizeof(struct fnnode)))
# endif /* solaris<20600 */
{
(void)snpf(Namech, Namechl - 1,
# if solaris < 20600
"node at %s: can't read autonode: %s",
# else /* solaris>=20600 */
"node at %s: can't read fnnode: %s",
# endif /* solaris<20600 */
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(aa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=20500 */
#if defined(HASCACHEFS)
/*
* read_ncn(na, ca, cn) - read node's cache node
*/
static int read_ncn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ca, /* cache node address */
struct cnode *cn) /* cache node receiver */
{
char tbuf[32];
if (!ca || kread(ctx, (KA_T)ca, (char *)cn, sizeof(struct cnode))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read cnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ca, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* defined(HASCACHEFS) */
#if solaris >= 100000
/*
* read_nctfsn(ty, na, ca, cn) - read node's cache node
*/
static int read_nctfsn(struct lsof_context *ctx, /* context */
int ty, /* node type -- i.e., N_CTFS* */
KA_T na, /* containing node's address */
KA_T ca, /* cache node address */
char *cn) /* CTFS node receiver */
{
char *cp, *nm, tbuf[32];
READLEN_T sz;
switch (ty) {
case N_CTFSADIR:
nm = "ADIR";
sz = (READLEN_T)sizeof(ctfs_adirnode_t);
break;
case N_CTFSBUND:
nm = "BUND";
sz = (READLEN_T)sizeof(ctfs_bunode_t);
break;
case N_CTFSCDIR:
nm = "CDIR";
sz = (READLEN_T)sizeof(ctfs_cdirnode_t);
break;
case N_CTFSCTL:
nm = "CTL";
sz = (READLEN_T)sizeof(ctfs_ctlnode_t);
break;
case N_CTFSEVT:
nm = "EVT";
sz = (READLEN_T)sizeof(ctfs_evnode_t);
break;
case N_CTFSLATE:
nm = "LATE";
sz = (READLEN_T)sizeof(ctfs_latenode_t);
break;
case N_CTFSROOT:
nm = "ROOT";
sz = (READLEN_T)sizeof(ctfs_rootnode_t);
break;
case N_CTFSSTAT:
nm = "STAT";
sz = (READLEN_T)sizeof(ctfs_ctlnode_t);
break;
case N_CTFSSYM:
nm = "SYM";
sz = (READLEN_T)sizeof(ctfs_symnode_t);
break;
case N_CTFSTDIR:
nm = "TDIR";
sz = (READLEN_T)sizeof(ctfs_tdirnode_t);
break;
case N_CTFSTMPL:
nm = "TMPL";
sz = (READLEN_T)sizeof(ctfs_tmplnode_t);
break;
default:
(void)snpf(Namech, Namechl - 1, "unknown CTFS node type: %d", ty);
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
if (!ca || kread(ctx, (KA_T)ca, cn, sz)) {
(void)snpf(Namech, Namechl - 1,
"node at %s: can't read CTFS %s node: %s",
print_kptr(na, tbuf, sizeof(tbuf)), nm,
print_kptr(ca, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=100000 */
/*
* read_nfn() - read node's fifonode
*/
static int read_nfn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T fa, /* fifonode address */
struct fifonode *f) /* fifonode receiver */
{
char tbuf[32];
if (!fa || readfifonode(ctx, fa, f)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read fifonode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(fa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
/*
* read_nhn() - read node's High Sierra node
*/
static int read_nhn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ha, /* hsnode address */
struct hsnode *h) /* hsnode receiver */
{
char tbuf[32];
if (!ha || readhsnode(ctx, ha, h)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read hsnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ha, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
/*
* read_nin() - read node's inode
*/
static int read_nin(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ia, /* kernel inode address */
struct inode *i) /* inode receiver */
{
char tbuf[32];
if (!ia || readinode(ctx, ia, i)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read inode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ia, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
/*
* read_nln(na, la, ln) - read node's loopback node
*/
static int read_nln(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T la, /* loopback node address */
struct lnode *ln) /* loopback node receiver */
{
char tbuf[32];
if (!la || kread(ctx, (KA_T)la, (char *)ln, sizeof(struct lnode))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read lnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(la, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
/*
* read_nnn() - read node's namenode
*/
static int read_nnn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T nna, /* namenode address */
struct namenode *nn) /* namenode receiver */
{
char tbuf[32];
if (!nna || kread(ctx, (KA_T)nna, (char *)nn, sizeof(struct namenode))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read namenode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(nna, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
/*
* read_nmn() - read node's mvfsnode
*/
static int read_nmn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ma, /* kernel mvfsnode address */
struct mvfsnode *m) /* mvfsnode receiver */
{
char tbuf[32];
if (!ma || kread(ctx, (KA_T)ma, (char *)m, sizeof(struct mvfsnode))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read mvfsnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ma, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if defined(HASPROCFS)
/*
* read_npi() - read node's /proc file system information
*/
static int read_npi(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
struct vnode *v, /* containing vnode */
struct pid *pids) /* pid structure receiver */
{
struct as as;
struct proc p;
struct prnode pr;
char tbuf[32];
# if solaris >= 20600
prcommon_t pc, ppc;
int pcs, ppcs, prpcs, prppcs;
struct proc pp;
kthread_t thread;
pid_t prpid;
id_t prtid;
char *ty = (char *)NULL;
# endif /* solaris>=20600 */
if (!v->v_data || kread(ctx, (KA_T)v->v_data, (char *)&pr, sizeof(pr))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read prnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr((KA_T)v->v_data, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
# if solaris < 20600
/*
* For Solaris < 2.6:
* * Read the proc structure, get the process size and PID;
* * Return the PID;
* * Enter a name, constructed from the file system and PID;
* * Enter an inode number, constructed from the PID.
*/
if (!pr.pr_proc) {
if (v->v_type == VDIR) {
(void)snpf(Namech, Namechl - 1, "/%s", HASPROCFS);
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
Lf->inode = (INODETYPE)PR_ROOTINO;
Lf->inp_ty = 1;
} else {
(void)snpf(Namech, Namechl - 1, "/%s/", HASPROCFS);
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
Lf->inp_ty = 0;
}
return (0);
}
if (kread(ctx, (KA_T)pr.pr_proc, (char *)&p, sizeof(p))) {
(void)snpf(Namech, Namechl - 1, "prnode at %s: can't read proc: %s",
print_kptr((KA_T)v->v_data, tbuf, sizeof(tbuf)),
print_kptr((KA_T)pr.pr_proc, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
if (p.p_as && !kread(ctx, (KA_T)p.p_as, (char *)&as, sizeof(as))) {
Lf->sz = (SZOFFTYPE)as.a_size;
Lf->sz_def = 1;
}
if (!p.p_pidp ||
kread(ctx, (KA_T)p.p_pidp, (char *)pids, sizeof(struct pid))) {
(void)snpf(Namech, Namechl - 1, "proc struct at %s: can't read pid: %s",
print_kptr((KA_T)pr.pr_proc, tbuf, sizeof(tbuf)),
print_kptr((KA_T)p.p_pidp, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
(void)snpf(Namech, Namechl, "/%s/%d", HASPROCFS, (int)pids->pid_id);
Namech[Namechl - 1] = '\0';
Lf->inode = (INODETYPE)ptoi(pids->pid_id);
Lf->inp_ty = 1;
# else /* solaris>=20600 */
/*
* Enter the >= Solaris 2.6 inode number.
*/
Lf->inode = (INODETYPE)pr.pr_ino;
Lf->inp_ty = 1;
/*
* Read the >= Solaris 2.6 prnode common structures.
*
* Return the PID number.
*
* Identify the lwp PID (the thread ID).
*/
if (pr.pr_common &&
kread(ctx, (KA_T)pr.pr_common, (char *)&pc, sizeof(pc)) == 0) {
pcs = 1;
if (pc.prc_proc &&
kread(ctx, (KA_T)pc.prc_proc, (char *)&p, sizeof(p)) == 0)
prpcs = 1;
else
prpcs = 0;
} else
pcs = prpcs = 0;
if (pr.pr_pcommon &&
kread(ctx, (KA_T)pr.pr_pcommon, (char *)&ppc, sizeof(ppc)) == 0) {
ppcs = 1;
if (ppc.prc_proc &&
kread(ctx, (KA_T)ppc.prc_proc, (char *)&pp, sizeof(pp)) == 0)
prppcs = 1;
else
prppcs = 0;
} else
ppcs = prppcs = 0;
if (prpcs && p.p_pidp &&
kread(ctx, (KA_T)p.p_pidp, (char *)pids, sizeof(struct pid)) == 0)
prpid = pids->pid_id;
else if (prppcs && pp.p_pidp &&
kread(ctx, (KA_T)pp.p_pidp, (char *)pids, sizeof(struct pid)) == 0)
prpid = pids->pid_id;
else
pids->pid_id = prpid = (pid_t)0;
if (pcs && pc.prc_thread &&
kread(ctx, (KA_T)pc.prc_thread, (char *)&thread, sizeof(kthread_t)) ==
0)
prtid = thread.t_tid;
else if (ppcs && ppc.prc_thread &&
kread(ctx, (KA_T)ppc.prc_thread, (char *)&thread,
sizeof(kthread_t)) == 0)
prtid = thread.t_tid;
else
prtid = (id_t)0;
/*
* Identify the Solaris 2.6 /proc file system name, file size, and file
* type.
*/
switch (pr.pr_type) {
case PR_PROCDIR:
(void)snpf(Namech, Namechl - 1, "/%s", HASPROCFS);
Lf->type = LSOF_FILE_PROC_DIR;
break;
case PR_PIDDIR:
(void)snpf(Namech, Namechl - 1, "/%s/%d", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_DIR;
break;
case PR_AS:
(void)snpf(Namech, Namechl - 1, "/%s/%d/as", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_AS;
if (prpcs &&
kread(ctx, (KA_T)pc.prc_proc, (char *)&p, sizeof(p)) == 0 &&
p.p_as && kread(ctx, (KA_T)p.p_as, (char *)&as, sizeof(as)) == 0) {
Lf->sz = (SZOFFTYPE)as.a_size;
Lf->sz_def = 1;
}
break;
case PR_CTL:
(void)snpf(Namech, Namechl - 1, "/%s/%d/ctl", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_CTRL;
break;
case PR_STATUS:
(void)snpf(Namech, Namechl - 1, "/%s/%d/status", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_STATUS;
break;
case PR_LSTATUS:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lstatus", HASPROCFS,
(int)prpid);
Lf->type = LSOF_FILE_PROC_LSTATUS;
break;
case PR_PSINFO:
(void)snpf(Namech, Namechl - 1, "/%s/%d/psinfo", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_PSINFO;
break;
case PR_LPSINFO:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lpsinfo", HASPROCFS,
(int)prpid);
Lf->type = LSOF_FILE_PROC_LPS_INFO;
break;
case PR_MAP:
(void)snpf(Namech, Namechl - 1, "/%s/%d/map", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_MAP;
break;
case PR_RMAP:
(void)snpf(Namech, Namechl - 1, "/%s/%d/rmap", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_RMAP;
break;
case PR_XMAP:
(void)snpf(Namech, Namechl - 1, "/%s/%d/xmap", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_XMAP;
break;
case PR_CRED:
(void)snpf(Namech, Namechl - 1, "/%s/%d/cred", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_CRED;
break;
case PR_SIGACT:
(void)snpf(Namech, Namechl - 1, "/%s/%d/sigact", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_SIGACT;
break;
case PR_AUXV:
(void)snpf(Namech, Namechl - 1, "/%s/%d/auxv", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_AUXV;
break;
# if defined(HASPR_LDT)
case PR_LDT:
(void)snpf(Namech, Namechl - 1, "/%s/%d/ldt", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_LDT;
break;
# endif /* defined(HASPR_LDT) */
case PR_USAGE:
(void)snpf(Namech, Namechl - 1, "/%s/%d/usage", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_USAGE;
break;
case PR_LUSAGE:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lusage", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_LUSAGE;
break;
case PR_PAGEDATA:
(void)snpf(Namech, Namechl - 1, "/%s/%d/pagedata", HASPROCFS,
(int)prpid);
Lf->type = LSOF_FILE_PROC_PAGE_DATA;
break;
case PR_WATCH:
(void)snpf(Namech, Namechl - 1, "/%s/%d/watch", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_WATCH;
break;
case PR_CURDIR:
(void)snpf(Namech, Namechl - 1, "/%s/%d/cwd", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_CWD;
break;
case PR_ROOTDIR:
(void)snpf(Namech, Namechl - 1, "/%s/%d/root", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_ROOT;
break;
case PR_FDDIR:
(void)snpf(Namech, Namechl - 1, "/%s/%d/fd", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_FD_DIR;
break;
case PR_FD:
(void)snpf(Namech, Namechl - 1, "/%s/%d/fd/%d", HASPROCFS, (int)prpid,
pr.pr_index);
Lf->type = LSOF_FILE_PROC_FD;
break;
case PR_OBJECTDIR:
(void)snpf(Namech, Namechl - 1, "/%s/%d/object", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_OBJ_DIR;
break;
case PR_OBJECT:
(void)snpf(Namech, Namechl - 1, "/%s/%d/object/", HASPROCFS,
(int)prpid);
Lf->type = LSOF_FILE_PROC_OBJ;
break;
case PR_LWPDIR:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lpw", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_LWP_DIR;
break;
case PR_LWPIDDIR:
(void)snpf(Namech, Namechl, "/%s/%d/lwp/%d", HASPROCFS, (int)prpid,
(int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_DIR;
break;
case PR_LWPCTL:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lwp/%d/lwpctl", HASPROCFS,
(int)prpid, (int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_CTL;
break;
case PR_LWPSTATUS:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lwp/%d/lwpstatus", HASPROCFS,
(int)prpid, (int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_STATUS;
break;
case PR_LWPSINFO:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lwp/%d/lwpsinfo", HASPROCFS,
(int)prpid, (int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_SINFO;
break;
case PR_LWPUSAGE:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lwp/%d/lwpusage", HASPROCFS,
(int)prpid, (int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_USAGE;
break;
case PR_XREGS:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lwp/%d/xregs", HASPROCFS,
(int)prpid, (int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_XREGS;
break;
# if defined(HASPR_GWINDOWS)
case PR_GWINDOWS:
(void)snpf(Namech, Namechl - 1, "/%s/%d/lwp/%d/gwindows", HASPROCFS,
(int)prpid, (int)prtid);
Lf->type = LSOF_FILE_PROC_LWP_GWINDOWS;
break;
# endif /* defined(HASPR_GWINDOWS) */
# if defined(PR_PIDFILE)
case PR_PIDFILE:
(void)snpf(Namech, Namechl - 1, "/%s/%d", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_OLD_PID;
break;
# endif /* defined(PR_PIDFILE) */
# if defined(PR_LWPIDFILE)
case PR_LWPIDFILE:
(void)snpf(Namech, Namechl - 1, "/%s/%d", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_OLD_LWP;
break;
# endif /* defined(PR_LWPIDFILE) */
case PR_OPAGEDATA:
(void)snpf(Namech, Namechl - 1, "/%s/%d", HASPROCFS, (int)prpid);
Lf->type = LSOF_FILE_PROC_OLD_PAGE;
break;
default:
Lf->type = LSOF_FILE_UNKNOWN_RAW;
Lf->unknown_file_type_number = pr.pr_type;
}
/*
* Record the Solaris 2.6 /proc file system inode number.
*/
Lf->inode = (INODETYPE)pr.pr_ino;
Lf->inp_ty = 1;
# endif /* solaris<20600 */
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (0);
}
#endif /* defined(HASPROCFS) */
/*
* read_npn() - read node's pcnode
*/
static int read_npn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T pa, /* pcnode address */
struct pcnode *p) /* pcnode receiver */
{
char tbuf[32];
if (!pa || kread(ctx, pa, (char *)p, sizeof(struct pcnode))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read pcnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(pa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if solaris >= 100000
/*
* read_nprtn() - read node's port node
*/
static int read_nprtn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T pa, /* port node address */
port_t *p) /* port node receiver */
{
char tbuf[32];
if (!pa || kread(ctx, pa, (char *)p, sizeof(port_t))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read port node: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(pa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=100000 */
/*
* read_nrn() - read node's rnode
*/
static int read_nrn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ra, /* rnode address */
struct rnode *r) /* rnode receiver */
{
char tbuf[32];
if (!ra || readrnode(ctx, ra, r)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read rnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ra, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if solaris >= 100000
/*
* read_nrn4() - read node's rnode4
*/
static int read_nrn4(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ra, /* rnode address */
struct rnode4 *r) /* rnode receiver */
{
char tbuf[32];
if (!ra || kread(ctx, (KA_T)ra, (char *)r, sizeof(struct rnode4))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read rnode4: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ra, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=100000 */
#if solaris >= 110000
/*
* read_nsdn() - read node's sdev_node
*/
static int read_nsdn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T sa, /* sdev_node address */
struct sdev_node *sdn, /* sdev_node receiver */
struct vattr *sdva) /* sdev_node's vattr receiver */
{
KA_T va;
char tbuf[32], tbuf1[32];
if (!sa || kread(ctx, (KA_T)sa, (char *)sdn, sizeof(struct sdev_node))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read sdev_node: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(sa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
if (!(va = (KA_T)sdn->sdev_attr) ||
kread(ctx, va, (char *)sdva, sizeof(struct vattr))) {
(void)snpf(Namech, Namechl - 1,
"node at %s; sdev_node at %s: can't read vattr: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(sa, tbuf1, sizeof(tbuf1)),
print_kptr(va, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=110000 */
#if solaris >= 20600
/*
* read_nson() - read node's sonode
*/
static int read_nson(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T sa, /* sonode address */
struct sonode *sn) /* sonode receiver */
{
char tbuf[32];
if (!sa || kread(ctx, (KA_T)sa, (char *)sn, sizeof(struct sonode))) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read sonode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(sa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=20600 */
/*
* read_nsn() - read node's snode
*/
static int read_nsn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T sa, /* snode address */
struct snode *s) /* snode receiver */
{
char tbuf[32];
if (!sa || readsnode(ctx, sa, s)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read snode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(sa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if solaris >= 110000
/*
* read_nsti() - read socket node's info
*/
static int read_nsti(struct lsof_context *ctx, /* context */
struct sonode *so, /* socket's sonode */
sotpi_info_t *stpi) /* local socket info receiver */
{
char tbuf[32];
(void)CTF_init(ctx, &Sockfs_ctfs, SOCKFS_MOD_FORMAT, Sockfs_requests);
if (!so || !so->so_priv ||
CTF_MEMBER_READ(so->so_priv, stpi, sotpi_info_members, sti_dev) ||
CTF_MEMBER_READ(so->so_priv, stpi, sotpi_info_members, sti_laddr) ||
CTF_MEMBER_READ(so->so_priv, stpi, sotpi_info_members, sti_faddr) ||
CTF_MEMBER_READ(so->so_priv, stpi, sotpi_info_members, sti_ux_laddr) ||
CTF_MEMBER_READ(so->so_priv, stpi, sotpi_info_members, sti_ux_faddr) ||
CTF_MEMBER_READ(so->so_priv, stpi, sotpi_info_members, sti_serv_type)) {
(void)snpf(Namech, Namechl - 1, "sonode at %s: can't read so_priv: %s",
print_kptr((KA_T)so, tbuf, sizeof(tbuf)),
print_kptr((KA_T)so->so_priv, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* solaris>=110000 */
/*
* read_ntn() - read node's tmpnode
*/
static int read_ntn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T ta, /* tmpnode address */
struct tmpnode *t) /* tmpnode receiver */
{
char tbuf[32];
if (!ta || readtnode(ctx, ta, t)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read tnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(ta, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if solaris >= 20600
/*
* read_nusa() - read sondode's UNIX socket address
*/
static int read_nusa(struct lsof_context *ctx, /* context */
struct soaddr *so, /* kernel socket info structure */
struct sockaddr_un *ua) /* local sockaddr_un address */
{
KA_T a;
int len;
int min = offsetof(struct sockaddr_un, sun_path);
ua->sun_path[0] = '\0';
if (!(a = (KA_T)so->soa_sa) || (len = so->soa_len) < (min + 2) ||
len > (int)sizeof(struct sockaddr_un) ||
kread(ctx, a, (char *)ua, len) || ua->sun_family != AF_UNIX)
return (0);
len -= min;
if (len >= sizeof(ua->sun_path))
len = sizeof(ua->sun_path) - 1;
ua->sun_path[len] = '\0';
return ((int)strlen(ua->sun_path));
}
#endif /* solaris>=20600 */
/*
* read_nvn() - read node's vnode
*/
static int read_nvn(struct lsof_context *ctx, /* context */
KA_T na, /* node's address */
KA_T va, /* vnode address */
struct vnode *v) /* vnode receiver */
{
char tbuf[32];
if (readvnode(ctx, va, v)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read real vnode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(va, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#if defined(HAS_ZFS)
/*
* read_nzn() - read node's ZFS node
*/
static int read_nzn(struct lsof_context *ctx, /* context */
KA_T na, /* containing node's address */
KA_T nza, /* znode address */
znode_t *zn) /* znode receiver */
{
int err = 0; /* error flag */
CTF_member_t *mp; /* member pointer */
char tbuf[32]; /* temporary buffer */
znode_phys_t zp; /* physical znode */
(void)CTF_init(ctx, &ZFS_ctfs, ZFS_MOD_FORMAT, ZFS_requests);
if (!nza || CTF_MEMBER_READ(nza, zn, znode_members, z_zfsvfs) ||
CTF_MEMBER_READ(nza, zn, znode_members, z_vnode) ||
CTF_MEMBER_READ(nza, zn, znode_members, z_id) ||
CTF_MEMBER_READ(nza, zn, znode_members, z_phys) ||
CTF_MEMBER_READ(nza, zn, znode_members, z_links) ||
CTF_MEMBER_READ(nza, zn, znode_members, z_size)) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read znode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(nza, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
/*
* If the physical znode pointer is defined, read the physizal znode
* and propagate its values to the znode.
*/
if (znode_members[MX_z_phys].m_offset != CTF_MEMBER_UNDEF) {
err = read_nznp(ctx, nza, (KA_T)zn->z_phys, &zp);
if (!err) {
zn->z_links = zp.zp_links;
zn->z_size = zp.zp_size;
}
} else {
/*
* Make sure z_link and z_size are defined when z_phys isn't.
*/
if (znode_members[MX_z_links].m_offset == CTF_MEMBER_UNDEF) {
(void)snpf(Namech, Namechl - 1,
"node at %s: can't read z_links: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(nza, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
err = 1;
}
if (znode_members[MX_z_size].m_offset == CTF_MEMBER_UNDEF) {
(void)snpf(Namech, Namechl - 1, "node at %s: can't read z_size: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(nza, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
err = 1;
}
}
return (err);
}
/*
* read_nznp() - read znode's persistent znode
*/
static int read_nznp(struct lsof_context *ctx, /* context */
KA_T nza, /* containing znode's address */
KA_T nzpa, /* persistent znode address */
znode_phys_t *zp) /* persistent znode receiver */
{
char tbuf[32];
(void)CTF_init(ctx, &ZFS_ctfs, ZFS_MOD_FORMAT, ZFS_requests);
if (!nzpa || CTF_MEMBER_READ(nzpa, zp, znode_phys_members, zp_size) ||
CTF_MEMBER_READ(nzpa, zp, znode_phys_members, zp_links)) {
(void)snpf(Namech, Namechl - 1,
"znode at %s: "
"can't read znode_phys: %s",
print_kptr(nza, tbuf, sizeof(tbuf)),
print_kptr(nzpa, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
/*
* read_nzvfs() - read znode's associated vfs
*/
static int read_nzvfs(struct lsof_context *ctx, /* context */
KA_T nza, /* containing znode's address */
KA_T nzva, /* associated vfs address */
zfsvfs_t *zv) /* associated vfs receiver */
{
char tbuf[32];
(void)CTF_init(ctx, &ZFS_ctfs, ZFS_MOD_FORMAT, ZFS_requests);
if (!nzva || CTF_MEMBER_READ(nzva, zv, zfsvfs_members, z_vfs)) {
(void)snpf(Namech, Namechl - 1, "znode at %s: can't read zfsvfs: %s",
print_kptr(nza, tbuf, sizeof(tbuf)),
print_kptr(nzva, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
return (0);
}
#endif /* defined(HAS_ZFS) */
#if solaris < 100000
/*
* savesockmod() - save addresses from sockmod so_so structure
*/
static void
savesockmod(struct so_so *so, /* new so_so structure pointer */
struct so_so *sop, /* previous so_so structure pointer */
int *so_st) /* status of *sop (0 if not loaded) */
{
# if solaris < 20500
dev_t d1, d2, d3;
# endif /* solaris<20500 */
# define luxadr lux_dev.addr.tu_addr
# define luxdev lux_dev.addr.tu_addr.dev
# define luxino lux_dev.addr.tu_addr.ino
# define ruxadr rux_dev.addr.tu_addr
# define ruxdev rux_dev.addr.tu_addr.dev
# define ruxino rux_dev.addr.tu_addr.ino
# if solaris < 20500
/*
* If either address in the new structure is missing a device number, clear
* its corresponding inode number. Then sort the inode-less device numbers.
*/
if (!so->luxdev)
so->luxino = (ino_t)0;
if (!so->ruxdev)
so->ruxino = (ino_t)0;
if (!so->luxino && !so->ruxino) {
if (so->luxdev > so->ruxdev) {
d2 = so->luxdev;
d1 = so->luxdev = so->ruxdev;
so->ruxdev = d2;
} else {
d1 = so->luxdev;
d2 = so->ruxdev;
}
} else
d1 = d2 = (dev_t)0;
/*
* If the previous structure hasn't been loaded, save the new one in it with
* adjusted or sorted addresses.
*/
if (!*so_st) {
if (so->luxdev && so->luxino) {
*sop = *so;
sop->ruxdev = (dev_t)0;
sop->ruxino = (ino_t)0;
*so_st = 1;
return;
}
if (so->ruxdev && so->ruxino) {
*sop = *so;
sop->luxadr = sop->ruxadr;
sop->ruxdev = (dev_t)0;
sop->ruxino = (ino_t)0;
*so_st = 1;
return;
}
*sop = *so;
*so_st = 1;
return;
}
/*
* See if the new sockmod addresses need to be merged with the previous
* ones:
*
* * Don't merge if the previous so_so structure's lux_dev has a non-
* zero device and a non-zero inode number.
*
* * If either of the device/inode pairs in the new structure is non-
* zero, propagate them to the previous so_so structure.
*
* * Don't merge if the both device numbers in the new structure are
* zero.
*/
if (sop->luxdev && sop->luxino)
return;
if (so->luxdev && so->luxino) {
sop->luxadr = so->luxadr;
sop->ruxdev = (dev_t)0;
sop->ruxino = (ino_t)0;
return;
}
if (so->ruxdev && so->ruxino) {
sop->luxadr = so->ruxadr;
sop->ruxdev = (dev_t)0;
sop->ruxino = (ino_t)0;
return;
}
if (!so->luxdev && !so->ruxdev)
return;
/*
* Check the previous structure's device numbers:
*
* * If both are zero, replace the previous structure with the new one.
*
* * Choose the minimum and maximum non-zero device numbers contained in
* either structure.
*/
if (!sop->luxdev && !sop->ruxdev) {
*sop = *so;
return;
}
if (!sop->luxdev && (d1 || d2)) {
if (d1) {
sop->luxdev = d1;
d1 = (dev_t)0;
} else {
sop->luxdev = d2;
d2 = (dev_t)0;
}
if (sop->luxdev > sop->ruxdev) {
d3 = sop->luxdev;
sop->luxdev = sop->ruxdev;
sop->ruxdev = d3;
}
}
if (!sop->ruxdev && (d1 || d2)) {
if (d1) {
sop->ruxdev = d1;
d1 = (dev_t)0;
} else {
sop->ruxdev = d2;
d2 = (dev_t)0;
}
if (sop->luxdev > sop->ruxdev) {
d3 = sop->luxdev;
sop->luxdev = sop->ruxdev;
sop->ruxdev = d3;
}
}
if (sop->luxdev && sop->ruxdev) {
if (d1) {
if (d1 < sop->luxdev)
sop->luxdev = d1;
else if (d1 > sop->ruxdev)
sop->ruxdev = d1;
}
if (d2) {
if (d2 < sop->luxdev)
sop->luxdev = d2;
else if (d2 > sop->ruxdev)
sop->ruxdev = d2;
}
}
# else /* solaris>=20500 */
/*
* Save the first sockmod structure.
*/
if (!*so_st) {
*so_st = 1;
*sop = *so;
}
# endif /* solaris<20500 */
}
#endif /* solaris<100000 */
/*
* vop2ty() - convert vnode operation switch address to internal type
*/
int vop2ty(struct lsof_context *ctx, /* context */
struct vnode *vp, /* local vnode pointer */
int fx) /* file system index (-1 if none) */
{
int h;
register int i;
KA_T ka;
int nty;
v_optab_t *nv, *v, *vt;
#if defined(HAS_AFS)
static int afs = 0; /* afs test status: -1 = no AFS
* 0 = not tested
* 1 = AFS */
#endif /* defined(HAS_AFS) */
/*
* Locate the node type by hashing the vnode's v_op address into the
* Voptab[].
*/
if (!(ka = (KA_T)vp->v_op))
return (-1);
h = HASHVOP(ka);
for (v = Voptab[h]; v; v = v->next) {
if (ka == v->v_op)
break;
}
if (!v) {
/*
* If there's no entry in the Voptab[] for the v_op address, see if
* an entry can be found via the file system type and FxToVoptab[].
*/
if ((fx >= 0) && (fx < Fsinfomax) && (v = FxToVoptab[fx])) {
/*
* There's an FxToVoptab[] mapping, so add an entry to Voptab[]
* for the v_op address.
*/
if (!(nv = (v_optab_t *)malloc((MALLOC_S)sizeof(v_optab_t)))) {
(void)fprintf(stderr, "%s: can't add \"%s\" to Voptab\n", Pn,
Fsinfo[fx]);
Error(ctx);
}
*nv = *v;
nv->v_op = ka;
h = HASHVOP(ka);
nv->next = Voptab[h];
Voptab[h] = v = nv;
}
}
if (!v)
return (-1);
#if defined(HAS_AFS)
/*
* Do special AFS checks.
*/
if (v->nty == N_AFS) {
if (vp->v_data || !vp->v_vfsp)
return (-1);
switch (afs) {
case -1:
return (-1);
case 0:
if (!hasAFS(vp)) {
afs = -1;
return (-1);
}
afs = 1;
return (N_AFS);
case 1:
if ((KA_T)vp->v_vfsp == AFSVfsp)
return (N_AFS);
}
return (-1);
}
#endif /* defined(HAS_AFS) */
return (v->nty);
}
#if solaris >= 100000
/*
* read_ndvn() -- read node's dv_node
*/
static int read_ndvn(struct lsof_context *ctx, /* context */
KA_T na, /* containing vnode's address */
KA_T da, /* containing vnode's v_data */
struct dv_node *dv, /* dv_node receiver */
dev_t *dev, /* underlying file system device
* number receptor */
unsigned char *devs) /* status of *dev */
{
struct vnode rv;
struct snode s;
char tbuf[32];
struct vfs v;
/*
* Read the snode.
*/
if (!da || kread(ctx, (KA_T)da, (char *)&s, sizeof(s))) {
(void)snpf(Namech, Namechl - 1,
"dv_node vnode at %s: can't read snode: %s",
print_kptr(na, tbuf, sizeof(tbuf)),
print_kptr(da, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
/*
* Read the snode's real vnode.
*/
if (!s.s_realvp ||
kread(ctx, (KA_T)s.s_realvp, (char *)&rv, sizeof(struct dv_node))) {
(void)snpf(Namech, Namechl - 1,
"dv_node snode at %s: can't read real vnode: %s",
print_kptr(da, tbuf, sizeof(tbuf)),
print_kptr((KA_T)s.s_realvp, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
/*
* Read the real vnode's dv_node.
*/
if (!rv.v_data || kread(ctx, (KA_T)rv.v_data, (char *)dv, sizeof(rv))) {
(void)snpf(Namech, Namechl - 1,
"dv_node real vnode at %s: can't read dv_node: %s",
print_kptr((KA_T)s.s_realvp, tbuf, sizeof(tbuf)),
print_kptr((KA_T)rv.v_data, (char *)NULL, 0));
Namech[Namechl - 1] = '\0';
enter_nm(ctx, Namech);
return (1);
}
/*
* Return the device number of the underlying file system, if possible.
*/
if (rv.v_vfsp && !kread(ctx, (KA_T)rv.v_vfsp, (char *)&v, sizeof(v))) {
*dev = v.vfs_dev;
*devs = 1;
}
return (0);
}
#endif /* solaris<100000 */
|