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
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
|
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
default: all
include Makefile.s10
# Build everything in parallel; use .WAIT for dependencies
.PARALLEL:
SUBDIRS = librtld_db s10_npreload s10_brand s10_support s10_replacefile \
zone cmd
MSGSUBDIRS = s10_support zone
all : TARGET= all
install : TARGET= install
clean : TARGET= clean
clobber : TARGET= clobber
_msg : TARGET= _msg
.KEEP_STATE:
all install clean clobber: $(SUBDIRS)
_msg: $(MSGSUBDIRS)
$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# include global definitions
BRAND = solaris10
include $(SRC)/lib/brand/Makefile.brand
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
PROGS = s10_native s10_isaexec_wrapper \
s10_net_physical
include $(SRC)/cmd/Makefile.cmd
include ../Makefile.s10
# override the install directory
ROOTBIN = $(ROOTBRANDDIR)
CLOBBERFILES = $(ROOTPROGS)
.KEEP_STATE:
all: $(PROGS)
install: all $(ROOTPROGS)
clean:
$(RM) $(PROGS) $(CLEANFILES)
include $(SRC)/cmd/Makefile.targ
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# This script is invoked by isaexec-governed executable wrappers from within
# s10-branded zones. It circumvents the native isaexec so that native wrappers
# will function correctly.
#
# All native executables must be run using the native linker.
# By default, the kernel loads the linker at /lib/ld.so.1, which
# in an s10 zone is the s10 linker. Hence when we run the native
# executable below, we explicitly specify /.SUNWnative/lib/ld.so.1 as our 32-
# bit linker and /.SUNWnative/lib/64/ld.so.1 as our 64-bit linker.
# For convience we define "n" to be the native path prefix.
# The initial s10_native argument is used as a way to tell the brand
# emulation that it needs to set up the process to run as an unbranded
# process.
#
# If this script gets setup with a mode that makes it suid, then things won't
# work because the script will be running with the incorrect name.
#
n=/.SUNWnative
bname=`/bin/basename $0`
dname=`/bin/dirname $0`
echo $dname | /bin/grep "^/" >/dev/null || dname=`/bin/pwd`/$dname
dname=`(cd $dname 2>/dev/null && /bin/pwd 2>/dev/null)`
arch64=/
LC_ALL=C /usr/bin/file $n/$dname/$bname | /bin/grep "64-bit" \
>/dev/null && arch64=/64/
# This wrapper is running in the S10 zone so there is no L10N for the
# following error msg.
if [ ! -f $n$dname/$bname ]; then
echo "Error: \"$dname/$bname\" is not installed in the global zone"
exit 1
fi
exec $n/usr/lib/brand/solaris10/s10_native \
$n/lib${arch64}ld.so.1 \
-e LD_NOENVIRON=1 \
-e LD_NOCONFIG=1 \
-e LD_PRELOAD_32=s10_npreload.so.1 \
-e LD_PRELOAD_64=s10_npreload.so.1 \
-e LD_LIBRARY_PATH_32="$n/lib:$n/usr/lib:$n/usr/lib/mps" \
-e LD_LIBRARY_PATH_64="$n/lib/64:$n/usr/lib/64:$n/usr/lib/mps/64" \
$n$dname/$bname "$@"
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
exit 0
#!/sbin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
# All rights reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
#
. /lib/svc/share/smf_include.sh
. /lib/svc/share/net_include.sh
#
# This file replaces the Solaris 10 net-physical script in S10C at
# boot time. Any S10C specific changes to net-physical script needs
# to be made in this file.
#
#
# In a shared-IP zone we need this service to be up, but all of the work
# it tries to do is irrelevant (and will actually lead to the service
# failing if we try to do it), so just bail out.
# In exclusive-IP zones we proceed.
#
if [ `/sbin/zonename -t` = shared ]; then
exit 0
fi
# Print warnings to console
warn_failed_ifs() {
echo "Failed to $1 interface(s): $2" >/dev/msglog
}
#
# Cause ifconfig to not automatically start in.mpathd when IPMP groups are
# configured. This is not strictly necessary but makes it so that in.mpathd
# will always be started explicitly from /etc/init.d/inetinit, when we're
# sure that /usr is mounted.
#
SUNW_NO_MPATHD=; export SUNW_NO_MPATHD
smf_netstrategy
#
# If the system was net booted by DHCP, hand DHCP management off to the
# DHCP agent (ifconfig communicates to the DHCP agent through the
# loopback interface).
#
if [ -n "$_INIT_NET_IF" -a "$_INIT_NET_STRATEGY" = "dhcp" ]; then
/sbin/dhcpagent -a
fi
#
# For IPv4 interfaces that were configured by the kernel and not
# configured by DHCP, reset the netmask using the local "/etc/netmasks"
# file if one exists, and then reset the broadcast address based on
# the netmask.
#
/sbin/ifconfig -auD4 netmask + broadcast +
#
# All the IPv4 and IPv6 interfaces are plumbed before doing any
# interface configuration. This prevents errors from plumb failures
# getting mixed in with the configured interface lists that the script
# outputs.
#
# Moreover in S10C, we process IPMP interfaces before non-IPMP
# interfaces to avoid accidental implicit IPMP group creation.
# Therefore we keep track of IPMP and non-IPMP interfaces in two
# different lists i.e. ipmp[6]_list vs inet[6]_list.
#
# Get the list of IPv4 interfaces to configure by breaking
# /etc/hostname.* into separate args by using "." as a shell separator
# character.
#
interface_names="`echo /etc/hostname.*[0-9] 2>/dev/null`"
if [ "$interface_names" != "/etc/hostname.*[0-9]" ]; then
ORIGIFS="$IFS"
IFS="$IFS."
set -- $interface_names
IFS="$ORIGIFS"
while [ $# -ge 2 ]; do
shift
if [ "$1" = "xx0" ]; then
#
# For some unknown historical reason the xx0
# ifname is ignored.
#
shift
continue
fi
if [ $# -gt 1 -a "$2" != "/etc/hostname" ]; then
while [ $# -gt 1 -a "$1" != "/etc/hostname" ]; do
shift
done
else
read one rest < /etc/hostname.$1
if [ "$one" = ipmp ]; then
ipmp_list="$ipmp_list $1"
else
inet_list="$inet_list $1"
fi
shift
fi
done
fi
#
# Get the list of IPv6 interfaces to configure by breaking
# /etc/hostname6.* into separate args by using "." as a shell separator
# character.
#
interface_names="`echo /etc/hostname6.*[0-9] 2>/dev/null`"
if [ "$interface_names" != "/etc/hostname6.*[0-9]" ]; then
ORIGIFS="$IFS"
IFS="$IFS."
set -- $interface_names
IFS="$ORIGIFS"
while [ $# -ge 2 ]; do
shift
if [ $# -gt 1 -a "$2" != "/etc/hostname6" ]; then
while [ $# -gt 1 -a "$1" != "/etc/hostname6" ]; do
shift
done
else
read one rest < /etc/hostname6.$1
if [ "$one" = ipmp ]; then
ipmp6_list="$ipmp6_list $1"
else
inet6_list="$inet6_list $1"
fi
shift
fi
done
fi
#
# Create all of the IPv4 IPMP interfaces.
#
if [ -n "$ipmp_list" ]; then
set -- $ipmp_list
while [ $# -gt 0 ]; do
if /sbin/ifconfig $1 ipmp; then
ipmp_created="$ipmp_created $1"
else
ipmp_failed="$ipmp_failed $1"
fi
shift
done
[ -n "$ipmp_failed" ] && warn_failed_ifs "create IPv4 IPMP" \
"$ipmp_failed"
fi
#
# Step through the IPv4 interface list and try to plumb every interface.
# Generate list of plumbed and failed IPv4 interfaces.
#
if [ -n "$inet_list" ]; then
set -- $inet_list
while [ $# -gt 0 ]; do
/sbin/ifconfig $1 plumb
if /sbin/ifconfig $1 inet >/dev/null 2>&1; then
inet_plumbed="$inet_plumbed $1"
else
inet_failed="$inet_failed $1"
fi
shift
done
[ -n "$inet_failed" ] && warn_failed_ifs "plumb IPv4" $inet_failed
fi
#
# Step through the IPv6 interface list and plumb every interface.
# Generate list of plumbed and failed IPv6 interfaces. Each plumbed
# interface will be brought up later, after processing any contents of
# the /etc/hostname6.* file.
#
if [ -n "$inet6_list" ]; then
set -- $inet6_list
while [ $# -gt 0 ]; do
/sbin/ifconfig $1 inet6 plumb
if /sbin/ifconfig $1 inet6 >/dev/null 2>&1; then
inet6_plumbed="$inet6_plumbed $1"
else
inet6_failed="$inet6_failed $1"
fi
shift
done
[ -n "$inet6_failed" ] && warn_failed_ifs "plumb IPv6" $inet6_failed
fi
#
# Create all of the IPv6 IPMP interfaces.
#
if [ -n "$ipmp6_list" ]; then
set -- $ipmp6_list
while [ $# -gt 0 ]; do
if /sbin/ifconfig $1 inet6 ipmp; then
ipmp6_created="$ipmp6_created $1"
else
ipmp6_failed="$ipmp6_failed $1"
fi
shift
done
[ -n "$ipmp6_failed" ] && warn_failed_ifs "create IPv6 IPMP" \
"$ipmp6_failed"
fi
#
# Process IPMP interfaces before non-IPMP interfaces
# to avoid accidental implicit IPMP group creation.
#
if [ -n "$ipmp_created" ]; then
i4s_fail=
echo "configuring IPv4 IPMP interfaces:\c"
set -- $ipmp_created
while [ $# -gt 0 ]; do
inet_process_hostname /sbin/ifconfig $1 inet \
</etc/hostname.$1 >/dev/null
[ $? != 0 ] && i4s_fail="$i4s_fail $1"
echo " $1\c"
shift
done
echo "."
[ -n "$i4s_fail" ] && warn_failed_ifs "configure IPv4 IPMP" \
$i4s_fail
fi
if [ -n "$ipmp6_created" ]; then
i6_fail=
echo "configuring IPv6 IPMP interfaces:\c"
set -- $ipmp6_created
while [ $# -gt 0 ]; do
inet6_process_hostname /sbin/ifconfig $1 inet6 \
</etc/hostname6.$1 >/dev/null &&
/sbin/ifconfig $1 inet6 up
[ $? != 0 ] && i6_fail="$i6_fail $1"
echo " $1\c"
shift
done
echo "."
[ -n "$i6_fail" ] && warn_failed_ifs "configure IPv6 IPMP" \
$i6_fail
fi
#
# Process the /etc/hostname.* files of plumbed IPv4 interfaces. If an
# /etc/hostname file is not present or is empty, the ifconfig auto-dhcp
# / auto-revarp command will attempt to set the address, later.
#
# If /etc/hostname.lo0 exists the loop below will do additional
# configuration of lo0.
#
if [ -n "$inet_plumbed" ]; then
i4s_fail=
echo "configuring IPv4 interfaces:\c"
set -- $inet_plumbed
while [ $# -gt 0 ]; do
l3protect=`/sbin/ifconfig $1|grep -c L3PROTECT`
if [ $l3protect != 0 ]; then
echo "Ignoring /etc/hostname.$1" > /dev/msglog
else
inet_process_hostname /sbin/ifconfig $1 inet \
</etc/hostname.$1 >/dev/null
[ $? != 0 ] && i4s_fail="$i4s_fail $1"
echo " $1\c"
fi
shift
done
echo "."
[ -n "$i4s_fail" ] && warn_failed_ifs "configure IPv4" $i4s_fail
fi
#
# Process the /etc/hostname6.* files of plumbed IPv6 interfaces. After
# processing the hostname6 file, bring the interface up. If
# /etc/hostname6.lo0 exists the loop below will do additional
# configuration of lo0.
#
if [ -n "$inet6_plumbed" ]; then
i6_fail=
echo "configuring IPv6 interfaces:\c"
set -- $inet6_plumbed
while [ $# -gt 0 ]; do
l3protect=`/sbin/ifconfig $1|grep -c L3PROTECT`
if [ $l3protect != 0 ]; then
echo "Ignoring /etc/hostname6.$1" > /dev/msglog
else
inet6_process_hostname /sbin/ifconfig $1 inet6 \
</etc/hostname6.$1 >/dev/null &&
/sbin/ifconfig $1 inet6 up
[ $? != 0 ] && i6_fail="$i6_fail $1"
echo " $1\c"
fi
shift
done
echo "."
[ -n "$i6_fail" ] && warn_failed_ifs "configure IPv6" $i6_fail
fi
# Run DHCP if requested. Skip boot-configured interface.
interface_names="`echo /etc/dhcp.*[0-9] 2>/dev/null`"
if [ "$interface_names" != '/etc/dhcp.*[0-9]' ]; then
#
# First find the primary interface. Default to the first
# interface if not specified. First primary interface found
# "wins". Use care not to "reconfigure" a net-booted interface
# configured using DHCP. Run through the list of interfaces
# again, this time trying DHCP.
#
i4d_fail=
firstif=
primary=
ORIGIFS="$IFS"
IFS="${IFS}."
set -- $interface_names
while [ $# -ge 2 ]; do
shift
[ -z "$firstif" ] && firstif=$1
for i in `shcat /etc/dhcp\.$1`; do
if [ "$i" = primary ]; then
primary=$1
break
fi
done
[ -n "$primary" ] && break
shift
done
[ -z "$primary" ] && primary="$firstif"
cmdline=`shcat /etc/dhcp\.${primary}`
if [ "$_INIT_NET_IF" != "$primary" ]; then
echo "starting DHCP on primary interface $primary"
/sbin/ifconfig $primary auto-dhcp primary $cmdline
# Exit code 4 means ifconfig timed out waiting for dhcpagent
[ $? != 0 ] && [ $? != 4 ] && i4d_fail="$i4d_fail $primary"
fi
set -- $interface_names
while [ $# -ge 2 ]; do
shift
cmdline=`shcat /etc/dhcp\.$1`
if [ "$1" != "$primary" -a \
"$1" != "$_INIT_NET_IF" ]; then
echo "starting DHCP on interface $1"
/sbin/ifconfig $1 dhcp start wait 0 $cmdline
# Exit code can't be timeout when wait is 0
[ $? != 0 ] && i4d_fail="$i4d_fail $1"
fi
shift
done
IFS="$ORIGIFS"
unset ORIGIFS
[ -n "$i4d_fail" ] && warn_failed_ifs "configure IPv4 DHCP" $i4d_fail
fi
# In order to avoid bringing up the interfaces that have
# intentionally been left down, perform RARP only if the system
# has no configured hostname in /etc/nodename
hostname="`shcat /etc/nodename 2>/dev/null`"
if [ "$_INIT_NET_STRATEGY" = "rarp" -o -z "$hostname" ]; then
/sbin/ifconfig -adD4 auto-revarp netmask + broadcast + up
fi
#
# Process IPv4 and IPv6 interfaces that failed to plumb. Find an
# alternative interface to host the addresses.
#
[ -n "$inet_failed" ] && move_addresses inet
[ -n "$inet6_failed" ] && move_addresses inet6
#
# If the /etc/defaultrouter file exists, process it now so that the next
# stage of booting will have access to NFS.
#
if [ -f /etc/defaultrouter ]; then
while read router rubbish; do
case "$router" in
'#'* | '') ;; # Ignore comments, empty lines
*) /sbin/route -n add default -gateway $router ;;
esac
done </etc/defaultrouter
fi
#
# We tell smf this service is online if any of the following is true:
# - no interfaces were configured for plumbing and no DHCP failures
# - there are any DHCP interfaces started
# - any non-loopback, non-DHCP IPv4 interfaces are up and have a non-zero
# address
# - any non-loopback IPv6 interfaces are up
#
# If we weren't asked to configure any interfaces, exit
if [ -z "$inet_list" ] && [ -z "$inet6_list" ]; then
# Config error if DHCP was attempted without plumbed interfaces
[ -n "$i4d_fail" ] && exit $SMF_EXIT_ERR_CONFIG
exit $SMF_EXIT_OK
fi
# Any DHCP interfaces?
[ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ] && exit $SMF_EXIT_OK
# Any non-loopback, non-DHCP IPv4 interfaces with usable addresses up?
if [ -n "`/sbin/ifconfig -a4uD`" ]; then
/sbin/ifconfig -a4uD | while read intf addr rest; do
[ $intf = inet ] && [ $addr != 127.0.0.1 ] &&
[ $addr != 0.0.0.0 ] && exit 0
done && exit $SMF_EXIT_OK
fi
# Any non-loopback IPv6 interfaces up?
if [ -n "`/sbin/ifconfig -au6`" ]; then
/sbin/ifconfig -au6 | while read intf addr rest; do
[ $intf = inet6 ] && [ $addr != ::1/128 ] && exit 0
done && exit $SMF_EXIT_OK
fi
# This service was supposed to configure something yet didn't. Exit
# with config error.
exit $SMF_EXIT_ERR_CONFIG
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
default: all
include $(SRC)/lib/Makefile.lib
# Hammerhead: amd64-only
SUBDIRS = $(MACH64)
all : TARGET= all
clean : TARGET= clean
clobber : TARGET= clobber
install : TARGET= install
.KEEP_STATE:
all install clean clobber: $(SUBDIRS)
$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
COBJS = brand_librtld_db.o
OBJECTS = $(COBJS) $(COBJS64)
include ../../Makefile.s10
include $(BRAND_SHARED)/librtld_db/Makefile.com
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
#
COBJS64 = brand_librtld_db64.o
include ../Makefile.com
include $(SRC)/lib/Makefile.lib.64
CLOBBERFILES = $(ROOTLIBDIR64)/$(DYNLIB)
install: all $(ROOTLIBS64)
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
include $(SRC)/lib/Makefile.lib
default: all
# Hammerhead: amd64-only
SUBDIRS = $(MACH64)
all : TARGET= all
clean : TARGET= clean
clobber : TARGET= clobber
install : TARGET= install
_msg : TARGET= _msg
.KEEP_STATE:
all install clean clobber _msg: $(SUBDIRS)
$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016 by Delphix. All rights reserved.
# Copyright 2020 Joyent, Inc.
#
LIBRARY = s10_brand.a
VERS = .1
COBJS = s10_brand.o s10_deleted.o s10_signal.o
ASOBJS = crt.o handler.o runexe.o brand_util.o
OBJECTS = $(COBJS)
include ../../Makefile.s10
include $(SRC)/lib/Makefile.lib
SRCDIR = ../common
UTSBASE = $(SRC)/uts
LIBS = $(DYNLIB)
CSRCS = $(COBJS:%o=../common/%c)
SHAREDOBJS = $(ASOBJS:%o=$(ISAOBJDIR)/%o)
SRCS = $(CSRCS)
#
# Note that the architecture specific makefiles MUST update DYNFLAGS to
# explicitly specify an interpreter for the brand emulation library so that we
# use /lib/ld.so.1 or /lib/64/ld.so.1, which in a s10 zone is the Solaris 10
# linker. This is different from some other brands where the linker that is
# used is the native system linker (/.SUNWnative/.../ld.so.1). We have to do
# this because the linker has a very incestuous relationship with libc and we
# don't want to use the native linker with the s10 version of libc. (This may
# come as a surprise to the reader, but when our library is loaded it get's
# linked against the s10 version of libc.) Although the linker interfaces are
# normally stable, there are examples, such as with the solaris8 brand, where
# we could not combine the brand's libc with the native linker. Since we want
# to run in a known configuration, we use the S10 libc/linker combination.
#
# There is one more non-obvious side effect of using the s10 linker that
# should be mentioned. Since the linker is used to setup processes before
# libc is loaded, it makes system calls directly (ie avoiding libc), and
# it makes these system calls before our library has been initialized.
# Since our library hasn't been initialized yet, there's no way for us
# to intercept and emulate any of those system calls. So if any of those
# system calls ever change in the native code such that they break the s10
# linker then we're kinda screwed and will need to re-visit the current
# solution. (The likely solution then will probably be to start using the
# native linker with our brand emulation library.)
#
# Note that we make sure to link our brand emulation library
# libmapmalloc. This is required because in most cases there will be two
# copies of libc in the same process and we don't want them to fight over
# the heap. So for our brand library we link against libmapmalloc so that
# if we (our or copy of libc) try to allocate any memory it will be done
# via mmap() instead of brk().
#
CPPFLAGS += -D_REENTRANT -U_ASM \
-I. -I$(BRAND_SHARED)/brand/sys -I../sys \
-I$(UTSBASE)/common/brand/solaris10 \
-I$(SRC)/uts/common/fs/zfs
CFLAGS += $(CCVERBOSE)
# Needed to handle zfs include files
CSTD= $(CSTD_GNU99)
DYNFLAGS += $(DYNFLAGS_$(CLASS))
DYNFLAGS += $(BLOCAL) $(ZNOVERSION) -Wl,-e_start
LDLIBS += -lmapmalloc -lc
#
# Disable stack protection as we're running in an s10 context.
#
STACKPROTECT = none
CERRWARN += $(CNOWARN_UNINIT)
$(LIBS): PICS += $(SHAREDOBJS)
.KEEP_STATE:
all: $(LIBS)
include $(SRC)/lib/Makefile.targ
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
ISAOBJDIR = $(BRAND_SHARED)/brand/amd64/pics/
include ../Makefile.com
include $(SRC)/lib/Makefile.lib.64
CPPFLAGS += -I$(BRAND_SHARED)/brand/amd64
#
# see ../Makefile.com for why we MUST explicity make ld.so.1 our interpreter
#
# S10 linker
DYNFLAGS += -Wl,-I/lib/64/ld.so.1
CPPFLAGS += -D_SYSCALL32
CLEANFILES += $(DYNLIB)
CLOBBERFILES += $(ROOTLIBS64)
install: all $(ROOTLIBS64)
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# MAPFILE HEADER START
#
# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
# Object versioning must comply with the rules detailed in
#
# usr/src/lib/README.mapfiles
#
# You should not be making modifications here until you've read the most current
# copy of that file. If you need help, contact a gatekeeper for guidance.
#
# MAPFILE HEADER END
#
$mapfile_version 2
#
# Scope everything local -- our .init section is our only public interface.
#
SYMBOL_SCOPE {
local:
*;
};
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2016 Toomas Soome <tsoome@me.com>
* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2024 Oxide Computer Company
*/
#include <errno.h>
#include <fcntl.h>
#include <dirent.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <thread.h>
#include <sys/auxv.h>
#include <sys/brand.h>
#include <sys/inttypes.h>
#include <sys/lwp.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/utsname.h>
#include <sys/sysconfig.h>
#include <sys/systeminfo.h>
#include <sys/zone.h>
#include <sys/stat.h>
#include <sys/mntent.h>
#include <sys/ctfs.h>
#include <sys/priv.h>
#include <sys/acctctl.h>
#include <libgen.h>
#include <bsm/audit.h>
#include <sys/crypto/ioctl.h>
#include <sys/fs/zfs.h>
#include <sys/zfs_ioctl.h>
#include <sys/ucontext.h>
#include <sys/mntio.h>
#include <sys/mnttab.h>
#include <sys/attr.h>
#include <sys/lofi.h>
#include <atomic.h>
#include <sys/acl.h>
#include <sys/socket.h>
#include <sys/fdsync.h>
#include <s10_brand.h>
#include <brand_misc.h>
#include <s10_misc.h>
#include <s10_signal.h>
/*
* See usr/src/lib/brand/shared/brand/common/brand_util.c for general
* emulation notes.
*/
static zoneid_t zoneid;
static boolean_t emul_global_zone = B_FALSE;
static s10_emul_bitmap_t emul_bitmap;
pid_t zone_init_pid;
/*
* S10_FEATURE_IS_PRESENT is a macro that helps facilitate conditional
* emulation. For each constant N defined in the s10_emulated_features
* enumeration in usr/src/uts/common/brand/solaris10/s10_brand.h,
* S10_FEATURE_IS_PRESENT(N) is true iff the feature/backport represented by N
* is present in the Solaris 10 image hosted within the zone. In other words,
* S10_FEATURE_IS_PRESENT(N) is true iff the file /usr/lib/brand/solaris10/M,
* where M is the enum value of N, was present in the zone when the zone booted.
*
*
* *** Sample Usage
*
* Suppose that you need to backport a fix to Solaris 10 and there is
* emulation in place for the fix. Suppose further that the emulation won't be
* needed if the fix is backported (i.e., if the fix is present in the hosted
* Solaris 10 environment, then the brand won't need the emulation). Then if
* you add a constant named "S10_FEATURE_X" to the end of the
* s10_emulated_features enumeration that represents the backported fix and
* S10_FEATURE_X evaluates to four, then you should create a file named
* /usr/lib/brand/solaris10/4 as part of your backport. Additionally, you
* should retain the aforementioned emulation but modify it so that it's
* performed only when S10_FEATURE_IS_PRESENT(S10_FEATURE_X) is false. Thus the
* emulation function should look something like the following:
*
* static int
* my_emul_function(sysret_t *rv, ...)
* {
* if (S10_FEATURE_IS_PRESENT(S10_FEATURE_X)) {
* // Don't emulate
* return (__systemcall(rv, ...));
* } else {
* // Emulate whatever needs to be emulated when the
* // backport isn't present in the Solaris 10 image.
* }
* }
*/
#define S10_FEATURE_IS_PRESENT(s10_emulated_features_constant) \
((emul_bitmap[(s10_emulated_features_constant) >> 3] & \
(1 << ((s10_emulated_features_constant) & 0x7))) != 0)
brand_sysent_table_t brand_sysent_table[];
#define S10_UTS_RELEASE "5.10"
#define S10_UTS_VERSION "Generic_Virtual"
/*
* If the ioctl fd's major doesn't match "major", then pass through the
* ioctl, since it is not the expected device. major should be a
* pointer to a static dev_t initialized to -1, and devname should be
* the path of the device.
*
* Returns 1 if the ioctl was handled (in which case *err contains the
* error code), or 0 if it still needs handling.
*/
static int
passthru_otherdev_ioctl(dev_t *majordev, const char *devname, int *err,
sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
struct stat sbuf;
if (*majordev == (dev_t)-1) {
if ((*err = __systemcall(rval, SYS_fstatat + 1024,
AT_FDCWD, devname, &sbuf, 0) != 0) != 0)
goto doioctl;
*majordev = major(sbuf.st_rdev);
}
if ((*err = __systemcall(rval, SYS_fstatat + 1024, fdes,
NULL, &sbuf, 0)) != 0)
goto doioctl;
if (major(sbuf.st_rdev) == *majordev)
return (0);
doioctl:
*err = (__systemcall(rval, SYS_ioctl + 1024, fdes, cmd, arg));
return (1);
}
/*
* Figures out the PID of init for the zone. Also returns a boolean
* indicating whether this process currently has that pid: if so,
* then at this moment, we are init.
*/
static boolean_t
get_initpid_info(void)
{
pid_t pid;
sysret_t rval;
int err;
/*
* Determine the current process PID and the PID of the zone's init.
* We use care not to call getpid() here, because we're not supposed
* to call getpid() until after the program is fully linked-- the
* first call to getpid() is a signal from the linker to debuggers
* that linking has been completed.
*/
if ((err = __systemcall(&rval, SYS_brand,
B_S10_PIDINFO, &pid, &zone_init_pid)) != 0) {
brand_abort(err, "Failed to get init's pid");
}
/*
* Note that we need to be cautious with the pid we get back--
* it should not be stashed and used in place of getpid(), since
* we might fork(2). So we keep zone_init_pid and toss the pid
* we otherwise got.
*/
if (pid == zone_init_pid)
return (B_TRUE);
return (B_FALSE);
}
/* Free the thread-local storage provided by mntfs_get_mntentbuf(). */
static void
mntfs_free_mntentbuf(void *arg)
{
struct mntentbuf *embufp = arg;
if (embufp == NULL)
return;
if (embufp->mbuf_emp)
free(embufp->mbuf_emp);
if (embufp->mbuf_buf)
free(embufp->mbuf_buf);
bzero(embufp, sizeof (struct mntentbuf));
free(embufp);
}
/* Provide the thread-local storage required by mntfs_ioctl(). */
static struct mntentbuf *
mntfs_get_mntentbuf(size_t size)
{
static mutex_t keylock;
static thread_key_t key;
static int once_per_keyname = 0;
void *tsd = NULL;
struct mntentbuf *embufp;
/* Create the key. */
if (!once_per_keyname) {
(void) mutex_lock(&keylock);
if (!once_per_keyname) {
if (thr_keycreate(&key, mntfs_free_mntentbuf)) {
(void) mutex_unlock(&keylock);
return (NULL);
} else {
once_per_keyname++;
}
}
(void) mutex_unlock(&keylock);
}
/*
* The thread-specific datum for this key is the address of a struct
* mntentbuf. If this is the first time here then we allocate the struct
* and its contents, and associate its address with the thread; if there
* are any problems then we abort.
*/
if (thr_getspecific(key, &tsd))
return (NULL);
if (tsd == NULL) {
if (!(embufp = calloc(1, sizeof (struct mntentbuf))) ||
!(embufp->mbuf_emp = malloc(sizeof (struct extmnttab))) ||
thr_setspecific(key, embufp)) {
mntfs_free_mntentbuf(embufp);
return (NULL);
}
} else {
embufp = tsd;
}
/* Return the buffer, resizing it if necessary. */
if (size > embufp->mbuf_bufsize) {
if (embufp->mbuf_buf)
free(embufp->mbuf_buf);
if ((embufp->mbuf_buf = malloc(size)) == NULL) {
embufp->mbuf_bufsize = 0;
return (NULL);
} else {
embufp->mbuf_bufsize = size;
}
}
return (embufp);
}
/*
* The MNTIOC_GETMNTENT command in this release differs from that in early
* versions of Solaris 10.
*
* Previously, the command would copy a pointer to a struct extmnttab to an
* address provided as an argument. The pointer would be somewhere within a
* mapping already present within the user's address space. In addition, the
* text to which the struct's members pointed would also be within a
* pre-existing mapping. Now, the user is required to allocate memory for both
* the struct and the text buffer, and to pass the address of each within a
* struct mntentbuf. In order to conceal these details from a Solaris 10 client
* we allocate some thread-local storage in which to create the necessary data
* structures; this is static, thread-safe memory that will be cleaned up
* without the caller's intervention.
*
* MNTIOC_GETEXTMNTENT and MNTIOC_GETMNTANY are new in this release; they should
* not work for older clients.
*/
int
mntfs_ioctl(sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
int err;
struct stat statbuf;
struct mntentbuf *embufp;
static size_t bufsize = MNT_LINE_MAX;
/* Do not emulate mntfs commands from up-to-date clients. */
if (S10_FEATURE_IS_PRESENT(S10_FEATURE_ALTERED_MNTFS_IOCTL))
return (__systemcall(rval, SYS_ioctl + 1024, fdes, cmd, arg));
/* Do not emulate mntfs commands directed at other file systems. */
if ((err = __systemcall(rval, SYS_fstatat + 1024,
fdes, NULL, &statbuf, 0)) != 0)
return (err);
if (strcmp(statbuf.st_fstype, MNTTYPE_MNTFS) != 0)
return (__systemcall(rval, SYS_ioctl + 1024, fdes, cmd, arg));
if (cmd == MNTIOC_GETEXTMNTENT || cmd == MNTIOC_GETMNTANY)
return (EINVAL);
if ((embufp = mntfs_get_mntentbuf(bufsize)) == NULL)
return (ENOMEM);
/*
* MNTIOC_GETEXTMNTENT advances the file pointer once it has
* successfully copied out the result to the address provided. We
* therefore need to check the user-supplied address now since the
* one we'll be providing is guaranteed to work.
*/
if (brand_uucopy(&embufp->mbuf_emp, (void *)arg, sizeof (void *)) != 0)
return (EFAULT);
/*
* Keep retrying for as long as we fail for want of a large enough
* buffer.
*/
for (;;) {
if ((err = __systemcall(rval, SYS_ioctl + 1024, fdes,
MNTIOC_GETEXTMNTENT, embufp)) != 0)
return (err);
if (rval->sys_rval1 == MNTFS_TOOLONG) {
/* The buffer wasn't large enough. */
(void) atomic_swap_ulong((unsigned long *)&bufsize,
2 * embufp->mbuf_bufsize);
if ((embufp = mntfs_get_mntentbuf(bufsize)) == NULL)
return (ENOMEM);
} else {
break;
}
}
if (brand_uucopy(&embufp->mbuf_emp, (void *)arg, sizeof (void *)) != 0)
return (EFAULT);
return (0);
}
/*
* Assign the structure member value from the s (source) structure to the
* d (dest) structure.
*/
#define struct_assign(d, s, val) (((d).val) = ((s).val))
/*
* The CRYPTO_GET_FUNCTION_LIST parameter structure crypto_function_list_t
* changed between S10 and Nevada, so we have to emulate the old S10
* crypto_function_list_t structure when interposing on the ioctl syscall.
*/
typedef struct s10_crypto_function_list {
boolean_t fl_digest_init;
boolean_t fl_digest;
boolean_t fl_digest_update;
boolean_t fl_digest_key;
boolean_t fl_digest_final;
boolean_t fl_encrypt_init;
boolean_t fl_encrypt;
boolean_t fl_encrypt_update;
boolean_t fl_encrypt_final;
boolean_t fl_decrypt_init;
boolean_t fl_decrypt;
boolean_t fl_decrypt_update;
boolean_t fl_decrypt_final;
boolean_t fl_mac_init;
boolean_t fl_mac;
boolean_t fl_mac_update;
boolean_t fl_mac_final;
boolean_t fl_sign_init;
boolean_t fl_sign;
boolean_t fl_sign_update;
boolean_t fl_sign_final;
boolean_t fl_sign_recover_init;
boolean_t fl_sign_recover;
boolean_t fl_verify_init;
boolean_t fl_verify;
boolean_t fl_verify_update;
boolean_t fl_verify_final;
boolean_t fl_verify_recover_init;
boolean_t fl_verify_recover;
boolean_t fl_digest_encrypt_update;
boolean_t fl_decrypt_digest_update;
boolean_t fl_sign_encrypt_update;
boolean_t fl_decrypt_verify_update;
boolean_t fl_seed_random;
boolean_t fl_generate_random;
boolean_t fl_session_open;
boolean_t fl_session_close;
boolean_t fl_session_login;
boolean_t fl_session_logout;
boolean_t fl_object_create;
boolean_t fl_object_copy;
boolean_t fl_object_destroy;
boolean_t fl_object_get_size;
boolean_t fl_object_get_attribute_value;
boolean_t fl_object_set_attribute_value;
boolean_t fl_object_find_init;
boolean_t fl_object_find;
boolean_t fl_object_find_final;
boolean_t fl_key_generate;
boolean_t fl_key_generate_pair;
boolean_t fl_key_wrap;
boolean_t fl_key_unwrap;
boolean_t fl_key_derive;
boolean_t fl_init_token;
boolean_t fl_init_pin;
boolean_t fl_set_pin;
boolean_t prov_is_hash_limited;
uint32_t prov_hash_threshold;
uint32_t prov_hash_limit;
} s10_crypto_function_list_t;
typedef struct s10_crypto_get_function_list {
uint_t fl_return_value;
crypto_provider_id_t fl_provider_id;
s10_crypto_function_list_t fl_list;
} s10_crypto_get_function_list_t;
/*
* The structure returned by the CRYPTO_GET_FUNCTION_LIST ioctl on /dev/crypto
* increased in size due to:
* 6482533 Threshold for HW offload via PKCS11 interface
* between S10 and Nevada. This is a relatively simple process of filling
* in the S10 structure fields with the Nevada data.
*
* We stat the device to make sure that the ioctl is meant for /dev/crypto.
*
*/
static int
crypto_ioctl(sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
int err;
s10_crypto_get_function_list_t s10_param;
crypto_get_function_list_t native_param;
static dev_t crypto_dev = (dev_t)-1;
if (passthru_otherdev_ioctl(&crypto_dev, "/dev/crypto", &err,
rval, fdes, cmd, arg) == 1)
return (err);
if (brand_uucopy((const void *)arg, &s10_param, sizeof (s10_param))
!= 0)
return (EFAULT);
struct_assign(native_param, s10_param, fl_provider_id);
if ((err = __systemcall(rval, SYS_ioctl + 1024, fdes, cmd,
&native_param)) != 0)
return (err);
struct_assign(s10_param, native_param, fl_return_value);
struct_assign(s10_param, native_param, fl_provider_id);
struct_assign(s10_param, native_param, fl_list.fl_digest_init);
struct_assign(s10_param, native_param, fl_list.fl_digest);
struct_assign(s10_param, native_param, fl_list.fl_digest_update);
struct_assign(s10_param, native_param, fl_list.fl_digest_key);
struct_assign(s10_param, native_param, fl_list.fl_digest_final);
struct_assign(s10_param, native_param, fl_list.fl_encrypt_init);
struct_assign(s10_param, native_param, fl_list.fl_encrypt);
struct_assign(s10_param, native_param, fl_list.fl_encrypt_update);
struct_assign(s10_param, native_param, fl_list.fl_encrypt_final);
struct_assign(s10_param, native_param, fl_list.fl_decrypt_init);
struct_assign(s10_param, native_param, fl_list.fl_decrypt);
struct_assign(s10_param, native_param, fl_list.fl_decrypt_update);
struct_assign(s10_param, native_param, fl_list.fl_decrypt_final);
struct_assign(s10_param, native_param, fl_list.fl_mac_init);
struct_assign(s10_param, native_param, fl_list.fl_mac);
struct_assign(s10_param, native_param, fl_list.fl_mac_update);
struct_assign(s10_param, native_param, fl_list.fl_mac_final);
struct_assign(s10_param, native_param, fl_list.fl_sign_init);
struct_assign(s10_param, native_param, fl_list.fl_sign);
struct_assign(s10_param, native_param, fl_list.fl_sign_update);
struct_assign(s10_param, native_param, fl_list.fl_sign_final);
struct_assign(s10_param, native_param, fl_list.fl_sign_recover_init);
struct_assign(s10_param, native_param, fl_list.fl_sign_recover);
struct_assign(s10_param, native_param, fl_list.fl_verify_init);
struct_assign(s10_param, native_param, fl_list.fl_verify);
struct_assign(s10_param, native_param, fl_list.fl_verify_update);
struct_assign(s10_param, native_param, fl_list.fl_verify_final);
struct_assign(s10_param, native_param, fl_list.fl_verify_recover_init);
struct_assign(s10_param, native_param, fl_list.fl_verify_recover);
struct_assign(s10_param, native_param,
fl_list.fl_digest_encrypt_update);
struct_assign(s10_param, native_param,
fl_list.fl_decrypt_digest_update);
struct_assign(s10_param, native_param, fl_list.fl_sign_encrypt_update);
struct_assign(s10_param, native_param,
fl_list.fl_decrypt_verify_update);
struct_assign(s10_param, native_param, fl_list.fl_seed_random);
struct_assign(s10_param, native_param, fl_list.fl_generate_random);
struct_assign(s10_param, native_param, fl_list.fl_session_open);
struct_assign(s10_param, native_param, fl_list.fl_session_close);
struct_assign(s10_param, native_param, fl_list.fl_session_login);
struct_assign(s10_param, native_param, fl_list.fl_session_logout);
struct_assign(s10_param, native_param, fl_list.fl_object_create);
struct_assign(s10_param, native_param, fl_list.fl_object_copy);
struct_assign(s10_param, native_param, fl_list.fl_object_destroy);
struct_assign(s10_param, native_param, fl_list.fl_object_get_size);
struct_assign(s10_param, native_param,
fl_list.fl_object_get_attribute_value);
struct_assign(s10_param, native_param,
fl_list.fl_object_set_attribute_value);
struct_assign(s10_param, native_param, fl_list.fl_object_find_init);
struct_assign(s10_param, native_param, fl_list.fl_object_find);
struct_assign(s10_param, native_param, fl_list.fl_object_find_final);
struct_assign(s10_param, native_param, fl_list.fl_key_generate);
struct_assign(s10_param, native_param, fl_list.fl_key_generate_pair);
struct_assign(s10_param, native_param, fl_list.fl_key_wrap);
struct_assign(s10_param, native_param, fl_list.fl_key_unwrap);
struct_assign(s10_param, native_param, fl_list.fl_key_derive);
struct_assign(s10_param, native_param, fl_list.fl_init_token);
struct_assign(s10_param, native_param, fl_list.fl_init_pin);
struct_assign(s10_param, native_param, fl_list.fl_set_pin);
struct_assign(s10_param, native_param, fl_list.prov_is_hash_limited);
struct_assign(s10_param, native_param, fl_list.prov_hash_threshold);
struct_assign(s10_param, native_param, fl_list.prov_hash_limit);
return (brand_uucopy(&s10_param, (void *)arg, sizeof (s10_param)));
}
/*
* The process contract CT_TGET and CT_TSET parameter structure ct_param_t
* changed between S10 and Nevada, so we have to emulate the old S10
* ct_param_t structure when interposing on the ioctl syscall.
*/
typedef struct s10_ct_param {
uint32_t ctpm_id;
uint32_t ctpm_pad;
uint64_t ctpm_value;
} s10_ct_param_t;
/*
* We have to emulate process contract ioctls for init(8) because the
* ioctl parameter structure changed between S10 and Nevada. This is
* a relatively simple process of filling Nevada structure fields,
* shuffling values, and initiating a native system call.
*
* For now, we'll assume that all consumers of CT_TGET and CT_TSET will
* need emulation. We'll issue a stat to make sure that the ioctl
* is meant for the contract file system.
*
*/
static int
ctfs_ioctl(sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
int err;
s10_ct_param_t s10param;
ct_param_t param;
struct stat statbuf;
if ((err = __systemcall(rval, SYS_fstatat + 1024,
fdes, NULL, &statbuf, 0)) != 0)
return (err);
if (strcmp(statbuf.st_fstype, MNTTYPE_CTFS) != 0)
return (__systemcall(rval, SYS_ioctl + 1024, fdes, cmd, arg));
if (brand_uucopy((const void *)arg, &s10param, sizeof (s10param)) != 0)
return (EFAULT);
param.ctpm_id = s10param.ctpm_id;
param.ctpm_size = sizeof (uint64_t);
param.ctpm_value = &s10param.ctpm_value;
if ((err = __systemcall(rval, SYS_ioctl + 1024, fdes, cmd, ¶m))
!= 0)
return (err);
if (cmd == CT_TGET)
return (brand_uucopy(&s10param, (void *)arg,
sizeof (s10param)));
return (0);
}
/*
* ZFS ioctls have changed in each Solaris 10 (S10) release as well as in
* Solaris Next. The brand wraps ZFS commands so that the native commands
* are used, but we want to be sure no command sneaks in that uses ZFS
* without our knowledge. We'll abort the process if we see a ZFS ioctl.
*/
static int
zfs_ioctl(sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
static dev_t zfs_dev = (dev_t)-1;
int err;
if (passthru_otherdev_ioctl(&zfs_dev, ZFS_DEV, &err,
rval, fdes, cmd, arg) == 1)
return (err);
brand_abort(0, "ZFS ioctl!");
/*NOTREACHED*/
return (0);
}
struct s10_lofi_ioctl {
uint32_t li_id;
boolean_t li_force;
char li_filename[MAXPATHLEN + 1];
};
static int
lofi_ioctl(sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
static dev_t lofi_dev = (dev_t)-1;
struct s10_lofi_ioctl s10_param;
struct lofi_ioctl native_param;
int err;
if (passthru_otherdev_ioctl(&lofi_dev, "/dev/lofictl", &err,
rval, fdes, cmd, arg) == 1)
return (err);
if (brand_uucopy((const void *)arg, &s10_param,
sizeof (s10_param)) != 0)
return (EFAULT);
/*
* Somewhat weirdly, EIO is what the S10 lofi driver would
* return for unrecognised cmds.
*/
if (cmd >= LOFI_CHECK_COMPRESSED)
return (EIO);
bzero(&native_param, sizeof (native_param));
struct_assign(native_param, s10_param, li_id);
struct_assign(native_param, s10_param, li_force);
/*
* Careful here, this has changed from [MAXPATHLEN + 1] to
* [MAXPATHLEN].
*/
bcopy(s10_param.li_filename, native_param.li_filename,
sizeof (native_param.li_filename));
native_param.li_filename[MAXPATHLEN - 1] = '\0';
err = __systemcall(rval, SYS_ioctl + 1024, fdes, cmd, &native_param);
struct_assign(s10_param, native_param, li_id);
/* li_force is input-only */
bcopy(native_param.li_filename, s10_param.li_filename,
sizeof (native_param.li_filename));
(void) brand_uucopy(&s10_param, (void *)arg, sizeof (s10_param));
return (err);
}
int
s10_ioctl(sysret_t *rval, int fdes, int cmd, intptr_t arg)
{
switch (cmd) {
case CRYPTO_GET_FUNCTION_LIST:
return (crypto_ioctl(rval, fdes, cmd, arg));
case CT_TGET:
/*FALLTHRU*/
case CT_TSET:
return (ctfs_ioctl(rval, fdes, cmd, arg));
case MNTIOC_GETMNTENT:
/*FALLTHRU*/
case MNTIOC_GETEXTMNTENT:
/*FALLTHRU*/
case MNTIOC_GETMNTANY:
return (mntfs_ioctl(rval, fdes, cmd, arg));
}
switch (cmd & ~0xff) {
case ZFS_IOC:
return (zfs_ioctl(rval, fdes, cmd, arg));
case LOFI_IOC_BASE:
return (lofi_ioctl(rval, fdes, cmd, arg));
default:
break;
}
return (__systemcall(rval, SYS_ioctl + 1024, fdes, cmd, arg));
}
/*
* Unfortunately, pwrite()'s behavior differs between S10 and Nevada when
* applied to files opened with O_APPEND. The offset argument is ignored and
* the buffer is appended to the target file in S10, whereas the current file
* position is ignored in Nevada (i.e., pwrite() acts as though the target file
* wasn't opened with O_APPEND). This is a result of the fix for CR 6655660
* (pwrite() must ignore the O_APPEND/FAPPEND flag).
*
* We emulate the old S10 pwrite() behavior by checking whether the target file
* was opened with O_APPEND. If it was, then invoke the write() system call
* instead of pwrite(); otherwise, invoke the pwrite() system call as usual.
*/
static int
s10_pwrite(sysret_t *rval, int fd, const void *bufferp, size_t num_bytes,
off_t offset)
{
int err;
if ((err = __systemcall(rval, SYS_fcntl + 1024, fd, F_GETFL, 0, 0)) !=
0) {
return (err);
}
if (rval->sys_rval1 & O_APPEND)
return (__systemcall(rval, SYS_write + 1024, fd, bufferp,
num_bytes));
return (__systemcall(rval, SYS_pwrite + 1024, fd, bufferp, num_bytes,
offset));
}
#if !defined(_LP64)
/*
* This is the large file version of the pwrite() system call for 32-bit
* processes. This exists for the same reason that s10_pwrite() exists; see
* the comment above s10_pwrite().
*/
static int
s10_pwrite64(sysret_t *rval, int fd, const void *bufferp, size32_t num_bytes,
uint32_t offset_1, uint32_t offset_2)
{
int err;
if ((err = __systemcall(rval, SYS_fcntl + 1024, fd, F_GETFL, 0, 0)) !=
0) {
return (err);
}
if (rval->sys_rval1 & O_APPEND)
return (__systemcall(rval, SYS_write + 1024, fd, bufferp,
num_bytes));
return (__systemcall(rval, SYS_pwrite64 + 1024, fd, bufferp,
num_bytes, offset_1, offset_2));
}
#endif /* !_LP64 */
/*
* These are convenience macros that s10_getdents_common() uses. Both treat
* their arguments, which should be character pointers, as dirent pointers or
* dirent64 pointers and yield their d_name and d_reclen fields. These
* macros shouldn't be used outside of s10_getdents_common().
*/
#define dirent_name(charptr) ((charptr) + name_offset)
#define dirent_reclen(charptr) \
(*(unsigned short *)(uintptr_t)((charptr) + reclen_offset))
/*
* This function contains code that is common to both s10_getdents() and
* s10_getdents64(). See the comment above s10_getdents() for details.
*
* rval, fd, buf, and nbyte should be passed unmodified from s10_getdents()
* and s10_getdents64(). getdents_syscall_id should be either SYS_getdents
* or SYS_getdents64. name_offset should be the the byte offset of
* the d_name field in the dirent structures passed to the kernel via the
* syscall represented by getdents_syscall_id. reclen_offset should be
* the byte offset of the d_reclen field in the aforementioned dirent
* structures.
*/
static int
s10_getdents_common(sysret_t *rval, int fd, char *buf, size_t nbyte,
int getdents_syscall_id, size_t name_offset, size_t reclen_offset)
{
int err;
size_t buf_size;
char *local_buf;
char *buf_current;
/*
* Use a special brand operation, B_S10_ISFDXATTRDIR, to determine
* whether the specified file descriptor refers to an extended file
* attribute directory. If it doesn't, then SYS_getdents won't
* reveal extended file attributes, in which case we can simply
* hand the syscall to the native kernel.
*/
if ((err = __systemcall(rval, SYS_brand + 1024, B_S10_ISFDXATTRDIR,
fd)) != 0)
return (err);
if (rval->sys_rval1 == 0)
return (__systemcall(rval, getdents_syscall_id + 1024, fd, buf,
nbyte));
/*
* The file descriptor refers to an extended file attributes directory.
* We need to create a dirent buffer that's as large as buf into which
* the native SYS_getdents will store the special extended file
* attribute directory's entries. We can't dereference buf because
* it might be an invalid pointer!
*/
if (nbyte > MAXGETDENTS_SIZE)
nbyte = MAXGETDENTS_SIZE;
local_buf = (char *)malloc(nbyte);
if (local_buf == NULL) {
/*
* getdents(2) doesn't return an error code indicating a memory
* allocation error and it doesn't make sense to return any of
* its documented error codes for a malloc(3C) failure. We'll
* use ENOMEM even though getdents(2) doesn't use it because it
* best describes the failure.
*/
(void) B_TRUSS_POINT_3(rval, getdents_syscall_id, ENOMEM, fd,
buf, nbyte);
rval->sys_rval1 = -1;
rval->sys_rval2 = 0;
return (EIO);
}
/*
* Issue a native SYS_getdents syscall but use our local dirent buffer
* instead of buf. This will allow us to examine the returned dirent
* structures immediately and copy them to buf later. That way the
* calling process won't be able to see the dirent structures until
* we finish examining them.
*/
if ((err = __systemcall(rval, getdents_syscall_id + 1024, fd, local_buf,
nbyte)) != 0) {
free(local_buf);
return (err);
}
buf_size = rval->sys_rval1;
if (buf_size == 0) {
free(local_buf);
return (0);
}
/*
* Look for SUNWattr_ro (VIEW_READONLY) and SUNWattr_rw
* (VIEW_READWRITE) in the directory entries and remove them
* from the dirent buffer.
*/
for (buf_current = local_buf;
(size_t)(buf_current - local_buf) < buf_size; /* cstyle */) {
if (strcmp(dirent_name(buf_current), VIEW_READONLY) != 0 &&
strcmp(dirent_name(buf_current), VIEW_READWRITE) != 0) {
/*
* The dirent refers to an attribute that should
* be visible to Solaris 10 processes. Keep it
* and examine the next entry in the buffer.
*/
buf_current += dirent_reclen(buf_current);
} else {
/*
* We found either SUNWattr_ro (VIEW_READONLY)
* or SUNWattr_rw (VIEW_READWRITE). Remove it
* from the dirent buffer by decrementing
* buf_size by the size of the entry and
* overwriting the entry with the remaining
* entries.
*/
buf_size -= dirent_reclen(buf_current);
(void) memmove(buf_current, buf_current +
dirent_reclen(buf_current), buf_size -
(size_t)(buf_current - local_buf));
}
}
/*
* Copy local_buf into buf so that the calling process can see
* the results.
*/
if ((err = brand_uucopy(local_buf, buf, buf_size)) != 0) {
free(local_buf);
rval->sys_rval1 = -1;
rval->sys_rval2 = 0;
return (err);
}
rval->sys_rval1 = buf_size;
free(local_buf);
return (0);
}
/*
* Solaris Next added two special extended file attributes, SUNWattr_ro and
* SUNWattr_rw, which are called "extended system attributes". They have
* special semantics (e.g., a process cannot unlink SUNWattr_ro) and should
* not appear in solaris10-branded zones because no Solaris 10 applications,
* including system commands such as tar(1), are coded to correctly handle these
* special attributes.
*
* This emulation function solves the aforementioned problem by emulating
* the getdents(2) syscall and filtering both system attributes out of resulting
* directory entry lists. The emulation function only filters results when
* the given file descriptor refers to an extended file attribute directory.
* Filtering getdents(2) results is expensive because it requires dynamic
* memory allocation; however, the performance cost is tolerable because
* we don't expect Solaris 10 processes to frequently examine extended file
* attribute directories.
*
* The brand's emulation library needs two getdents(2) emulation functions
* because getdents(2) comes in two flavors: non-largefile-aware getdents(2)
* and largefile-aware getdents64(2). s10_getdents() handles the non-largefile-
* aware case for 32-bit processes and all getdents(2) syscalls for 64-bit
* processes (64-bit processes use largefile-aware interfaces by default).
* See s10_getdents64() below for the largefile-aware getdents64(2) emulation
* function for 32-bit processes.
*/
static int
s10_getdents(sysret_t *rval, int fd, struct dirent *buf, size_t nbyte)
{
return (s10_getdents_common(rval, fd, (char *)buf, nbyte, SYS_getdents,
offsetof(struct dirent, d_name),
offsetof(struct dirent, d_reclen)));
}
#ifndef _LP64
/*
* This is the largefile-aware version of getdents(2) for 32-bit processes.
* This exists for the same reason that s10_getdents() exists. See the comment
* above s10_getdents().
*/
static int
s10_getdents64(sysret_t *rval, int fd, struct dirent64 *buf, size_t nbyte)
{
return (s10_getdents_common(rval, fd, (char *)buf, nbyte,
SYS_getdents64, offsetof(struct dirent64, d_name),
offsetof(struct dirent64, d_reclen)));
}
#endif /* !_LP64 */
#define S10_TRIVIAL_ACL_CNT 6
#define NATIVE_TRIVIAL_ACL_CNT 3
/*
* Check if the ACL qualifies as a trivial ACL based on the native
* interpretation.
*/
static boolean_t
has_trivial_native_acl(int cmd, int cnt, const char *fname, int fd)
{
int i, err;
sysret_t rval;
ace_t buf[NATIVE_TRIVIAL_ACL_CNT];
if (fname != NULL)
err = __systemcall(&rval, SYS_pathconf + 1024, fname,
_PC_ACL_ENABLED);
else
err = __systemcall(&rval, SYS_fpathconf + 1024, fd,
_PC_ACL_ENABLED);
if (err != 0 || rval.sys_rval1 != _ACL_ACE_ENABLED)
return (B_FALSE);
/*
* If we just got the ACL cnt, we don't need to get it again, its
* passed in as the cnt arg.
*/
if (cmd != ACE_GETACLCNT) {
if (fname != NULL) {
if (__systemcall(&rval, SYS_acl + 1024, fname,
ACE_GETACLCNT, 0, NULL) != 0)
return (B_FALSE);
} else {
if (__systemcall(&rval, SYS_facl + 1024, fd,
ACE_GETACLCNT, 0, NULL) != 0)
return (B_FALSE);
}
cnt = rval.sys_rval1;
}
if (cnt != NATIVE_TRIVIAL_ACL_CNT)
return (B_FALSE);
if (fname != NULL) {
if (__systemcall(&rval, SYS_acl + 1024, fname, ACE_GETACL, cnt,
buf) != 0)
return (B_FALSE);
} else {
if (__systemcall(&rval, SYS_facl + 1024, fd, ACE_GETACL, cnt,
buf) != 0)
return (B_FALSE);
}
/*
* The following is based on the logic from the native OS
* ace_trivial_common() to determine if the native ACL is trivial.
*/
for (i = 0; i < cnt; i++) {
switch (buf[i].a_flags & ACE_TYPE_FLAGS) {
case ACE_OWNER:
case ACE_GROUP|ACE_IDENTIFIER_GROUP:
case ACE_EVERYONE:
break;
default:
return (B_FALSE);
}
if (buf[i].a_flags & (ACE_FILE_INHERIT_ACE|
ACE_DIRECTORY_INHERIT_ACE|ACE_NO_PROPAGATE_INHERIT_ACE|
ACE_INHERIT_ONLY_ACE))
return (B_FALSE);
/*
* Special check for some special bits
*
* Don't allow anybody to deny reading basic
* attributes or a files ACL.
*/
if (buf[i].a_access_mask & (ACE_READ_ACL|ACE_READ_ATTRIBUTES) &&
buf[i].a_type == ACE_ACCESS_DENIED_ACE_TYPE)
return (B_FALSE);
/*
* Delete permissions are never set by default
*/
if (buf[i].a_access_mask & (ACE_DELETE|ACE_DELETE_CHILD))
return (B_FALSE);
/*
* only allow owner@ to have
* write_acl/write_owner/write_attributes/write_xattr/
*/
if (buf[i].a_type == ACE_ACCESS_ALLOWED_ACE_TYPE &&
(!(buf[i].a_flags & ACE_OWNER) && (buf[i].a_access_mask &
(ACE_WRITE_OWNER|ACE_WRITE_ACL| ACE_WRITE_ATTRIBUTES|
ACE_WRITE_NAMED_ATTRS))))
return (B_FALSE);
}
return (B_TRUE);
}
/*
* The following logic is based on the S10 adjust_ace_pair_common() code.
*/
static void
s10_adjust_ace_mask(void *pair, size_t access_off, size_t pairsize, mode_t mode)
{
char *datap = (char *)pair;
uint32_t *amask0 = (uint32_t *)(uintptr_t)(datap + access_off);
uint32_t *amask1 = (uint32_t *)(uintptr_t)(datap + pairsize +
access_off);
if (mode & S_IROTH)
*amask1 |= ACE_READ_DATA;
else
*amask0 |= ACE_READ_DATA;
if (mode & S_IWOTH)
*amask1 |= ACE_WRITE_DATA|ACE_APPEND_DATA;
else
*amask0 |= ACE_WRITE_DATA|ACE_APPEND_DATA;
if (mode & S_IXOTH)
*amask1 |= ACE_EXECUTE;
else
*amask0 |= ACE_EXECUTE;
}
/*
* Construct a trivial S10 style ACL.
*/
static int
make_trivial_s10_acl(const char *fname, int fd, ace_t *bp)
{
int err;
sysret_t rval;
struct stat64 buf;
ace_t trivial_s10_acl[] = {
{(uint_t)-1, 0, ACE_OWNER, ACE_ACCESS_DENIED_ACE_TYPE},
{(uint_t)-1, ACE_WRITE_ACL|ACE_WRITE_OWNER|ACE_WRITE_ATTRIBUTES|
ACE_WRITE_NAMED_ATTRS, ACE_OWNER,
ACE_ACCESS_ALLOWED_ACE_TYPE},
{(uint_t)-1, 0, ACE_GROUP|ACE_IDENTIFIER_GROUP,
ACE_ACCESS_DENIED_ACE_TYPE},
{(uint_t)-1, 0, ACE_GROUP|ACE_IDENTIFIER_GROUP,
ACE_ACCESS_ALLOWED_ACE_TYPE},
{(uint_t)-1, ACE_WRITE_ACL|ACE_WRITE_OWNER|ACE_WRITE_ATTRIBUTES|
ACE_WRITE_NAMED_ATTRS, ACE_EVERYONE,
ACE_ACCESS_DENIED_ACE_TYPE},
{(uint_t)-1, ACE_READ_ACL|ACE_READ_ATTRIBUTES|
ACE_READ_NAMED_ATTRS|ACE_SYNCHRONIZE, ACE_EVERYONE,
ACE_ACCESS_ALLOWED_ACE_TYPE}
};
if (fname != NULL) {
if ((err = __systemcall(&rval, SYS_fstatat64 + 1024, AT_FDCWD,
fname, &buf, 0)) != 0)
return (err);
} else {
if ((err = __systemcall(&rval, SYS_fstatat64 + 1024, fd,
NULL, &buf, 0)) != 0)
return (err);
}
s10_adjust_ace_mask(&trivial_s10_acl[0], offsetof(ace_t, a_access_mask),
sizeof (ace_t), (buf.st_mode & 0700) >> 6);
s10_adjust_ace_mask(&trivial_s10_acl[2], offsetof(ace_t, a_access_mask),
sizeof (ace_t), (buf.st_mode & 0070) >> 3);
s10_adjust_ace_mask(&trivial_s10_acl[4], offsetof(ace_t, a_access_mask),
sizeof (ace_t), buf.st_mode & 0007);
if (brand_uucopy(&trivial_s10_acl, bp, sizeof (trivial_s10_acl)) != 0)
return (EFAULT);
return (0);
}
/*
* The definition of a trivial ace-style ACL (used by ZFS and NFSv4) has been
* simplified since S10. Instead of 6 entries on a trivial S10 ACE ACL we now
* have 3 streamlined entries. The new, simpler trivial style confuses S10
* commands such as 'ls -v' or 'cp -p' which don't see the expected S10 trivial
* ACL entries and thus assume that there is a complex ACL on the file.
*
* See: PSARC/2010/029 Improved ACL interoperability
*
* Note that the trival ACL detection code is implemented in acl_trival() in
* lib/libsec/common/aclutils.c. It always uses the acl() syscall (not the
* facl syscall) to determine if an ACL is trivial. However, we emulate both
* acl() and facl() so that the two provide consistent results.
*
* We don't currently try to emulate setting of ACLs since the primary
* consumer of this feature is SMB or NFSv4 servers, neither of which are
* supported in solaris10-branded zones. If ACLs are used they must be set on
* files using the native OS interpretation.
*/
int
s10_acl(sysret_t *rval, const char *fname, int cmd, int nentries, void *aclbufp)
{
int res;
res = __systemcall(rval, SYS_acl + 1024, fname, cmd, nentries, aclbufp);
switch (cmd) {
case ACE_GETACLCNT:
if (res == 0 && has_trivial_native_acl(ACE_GETACLCNT,
rval->sys_rval1, fname, 0)) {
rval->sys_rval1 = S10_TRIVIAL_ACL_CNT;
}
break;
case ACE_GETACL:
if (res == 0 &&
has_trivial_native_acl(ACE_GETACL, 0, fname, 0) &&
nentries >= S10_TRIVIAL_ACL_CNT) {
res = make_trivial_s10_acl(fname, 0, aclbufp);
rval->sys_rval1 = S10_TRIVIAL_ACL_CNT;
}
break;
}
return (res);
}
int
s10_facl(sysret_t *rval, int fdes, int cmd, int nentries, void *aclbufp)
{
int res;
res = __systemcall(rval, SYS_facl + 1024, fdes, cmd, nentries, aclbufp);
switch (cmd) {
case ACE_GETACLCNT:
if (res == 0 && has_trivial_native_acl(ACE_GETACLCNT,
rval->sys_rval1, NULL, fdes)) {
rval->sys_rval1 = S10_TRIVIAL_ACL_CNT;
}
break;
case ACE_GETACL:
if (res == 0 &&
has_trivial_native_acl(ACE_GETACL, 0, NULL, fdes) &&
nentries >= S10_TRIVIAL_ACL_CNT) {
res = make_trivial_s10_acl(NULL, fdes, aclbufp);
rval->sys_rval1 = S10_TRIVIAL_ACL_CNT;
}
break;
}
return (res);
}
#define S10_AC_PROC (0x1 << 28)
#define S10_AC_TASK (0x2 << 28)
#define S10_AC_FLOW (0x4 << 28)
#define S10_AC_MODE(x) ((x) & 0xf0000000)
#define S10_AC_OPTION(x) ((x) & 0x0fffffff)
/*
* The mode shift, mode mask and option mask for acctctl have changed. The
* mode is currently the top full byte and the option is the lower 3 full bytes.
*/
int
s10_acctctl(sysret_t *rval, int cmd, void *buf, size_t bufsz)
{
int mode = S10_AC_MODE(cmd);
int option = S10_AC_OPTION(cmd);
switch (mode) {
case S10_AC_PROC:
mode = AC_PROC;
break;
case S10_AC_TASK:
mode = AC_TASK;
break;
case S10_AC_FLOW:
mode = AC_FLOW;
break;
default:
return (B_TRUSS_POINT_3(rval, SYS_acctctl, EINVAL, cmd, buf,
bufsz));
}
return (__systemcall(rval, SYS_acctctl + 1024, mode | option, buf,
bufsz));
}
/*
* The Audit Policy parameters have changed due to:
* 6466722 audituser and AUDIT_USER are defined, unused, undocumented and
* should be removed.
*
* In S10 we had the following flag:
* #define AUDIT_USER 0x0040
* which doesn't exist in Solaris Next where the subsequent flags are shifted
* down. For example, in S10 we had:
* #define AUDIT_GROUP 0x0080
* but on Solaris Next we have:
* #define AUDIT_GROUP 0x0040
* AUDIT_GROUP has the value AUDIT_USER had in S10 and all of the subsequent
* bits are also shifted one place.
*
* When we're getting or setting the Audit Policy parameters we need to
* shift the outgoing or incoming bits into their proper positions. Since
* S10_AUDIT_USER was always unused, we always clear that bit on A_GETPOLICY.
*
* The command we care about, BSM_AUDITCTL, passes the most parameters (3),
* so declare this function to take up to 4 args and just pass them on.
* The number of parameters for s10_auditsys needs to be equal to the BSM_*
* subcommand that has the most parameters, since we want to pass all
* parameters through, regardless of which subcommands we interpose on.
*
* Note that the auditsys system call uses the SYSENT_AP macro wrapper instead
* of the more common SYSENT_CI macro. This means the return value is a
* SE_64RVAL so the syscall table uses RV_64RVAL.
*/
#define S10_AUDIT_HMASK 0xffffffc0
#define S10_AUDIT_LMASK 0x3f
#define S10_AUC_NOSPACE 0x3
int
s10_auditsys(sysret_t *rval, int bsmcmd, intptr_t a0, intptr_t a1, intptr_t a2)
{
int err;
uint32_t m;
if (bsmcmd != BSM_AUDITCTL)
return (__systemcall(rval, SYS_auditsys + 1024, bsmcmd, a0, a1,
a2));
if ((int)a0 == A_GETPOLICY) {
if ((err = __systemcall(rval, SYS_auditsys + 1024, bsmcmd, a0,
&m, a2)) != 0)
return (err);
m = ((m & S10_AUDIT_HMASK) << 1) | (m & S10_AUDIT_LMASK);
if (brand_uucopy(&m, (void *)a1, sizeof (m)) != 0)
return (EFAULT);
return (0);
} else if ((int)a0 == A_SETPOLICY) {
if (brand_uucopy((const void *)a1, &m, sizeof (m)) != 0)
return (EFAULT);
m = ((m >> 1) & S10_AUDIT_HMASK) | (m & S10_AUDIT_LMASK);
return (__systemcall(rval, SYS_auditsys + 1024, bsmcmd, a0, &m,
a2));
} else if ((int)a0 == A_GETCOND) {
if ((err = __systemcall(rval, SYS_auditsys + 1024, bsmcmd, a0,
&m, a2)) != 0)
return (err);
if (m == AUC_NOSPACE)
m = S10_AUC_NOSPACE;
if (brand_uucopy(&m, (void *)a1, sizeof (m)) != 0)
return (EFAULT);
return (0);
} else if ((int)a0 == A_SETCOND) {
if (brand_uucopy((const void *)a1, &m, sizeof (m)) != 0)
return (EFAULT);
if (m == S10_AUC_NOSPACE)
m = AUC_NOSPACE;
return (__systemcall(rval, SYS_auditsys + 1024, bsmcmd, a0, &m,
a2));
}
return (__systemcall(rval, SYS_auditsys + 1024, bsmcmd, a0, a1, a2));
}
/*
* Determine whether the executable passed to SYS_exec or SYS_execve is a
* native executable. The s10_npreload.so invokes the B_S10_NATIVE brand
* operation which patches up the processes exec info to eliminate any trace
* of the wrapper. That will make pgrep and other commands that examine
* process' executable names and command-line parameters work properly.
*/
static int
s10_exec_native(sysret_t *rval, const char *fname, const char **argp,
const char **envp)
{
const char *filename = fname;
char path[64];
int err;
/* Get a copy of the executable we're trying to run */
path[0] = '\0';
(void) brand_uucopystr(filename, path, sizeof (path));
/* Check if we're trying to run a native binary */
if (strncmp(path, "/.SUNWnative/usr/lib/brand/solaris10/s10_native",
sizeof (path)) != 0)
return (0);
/* Skip the first element in the argv array */
argp++;
/*
* The the path of the dynamic linker is the second parameter
* of s10_native_exec().
*/
if (brand_uucopy(argp, &filename, sizeof (char *)) != 0)
return (EFAULT);
/* If an exec call succeeds, it never returns */
err = __systemcall(rval, SYS_brand + 1024, B_EXEC_NATIVE, filename,
argp, envp, NULL, NULL, NULL);
brand_assert(err != 0);
return (err);
}
/*
* Interpose on the SYS_exec syscall to detect native wrappers.
*/
int
s10_exec(sysret_t *rval, const char *fname, const char **argp)
{
int err;
if ((err = s10_exec_native(rval, fname, argp, NULL)) != 0)
return (err);
/* If an exec call succeeds, it never returns */
err = __systemcall(rval, SYS_execve + 1024, fname, argp, NULL, 0);
brand_assert(err != 0);
return (err);
}
/*
* Interpose on the SYS_execve syscall to detect native wrappers.
*/
int
s10_execve(sysret_t *rval, const char *fname, const char **argp,
const char **envp)
{
int err;
if ((err = s10_exec_native(rval, fname, argp, envp)) != 0)
return (err);
/* If an exec call succeeds, it never returns */
err = __systemcall(rval, SYS_execve + 1024, fname, argp, envp, 0);
brand_assert(err != 0);
return (err);
}
/*
* fcntl(2) added an additional argument which we need to pass as zero.
*/
int
s10_fcntl(sysret_t *rval, int fd, int cmd, intptr_t arg)
{
return (__systemcall(rval, SYS_fcntl + 1024, fd, cmd, arg, 0));
}
/*
* Interpose on the SYS_fdsync system call. The structure was chagned to use a
* distinct enum rather than passing a combination of the <sys/file.h> flags
* FSYNC and FDSYNC. The prior system call implementation only passed those two
* flags on to the VFS operation. The system call did not check if the 'flag'
* argument was zero or not; however, we know that in illumos it was always
* called with either FSYNC or FDSYNC explicitly. To try and fail open in a
* sense, we translate any call with no explicit level to a normal fsync(3C)
* style operation.
*/
static int
s10_fdsync(sysret_t *rval, int fd, int flag)
{
uint32_t level;
if ((flag & FSYNC) != 0) {
level = FDSYNC_FILE;
} else if ((flag & FDSYNC) != 0) {
level = FDSYNC_DATA;
} else {
level = FDSYNC_FILE;
}
return (__systemcall(rval, SYS_fdsync + 1024, fd, level));
}
/*
* S10's issetugid() syscall is now a subcode to privsys().
*/
static int
s10_issetugid(sysret_t *rval)
{
return (__systemcall(rval, SYS_privsys + 1024, PRIVSYS_ISSETUGID,
0, 0, 0, 0, 0));
}
/*
* S10's socket() syscall does not split type and flags
*/
static int
s10_so_socket(sysret_t *rval, int domain, int type, int protocol,
char *devpath, int version)
{
if ((type & ~SOCK_TYPE_MASK) != 0) {
errno = EINVAL;
return (-1);
}
return (__systemcall(rval, SYS_so_socket + 1024, domain, type,
protocol, devpath, version));
}
/*
* S10's pipe() syscall has a different calling convention
*/
static int
s10_pipe(sysret_t *rval)
{
int fds[2], err;
if ((err = __systemcall(rval, SYS_pipe + 1024, fds, 0)) != 0)
return (err);
rval->sys_rval1 = fds[0];
rval->sys_rval2 = fds[1];
return (0);
}
/*
* S10's accept() syscall takes three arguments
*/
static int
s10_accept(sysret_t *rval, int sock, struct sockaddr *addr, uint_t *addrlen,
int version)
{
return (__systemcall(rval, SYS_accept + 1024, sock, addr, addrlen,
version, 0));
}
static long
s10_uname(sysret_t *rv, uintptr_t p1)
{
struct utsname un, *unp = (struct utsname *)p1;
int rev, err;
if ((err = __systemcall(rv, SYS_uname + 1024, &un)) != 0)
return (err);
rev = atoi(&un.release[2]);
brand_assert(rev >= 11);
bzero(un.release, _SYS_NMLN);
(void) strlcpy(un.release, S10_UTS_RELEASE, _SYS_NMLN);
bzero(un.version, _SYS_NMLN);
(void) strlcpy(un.version, S10_UTS_VERSION, _SYS_NMLN);
/* copy out the modified uname info */
return (brand_uucopy(&un, unp, sizeof (un)));
}
int
s10_sysconfig(sysret_t *rv, int which)
{
long value;
/*
* We must interpose on the sysconfig(2) requests
* that deal with the realtime signal number range.
* All others get passed to the native sysconfig(2).
*/
switch (which) {
case _CONFIG_RTSIG_MAX:
value = S10_SIGRTMAX - S10_SIGRTMIN + 1;
break;
case _CONFIG_SIGRT_MIN:
value = S10_SIGRTMIN;
break;
case _CONFIG_SIGRT_MAX:
value = S10_SIGRTMAX;
break;
default:
return (__systemcall(rv, SYS_sysconfig + 1024, which));
}
(void) B_TRUSS_POINT_1(rv, SYS_sysconfig, 0, which);
rv->sys_rval1 = value;
rv->sys_rval2 = 0;
return (0);
}
int
s10_sysinfo(sysret_t *rv, int command, char *buf, long count)
{
char *value;
int len;
/*
* We must interpose on the sysinfo(2) commands SI_RELEASE and
* SI_VERSION; all others get passed to the native sysinfo(2)
* command.
*/
switch (command) {
case SI_RELEASE:
value = S10_UTS_RELEASE;
break;
case SI_VERSION:
value = S10_UTS_VERSION;
break;
default:
/*
* The default action is to pass the command to the
* native sysinfo(2) syscall.
*/
return (__systemcall(rv, SYS_systeminfo + 1024,
command, buf, count));
}
len = strlen(value) + 1;
if (count > 0) {
if (brand_uucopystr(value, buf, count) != 0)
return (EFAULT);
/*
* Assure NULL termination of buf as brand_uucopystr() doesn't.
*/
if (len > count && brand_uucopy("\0", buf + (count - 1), 1)
!= 0)
return (EFAULT);
}
/*
* On success, sysinfo(2) returns the size of buffer required to hold
* the complete value plus its terminating NULL byte.
*/
(void) B_TRUSS_POINT_3(rv, SYS_systeminfo, 0, command, buf, count);
rv->sys_rval1 = len;
rv->sys_rval2 = 0;
return (0);
}
#if defined(__x86)
#if defined(__amd64)
/*
* 64-bit x86 LWPs created by SYS_lwp_create start here if they need to set
* their %fs registers to the legacy Solaris 10 selector value.
*
* This function does three things:
*
* 1. Trap to the kernel so that it can set %fs to the legacy Solaris 10
* selector value.
* 2. Read the LWP's true entry point (the entry point supplied by libc
* when SYS_lwp_create was invoked) from %r14.
* 3. Eliminate this function's stack frame and pass control to the LWP's
* true entry point.
*
* See the comment above s10_lwp_create_correct_fs() (see below) for the reason
* why this function exists.
*/
/*ARGSUSED*/
static void
s10_lwp_create_entry_point(void *ulwp_structp)
{
sysret_t rval;
/*
* The new LWP's %fs register is initially zero, but libc won't
* function correctly when %fs is zero. Change the LWP's %fs register
* via SYS_brand.
*/
(void) __systemcall(&rval, SYS_brand + 1024, B_S10_FSREGCORRECTION);
/*
* Jump to the true entry point, which is stored in %r14.
* Remove our stack frame before jumping so that
* s10_lwp_create_entry_point() won't be seen in stack traces.
*
* NOTE: s10_lwp_create_entry_point() pushes %r12 onto its stack frame
* so that it can use it as a temporary register. We don't restore %r12
* in this assembly block because we don't care about its value (and
* neither does _lwp_start()). Besides, the System V ABI AMD64
* Actirecture Processor Supplement doesn't specify that %r12 should
* have a special value when LWPs start, so we can ignore its value when
* we jump to the true entry point. Furthermore, %r12 is a callee-saved
* register, so the true entry point should push %r12 onto its stack
* before using the register. We ignore %r14 after we read it for
* similar reasons.
*
* NOTE: The compiler will generate a function epilogue for this
* function despite the fact that the LWP will never execute it.
* We could hand-code this entire function in assembly to eliminate
* the epilogue, but the epilogue is only three or four instructions,
* so we wouldn't save much space. Besides, why would we want
* to create yet another ugly, hard-to-maintain assembly function when
* we could write most of it in C?
*/
__asm__ __volatile__(
"movq %0, %%rdi\n\t" /* pass ulwp_structp as arg1 */
"movq %%rbp, %%rsp\n\t" /* eliminate the stack frame */
"popq %%rbp\n\t"
"jmp *%%r14\n\t" /* jump to the true entry point */
: : "r" (ulwp_structp));
/*NOTREACHED*/
}
/*
* The S10 libc expects that %fs will be nonzero for new 64-bit x86 LWPs but the
* Nevada kernel clears %fs for such LWPs. Unforunately, new LWPs do not issue
* SYS_lwp_private (see s10_lwp_private() below) after they are created, so
* we must ensure that new LWPs invoke a brand operation that sets %fs to a
* nonzero value immediately after their creation.
*
* The easiest way to do this is to make new LWPs start at a special function,
* s10_lwp_create_entry_point() (see its definition above), that invokes the
* brand operation that corrects %fs. We'll store the entry points of new LWPs
* in their %r14 registers so that s10_lwp_create_entry_point() can find and
* call them after invoking the special brand operation. %r14 is a callee-saved
* register; therefore, any functions invoked by s10_lwp_create_entry_point()
* and all functions dealing with signals (e.g., sigacthandler()) will preserve
* %r14 for s10_lwp_create_entry_point().
*
* The Nevada kernel can safely work with nonzero %fs values because the kernel
* configures per-thread %fs segment descriptors so that the legacy %fs selector
* value will still work. See the comment in lwp_load() regarding %fs and
* %fsbase in 64-bit x86 processes.
*
* This emulation exists thanks to CRs 6467491 and 6501650.
*/
static int
s10_lwp_create_correct_fs(sysret_t *rval, ucontext_t *ucp, int flags,
id_t *new_lwp)
{
ucontext_t s10_uc;
/*
* Copy the supplied ucontext_t structure to the local stack
* frame and store the new LWP's entry point (the value of %rip
* stored in the ucontext_t) in the new LWP's %r14 register.
* Then make s10_lwp_create_entry_point() the new LWP's entry
* point.
*/
if (brand_uucopy(ucp, &s10_uc, sizeof (s10_uc)) != 0)
return (EFAULT);
s10_uc.uc_mcontext.gregs[REG_R14] = s10_uc.uc_mcontext.gregs[REG_RIP];
s10_uc.uc_mcontext.gregs[REG_RIP] = (greg_t)s10_lwp_create_entry_point;
/* fix up the signal mask */
if (s10_uc.uc_flags & UC_SIGMASK)
(void) s10sigset_to_native(&s10_uc.uc_sigmask,
&s10_uc.uc_sigmask);
/*
* Issue SYS_lwp_create to create the new LWP. We pass the
* modified ucontext_t to make sure that the new LWP starts at
* s10_lwp_create_entry_point().
*/
return (__systemcall(rval, SYS_lwp_create + 1024, &s10_uc,
flags, new_lwp));
}
#endif /* __amd64 */
/*
* SYS_lwp_private is issued by libc_init() to set %fsbase in 64-bit x86
* processes. The Nevada kernel sets %fs to zero but the S10 libc expects
* %fs to be nonzero. We'll pass the issued system call to the kernel untouched
* and invoke a brand operation to set %fs to the legacy S10 selector value.
*
* This emulation exists thanks to CRs 6467491 and 6501650.
*/
static int
s10_lwp_private(sysret_t *rval, int cmd, int which, uintptr_t base)
{
#if defined(__amd64)
int err;
/*
* The current LWP's %fs register should be zero. Determine whether the
* Solaris 10 libc with which we're working functions correctly when %fs
* is zero by calling thr_main() after issuing the SYS_lwp_private
* syscall. If thr_main() barfs (returns -1), then change the LWP's %fs
* register via SYS_brand and patch brand_sysent_table so that issuing
* SYS_lwp_create executes s10_lwp_create_correct_fs() rather than the
* default s10_lwp_create(). s10_lwp_create_correct_fs() will
* guarantee that new LWPs will have correct %fs values.
*/
if ((err = __systemcall(rval, SYS_lwp_private + 1024, cmd, which,
base)) != 0)
return (err);
if (thr_main() == -1) {
/*
* SYS_lwp_private is only issued by libc_init(), which is
* executed when libc is first loaded by ld.so.1. Thus we
* are guaranteed to be single-threaded at this point. Even
* if we were multithreaded at this point, writing a 64-bit
* value to the st_callc field of a brand_sysent_table
* entry is guaranteed to be atomic on 64-bit x86 chips
* as long as the field is not split across cache lines
* (It shouldn't be.). See chapter 8, section 1.1 of
* "The Intel 64 and IA32 Architectures Software Developer's
* Manual," Volume 3A for more details.
*/
brand_sysent_table[SYS_lwp_create].st_callc =
(sysent_cb_t)(uintptr_t)s10_lwp_create_correct_fs;
return (__systemcall(rval, SYS_brand + 1024,
B_S10_FSREGCORRECTION));
}
return (0);
#else /* !__amd64 */
return (__systemcall(rval, SYS_lwp_private + 1024, cmd, which, base));
#endif /* !__amd64 */
}
#endif /* __x86 */
/*
* The Opensolaris versions of lwp_mutex_timedlock() and lwp_mutex_trylock()
* add an extra argument to the interfaces, a uintptr_t value for the mutex's
* mutex_owner field. The Solaris 10 libc assigns the mutex_owner field at
* user-level, so we just make the extra argument be zero in both syscalls.
*/
static int
s10_lwp_mutex_timedlock(sysret_t *rval, lwp_mutex_t *lp, timespec_t *tsp)
{
return (__systemcall(rval, SYS_lwp_mutex_timedlock + 1024, lp, tsp, 0));
}
static int
s10_lwp_mutex_trylock(sysret_t *rval, lwp_mutex_t *lp)
{
return (__systemcall(rval, SYS_lwp_mutex_trylock + 1024, lp, 0));
}
/*
* If the emul_global_zone flag is set then emulate some aspects of the
* zone system call. In particular, emulate the global zone ID on the
* ZONE_LOOKUP subcommand and emulate some of the global zone attributes
* on the ZONE_GETATTR subcommand. If the flag is not set or we're performing
* some other operation, simply pass the calls through.
*/
int
s10_zone(sysret_t *rval, int cmd, void *arg1, void *arg2, void *arg3,
void *arg4)
{
char *aval;
int len;
zoneid_t zid;
int attr;
char *buf;
size_t bufsize;
/*
* We only emulate the zone syscall for a subset of specific commands,
* otherwise we just pass the call through.
*/
if (!emul_global_zone)
return (__systemcall(rval, SYS_zone + 1024, cmd, arg1, arg2,
arg3, arg4));
switch (cmd) {
case ZONE_LOOKUP:
(void) B_TRUSS_POINT_1(rval, SYS_zone, 0, cmd);
rval->sys_rval1 = GLOBAL_ZONEID;
rval->sys_rval2 = 0;
return (0);
case ZONE_GETATTR:
zid = (zoneid_t)(uintptr_t)arg1;
attr = (int)(uintptr_t)arg2;
buf = (char *)arg3;
bufsize = (size_t)arg4;
/*
* If the request is for the global zone then we're emulating
* that, otherwise pass this thru.
*/
if (zid != GLOBAL_ZONEID)
goto passthru;
switch (attr) {
case ZONE_ATTR_NAME:
aval = GLOBAL_ZONENAME;
break;
case ZONE_ATTR_BRAND:
aval = NATIVE_BRAND_NAME;
break;
default:
/*
* We only emulate a subset of the attrs, use the
* real zone id to pass thru the rest.
*/
arg1 = (void *)(uintptr_t)zoneid;
goto passthru;
}
(void) B_TRUSS_POINT_5(rval, SYS_zone, 0, cmd, zid, attr,
buf, bufsize);
len = strlen(aval) + 1;
if (len > bufsize)
return (ENAMETOOLONG);
if (buf != NULL) {
if (len == 1) {
if (brand_uucopy("\0", buf, 1) != 0)
return (EFAULT);
} else {
if (brand_uucopystr(aval, buf, len) != 0)
return (EFAULT);
/*
* Assure NULL termination of "buf" as
* brand_uucopystr() does NOT.
*/
if (brand_uucopy("\0", buf + (len - 1), 1) != 0)
return (EFAULT);
}
}
rval->sys_rval1 = len;
rval->sys_rval2 = 0;
return (0);
default:
break;
}
passthru:
return (__systemcall(rval, SYS_zone + 1024, cmd, arg1, arg2, arg3,
arg4));
}
/*ARGSUSED*/
int
brand_init(int argc, char *argv[], char *envp[])
{
sysret_t rval;
ulong_t ldentry;
int err;
char *bname;
brand_pre_init();
/*
* Cache the pid of the zone's init process and determine if
* we're init(8) for the zone. Remember: we might be init
* now, but as soon as we fork(2) we won't be.
*/
(void) get_initpid_info();
/* get the current zoneid */
err = __systemcall(&rval, SYS_zone, ZONE_LOOKUP, NULL);
brand_assert(err == 0);
zoneid = (zoneid_t)rval.sys_rval1;
/* Get the zone's emulation bitmap. */
if ((err = __systemcall(&rval, SYS_zone, ZONE_GETATTR, zoneid,
S10_EMUL_BITMAP, emul_bitmap, sizeof (emul_bitmap))) != 0) {
brand_abort(err, "The zone's patch level is unsupported");
/*NOTREACHED*/
}
bname = basename(argv[0]);
/*
* In general we want the S10 commands that are zone-aware to continue
* to behave as they normally do within a zone. Since these commands
* are zone-aware, they should continue to "do the right thing".
* However, some zone-aware commands aren't going to work the way
* we expect them to inside the branded zone. In particular, the pkg
* and patch commands will not properly manage all pkgs/patches
* unless the commands think they are running in the global zone. For
* these commands we want to emulate the global zone.
*
* We don't do any emulation for pkgcond since it is typically used
* in pkg/patch postinstall scripts and we want those scripts to do
* the right thing inside a zone.
*
* One issue is the handling of hollow pkgs. Since the pkgs are
* hollow, they won't use pkgcond in their postinstall scripts. These
* pkgs typically are installing drivers so we handle that by
* replacing add_drv and rem_drv in the s10_boot script.
*/
if (strcmp("pkgadd", bname) == 0 || strcmp("pkgrm", bname) == 0 ||
strcmp("patchadd", bname) == 0 || strcmp("patchrm", bname) == 0)
emul_global_zone = B_TRUE;
ldentry = brand_post_init(S10_VERSION, argc, argv, envp);
brand_runexe(argv, ldentry);
/*NOTREACHED*/
brand_abort(0, "brand_runexe() returned");
return (-1);
}
/*
* This table must have at least NSYSCALL entries in it.
*
* The second parameter of each entry in the brand_sysent_table
* contains the number of parameters and flags that describe the
* syscall return value encoding. See the block comments at the
* top of this file for more information about the syscall return
* value flags and when they should be used.
*/
brand_sysent_table_t brand_sysent_table[] = {
#if defined(__sparc) && !defined(__sparcv9)
EMULATE(brand_indir, 9 | RV_64RVAL), /* 0 */
#else
NOSYS, /* 0 */
#endif
NOSYS, /* 1 */
EMULATE(s10_forkall, 0 | RV_32RVAL2), /* 2 */
NOSYS, /* 3 */
NOSYS, /* 4 */
EMULATE(s10_open, 3 | RV_DEFAULT), /* 5 */
NOSYS, /* 6 */
EMULATE(s10_wait, 0 | RV_32RVAL2), /* 7 */
EMULATE(s10_creat, 2 | RV_DEFAULT), /* 8 */
EMULATE(s10_link, 2 | RV_DEFAULT), /* 9 */
EMULATE(s10_unlink, 1 | RV_DEFAULT), /* 10 */
EMULATE(s10_exec, 2 | RV_DEFAULT), /* 11 */
NOSYS, /* 12 */
NOSYS, /* 13 */
EMULATE(s10_mknod, 3 | RV_DEFAULT), /* 14 */
EMULATE(s10_chmod, 2 | RV_DEFAULT), /* 15 */
EMULATE(s10_chown, 3 | RV_DEFAULT), /* 16 */
NOSYS, /* 17 */
EMULATE(s10_stat, 2 | RV_DEFAULT), /* 18 */
NOSYS, /* 19 */
NOSYS, /* 20 */
NOSYS, /* 21 */
EMULATE(s10_umount, 1 | RV_DEFAULT), /* 22 */
NOSYS, /* 23 */
NOSYS, /* 24 */
NOSYS, /* 25 */
NOSYS, /* 26 */
NOSYS, /* 27 */
EMULATE(s10_fstat, 2 | RV_DEFAULT), /* 28 */
NOSYS, /* 29 */
EMULATE(s10_utime, 2 | RV_DEFAULT), /* 30 */
NOSYS, /* 31 */
NOSYS, /* 32 */
EMULATE(s10_access, 2 | RV_DEFAULT), /* 33 */
NOSYS, /* 34 */
NOSYS, /* 35 */
NOSYS, /* 36 */
EMULATE(s10_kill, 2 | RV_DEFAULT), /* 37 */
NOSYS, /* 38 */
NOSYS, /* 39 */
NOSYS, /* 40 */
EMULATE(s10_dup, 1 | RV_DEFAULT), /* 41 */
EMULATE(s10_pipe, 0 | RV_32RVAL2), /* 42 */
NOSYS, /* 43 */
NOSYS, /* 44 */
NOSYS, /* 45 */
NOSYS, /* 46 */
NOSYS, /* 47 */
NOSYS, /* 48 */
NOSYS, /* 49 */
NOSYS, /* 50 */
NOSYS, /* 51 */
NOSYS, /* 52 */
NOSYS, /* 53 */
EMULATE(s10_ioctl, 3 | RV_DEFAULT), /* 54 */
NOSYS, /* 55 */
NOSYS, /* 56 */
NOSYS, /* 57 */
EMULATE(s10_fdsync, 2 | RV_DEFAULT), /* 58 */
EMULATE(s10_execve, 3 | RV_DEFAULT), /* 59 */
NOSYS, /* 60 */
NOSYS, /* 61 */
EMULATE(s10_fcntl, 3 | RV_DEFAULT), /* 62 */
NOSYS, /* 63 */
NOSYS, /* 64 */
NOSYS, /* 65 */
NOSYS, /* 66 */
NOSYS, /* 67 */
NOSYS, /* 68 */
NOSYS, /* 69 */
NOSYS, /* 70 */
EMULATE(s10_acctctl, 3 | RV_DEFAULT), /* 71 */
NOSYS, /* 72 */
NOSYS, /* 73 */
NOSYS, /* 74 */
EMULATE(s10_issetugid, 0 | RV_DEFAULT), /* 75 */
EMULATE(s10_fsat, 6 | RV_DEFAULT), /* 76 */
NOSYS, /* 77 */
NOSYS, /* 78 */
EMULATE(s10_rmdir, 1 | RV_DEFAULT), /* 79 */
EMULATE(s10_mkdir, 2 | RV_DEFAULT), /* 80 */
EMULATE(s10_getdents, 3 | RV_DEFAULT), /* 81 */
NOSYS, /* 82 */
NOSYS, /* 83 */
NOSYS, /* 84 */
NOSYS, /* 85 */
NOSYS, /* 86 */
EMULATE(s10_poll, 3 | RV_DEFAULT), /* 87 */
EMULATE(s10_lstat, 2 | RV_DEFAULT), /* 88 */
EMULATE(s10_symlink, 2 | RV_DEFAULT), /* 89 */
EMULATE(s10_readlink, 3 | RV_DEFAULT), /* 90 */
NOSYS, /* 91 */
NOSYS, /* 92 */
EMULATE(s10_fchmod, 2 | RV_DEFAULT), /* 93 */
EMULATE(s10_fchown, 3 | RV_DEFAULT), /* 94 */
EMULATE(s10_sigprocmask, 3 | RV_DEFAULT), /* 95 */
EMULATE(s10_sigsuspend, 1 | RV_DEFAULT), /* 96 */
NOSYS, /* 97 */
EMULATE(s10_sigaction, 3 | RV_DEFAULT), /* 98 */
EMULATE(s10_sigpending, 2 | RV_DEFAULT), /* 99 */
NOSYS, /* 100 */
NOSYS, /* 101 */
NOSYS, /* 102 */
NOSYS, /* 103 */
NOSYS, /* 104 */
NOSYS, /* 105 */
NOSYS, /* 106 */
EMULATE(s10_waitid, 4 | RV_DEFAULT), /* 107 */
EMULATE(s10_sigsendsys, 2 | RV_DEFAULT), /* 108 */
NOSYS, /* 109 */
NOSYS, /* 110 */
NOSYS, /* 111 */
NOSYS, /* 112 */
NOSYS, /* 113 */
NOSYS, /* 114 */
NOSYS, /* 115 */
NOSYS, /* 116 */
NOSYS, /* 117 */
NOSYS, /* 118 */
NOSYS, /* 119 */
NOSYS, /* 120 */
NOSYS, /* 121 */
NOSYS, /* 122 */
#if defined(__x86)
EMULATE(s10_xstat, 3 | RV_DEFAULT), /* 123 */
EMULATE(s10_lxstat, 3 | RV_DEFAULT), /* 124 */
EMULATE(s10_fxstat, 3 | RV_DEFAULT), /* 125 */
EMULATE(s10_xmknod, 4 | RV_DEFAULT), /* 126 */
#else
NOSYS, /* 123 */
NOSYS, /* 124 */
NOSYS, /* 125 */
NOSYS, /* 126 */
#endif
NOSYS, /* 127 */
NOSYS, /* 128 */
NOSYS, /* 129 */
EMULATE(s10_lchown, 3 | RV_DEFAULT), /* 130 */
NOSYS, /* 131 */
NOSYS, /* 132 */
NOSYS, /* 133 */
EMULATE(s10_rename, 2 | RV_DEFAULT), /* 134 */
EMULATE(s10_uname, 1 | RV_DEFAULT), /* 135 */
NOSYS, /* 136 */
EMULATE(s10_sysconfig, 1 | RV_DEFAULT), /* 137 */
NOSYS, /* 138 */
EMULATE(s10_sysinfo, 3 | RV_DEFAULT), /* 139 */
NOSYS, /* 140 */
NOSYS, /* 141 */
NOSYS, /* 142 */
EMULATE(s10_fork1, 0 | RV_32RVAL2), /* 143 */
EMULATE(s10_sigtimedwait, 3 | RV_DEFAULT), /* 144 */
NOSYS, /* 145 */
NOSYS, /* 146 */
EMULATE(s10_lwp_sema_wait, 1 | RV_DEFAULT), /* 147 */
NOSYS, /* 148 */
NOSYS, /* 149 */
NOSYS, /* 150 */
NOSYS, /* 151 */
NOSYS, /* 152 */
NOSYS, /* 153 */
EMULATE(s10_utimes, 2 | RV_DEFAULT), /* 154 */
NOSYS, /* 155 */
NOSYS, /* 156 */
NOSYS, /* 157 */
NOSYS, /* 158 */
EMULATE(s10_lwp_create, 3 | RV_DEFAULT), /* 159 */
NOSYS, /* 160 */
NOSYS, /* 161 */
NOSYS, /* 162 */
EMULATE(s10_lwp_kill, 2 | RV_DEFAULT), /* 163 */
NOSYS, /* 164 */
EMULATE(s10_lwp_sigmask, 3 | RV_32RVAL2), /* 165 */
#if defined(__x86)
EMULATE(s10_lwp_private, 3 | RV_DEFAULT), /* 166 */
#else
NOSYS, /* 166 */
#endif
NOSYS, /* 167 */
NOSYS, /* 168 */
EMULATE(s10_lwp_mutex_lock, 1 | RV_DEFAULT), /* 169 */
NOSYS, /* 170 */
NOSYS, /* 171 */
NOSYS, /* 172 */
NOSYS, /* 173 */
EMULATE(s10_pwrite, 4 | RV_DEFAULT), /* 174 */
NOSYS, /* 175 */
NOSYS, /* 176 */
NOSYS, /* 177 */
NOSYS, /* 178 */
NOSYS, /* 179 */
NOSYS, /* 180 */
NOSYS, /* 181 */
NOSYS, /* 182 */
NOSYS, /* 183 */
NOSYS, /* 184 */
EMULATE(s10_acl, 4 | RV_DEFAULT), /* 185 */
EMULATE(s10_auditsys, 4 | RV_64RVAL), /* 186 */
NOSYS, /* 187 */
NOSYS, /* 188 */
NOSYS, /* 189 */
EMULATE(s10_sigqueue, 4 | RV_DEFAULT), /* 190 */
NOSYS, /* 191 */
NOSYS, /* 192 */
NOSYS, /* 193 */
NOSYS, /* 194 */
NOSYS, /* 195 */
NOSYS, /* 196 */
NOSYS, /* 197 */
NOSYS, /* 198 */
NOSYS, /* 199 */
EMULATE(s10_facl, 4 | RV_DEFAULT), /* 200 */
NOSYS, /* 201 */
NOSYS, /* 202 */
NOSYS, /* 203 */
NOSYS, /* 204 */
EMULATE(s10_signotify, 3 | RV_DEFAULT), /* 205 */
NOSYS, /* 206 */
NOSYS, /* 207 */
NOSYS, /* 208 */
NOSYS, /* 209 */
EMULATE(s10_lwp_mutex_timedlock, 2 | RV_DEFAULT), /* 210 */
NOSYS, /* 211 */
NOSYS, /* 212 */
#if defined(_LP64)
NOSYS, /* 213 */
#else
EMULATE(s10_getdents64, 3 | RV_DEFAULT), /* 213 */
#endif
NOSYS, /* 214 */
#if defined(_LP64)
NOSYS, /* 215 */
NOSYS, /* 216 */
NOSYS, /* 217 */
#else
EMULATE(s10_stat64, 2 | RV_DEFAULT), /* 215 */
EMULATE(s10_lstat64, 2 | RV_DEFAULT), /* 216 */
EMULATE(s10_fstat64, 2 | RV_DEFAULT), /* 217 */
#endif
NOSYS, /* 218 */
NOSYS, /* 219 */
NOSYS, /* 220 */
NOSYS, /* 221 */
NOSYS, /* 222 */
#if defined(_LP64)
NOSYS, /* 223 */
NOSYS, /* 224 */
NOSYS, /* 225 */
#else
EMULATE(s10_pwrite64, 5 | RV_DEFAULT), /* 223 */
EMULATE(s10_creat64, 2 | RV_DEFAULT), /* 224 */
EMULATE(s10_open64, 3 | RV_DEFAULT), /* 225 */
#endif
NOSYS, /* 226 */
EMULATE(s10_zone, 5 | RV_DEFAULT), /* 227 */
NOSYS, /* 228 */
NOSYS, /* 229 */
EMULATE(s10_so_socket, 5 | RV_DEFAULT), /* 230 */
NOSYS, /* 231 */
NOSYS, /* 232 */
NOSYS, /* 233 */
EMULATE(s10_accept, 4 | RV_DEFAULT), /* 234 */
NOSYS, /* 235 */
NOSYS, /* 236 */
NOSYS, /* 237 */
NOSYS, /* 238 */
NOSYS, /* 239 */
NOSYS, /* 240 */
NOSYS, /* 241 */
NOSYS, /* 242 */
NOSYS, /* 243 */
NOSYS, /* 244 */
NOSYS, /* 245 */
NOSYS, /* 246 */
NOSYS, /* 247 */
NOSYS, /* 248 */
NOSYS, /* 249 */
NOSYS, /* 250 */
EMULATE(s10_lwp_mutex_trylock, 1 | RV_DEFAULT), /* 251 */
NOSYS, /* 252 */
NOSYS, /* 253 */
NOSYS, /* 254 */
NOSYS /* 255 */
};
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/poll.h>
#include <sys/file.h>
#include <sys/syscall.h>
#include <s10_brand.h>
#include <brand_misc.h>
#include <s10_misc.h>
/*
* This file contains the emulation functions for all of the
* obsolete system call traps that existed in Solaris 10 but
* that have been deleted in the current version of Solaris.
*/
static int
s10_fstatat(sysret_t *rval,
int fd, const char *path, struct stat *sb, int flags)
{
return (__systemcall(rval, SYS_fstatat + 1024,
fd, path, sb, flags));
}
int
s10_stat(sysret_t *rval, const char *path, struct stat *sb)
{
return (__systemcall(rval, SYS_fstatat + 1024,
AT_FDCWD, path, sb, 0));
}
int
s10_lstat(sysret_t *rval, const char *path, struct stat *sb)
{
return (__systemcall(rval, SYS_fstatat + 1024,
AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
}
int
s10_fstat(sysret_t *rval, int filedes, struct stat *sb)
{
return (__systemcall(rval, SYS_fstatat + 1024,
filedes, NULL, sb, 0));
}
#if !defined(_LP64)
static int
s10_fstatat64(sysret_t *rval,
int fd, const char *path, struct stat64 *sb, int flags)
{
return (__systemcall(rval, SYS_fstatat64 + 1024,
fd, path, sb, flags));
}
int
s10_stat64(sysret_t *rval, const char *path, struct stat64 *sb)
{
return (__systemcall(rval, SYS_fstatat64 + 1024,
AT_FDCWD, path, sb, 0));
}
int
s10_lstat64(sysret_t *rval, const char *path, struct stat64 *sb)
{
return (__systemcall(rval, SYS_fstatat64 + 1024,
AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
}
int
s10_fstat64(sysret_t *rval, int filedes, struct stat64 *sb)
{
return (__systemcall(rval, SYS_fstatat64 + 1024,
filedes, NULL, sb, 0));
}
#endif /* !_LP64 */
static int
s10_openat(sysret_t *rval, int fd, const char *path, int oflag, mode_t mode)
{
return (__systemcall(rval, SYS_openat + 1024,
fd, path, oflag, mode));
}
int
s10_open(sysret_t *rval, char *path, int oflag, mode_t mode)
{
return (__systemcall(rval, SYS_openat + 1024,
AT_FDCWD, path, oflag, mode));
}
int
s10_creat(sysret_t *rval, char *path, mode_t mode)
{
return (__systemcall(rval, SYS_openat + 1024,
AT_FDCWD, path, O_WRONLY | O_CREAT | O_TRUNC, mode));
}
#if !defined(_LP64)
static int
s10_openat64(sysret_t *rval, int fd, const char *path, int oflag, mode_t mode)
{
return (__systemcall(rval, SYS_openat64 + 1024,
fd, path, oflag, mode));
}
int
s10_open64(sysret_t *rval, char *path, int oflag, mode_t mode)
{
return (__systemcall(rval, SYS_openat64 + 1024,
AT_FDCWD, path, oflag, mode));
}
int
s10_creat64(sysret_t *rval, char *path, mode_t mode)
{
return (__systemcall(rval, SYS_openat64 + 1024,
AT_FDCWD, path, O_WRONLY | O_CREAT | O_TRUNC, mode));
}
#endif /* !_LP64 */
int
s10_fork1(sysret_t *rval)
{
return (__systemcall(rval, SYS_forksys + 1024, 0, 0));
}
int
s10_forkall(sysret_t *rval)
{
return (__systemcall(rval, SYS_forksys + 1024, 1, 0));
}
int
s10_dup(sysret_t *rval, int fd)
{
return (__systemcall(rval, SYS_fcntl + 1024, fd, F_DUPFD, 0, 0));
}
int
s10_poll(sysret_t *rval, struct pollfd *fds, nfds_t nfd, int timeout)
{
timespec_t ts;
timespec_t *tsp;
if (timeout < 0)
tsp = NULL;
else {
ts.tv_sec = timeout / MILLISEC;
ts.tv_nsec = (timeout % MILLISEC) * MICROSEC;
tsp = &ts;
}
return (__systemcall(rval, SYS_pollsys + 1024,
fds, nfd, tsp, NULL));
}
int
s10_lwp_mutex_lock(sysret_t *rval, void *mp)
{
return (__systemcall(rval, SYS_lwp_mutex_timedlock + 1024,
mp, NULL, 0));
}
int
s10_lwp_sema_wait(sysret_t *rval, void *sp)
{
return (__systemcall(rval, SYS_lwp_sema_timedwait + 1024,
sp, NULL, 0));
}
int
s10_chmod(sysret_t *rval, const char *name, mode_t mode)
{
return (__systemcall(rval, SYS_fchmodat + 1024,
AT_FDCWD, name, mode, 0));
}
int
s10_fchmod(sysret_t *rval, int filedes, mode_t mode)
{
return (__systemcall(rval, SYS_fchmodat + 1024,
filedes, NULL, mode, 0));
}
static int
s10_fchownat(sysret_t *rval,
int fd, const char *name, uid_t uid, gid_t gid, int flag)
{
return (__systemcall(rval, SYS_fchownat + 1024,
fd, name, uid, gid, flag));
}
int
s10_chown(sysret_t *rval, const char *name, uid_t uid, gid_t gid)
{
return (__systemcall(rval, SYS_fchownat + 1024,
AT_FDCWD, name, uid, gid, 0));
}
int
s10_lchown(sysret_t *rval, const char *name, uid_t uid, gid_t gid)
{
return (__systemcall(rval, SYS_fchownat + 1024,
AT_FDCWD, name, uid, gid, AT_SYMLINK_NOFOLLOW));
}
int
s10_fchown(sysret_t *rval, int filedes, uid_t uid, gid_t gid)
{
return (__systemcall(rval, SYS_fchownat + 1024,
filedes, NULL, uid, gid, 0));
}
int
s10_mkdir(sysret_t *rval, const char *dname, int dmode)
{
return (__systemcall(rval, SYS_mkdirat + 1024,
AT_FDCWD, dname, dmode));
}
int
s10_mknod(sysret_t *rval, const char *fname, int fmode, dev_t dev)
{
return (__systemcall(rval, SYS_mknodat + 1024,
AT_FDCWD, fname, fmode, dev));
}
int
s10_link(sysret_t *rval, const char *path1, const char *path2)
{
return (__systemcall(rval, SYS_linkat + 1024,
AT_FDCWD, path1, AT_FDCWD, path2, 0));
}
static int
s10_unlinkat(sysret_t *rval, int fd, const char *name, int flags)
{
return (__systemcall(rval, SYS_unlinkat + 1024,
fd, name, flags));
}
int
s10_unlink(sysret_t *rval, const char *name)
{
return (__systemcall(rval, SYS_unlinkat + 1024,
AT_FDCWD, name, 0));
}
int
s10_rmdir(sysret_t *rval, const char *name)
{
return (__systemcall(rval, SYS_unlinkat + 1024,
AT_FDCWD, name, AT_REMOVEDIR));
}
static int
s10_renameat(sysret_t *rval,
int oldfd, const char *oldname, int newfd, const char *newname)
{
return (__systemcall(rval, SYS_renameat + 1024,
oldfd, oldname, newfd, newname));
}
int
s10_rename(sysret_t *rval, const char *oldname, const char *newname)
{
return (__systemcall(rval, SYS_renameat + 1024,
AT_FDCWD, oldname, AT_FDCWD, newname));
}
int
s10_symlink(sysret_t *rval, const char *path1, const char *path2)
{
return (__systemcall(rval, SYS_symlinkat + 1024,
path1, AT_FDCWD, path2));
}
int
s10_readlink(sysret_t *rval, const char *path, char *buf, size_t bufsize)
{
return (__systemcall(rval, SYS_readlinkat + 1024,
AT_FDCWD, path, buf, bufsize));
}
static int
s10_faccessat(sysret_t *rval, int fd, const char *fname, int amode, int flag)
{
return (__systemcall(rval, SYS_faccessat + 1024,
fd, fname, amode, flag));
}
int
s10_access(sysret_t *rval, const char *fname, int amode)
{
return (__systemcall(rval, SYS_faccessat + 1024,
AT_FDCWD, fname, amode, 0));
}
int
s10_utime(sysret_t *rval, const char *path, const struct utimbuf *times)
{
struct utimbuf ltimes;
timespec_t ts[2];
timespec_t *tsp;
if (times == NULL) {
tsp = NULL;
} else {
if (brand_uucopy(times, <imes, sizeof (ltimes)) != 0)
return (EFAULT);
ts[0].tv_sec = ltimes.actime;
ts[0].tv_nsec = 0;
ts[1].tv_sec = ltimes.modtime;
ts[1].tv_nsec = 0;
tsp = ts;
}
return (__systemcall(rval, SYS_utimesys + 1024, 1,
AT_FDCWD, path, tsp, 0));
}
int
s10_utimes(sysret_t *rval, const char *path, const struct timeval times[2])
{
struct timeval ltimes[2];
timespec_t ts[2];
timespec_t *tsp;
if (times == NULL) {
tsp = NULL;
} else {
if (brand_uucopy(times, ltimes, sizeof (ltimes)) != 0)
return (EFAULT);
ts[0].tv_sec = ltimes[0].tv_sec;
ts[0].tv_nsec = ltimes[0].tv_usec * 1000;
ts[1].tv_sec = ltimes[1].tv_sec;
ts[1].tv_nsec = ltimes[1].tv_usec * 1000;
tsp = ts;
}
return (__systemcall(rval, SYS_utimesys + 1024, 1,
AT_FDCWD, path, tsp, 0));
}
static int
s10_futimesat(sysret_t *rval,
int fd, const char *path, const struct timeval times[2])
{
struct timeval ltimes[2];
timespec_t ts[2];
timespec_t *tsp;
if (times == NULL) {
tsp = NULL;
} else {
if (brand_uucopy(times, ltimes, sizeof (ltimes)) != 0)
return (EFAULT);
ts[0].tv_sec = ltimes[0].tv_sec;
ts[0].tv_nsec = ltimes[0].tv_usec * 1000;
ts[1].tv_sec = ltimes[1].tv_sec;
ts[1].tv_nsec = ltimes[1].tv_usec * 1000;
tsp = ts;
}
if (path == NULL)
return (__systemcall(rval, SYS_utimesys + 1024, 0, fd, tsp));
return (__systemcall(rval, SYS_utimesys + 1024, 1, fd, path, tsp, 0));
}
#if defined(__x86)
/* ARGSUSED */
int
s10_xstat(sysret_t *rval, int version, const char *path, struct stat *statb)
{
#if defined(__amd64)
return (EINVAL);
#else
if (version != _STAT_VER)
return (EINVAL);
return (__systemcall(rval, SYS_fstatat + 1024,
AT_FDCWD, path, statb, 0));
#endif
}
/* ARGSUSED */
int
s10_lxstat(sysret_t *rval, int version, const char *path, struct stat *statb)
{
#if defined(__amd64)
return (EINVAL);
#else
if (version != _STAT_VER)
return (EINVAL);
return (__systemcall(rval, SYS_fstatat + 1024,
AT_FDCWD, path, statb, AT_SYMLINK_NOFOLLOW));
#endif
}
/* ARGSUSED */
int
s10_fxstat(sysret_t *rval, int version, int fd, struct stat *statb)
{
#if defined(__amd64)
return (EINVAL);
#else
if (version != _STAT_VER)
return (EINVAL);
return (__systemcall(rval, SYS_fstatat + 1024,
fd, NULL, statb, 0));
#endif
}
/* ARGSUSED */
int
s10_xmknod(sysret_t *rval, int version, const char *path,
mode_t mode, dev_t dev)
{
#if defined(__amd64)
return (EINVAL);
#else
if (version != _MKNOD_VER)
return (EINVAL);
return (__systemcall(rval, SYS_mknodat + 1024,
AT_FDCWD, path, mode, dev));
#endif
}
#endif /* __x86 */
/*
* This is the fsat() system call trap in s10.
* It has been removed in the current system.
*/
int
s10_fsat(sysret_t *rval,
int code, uintptr_t arg1, uintptr_t arg2,
uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
{
switch (code) {
case 0: /* openat */
return (s10_openat(rval, (int)arg1,
(const char *)arg2, (int)arg3, (mode_t)arg4));
case 1: /* openat64 */
#if defined(_LP64)
return (EINVAL);
#else
return (s10_openat64(rval, (int)arg1,
(const char *)arg2, (int)arg3, (mode_t)arg4));
#endif
case 2: /* fstatat64 */
#if defined(_LP64)
return (EINVAL);
#else
return (s10_fstatat64(rval, (int)arg1,
(const char *)arg2, (struct stat64 *)arg3, (int)arg4));
#endif
case 3: /* fstatat */
return (s10_fstatat(rval, (int)arg1,
(const char *)arg2, (struct stat *)arg3, (int)arg4));
case 4: /* fchownat */
return (s10_fchownat(rval, (int)arg1, (char *)arg2,
(uid_t)arg3, (gid_t)arg4, (int)arg5));
case 5: /* unlinkat */
return (s10_unlinkat(rval, (int)arg1, (char *)arg2,
(int)arg3));
case 6: /* futimesat */
return (s10_futimesat(rval, (int)arg1,
(const char *)arg2, (const struct timeval *)arg3));
case 7: /* renameat */
return (s10_renameat(rval, (int)arg1, (char *)arg2,
(int)arg3, (char *)arg4));
case 8: /* faccessat */
return (s10_faccessat(rval, (int)arg1, (char *)arg2,
(int)arg3, (int)arg4));
case 9: /* openattrdirat */
return (s10_openat(rval, (int)arg1,
(const char *)arg2, FXATTRDIROPEN, 0));
}
return (EINVAL);
}
/*
* Interposition upon SYS_umount
*/
int
s10_umount(sysret_t *rval, const char *path)
{
return (__systemcall(rval, SYS_umount2 + 1024, path, 0));
}
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <sys/types.h>
#include <sys/brand.h>
#include <sys/errno.h>
#include <sys/sysconfig.h>
#include <sys/ucontext.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <strings.h>
#include <signal.h>
#include <s10_brand.h>
#include <brand_misc.h>
#include <s10_misc.h>
#include <s10_signal.h>
s10_sighandler_t s10_handlers[S10_NSIG - 1];
/*
* Theory of operation:
*
* As of now, Solaris 10 and solaris_nevada signal numbers match all the
* way through SIGJVM2 (1 - 40) and the first 8 realtime signals (41 - 48).
* However, solaris_nevada provides 32 realtime signals rather than 8 for S10.
*
* We do not assume that the current range of realtime signals is
* _SIGRTMIN - _SIGRTMAX. As a hedge against future changes,
* we obtain the realtime signal range via SIGRTMIN and SIGRTMAX.
*
* Therefore, we must interpose on the various signal calls to translate
* signal masks and signal handlers that deal with SIGRTMIN - SIGRTMAX to
* refer to a potentially different range and to intercenpt any "illegal"
* signals that might otherwise be sent to an S10 process.
*
* Important exception:
* We cannot interpose on the SYS_context system call in order to deal with the
* sigset_t contained within the ucontext_t structure because the getcontext()
* part of this system call trap would then return an incorrect set of machine
* registers. See the getcontext() functions in libc to get the gory details.
* The kernel code for getcontext() and setcontext() has been made brand-aware
* in order to deal with this.
*
* Simple translation is all that is required to handle most system calls,
* but signal handlers also must be interposed upon so that a user signal
* handler sees proper signal numbers in its arguments, any passed siginfo_t
* and in the signal mask reported in its ucontext_t.
*
* libc adds its own signal handler to handled signals such that the
* signal delivery mechanism looks like:
*
* signal ->
* libc sigacthandler() ->
* user signal handler()
*
* With interposition, this will instead look like:
*
* signal ->
* s10_sigacthandler() ->
* libc sigacthandler() ->
* user signal handler()
*/
/*
* A little exposition on SIGRTMIN and SIGRTMAX:
*
* For configurability reasons, in Solaris SIGRTMIN and SIGRTMAX are actually
* #defined to be routines:
*
* #define SIGRTMIN ((int)_sysconf(_SC_SIGRT_MIN))
* #define SIGRTMAX ((int)_sysconf(_SC_SIGRT_MAX))
*
* This means we need routines that will call the native sysconfig() system
* call to find out what the native values for SIGRTMIN and SIGRTMAX are, and
* those are native_sigrtmin() and native_sigrtmax(), respectively.
*
* To try and mitigate confusion this might cause, rather than use SIGRTMIN and
* SIGRTMAX directly, mnemonic convenience macros are #defined to clarify the
* matter:
*
* S10_SIGRTMIN
* S10_SIGRTMAX
* NATIVE_SIGRTMIN
* NATIVE_SIGRTMAX
*/
static int
native_sigrtmin()
{
static int sigrtmin;
sysret_t rval;
if (sigrtmin)
return (sigrtmin);
sigrtmin = __systemcall(&rval, SYS_sysconfig + 1024, _CONFIG_SIGRT_MIN)?
_SIGRTMIN : (int)rval.sys_rval1;
return (sigrtmin);
}
static int
native_sigrtmax()
{
static int sigrtmax;
sysret_t rval;
if (sigrtmax)
return (sigrtmax);
sigrtmax = __systemcall(&rval, SYS_sysconfig + 1024, _CONFIG_SIGRT_MAX)?
_SIGRTMAX : (int)rval.sys_rval1;
return (sigrtmax);
}
#define NATIVE_SIGRTMIN (native_sigrtmin())
#define NATIVE_SIGRTMAX (native_sigrtmax())
/*
* These #defines are setup to create the SIGADDSET and SIGISMEMBER macros,
* needed because the sigaddset(3C) and sigismember(3C) calls make function
* calls that end up being recursive in an interpositioned system call
* environment.
*/
#define MAXBITNO (NBPW*8)
#define SIGWORD(n) ((n-1)/MAXBITNO)
#define BITMASK(n) (1L<<((n-1)%MAXBITNO))
#define SIGADDSET(sigset, sig) \
((sigset)->__sigbits[SIGWORD(sig)] |= BITMASK(sig))
#define SIGISMEMBER(sigset, sig) \
(((sigset)->__sigbits[SIGWORD(sig)] & BITMASK(sig)) != 0)
/*
* Convert an S10 signal number to its native value.
*/
static int
s10sig_to_native(int sig)
{
/* signals 1 .. SIGJVM2 are the same between S10 and native */
if (sig <= SIGJVM2)
return (sig);
/*
* If a signal is > SIGJVM2 but is < S10_SIGRTMIN, it's being used
* for some private purpose we likely wouldn't emulate properly.
*/
if (sig < S10_SIGRTMIN) /* can't happen */
return (-1);
/*
* If an app passes in a signal that is out of range, it
* expects to get back EINVAL.
*/
if (sig > S10_MAXSIG)
return (-1);
/*
* Map S10 RT signals to their native counterparts to the degree
* possible. If the signal would be out of the native RT signal
* range, return an error to the caller.
*/
sig -= S10_SIGRTMIN;
if (sig > (NATIVE_SIGRTMAX - NATIVE_SIGRTMIN))
return (-1);
return (NATIVE_SIGRTMIN + sig);
}
/*
* Convert an S10 sigset_t to its native version.
*/
int
s10sigset_to_native(const sigset_t *s10_set, sigset_t *native_set)
{
int sig;
int nativesig;
sigset_t srcset, newset;
if (brand_uucopy(s10_set, &srcset, sizeof (sigset_t)) != 0)
return (EFAULT);
(void) sigemptyset(&newset);
/*
* Shortcut: we know the first 32 signals are the same in both
* s10 and native Solaris. Just assign the first word.
*/
newset.__sigbits[0] = srcset.__sigbits[0];
/*
* Copy the remainder of the initial set of common signals.
*/
for (sig = 33; sig <= SIGJVM2; sig++)
if (SIGISMEMBER(&srcset, sig))
SIGADDSET(&newset, sig);
/* convert any S10 RT signals to their native equivalents */
for (sig = S10_SIGRTMIN; sig <= S10_SIGRTMAX; sig++) {
if (SIGISMEMBER(&srcset, sig) &&
(nativesig = s10sig_to_native(sig)) > 0)
SIGADDSET(&newset, nativesig);
}
if (brand_uucopy(&newset, native_set, sizeof (sigset_t)) != 0)
return (EFAULT);
return (0);
}
/*
* Convert a native signal number to its S10 value.
*/
int
nativesig_to_s10(int sig)
{
/* signals 1 .. SIGJVM2 are the same between native and S10 */
if (sig <= SIGJVM2)
return (sig);
/*
* We have no way to emulate native signals between (SIGJVM2 + 1) and
* NATIVE_SIGRTMIN, so return an error to the caller.
*/
if (sig < NATIVE_SIGRTMIN) /* can't happen */
return (-1);
/*
* Map native RT signals to their S10 counterparts to the degree
* possible. If the signal would be out of range for S10, return
* an error to the caller.
*/
sig -= NATIVE_SIGRTMIN;
if (sig > (S10_SIGRTMAX - S10_SIGRTMIN))
return (-1);
return (S10_SIGRTMIN + sig);
}
/*
* Convert a native sigset_t to its S10 version.
*/
int
nativesigset_to_s10(const sigset_t *native_set, sigset_t *s10_set)
{
int sig;
int s10sig;
sigset_t srcset, newset;
if (brand_uucopy(native_set, &srcset, sizeof (sigset_t)) != 0)
return (EFAULT);
(void) sigemptyset(&newset);
/*
* Shortcut: we know the first 32 signals are the same in both
* s10 and native Solaris. Just assign the first word.
*/
newset.__sigbits[0] = srcset.__sigbits[0];
/*
* Copy the remainder of the initial set of common signals.
*/
for (sig = 33; sig <= SIGJVM2; sig++)
if (SIGISMEMBER(&srcset, sig))
SIGADDSET(&newset, sig);
/* convert any RT signals to their S10 values */
for (sig = NATIVE_SIGRTMIN; sig <= NATIVE_SIGRTMAX; sig++) {
if (SIGISMEMBER(&srcset, sig) &&
(s10sig = nativesig_to_s10(sig)) > 0)
SIGADDSET(&newset, s10sig);
}
if (brand_uucopy(&newset, s10_set, sizeof (sigset_t)) != 0)
return (EFAULT);
return (0);
}
/*
* This is our interposed signal handler.
* Fix up the arguments received from the kernel and jump
* to the s10 signal handler, normally libc's sigacthandler().
*/
static void
s10_sigacthandler(int sig, siginfo_t *sip, void *uvp)
{
int s10_sig;
ucontext_t *ucp;
s10_sig = nativesig_to_s10(sig);
if (s10_sig <= 0) /* can't happen? */
brand_abort(sig, "Received an impossible signal");
if (sip != NULL) {
/*
* All we really have to do is map the signal number,
* which changes only for the realtime signals,
* so all the rest of the siginfo structure is the
* same between s10 and native.
*/
if (sip->si_signo != sig) /* can't happen? */
brand_abort(sig, "Received an impossible siginfo");
sip->si_signo = s10_sig;
}
if ((ucp = uvp) != NULL &&
(ucp->uc_flags & UC_SIGMASK))
(void) nativesigset_to_s10(&ucp->uc_sigmask, &ucp->uc_sigmask);
s10_handlers[s10_sig - 1](s10_sig, sip, uvp);
}
/*
* Interposition upon SYS_lwp_sigmask
*/
int
s10_lwp_sigmask(sysret_t *rval, int how, uint_t bits0, uint_t bits1)
{
sigset_t s10_blockset;
sigset_t native_blockset;
int err;
s10_blockset.__sigbits[0] = bits0;
s10_blockset.__sigbits[1] = bits1;
s10_blockset.__sigbits[2] = 0;
s10_blockset.__sigbits[3] = 0;
(void) s10sigset_to_native(&s10_blockset, &native_blockset);
err = __systemcall(rval, SYS_lwp_sigmask + 1024,
how,
native_blockset.__sigbits[0],
native_blockset.__sigbits[1],
native_blockset.__sigbits[2],
native_blockset.__sigbits[3]);
if (err != 0)
return (err);
native_blockset.__sigbits[0] = (int)rval->sys_rval1;
native_blockset.__sigbits[1] = (int)rval->sys_rval2;
native_blockset.__sigbits[2] = 0;
native_blockset.__sigbits[3] = 0;
(void) nativesigset_to_s10(&native_blockset, &s10_blockset);
rval->sys_rval1 = s10_blockset.__sigbits[0];
rval->sys_rval2 = s10_blockset.__sigbits[1];
return (0);
}
/*
* Interposition upon SYS_sigprocmask
*/
int
s10_sigprocmask(sysret_t *rval, int how, const sigset_t *set, sigset_t *oset)
{
sigset_t sigset_set, sigset_oset;
sigset_t *set_ptr, *oset_ptr;
int err;
oset_ptr = (oset == NULL) ? NULL : &sigset_oset;
set_ptr = (set == NULL) ? NULL : &sigset_set;
if (set_ptr != NULL &&
(err = s10sigset_to_native(set, set_ptr)) != 0)
return (err);
if ((err = __systemcall(rval, SYS_sigprocmask + 1024,
how, set_ptr, oset_ptr)) != 0)
return (err);
if (oset_ptr != NULL &&
(err = nativesigset_to_s10(oset_ptr, oset)) != 0)
return (err);
return (0);
}
/*
* Interposition upon SYS_sigsuspend
*/
int
s10_sigsuspend(sysret_t *rval, const sigset_t *set)
{
sigset_t sigset_set;
int err;
if ((err = s10sigset_to_native(set, &sigset_set)) != 0) {
(void) B_TRUSS_POINT_1(rval, SYS_sigsuspend, err, set);
return (err);
}
return (__systemcall(rval, SYS_sigsuspend + 1024, &sigset_set));
}
/*
* Interposition upon SYS_sigaction
*
* There is a fair amount of complexity here due to the need to interpose
* on any registered user signal handler.
*
* The idea is that if a user signal handler is installed, we must install
* our own signal handler between the system and the signal handler being
* registered. If the signal handler to be registered is SIG_DFL or SIG_IGN,
* we should remove our interpositioned handler as it's no longer needed.
*
* The way we do this is we set the signal handler to call s10_sigacthandler(),
* and then store the address of the passed signal handler in a global
* per-process array, s10_handlers[].
*
* We rely on the fact that the s10 libc blocks all signals during
* its call to the sigaction() system call to guarantee atomicity.
*/
int
s10_sigaction(sysret_t *rval,
int sig, const struct sigaction *act, struct sigaction *oact)
{
struct sigaction sigact, osigact;
struct sigaction *sigactp, *osigactp;
int err, nativesig;
void (*handler)();
if ((nativesig = s10sig_to_native(sig)) < 0) {
(void) B_TRUSS_POINT_3(rval, SYS_sigaction, EINVAL,
sig, act, oact);
return (EINVAL);
}
if (act == NULL) {
sigactp = NULL;
} else {
sigactp = &sigact;
if (brand_uucopy(act, sigactp, sizeof (struct sigaction)) != 0)
return (EFAULT);
if ((err = s10sigset_to_native(&sigactp->sa_mask,
&sigactp->sa_mask)) != 0) {
(void) B_TRUSS_POINT_3(rval, SYS_sigaction, err,
sig, act, oact);
return (err);
}
}
osigactp = ((oact == NULL) ? NULL : &osigact);
if (sigactp != NULL) {
handler = sigactp->sa_handler;
if (handler != SIG_DFL && handler != SIG_IGN)
sigactp->sa_sigaction = s10_sigacthandler;
}
if ((err = __systemcall(rval, SYS_sigaction + 1024,
nativesig, sigactp, osigactp)) != 0)
return (err);
/*
* Translate the old signal mask if we are supposed to return the old
* struct sigaction.
*
* Note that we may have set the signal handler, but may return EFAULT
* here if the oact parameter is bad.
*
* That's OK, because the direct system call acts the same way.
*/
if (osigactp != NULL) {
err = nativesigset_to_s10(&osigactp->sa_mask,
&osigactp->sa_mask);
if (osigactp->sa_sigaction == s10_sigacthandler)
osigactp->sa_sigaction = s10_handlers[sig - 1];
if (err == 0 && brand_uucopy(osigactp, oact,
sizeof (struct sigaction)) != 0)
err = EFAULT;
}
/*
* Do not store SIG_DFL or SIG_IGN into the array of remembered
* signal handlers. Only store bona-fide function addresses.
* This is to avoid a race condition in which some thread
* sets the signal handler to SIG_DFL or SIG_IGN while some
* other thread is fielding the signal but has not yet reached
* s10_sigacthandler(). s10_sigacthandler() will unconditionally
* call the remembered signal handler and it it calls SIG_DFL or
* SIG_IGN, the process will incur a SIGSEGV or SIGBUS signal.
* This also allows a vfork() child to set signal handlers
* to SIG_DFL or SIG_IGN without corrupting the parent's
* address space.
*/
if (sigactp != NULL &&
handler != SIG_DFL && handler != SIG_IGN)
s10_handlers[sig - 1] = handler;
return (err);
}
/*
* Interposition upon SYS_sigpending
*/
int
s10_sigpending(sysret_t *rval, int flag, sigset_t *set)
{
sigset_t sigset_set;
int err;
if ((err = __systemcall(rval, SYS_sigpending + 1024,
flag, &sigset_set)) != 0)
return (err);
if ((err = nativesigset_to_s10(&sigset_set, set)) != 0)
return (err);
return (0);
}
/*
* Interposition upon SYS_sigsendsys
*/
int
s10_sigsendsys(sysret_t *rval, procset_t *psp, int sig)
{
int nativesig;
if ((nativesig = s10sig_to_native(sig)) < 0) {
(void) B_TRUSS_POINT_2(rval, SYS_sigsendsys, EINVAL,
psp, sig);
return (EINVAL);
}
return (__systemcall(rval, SYS_sigsendsys + 1024, psp, nativesig));
}
/*
* Convert the siginfo_t code and status fields to an old style
* wait status for s10_wait(), below.
*/
static int
wstat(int code, int status)
{
int stat = (status & 0377);
switch (code) {
case CLD_EXITED:
stat <<= 8;
break;
case CLD_DUMPED:
stat |= WCOREFLG;
break;
case CLD_KILLED:
break;
case CLD_TRAPPED:
case CLD_STOPPED:
stat <<= 8;
stat |= WSTOPFLG;
break;
case CLD_CONTINUED:
stat = WCONTFLG;
break;
}
return (stat);
}
/*
* Interposition upon SYS_wait
*/
int
s10_wait(sysret_t *rval)
{
int err;
siginfo_t info;
err = s10_waitid(rval, P_ALL, 0, &info, WEXITED | WTRAPPED);
if (err != 0)
return (err);
rval->sys_rval1 = info.si_pid;
rval->sys_rval2 = wstat(info.si_code, info.si_status);
return (0);
}
/*
* Interposition upon SYS_waitid
*/
int
s10_waitid(sysret_t *rval,
idtype_t idtype, id_t id, siginfo_t *infop, int options)
{
int err, sig;
err = __systemcall(rval, SYS_waitid + 1024, idtype, id, infop, options);
if (err != 0)
return (err);
/*
* If the process being waited for terminated or stopped due to a
* signal, translate the signal number from its native value to its
* S10 equivalent.
*
* If we can't legally translate the signal number, just sort of punt
* and leave it untranslated.
*
* We shouldn't return EINVAL as the syscall didn't technically fail.
*/
if (infop->si_signo == SIGCLD && infop->si_code != CLD_EXITED &&
(sig = nativesig_to_s10(infop->si_status)) > 0)
infop->si_status = sig;
return (0);
}
/*
* Interposition upon SYS_sigtimedwait
*/
int
s10_sigtimedwait(sysret_t *rval,
const sigset_t *set, siginfo_t *info, const timespec_t *timeout)
{
sigset_t sigset_set;
int err, sig;
if ((err = s10sigset_to_native(set, &sigset_set)) != 0) {
(void) B_TRUSS_POINT_3(rval, SYS_sigtimedwait, err,
set, info, timeout);
return (err);
}
if ((err = __systemcall(rval, SYS_sigtimedwait + 1024,
&sigset_set, info, timeout)) != 0)
return (err);
if (info != NULL) {
/*
* If we can't legally translate the signal number in the
* siginfo_t, just sort of punt and leave it untranslated.
*
* We shouldn't return EINVAL as the syscall didn't technically
* fail.
*/
if ((sig = nativesig_to_s10(info->si_signo)) > 0)
info->si_signo = sig;
}
/*
* If we can't legally translate the signal number returned by the
* sigtimedwait syscall, just sort of punt and leave it untranslated.
*
* We shouldn't return EINVAL as the syscall didn't technically
* fail.
*/
if ((sig = nativesig_to_s10((int)rval->sys_rval1)) > 0)
rval->sys_rval1 = sig;
return (0);
}
/*
* Interposition upon SYS_sigqueue
*/
int
s10_sigqueue(sysret_t *rval, pid_t pid, int signo, void *value, int si_code)
{
int nativesig;
if ((nativesig = s10sig_to_native(signo)) < 0) {
(void) B_TRUSS_POINT_4(rval, SYS_sigqueue, EINVAL,
pid, signo, value, si_code);
return (EINVAL);
}
if (pid == 1)
pid = zone_init_pid;
/*
* The native version of this syscall takes an extra argument.
* The new last arg "block" flag should be zero. The block flag
* is used by the Opensolaris AIO implementation, which is now
* part of libc.
*/
return (__systemcall(rval, SYS_sigqueue + 1024,
pid, nativesig, value, si_code, 0));
}
/*
* Interposition upon SYS_signotify
*/
int
s10_signotify(sysret_t *rval,
int cmd, siginfo_t *siginfo, signotify_id_t *sn_id)
{
siginfo_t *infop, info;
infop = siginfo;
/* only check for a valid siginfo pointer in the case of SN_PROC */
if (cmd == SN_PROC) {
int nativesig;
if (brand_uucopy(infop, &info, sizeof (siginfo_t)) != 0)
return (EFAULT);
if ((nativesig = s10sig_to_native(info.si_signo)) < 0) {
(void) B_TRUSS_POINT_3(rval, SYS_signotify, EINVAL,
cmd, siginfo, sn_id);
return (EINVAL);
}
info.si_signo = nativesig;
infop = &info;
}
return (__systemcall(rval, SYS_signotify + 1024, cmd, infop, sn_id));
}
/*
* Interposition upon SYS_kill
*/
int
s10_kill(sysret_t *rval, pid_t pid, int sig)
{
int nativesig;
if ((nativesig = s10sig_to_native(sig)) < 0) {
(void) B_TRUSS_POINT_2(rval, SYS_kill, EINVAL, pid, sig);
return (EINVAL);
}
if (pid == 1)
pid = zone_init_pid;
return (__systemcall(rval, SYS_kill + 1024, pid, nativesig));
}
/*
* Interposition upon SYS_lwp_create
*
* See also the s10_lwp_create_correct_fs() function in s10_brand.c
* for the special case of creating an lwp in a 64-bit x86 process.
*/
int
s10_lwp_create(sysret_t *rval, ucontext_t *ucp, int flags, id_t *new_lwp)
{
ucontext_t s10_uc;
if (brand_uucopy(ucp, &s10_uc, sizeof (ucontext_t)) != 0)
return (EFAULT);
if (s10_uc.uc_flags & UC_SIGMASK)
(void) s10sigset_to_native(&s10_uc.uc_sigmask,
&s10_uc.uc_sigmask);
return (__systemcall(rval, SYS_lwp_create + 1024,
&s10_uc, flags, new_lwp));
}
/*
* Interposition upon SYS_lwp_kill
*/
int
s10_lwp_kill(sysret_t *rval, id_t lwpid, int sig)
{
int nativesig;
if ((nativesig = s10sig_to_native(sig)) < 0) {
(void) B_TRUSS_POINT_2(rval, SYS_lwp_kill, EINVAL,
lwpid, sig);
return (EINVAL);
}
return (__systemcall(rval, SYS_lwp_kill + 1024, lwpid, nativesig));
}
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#ifndef _S10_MISC_H
#define _S10_MISC_H
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(_ASM)
/*
* From s10_deleted.c
*/
extern int s10_stat();
extern int s10_lstat();
extern int s10_fstat();
extern int s10_stat64();
extern int s10_lstat64();
extern int s10_fstat64();
extern int s10_open();
extern int s10_open64();
extern int s10_chmod();
extern int s10_fchmod();
extern int s10_chown();
extern int s10_lchown();
extern int s10_fchown();
extern int s10_mkdir();
extern int s10_mknod();
extern int s10_link();
extern int s10_unlink();
extern int s10_symlink();
extern int s10_readlink();
extern int s10_rmdir();
extern int s10_rename();
extern int s10_access();
extern int s10_creat();
extern int s10_creat64();
extern int s10_fork1();
extern int s10_forkall();
extern int s10_dup();
extern int s10_poll();
extern int s10_lwp_mutex_lock();
extern int s10_lwp_sema_wait();
extern int s10_utime();
extern int s10_utimes();
extern int s10_xstat();
extern int s10_lxstat();
extern int s10_fxstat();
extern int s10_xmknod();
extern int s10_fsat();
extern int s10_umount();
/*
* From s10_signal.c
*/
extern int s10sigset_to_native(const sigset_t *, sigset_t *);
extern int s10_kill();
extern int s10_lwp_create();
extern int s10_lwp_kill();
extern int s10_lwp_sigmask();
extern int s10_sigaction();
extern int s10_signotify();
extern int s10_sigpending();
extern int s10_sigprocmask();
extern int s10_sigqueue();
extern int s10_sigsendsys();
extern int s10_sigsuspend();
extern int s10_sigtimedwait();
extern int s10_wait();
extern int s10_waitid();
#endif /* !_ASM */
#ifdef __cplusplus
}
#endif
#endif /* _S10_MISC_H */
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _S10_SIGNAL_H
#define _S10_SIGNAL_H
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(_ASM)
#include <sys/types.h>
#include <sys/signal.h>
extern pid_t zone_init_pid;
typedef void (*s10_sighandler_t)(int, siginfo_t *, void *);
#endif /* !_ASM */
#ifdef __cplusplus
}
#endif
#endif /* _S10_SIGNAL_H */
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
include $(SRC)/lib/Makefile.lib
default: all
# Hammerhead: amd64-only
SUBDIRS = $(MACH64)
all : TARGET= all
clean : TARGET= clean
clobber : TARGET= clobber
install : TARGET= install
_msg : TARGET= _msg
.KEEP_STATE:
all install clean clobber _msg: $(SUBDIRS)
$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
LIBRARY = s10_npreload.a
VERS = .1
COBJS = s10_npreload.o
OBJECTS = $(COBJS)
UTSBASE = $(SRC)/uts
include ../../Makefile.s10
include $(SRC)/lib/Makefile.lib
LIBS = $(DYNLIB)
CSRCS = $(COBJS:%o=../common/%c)
SRCS = $(CSRCS)
SRCDIR = ../common
CPPFLAGS += -D_REENTRANT -U_ASM -I../sys \
-I$(UTSBASE)/common/brand/solaris10
CFLAGS += $(CCVERBOSE)
DYNFLAGS += $(BLOCAL) $(ZNOVERSION)
# Hammerhead: Add -ldl for dlinfo (GNU ld requires explicit linkage)
LDLIBS += -ldl -lc
CLEANFILES += $(DYNLIB)
.KEEP_STATE:
all: $(LIBS)
include $(SRC)/lib/Makefile.targ
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
include ../Makefile.com
include $(SRC)/lib/Makefile.lib.64
CLOBBERFILES = $(ROOTLIBDIR64)/$(DYNLIB)
install: all $(ROOTLIBS64)
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
#
# MAPFILE HEADER START
#
# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
# Object versioning must comply with the rules detailed in
#
# usr/src/lib/README.mapfiles
#
# You should not be making modifications here until you've read the most current
# copy of that file. If you need help, contact a gatekeeper for guidance.
#
# MAPFILE HEADER END
#
$mapfile_version 2
SYMBOL_VERSION SUNWprivate_1.0 {
local:
*;
};
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
#pragma init(init)
#include <s10_brand.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <dlfcn.h>
#include <link.h>
#include <limits.h>
#include <sys/mman.h>
#include <strings.h>
/* MAXCOMLEN is only defined in user.h in the kernel. */
#define MAXCOMLEN 16
/*
* This is a library that is LD_PRELOADed into native processes.
* Its primary function is to perform one brand operation, B_S10_NATIVE,
* which checks that this is actually a native process. If it is, then
* the operation changes the executable name so that it is no longer
* ld.so.1. Instead it changes it to be the name of the real native
* executable that we're runnning. This allows things like pgrep to work
* as expected. Note that this brand operation only changes the process
* name wrt the kernel. From the process' perspective, AT_SUN_EXECNAME is
* still ld.so.1. ld.so.1 removes itself and its arguments from the argv list.
*/
void
init(void)
{
int i;
Dl_argsinfo_t argsinfo;
sysret_t rval;
char *pcomm;
char cmd_buf[MAXCOMLEN + 1];
char arg_buf[PSARGSZ];
if (dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &argsinfo) == -1)
return;
/* get the base cmd name */
if ((pcomm = strrchr(argsinfo.dla_argv[0], '/')) != NULL)
pcomm = pcomm + 1;
else
pcomm = argsinfo.dla_argv[0];
(void) strlcpy(cmd_buf, pcomm, sizeof (cmd_buf));
(void) strlcpy(arg_buf, argsinfo.dla_argv[0], sizeof (arg_buf));
for (i = 1; i < argsinfo.dla_argc; i++) {
(void) strlcat(arg_buf, " ", sizeof (arg_buf));
if (strlcat(arg_buf, argsinfo.dla_argv[i], sizeof (arg_buf))
>= sizeof (arg_buf))
break;
}
(void) __systemcall(&rval, SYS_brand, B_S10_NATIVE, cmd_buf, arg_buf);
}
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
PROG = s10_replacefile
PROGS = $(PROG)
OBJS = s10_replacefile
all: $(PROG)
include ../Makefile.s10
include $(SRC)/cmd/Makefile.cmd
# override the install directory
ROOTBIN = $(ROOTBRANDDIR)
CLOBBERFILES = $(OBJS) $(ROOTPROGS)
UTSBASE = $(SRC)/uts
CFLAGS += $(CCVERBOSE)
CPPFLAGS += -D_REENTRANT
.KEEP_STATE:
install: all $(ROOTPROGS)
clean:
$(RM) $(PROG) $(OBJS)
include $(SRC)/cmd/Makefile.targ
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
*/
#include <stdio.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/mntent.h>
#include <unistd.h>
/*
* This program aids the Solaris 10 patch tools (specifically
* /usr/lib/patch/patch_common_lib) in DAP patching.
*
* Whenever the patch tools replace a critical system component (e.g.,
* /lib/libc.so.1), they move the old component to a temporary location,
* move the new component to where the old component was, and establish
* an overlay mount of the old component on top of the new component.
* The patch tools do this with a shell script; consequently, the three
* operations occur in three processes.
*
* This doesn't work inside Solaris 10 Containers (S10Cs). Suppose the
* patch tools need to replace /lib/libc.so.1. The tools will move the old
* libc.so.1 to a temporary location. But when they try to move the new
* libc.so.1, they fork a mv(1) process, which loads the solaris10 brand's
* emulation library. The emulation library will try to load the zone's
* libc.so.1, but the library no longer exists; consequently, the emulation
* library aborts and the zone's users won't be able to start any processes.
*
* This program solves the problem by combining the move and mount operations
* into a single process. The emulation library will already have loaded
* libc.so.1 for the process by the time the process starts to replace
* libc.so.1.
*
* This program takes six parameters that correspond to six variables within
* /usr/lib/patch/patch_common_lib:InstallSafemodeObject():
*
* argv[1] - dstActual (the path to the file that will be replaced)
* argv[2] - tmp_file (the temporary location to which the file will be
* moved)
* argv[3] - tmpDst (the path to the replacement file)
* argv[4] - tmpFile (the path to a temporary copy of the running system's
* version of the file being replaced; the source [special] of
* the overlay mount)
* argv[5] - cksumTmpDst (checksum of the file represented by tmpDst)
* argv[6] - cksumTmpFile (checksum of the file represented by tmpFile)
*
* NOTE: This program will only establish an overlay mount if argv[4] or argv[5]
* is emtpy or if argv[4] and argv[5] differ.
*
* This program returns zero when it succeeds. Non-negative values indicate
* failure.
*/
int
main(int argc, char **argv)
{
struct stat statbuf;
char mntoptions[MAX_MNTOPT_STR];
/*
* Check the number of arguments that were passed to s10_replacefile.
*/
if (argc != 7) {
(void) fprintf(stderr, "Usage: %s dstActual tmp_file tmpDst "
"tmpFile cksumTmpDst cksumTmpFile\n", argv[0]);
return (1);
}
/*
* Move the destination file (dstActual) out of the way and move the
* new file (tmpDst) into its place.
*
* NOTE: s10_replacefile won't print error messages here because
* the Solaris 10 patch tools will.
*/
if (rename(argv[1], argv[2]) != 0)
return (2);
if (rename(argv[3], argv[1]) != 0)
return (3);
/*
* If there was a lofs mount on dstActual (which we just moved), then
* s10_replacefile should reestablish the lofs mount. A lofs mount
* existed if tmpFile exists.
*/
if (stat(argv[4], &statbuf) == 0 && (statbuf.st_mode & S_IFREG)) {
/*
* Create a lofs overlay mount only if the checksums of the
* old file at dstActual and the new file at dstActual differ.
*/
if (argv[5][0] == '\0' || argv[6][0] == '\0' ||
strcmp(argv[5], argv[6]) != 0) {
mntoptions[0] = '\0';
if (mount(argv[4], argv[1], MS_OVERLAY | MS_OPTIONSTR,
MNTTYPE_LOFS, NULL, 0, mntoptions,
sizeof (mntoptions)) != 0) {
/*
* Although the patch tools will print error
* messages, the tools won't know that
* s10_replacefile failed to establish an
* overlay mount. Printing an error message
* here clarifies the problem for the user.
*/
(void) fprintf(stderr, "ERROR: Failed to "
"overlay mount %s onto %s\n", argv[4],
argv[1]);
return (4);
}
} else {
/*
* dstActual does not need an overlay mount. Delete
* tmpFile.
*/
(void) unlink(argv[4]);
}
}
return (0);
}
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
PROG = s10_support
PROGS = $(PROG)
OBJS = s10_support
all: $(PROG)
include ../Makefile.s10
include $(SRC)/cmd/Makefile.cmd
# override the install directory
ROOTBIN = $(ROOTBRANDDIR)
UTSBASE = $(SRC)/uts
CFLAGS += $(CCVERBOSE)
CPPFLAGS += -D_REENTRANT -I$(UTSBASE)/common/brand/solaris10
LDLIBS += -lzonecfg
.KEEP_STATE:
install: all $(ROOTPROGS)
clean:
$(RM) $(OBJS)
include $(SRC)/cmd/Makefile.targ
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
* s10_support is a small cli utility used to perform some brand-specific
* tasks when verifying a zone. This utility is not intended to be called
* by users - it is intended to be invoked by the zones utilities.
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <s10_brand.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stropts.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/varargs.h>
#include <unistd.h>
#include <libintl.h>
#include <locale.h>
#include <dirent.h>
#include <sys/systeminfo.h>
#include <libzonecfg.h>
static void s10_err(char *msg, ...) __NORETURN;
static void usage(void) __NORETURN;
/*
* XXX This is a temporary flag for the initial release to enable the
* use of features which are not yet tested or fully implemented.
*/
static boolean_t override = B_FALSE;
static char *bname = NULL;
/*
* DELETE_LIST_PATH represents the path to a solaris10-branded zone's "delete
* list", which is generated by patchrm when it needs to remove files after
* the zone reboots. See set_zone_emul_bitmap() below for additional details.
*/
#define DELETE_LIST_PATH "/var/sadm/patch/.delete_list"
#define PKGINFO_RD_LEN 128
#define PATCHLIST "PATCHLIST="
#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
#endif
/*PRINTFLIKE1*/
static void
s10_err(char *msg, ...)
{
char buf[1024];
va_list ap;
va_start(ap, msg);
(void) vsnprintf(buf, sizeof (buf), msg, ap);
va_end(ap);
/* This needs go to stdout so the msgs show up through zoneadm. */
(void) printf("Error: %s\n", buf);
exit(1);
/*NOTREACHED*/
}
static int
s10_verify(char *xmlfile)
{
zone_dochandle_t handle;
struct zone_devtab devtab;
if ((handle = zonecfg_init_handle()) == NULL)
s10_err(gettext("internal libzonecfg.so.1 error"), 0);
if (zonecfg_get_xml_handle(xmlfile, handle) != Z_OK) {
zonecfg_fini_handle(handle);
s10_err(gettext("zonecfg provided an invalid XML file"));
}
/*
* Check to see whether the zone has any unsupported devices
* configured.
*
* The audio framework has changed in Solaris Next as compared to
* S10. Data indicates the less than 1/10 of 1 percent of zones
* are using /dev/sound. Given the low usage vs. the effort to
* provide emulation, /dev/sound is currently disallowed. We can
* revisit this if there is enough demand.
*/
if (zonecfg_setdevent(handle) != Z_OK) {
zonecfg_fini_handle(handle);
s10_err(gettext("zonecfg provided an invalid XML file"));
}
if (zonecfg_getdevent(handle, &devtab) == Z_OK) {
if (strncmp(devtab.zone_dev_match, "/dev/sound", 10) == 0 &&
!override) {
zonecfg_fini_handle(handle);
s10_err(gettext("solaris10 zones do not currently "
"support /dev/sound"));
}
}
(void) zonecfg_enddevent(handle);
zonecfg_fini_handle(handle);
return (0);
}
/*
* Read an entry from a pkginfo file. Some of these lines can
* either be arbitrarily long or be continued by a backslash at the end of
* the line. This function coalesces lines that are longer than the read
* buffer, and lines that are continued, into one buffer which is returned.
* The caller must free this memory. NULL is returned when we hit EOF or
* if we run out of memory (errno is set to ENOMEM).
*/
static char *
read_pkg_data(FILE *fp)
{
char *start;
char *inp;
char *p;
int char_cnt = 0;
errno = 0;
if ((start = (char *)malloc(PKGINFO_RD_LEN)) == NULL) {
errno = ENOMEM;
return (NULL);
}
inp = start;
while ((p = fgets(inp, PKGINFO_RD_LEN, fp)) != NULL) {
int len;
len = strlen(inp);
if (inp[len - 1] == '\n' &&
(len == 1 || inp[len - 2] != '\\')) {
char_cnt = len;
break;
}
if (inp[len - 1] == '\n' && inp[len - 2] == '\\')
char_cnt += len - 2;
else
char_cnt += PKGINFO_RD_LEN - 1;
if ((p = realloc(start, char_cnt + PKGINFO_RD_LEN)) == NULL) {
errno = ENOMEM;
break;
}
start = p;
inp = start + char_cnt;
}
if (errno == ENOMEM || (p == NULL && char_cnt == 0)) {
free(start);
start = NULL;
}
return (start);
}
/*
* Read the SUNWcakr pkginfo file and get the PATCHLIST for the pkg.
*/
static int
get_ku_patchlist(char *zonepath, char **patchlist)
{
char pkginfo[MAXPATHLEN];
FILE *fp;
char *buf;
int err = 0;
if (snprintf(pkginfo, sizeof (pkginfo),
"%s/root/var/sadm/pkg/SUNWcakr/pkginfo", zonepath)
>= sizeof (pkginfo))
s10_err(gettext("error formating pkg path"));
if ((fp = fopen(pkginfo, "r")) == NULL)
return (errno);
while ((buf = read_pkg_data(fp)) != NULL) {
if (strncmp(buf, PATCHLIST, sizeof (PATCHLIST) - 1) == 0) {
int len;
/* remove trailing newline */
len = strlen(buf);
buf[len - 1] = '\0';
if ((*patchlist =
strdup(buf + sizeof (PATCHLIST) - 1)) == NULL)
err = ENOMEM;
free(buf);
break;
}
free(buf);
}
(void) fclose(fp);
return (err);
}
/*
* Verify that we have the minimum KU needed.
* Note that KU patches are accumulative so future KUs will still deliver
* 141444 or 141445.
*/
static boolean_t
have_valid_ku(char *zonename)
{
char *p;
char *lastp;
char *pstr;
char *patchlist = NULL;
char zonepath[MAXPATHLEN];
char sanity_skip[MAXPATHLEN];
struct stat64 buf;
boolean_t is_xpv = B_FALSE;
char platform[80];
char *xpv_vers = "142910";
char *vers_table[] = {
"141444-09",
"141445-09"};
if (zone_get_zonepath(zonename, zonepath, sizeof (zonepath)) != Z_OK)
s10_err(gettext("error getting zone's path"));
/*
* If the zone was installed to bypass sanity checking for internal
* testing purposes, just return success.
*/
if (snprintf(sanity_skip, sizeof (sanity_skip), "%s/root/.sanity_skip",
zonepath) >= sizeof (sanity_skip))
s10_err(gettext("error formating file path"));
if (stat64(sanity_skip, &buf) == 0)
return (B_TRUE);
if (get_ku_patchlist(zonepath, &patchlist) != 0 || patchlist == NULL)
return (B_FALSE);
/*
* Check if we're running on the i86xpv platform. If so, the zone
* needs a different ku patch to work properly.
*/
if (sysinfo(SI_PLATFORM, platform, sizeof (platform)) != -1 &&
strcmp(platform, "i86xpv") == 0)
is_xpv = B_TRUE;
pstr = patchlist;
while ((p = strtok_r(pstr, " ", &lastp)) != NULL) {
if (is_xpv) {
if (strncmp(p, xpv_vers, 6) == 0)
return (B_TRUE);
} else {
if (strcmp(p, vers_table[0]) == 0 ||
strcmp(p, vers_table[1]) == 0)
return (B_TRUE);
}
pstr = NULL;
}
if (is_xpv)
s10_err(gettext("the zone must have patch 142910 installed "
"when running in a paravirtualized domain"));
return (B_FALSE);
}
/*
* Convert the specified file basename into an unsigned integer. If the
* basename contains characters that cannot be converted into digits or the
* basename isn't NULL or newline-terminated, then this function returns
* the unsigned equivalent of -1.
*/
static unsigned int
basename_to_uint(const char *basenamep)
{
char *filename_endptr;
unsigned int bit_index;
errno = 0;
bit_index = (unsigned int)strtoul(basenamep, &filename_endptr, 10);
if (errno != 0 || (*filename_endptr != '\n' &&
*filename_endptr != '\0') || filename_endptr == basenamep)
return ((unsigned int)-1);
return (bit_index);
}
/*
* Determine which features/behaviors should be emulated and construct a bitmap
* representing the results. Associate the bitmap with the zone so that
* the brand's emulation library will be able to retrieve the bitmap and
* determine how the zone's process' behaviors should be emulated.
*
* This function does not return if an error occurs.
*/
static void
set_zone_emul_bitmap(char *zonename)
{
char zoneroot[MAXPATHLEN];
char path[MAXPATHLEN];
DIR *req_emulation_dirp;
struct dirent *emul_feature_filep;
s10_emul_bitmap_t bitmap;
unsigned int bit_index;
zoneid_t zoneid;
FILE *delete_listp;
/*
* If the Solaris 10 directory containing emulation feature files
* doesn't exist in the zone, then assume that it only needs the
* most basic emulation and, therefore, doesn't need a bitmap.
*/
if (zone_get_rootpath(zonename, zoneroot, sizeof (zoneroot)) != Z_OK)
s10_err(gettext("error getting zone's path"));
if (snprintf(path, sizeof (path), "%s" S10_REQ_EMULATION_DIR,
zoneroot) >= sizeof (path))
s10_err(gettext("zone's emulation versioning directory's path "
"%s" S10_REQ_EMULATION_DIR " is too long"), zoneroot);
if ((req_emulation_dirp = opendir(path)) == NULL)
return;
bzero(bitmap, sizeof (bitmap));
/*
* Iterate over the contents of the directory and determine which
* features the brand should emulate for this zone.
*/
while ((emul_feature_filep = readdir(req_emulation_dirp)) != NULL) {
if (strcmp(emul_feature_filep->d_name, ".") == 0 ||
strcmp(emul_feature_filep->d_name, "..") == 0)
continue;
/*
* Convert the file's name to an unsigned integer. Ignore
* files whose names aren't unsigned integers.
*/
bit_index = basename_to_uint(emul_feature_filep->d_name);
if (bit_index == (unsigned int)-1)
continue;
/*
* Determine if the brand can emulate the feature specified
* by bit_index.
*/
if (bit_index >= S10_NUM_EMUL_FEATURES) {
/*
* The zone requires emulation that the brand can't
* provide. Notify the user by displaying an error
* message.
*/
s10_err(gettext("The zone's version of Solaris 10 is "
"incompatible with the\ncurrent version of the "
"solaris10 brand.\nPlease update your Solaris "
"system to the latest release."));
} else {
/*
* Set the feature's flag in the bitmap.
*/
bitmap[(bit_index >> 3)] |= (1 << (bit_index & 0x7));
}
}
(void) closedir(req_emulation_dirp);
/*
* The zone's administrator might have removed a patch that delivered
* an emulation feature file the last time the zone ran. If so, then
* the zone's patch utilities won't delete the file until the zone's
* svc:/system/patch-finish:delete SMF service runs. This is
* problematic because the zone will be using system libraries whose
* ioctl structures and syscall invocations will differ from those
* expected by the emulation library. For example, if an administrator
* removes a patch that affects the formats of MNTFS ioctls, then the
* administrator's zone will use a version of libc.so.1 that issues
* MNTFS ioctls that use older structure versions than the zone's
* emulation library will expect.
*
* Fortunately, the patchrm utility creates a hidden file,
* /var/sadm/patch/.delete_list, which lists all files that
* svc:/system/patch-finish:delete will delete. We'll determine whether
* this file exists in the zone and disable the emulation bits
* associated with the emulation feature files that will be deleted.
*
* NOTE: The patch tools lofs mount backup copies of critical system
* libraries, such as /lib/libc.so.1, over their replacements whenever
* administrators add or remove DAP patches. Consequently, there isn't
* a window of vulnerability between patch addition or removal and
* zone reboot. The aforementioned problem only occurs after a zone
* reboots.
*/
if (snprintf(path, sizeof (path), "%s" DELETE_LIST_PATH, zoneroot) >=
sizeof (path))
s10_err(gettext("zone's delete list's path %s" DELETE_LIST_PATH
" is too long"), zoneroot);
if ((delete_listp = fopen(path, "r")) != NULL) {
while (fgets(path, sizeof (path), delete_listp) != NULL) {
char *const basenamep = path +
sizeof (S10_REQ_EMULATION_DIR);
/*
* Make sure that the file is in the directory
* containing emulation feature files. If it is,
* then basenamep should refer to the basename of
* the file.
*/
if (strncmp(path, S10_REQ_EMULATION_DIR,
sizeof (S10_REQ_EMULATION_DIR) - 1) != 0)
continue;
if (*(basenamep - 1) != '/')
continue;
/*
* Convert the file's basename into a bit index in
* the emulation bitmap. If the file's basename isn't
* integral, then skip the file. Otherwise, clear the
* corresponding bit in the bitmap.
*/
bit_index = basename_to_uint(basenamep);
if (bit_index == (unsigned int)-1)
continue;
if (bit_index < S10_NUM_EMUL_FEATURES)
bitmap[(bit_index >> 3)] &=
~(1 << (bit_index & 0x7));
}
if (ferror(delete_listp) != 0 || feof(delete_listp) == 0)
s10_err(gettext("The program encountered an error while"
" reading from %s" DELETE_LIST_PATH "."), zoneroot);
(void) fclose(delete_listp);
} else if (errno != ENOENT) {
/*
* The delete list exists but couldn't be opened. Warn the
* administrator.
*/
s10_err(gettext("Unable to open %s" DELETE_LIST_PATH ": %s"),
zoneroot, strerror(errno));
}
/*
* We're done scanning files. Set the zone's emulation bitmap.
*/
if ((zoneid = getzoneidbyname(zonename)) < 0)
s10_err(gettext("unable to get zoneid"));
if (zone_setattr(zoneid, S10_EMUL_BITMAP, bitmap, sizeof (bitmap)) != 0)
s10_err(gettext("error setting zone's emulation bitmap"));
}
static int
s10_boot(char *zonename)
{
if (!have_valid_ku(zonename))
s10_err(gettext("The installed version of Solaris 10 is "
"not supported"));
set_zone_emul_bitmap(zonename);
return (0);
}
static void
usage()
{
(void) fprintf(stderr, gettext(
"usage:\t%s verify <xml file>\n"
"\t%s boot\n"),
bname, bname);
exit(1);
}
int
main(int argc, char *argv[])
{
(void) setlocale(LC_ALL, "");
(void) textdomain(TEXT_DOMAIN);
bname = basename(argv[0]);
if (argc != 3)
usage();
/*
* XXX This is a temporary env variable for the initial release to
* enable the use of features which are not yet tested or fully
* implemented.
*/
if (getenv("S10BRAND_TEST") != NULL)
override = B_TRUE;
if (strcmp(argv[1], "verify") == 0)
return (s10_verify(argv[2]));
if (strcmp(argv[1], "boot") == 0)
return (s10_boot(argv[2]));
usage();
/*NOTREACHED*/
}
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
PROGS = attach clone detach image_install p2v postattach poststate \
prestate preuninstall s10_boot uninstall
XMLDOCS= config.xml platform.xml smf_disable.lst pkgrm.lst common.ksh \
version
USERFILES= smf_disable.conf pkgrm.conf
TEMPLATES = SUNWsolaris10.xml
CLOBBERFILES= $(ROOTPROGS) $(ROOTXMLDOCS) $(ROOTTEMPLATES) $(ETCUSER)
include $(SRC)/cmd/Makefile.cmd
include ../Makefile.s10
.KEEP_STATE:
all: $(PROGS)
POFILES = $(PROGS:%=%.po) common.po
POFILE = s10_zone.po
$(POFILE): $(POFILES)
$(RM) $@
$(CAT) $(POFILES) > $@
install: $(PROGS) $(ROOTPROGS) $(ROOTXMLDOCS) $(ROOTTEMPLATES) $(ETCUSER)
clean:
-$(RM) $(PROGS) $(POFILES) $(POFILE)
include $(SRC)/cmd/Makefile.targ
<?xml version="1.0"?>
<!--
Copyright 2009 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
DO NOT EDIT THIS FILE. Use zonecfg(8) instead.
-->
<!DOCTYPE zone PUBLIC "-//Sun Microsystems Inc//DTD Zones//EN" "file:///usr/share/lib/xml/dtd/zonecfg.dtd.1">
<zone name="default" zonepath="" autoboot="false" brand="solaris10">
</zone>
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
. /usr/lib/brand/solaris10/common.ksh
m_attach_log=$(gettext "Log File: %s")
m_zfs=$(gettext "A ZFS file system was created for the zone.")
m_attaching=$(gettext "Attaching...")
m_usage=$(gettext "solaris10 brand usage:\n\tattach [-a archive | -d directory | -r recv_type]\n\tThe -a archive option specifies an archive name which can be a flar,\n\ttar, pax or cpio archive.\n\tThe -d directory option specifies an existing directory.\n\tThe -r recv_type option specifies the type of archive to be read from\n\tstdin.")
m_complete=$(gettext "Attach complete.")
install_fail=$(gettext "*** Attach FAILED ***")
f_n_unimpl=$(gettext "The -n option is not yet implemented.")
f_zfs=$(gettext "Error creating a ZFS file system (%s) for the zone.")
f_nodataset=$(gettext "Error: there is no ZFS file system for the zone.")
f_zfsdestroy=$(gettext "Error destroying ZFS file system %s.")
f_sanity_notzone=$(gettext "Error: this is a system image and not a zone image.")
f_baddir=$(gettext "Invalid '%s' directory within the zone")
# Clean up on interrupt
trap_cleanup()
{
msg=$(gettext "Installation cancelled due to interrupt.")
log "$msg"
# umount any mounted file systems
umnt_fs
trap_exit
}
# If the attach failed then clean up the ZFS datasets we created.
trap_exit()
{
if [[ $EXIT_CODE != $ZONE_SUBPROC_OK && $rm_ds == 1 ]]; then
/usr/lib/brand/solaris10/uninstall $ZONENAME $ZONEPATH -F
fi
exit $EXIT_CODE
}
EXIT_CODE=$ZONE_SUBPROC_USAGE
install_media="-"
rm_ds=0
trap trap_cleanup INT
trap trap_exit EXIT
# If we weren't passed at least two arguments, exit now.
(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
ZONENAME="$1"
ZONEPATH="$2"
# XXX shared/common script currently uses lower case zonename & zonepath
zonename="$ZONENAME"
zonepath="$ZONEPATH"
shift; shift # remove ZONENAME and ZONEPATH from arguments array
ZONEROOT="$ZONEPATH/root"
logdir="$ZONEROOT/var/log"
noexecute=0
unset inst_type
# Other brand attach options are invalid for this brand.
while getopts "a:d:nr:" opt; do
case $opt in
a)
if [[ -n "$inst_type" ]]; then
fatal "$incompat_options" "$m_usage"
fi
inst_type="archive"
install_media="$OPTARG"
;;
d)
if [[ -n "$inst_type" ]]; then
fatal "$incompat_options" "$m_usage"
fi
inst_type="directory"
install_media="$OPTARG"
# '-d -' means use the existing zonepath.
if [[ "$install_media" == "$ZONEPATH" ]]; then
install_media="-"
fi
;;
n) noexecute=1 ;;
r)
if [[ -n "$inst_type" ]]; then
fatal "$incompat_options" "$m_usage"
fi
inst_type="stdin"
install_media="$OPTARG"
;;
?) printf "$m_usage\n"
exit $ZONE_SUBPROC_USAGE;;
*) printf "$m_usage\n"
exit $ZONE_SUBPROC_USAGE;;
esac
done
shift $((OPTIND-1))
if [[ $noexecute == 1 && -n "$inst_type" ]]; then
fatal "$m_usage"
fi
if [ $noexecute -eq 1 ]; then
#
# The zone doesn't have to exist when the -n option is used, so do
# this work early.
#
# XXX do the sw validation for solaris10 minimal patch level to ensure
# everything will be ok.
EXIT_CODE=$ZONE_SUBPROC_NOTCOMPLETE
fatal "$f_n_unimpl"
fi
EXIT_CODE=$ZONE_SUBPROC_NOTCOMPLETE
if [[ -z "$inst_type" ]]; then
inst_type="directory"
elif [[ "$install_media" != "-" ]]; then
#
# If we're not using a pre-existing zone directory layout then create
# the zone datasets and mount them.
#
unset DATASET
pdir=$(/bin/dirname $ZONEPATH)
zds=$(/sbin/zfs list -H -t filesystem -o name $pdir 2>/dev/null)
if (( $? == 0 )); then
pnm=$(/bin/basename $ZONEPATH)
/sbin/zfs create "$zds/$pnm"
if (( $? == 0 )); then
vlog "$m_zfs"
DATASET="$zds/$pnm"
rm_ds=1
else
log "$f_zfs" "$zds/$pnm"
fi
fi
create_active_ds
fi
#
# The zone's datasets are now in place, validate that things
# are setup correctly.
#
get_zonepath_ds $zonepath
/sbin/zfs list -H -o name $ZONEPATH_DS/ROOT >/dev/null 2>&1
(( $? != 0 )) && fail_fatal "$f_no_active_ds"
zfs set mountpoint=legacy $ZONEPATH_DS/ROOT >/dev/null 2>&1
zfs set zoned=on $ZONEPATH_DS/ROOT >/dev/null 2>&1
get_active_ds $ZONEPATH_DS
zfs list -H -o name $ACTIVE_DS >/dev/null 2>&1
(( $? != 0 )) && fail_fatal "$f_zfs_create"
zfs set canmount=noauto $ACTIVE_DS >/dev/null 2>&1
zfs inherit mountpoint $ACTIVE_DS >/dev/null 2>&1
zfs inherit zoned $ACTIVE_DS >/dev/null 2>&1
if [ ! -d $ZONEROOT ]; then
mkdir -p $ZONEROOT || fail_fatal "$f_mkdir" "$ZONEROOT"
chmod 700 $ZONEPATH || fail_fatal "$f_chmod" "$ZONEPATH"
fi
mnted=`zfs get -H mounted $ACTIVE_DS | cut -f3`
if [[ $mnted = "no" ]]; then
mount -F zfs $ACTIVE_DS $ZONEROOT || fail_fatal "$f_zfs_mount"
fi
LOGFILE=$(/usr/bin/mktemp -t -p /var/tmp $zonename.attach_log.XXXXXX)
if [[ -z "$LOGFILE" ]]; then
fatal "$e_tmpfile"
fi
exec 2>>"$LOGFILE"
log "$m_attach_log" "$LOGFILE"
log "$m_attaching"
install_image "$inst_type" "$install_media"
mk_zone_dirs
#
# Perform a final check that this is really a zone image and not an archive of
# a system image which would need p2v. Check for a well-known S10 SMF service
# that shouldn't exist in a zone.
#
if [[ -e $ZONEROOT/var/svc/manifest/system/sysevent.xml ]]; then
log "$f_sanity_notzone"
exit $ZONE_SUBPROC_NOTCOMPLETE
fi
EXIT_CODE=$ZONE_SUBPROC_OK
log "$m_complete"
zone_logfile="${logdir}/$zonename.attach$$.log"
safe_dir /var
safe_dir /var/log
safe_copy $LOGFILE $zone_logfile
log "$m_attach_log" "$zone_logfile"
rm -f $LOGFILE
exit $ZONE_SUBPROC_OK
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
. /usr/lib/brand/solaris10/common.ksh
m_usage=$(gettext "solaris10 brand usage: clone {sourcezone}.")
f_nosource=$(gettext "Error: unable to determine source zone dataset.")
f_sysunconfig=$(gettext "Error: sys-unconfig failed.")
# Other brand clone options are invalid for this brand.
while getopts "R:z:" opt; do
case $opt in
R) ZONEPATH="$OPTARG" ;;
z) ZONENAME="$OPTARG" ;;
*) printf "$m_usage\n"
exit $ZONE_SUBPROC_USAGE;;
esac
done
shift $((OPTIND-1))
if [ $# -ne 1 ]; then
fail_usage "$0 {sourcezone}";
fi
ZONEROOT="$ZONEPATH/root"
sourcezone=$1
# Find the active source zone dataset to clone.
sourcezonepath=`/usr/sbin/zonecfg -z $sourcezone info zonepath | \
/usr/bin/cut -f2 -d' '`
if [ -z "$sourcezonepath" ]; then
fail_fatal "$f_nosource"
fi
get_zonepath_ds $sourcezonepath
get_active_ds $ZONEPATH_DS
ACTIVE_SRC=$ACTIVE_DS
#
# Now set up the zone's datasets
#
#
# First make the top-level dataset.
#
pdir=`/bin/dirname $ZONEPATH`
zpname=`/bin/basename $ZONEPATH`
get_zonepath_ds $pdir
zpds=$ZONEPATH_DS
# Create the datasets.
/sbin/zfs create $zpds/$zpname
if (( $? != 0 )); then
fail_fatal "$f_zfs_create"
fi
/sbin/zfs create -o mountpoint=legacy -o zoned=on $zpds/$zpname/ROOT
if (( $? != 0 )); then
fail_fatal "$f_zfs_create"
fi
# make snapshot
SNAPNAME=${ZONENAME}_snap
SNAPNUM=0
while [ $SNAPNUM -lt 100 ]; do
zfs snapshot $ACTIVE_SRC@$SNAPNAME
if [ $? = 0 ]; then
break
fi
SNAPNUM=`expr $SNAPNUM + 1`
SNAPNAME="${ZONENAME}_snap$SNAPNUM"
done
if [ $SNAPNUM -ge 100 ]; then
fail_fatal "$f_zfs_create"
fi
# do clone
get_active_ds $zpds/$zpname
zfs clone -o canmount=noauto $ACTIVE_SRC@$SNAPNAME $ACTIVE_DS
(( $? != 0 )) && fail_fatal "$f_zfs_create"
if [ ! -d $ZONEROOT ]; then
mkdir -p $ZONEROOT || fail_fatal "$f_mkdir" "$ZONEROOT"
chmod 700 $ZONEPATH || fail_fatal "$f_chmod" "$ZONEPATH"
fi
mount -F zfs $ACTIVE_DS $ZONEROOT || fail_fatal "$f_zfs_mount"
# Don't re-sysunconfig if we've already done so
if [[ ! -f $ZONEROOT/etc/.UNCONFIGURED ]]; then
/usr/sbin/zoneadm -z $ZONENAME boot -f -- -m milestone=none
if (( $? != 0 )); then
error "$e_badboot"
fail_incomplete "$f_sysunconfig"
fi
sysunconfig_zone
if (( $? != 0 )); then
/usr/sbin/zoneadm -z $ZONENAME halt
fail_incomplete "$f_sysunconfig"
fi
/usr/sbin/zoneadm -z $ZONENAME halt
fi
# Add a service tag for this zone.
add_svc_tag "$ZONENAME" "clone $sourcezone"
exit $ZONE_SUBPROC_OK
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
unset LD_LIBRARY_PATH
PATH=/usr/bin:/usr/sbin
export PATH
. /usr/lib/brand/shared/common.ksh
# Values for service tags.
STCLIENT=/usr/bin/stclient
ST_PRODUCT_NAME="Solaris 10 Containers"
ST_PRODUCT_REV="1.0"
ST_PRODUCT_UUID="urn:uuid:2f459121-dec7-11de-9af7-080020a9ed93"
w_sanity_detail=$(gettext " WARNING: Skipping image sanity checks.")
f_sanity_detail=$(gettext "Missing %s at %s")
f_sanity_sparse=$(gettext "Is this a sparse zone image? The image must be whole-root.")
f_sanity_vers=$(gettext "The image release version must be 10 (got %s), the zone is not usable on this system.")
f_not_s10_image=$(gettext "%s doesn't look like a Solaris 10 image.")
f_sanity_nopatch=$(gettext "Unable to determine the image's patch level.")
f_sanity_downrev=$(gettext "The image patch level is downrev for running in a solaris10 branded zone.\n(patchlist %s)")
f_need_newer_emul=$(gettext "The image requires a newer version of the solaris10 brand emulation.")
f_zfs_create=$(gettext "Unable to create the zone's ZFS dataset.")
f_no_ds=$(gettext "No zonepath dataset; the zonepath must be a ZFS dataset.")
f_multiple_ds=$(gettext "Multiple active datasets.")
f_no_active_ds=$(gettext "No active dataset; the zone's ZFS root dataset must be configured as\n\ta zone boot environment.")
f_zfs_unmount=$(gettext "Unable to unmount the zone's root ZFS dataset (%s).\nIs there a global zone process inside the zone root?\nThe current zone boot environment will remain mounted.\n")
f_zfs_mount=$(gettext "Unable to mount the zone's ZFS dataset.")
incompat_options=$(gettext "mutually exclusive options.\n%s")
sanity_ok=$(gettext " Sanity Check: Passed. Looks like a Solaris 10 image.")
sanity_fail=$(gettext " Sanity Check: FAILED (see log for details).")
e_badboot=$(gettext "Zone boot failed")
e_nosingleuser=$(gettext "ERROR: zone did not finish booting to single-user.")
e_unconfig=$(gettext "sys-unconfig failed")
v_unconfig=$(gettext "Performing zone sys-unconfig")
v_no_tags=$(gettext "Service tags facility not present.")
e_bad_uuid=$(gettext "Failed to get zone UUID")
v_addtag=$(gettext "Adding service tag: %s")
v_deltag=$(gettext "Removing service tag: %s")
e_addtag_fail=$(gettext "Adding service tag failed (error: %s)")
sanity_check()
{
typeset dir="$1"
res=0
#
# Check for some required directories and make sure this isn't a
# sparse zone image.
#
checks="etc etc/svc var var/svc"
for x in $checks; do
if [[ ! -e $dir/$x ]]; then
log "$f_sanity_detail" "$x" "$dir"
res=1
fi
done
# Files from SUNWcsr and SUNWcsu that are in sparse inherit-pkg-dirs.
checks="lib/svc sbin/zonename usr/bin/chmod"
for x in $checks; do
if [[ ! -e $dir/$x ]]; then
log "$f_sanity_detail" "$x" "$dir"
log "$f_sanity_sparse"
res=1
fi
done
if (( $res != 0 )); then
log "$sanity_fail"
fatal "$install_fail" "$ZONENAME"
fi
if [[ "$SANITY_SKIP" == 1 ]]; then
log "$w_sanity_detail"
return
fi
#
# Check image release to be sure its S10.
#
image_vers="unknown"
if [[ -f $dir/var/sadm/system/admin/INST_RELEASE ]]; then
image_vers=$(nawk -F= '{if ($1 == "VERSION") print $2}' \
$dir/var/sadm/system/admin/INST_RELEASE)
fi
if [[ "$image_vers" != "10" ]]; then
log "$f_sanity_vers" "$image_vers"
res=1
fi
#
# Make sure we have the minimal KU patch we support. These are the
# KUs for S10u8.
#
if [[ $(uname -p) == "amd64" || $(uname -p) == "i386" ]]; then
req_patch="141445-09"
else
req_patch="141444-09"
fi
for i in $dir/var/sadm/pkg/SUNWcakr*
do
if [[ ! -d $i || ! -f $i/pkginfo ]]; then
log "$f_sanity_nopatch"
res=1
fi
done
#
# Check the core kernel pkg for the required KU patch.
#
found=0
for i in $dir/var/sadm/pkg/SUNWcakr*/pkginfo
do
patches=$(nawk -F= '{if ($1 == "PATCHLIST") print $2}' $i)
for patch in $patches
do
if [[ $patch == $req_patch ]]; then
found=1
break
fi
done
if (( $found == 1 )); then
break
fi
done
if (( $found != 1 )); then
log "$f_sanity_downrev" "$patches"
res=1
fi
#
# Check the S10 image for a required version of the emulation.
#
VERS_FILE=/usr/lib/brand/solaris10/version
s10vers_needs=0
if [[ -f $dir/$VERS_FILE ]]; then
s10vers_needs=$(/bin/egrep -v "^#" $dir/$VERS_FILE)
fi
# Now get the current emulation version.
emul_vers=$(/bin/egrep -v "^#" $VERS_FILE)
# Verify that the emulation can run this version of S10.
if (( $s10vers_needs > $emul_vers )); then
log "$f_need_newer_emul"
res=1
fi
if (( $res != 0 )); then
log "$sanity_fail"
fatal "$install_fail" "$ZONENAME"
fi
vlog "$sanity_ok"
}
# Find the active dataset under the zonepath dataset to mount on zonepath/root.
# $1 ZONEPATH_DS
get_active_ds() {
ACTIVE_DS=$1/ROOT/zbe-0
}
#
# Make sure the active dataset is mounted for the zone.
#
mount_active_ds() {
get_zonepath_ds $zonepath
get_active_ds $ZONEPATH_DS
# If already mounted then we're done.
mnted=`zfs get -H mounted $ACTIVE_DS | cut -f3`
[[ $mnted = "yes" ]] && return
mount -F zfs $ACTIVE_DS $zonepath/root || fail_fatal "$f_zfs_mount"
}
#
# Set up ZFS dataset hierarchy for the zone root dataset.
#
create_active_ds() {
# Find the zone's current dataset. This should have been created by
# zoneadm (or the attach hook).
get_zonepath_ds $zonepath
#
# We need to tolerate errors while creating the datasets and making the
# mountpoint, since these could already exist from an attach scenario.
#
/sbin/zfs list -H -o name $ZONEPATH_DS/ROOT >/dev/null 2>&1
if (( $? != 0 )); then
/sbin/zfs create -o mountpoint=legacy -o zoned=on \
$ZONEPATH_DS/ROOT
if (( $? != 0 )); then
fail_fatal "$f_zfs_create"
fi
else
/sbin/zfs set mountpoint=legacy $ZONEPATH_DS/ROOT \
>/dev/null 2>&1
/sbin/zfs set zoned=on $ZONEPATH_DS/ROOT \
>/dev/null 2>&1
fi
get_active_ds $ZONEPATH_DS
zfs list -H -o name $ACTIVE_DS >/dev/null 2>&1
if (( $? != 0 )); then
zfs create -o canmount=noauto $ACTIVE_DS
(( $? != 0 )) && fail_fatal "$f_zfs_create"
else
zfs set canmount=noauto $ACTIVE_DS >/dev/null 2>&1
zfs inherit mountpoint $ACTIVE_DS >/dev/null 2>&1
zfs inherit zoned $ACTIVE_DS >/dev/null 2>&1
fi
if [ ! -d $ZONEROOT ]; then
/bin/mkdir -m 0755 -p $ZONEROOT || \
fail_fatal "$f_mkdir" "$ZONEROOT"
fi
/bin/chmod 700 $ZONEPATH || fail_fatal "$f_chmod" "$ZONEPATH"
mount -F zfs $ACTIVE_DS $ZONEROOT || fail_fatal "$f_zfs_mount"
}
#
# Before booting the zone we may need to create a few mnt points, just in
# case they don't exist for some reason.
#
# Whenever we reach into the zone while running in the global zone we
# need to validate that none of the interim directories are symlinks
# that could cause us to inadvertently modify the global zone.
#
mk_zone_dirs() {
vlog "$v_mkdirs"
if [[ ! -f $ZONEROOT/tmp && ! -d $ZONEROOT/tmp ]]; then
mkdir -m 1777 -p $ZONEROOT/tmp || exit $EXIT_CODE
fi
if [[ ! -f $ZONEROOT/var/run && ! -d $ZONEROOT/var/run ]]; then
mkdir -m 1755 -p $ZONEROOT/var/run || exit $EXIT_CODE
fi
if [[ ! -f $ZONEROOT/var/tmp && ! -d $ZONEROOT/var/tmp ]]; then
mkdir -m 1777 -p $ZONEROOT/var/tmp || exit $EXIT_CODE
fi
if [[ ! -h $ZONEROOT/etc && ! -f $ZONEROOT/etc/mnttab ]]; then
/usr/bin/touch $ZONEROOT/etc/mnttab || exit $EXIT_CODE
/bin/chmod 444 $ZONEROOT/etc/mnttab || exit $EXIT_CODE
fi
if [[ ! -f $ZONEROOT/proc && ! -d $ZONEROOT/proc ]]; then
mkdir -m 755 -p $ZONEROOT/proc || exit $EXIT_CODE
fi
if [[ ! -f $ZONEROOT/dev && ! -d $ZONEROOT/dev ]]; then
mkdir -m 755 -p $ZONEROOT/dev || exit $EXIT_CODE
fi
if [[ ! -h $ZONEROOT/etc && ! -h $ZONEROOT/etc/svc && \
! -d $ZONEROOT/etc/svc ]]; then
mkdir -m 755 -p $ZONEROOT/etc/svc/volatile || exit $EXIT_CODE
fi
}
#
# We're sys-unconfig-ing the zone. This will normally halt the zone, however
# there are problems with sys-unconfig and it can hang when the zone is booted
# to milestone=none. Sys-unconfig also sometimes hangs halting the zone.
# Thus, we take some care to workaround these sys-unconfig limitations.
#
# On entry we expect the zone to be booted. We use sys-unconfig -R to make it
# think its working on an alternate root and let the caller halt the zone.
#
sysunconfig_zone() {
/usr/sbin/zlogin -S $ZONENAME /usr/sbin/sys-unconfig -R /./ \
>/dev/null 2>&1
if (( $? != 0 )); then
error "$e_unconfig"
return 1
fi
return 0
}
#
# Get zone's uuid for service tag.
#
get_inst_uuid()
{
typeset ZONENAME="$1"
ZONEUUID=`zoneadm -z $ZONENAME list -p | nawk -F: '{print $5}'`
[[ $? -ne 0 || -z $ZONEUUID ]] && return 1
INSTANCE_UUID="urn:st:${ZONEUUID}"
return 0
}
#
# Add a service tag for a given zone. We use two UUIDs-- the first,
# the Product UUID, comes from the Sun swoRDFish ontology. The second
# is the UUID of the zone itself, which forms the instance UUID.
#
add_svc_tag()
{
typeset ZONENAME="$1"
typeset SOURCE="$2"
if [ ! -x $STCLIENT ]; then
vlog "$v_no_tags"
return 0
fi
get_inst_uuid "$ZONENAME" || (error "$e_bad_uuid"; return 1)
vlog "$v_addtag" "$INSTANCE_UUID"
$STCLIENT -a \
-p "$ST_PRODUCT_NAME" \
-e "$ST_PRODUCT_REV" \
-t "$ST_PRODUCT_UUID" \
-i "$INSTANCE_UUID" \
-P "none" \
-m "Sun" \
-A `uname -p` \
-z "$ZONENAME" \
-S "$SOURCE" >/dev/null 2>&1
err=$?
# 226 means "duplicate record," which we can ignore.
if [[ $err -ne 0 && $err -ne 226 ]]; then
error "$e_addtag_fail" "$err"
return 1
fi
return 0
}
#
# Remove a service tag for a given zone.
#
del_svc_tag()
{
typeset ZONENAME="$1"
if [ ! -x $STCLIENT ]; then
vlog "$v_no_tags"
return 0
fi
get_inst_uuid "$ZONENAME" || (error "$e_bad_uuid"; return 1)
vlog "$v_deltag" "$INSTANCE_UUID"
$STCLIENT -d -i "$INSTANCE_UUID" >/dev/null 2>&1
return 0
}
<?xml version="1.0"?>
<!--
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
DO NOT EDIT THIS FILE.
Copyright 2014 Nexenta Systems, Inc. All rights reserved.
-->
<!DOCTYPE brand PUBLIC "-//Sun Microsystems Inc//DTD Brands//EN"
"file:///usr/share/lib/xml/dtd/brand.dtd.1">
<brand name="solaris10">
<modname>s10_brand</modname>
<initname>/sbin/init</initname>
<login_cmd>/usr/bin/login -z %Z %u</login_cmd>
<forcedlogin_cmd>/usr/bin/login -z %Z -f %u</forcedlogin_cmd>
<user_cmd>/usr/bin/getent passwd %u</user_cmd>
<install>/usr/lib/brand/solaris10/image_install %z %R</install>
<installopts>a:d:Fpsuv</installopts>
<boot>/usr/lib/brand/solaris10/s10_boot %z %R</boot>
<sysboot>/usr/lib/brand/solaris10/prestate %z %R 2 0</sysboot>
<halt></halt>
<shutdown>/sbin/shutdown -y -g0 -i5</shutdown>
<verify_cfg>/usr/lib/brand/solaris10/s10_support verify</verify_cfg>
<verify_adm></verify_adm>
<postattach>/usr/lib/brand/solaris10/postattach %z %R</postattach>
<attach>/usr/lib/brand/solaris10/attach %z %R</attach>
<detach>/usr/lib/brand/solaris10/detach %z %R</detach>
<clone>/usr/lib/brand/solaris10/clone -z %z -R %R</clone>
<preuninstall>/usr/lib/brand/solaris10/preuninstall %z %R</preuninstall>
<uninstall>/usr/lib/brand/solaris10/uninstall %z %R</uninstall>
<prestatechange>/usr/lib/brand/solaris10/prestate %z %R</prestatechange>
<poststatechange>/usr/lib/brand/solaris10/poststate %z %R</poststatechange>
<query>/usr/lib/brand/shared/query %z %R</query>
<privilege set="default" name="contract_event" />
<privilege set="default" name="contract_identity" />
<privilege set="default" name="contract_observer" />
<privilege set="default" name="file_chown" />
<privilege set="default" name="file_chown_self" />
<privilege set="default" name="file_dac_execute" />
<privilege set="default" name="file_dac_read" />
<privilege set="default" name="file_dac_search" />
<privilege set="default" name="file_dac_write" />
<privilege set="default" name="file_owner" />
<privilege set="default" name="file_setid" />
<privilege set="default" name="ipc_dac_read" />
<privilege set="default" name="ipc_dac_write" />
<privilege set="default" name="ipc_owner" />
<privilege set="default" name="net_bindmlp" />
<privilege set="default" name="net_icmpaccess" />
<privilege set="default" name="net_mac_aware" />
<privilege set="default" name="net_observability" />
<privilege set="default" name="net_privaddr" />
<privilege set="default" name="net_rawaccess" ip-type="exclusive" />
<privilege set="default" name="proc_chroot" />
<privilege set="default" name="sys_audit" />
<privilege set="default" name="proc_audit" />
<privilege set="default" name="proc_lock_memory" />
<privilege set="default" name="proc_owner" />
<privilege set="default" name="proc_setid" />
<privilege set="default" name="proc_taskid" />
<privilege set="default" name="sys_acct" />
<privilege set="default" name="sys_admin" />
<privilege set="default" name="sys_ip_config" ip-type="exclusive" />
<privilege set="default" name="sys_iptun_config" ip-type="exclusive" />
<privilege set="default" name="sys_mount" />
<privilege set="default" name="sys_nfs" />
<privilege set="default" name="sys_resource" />
<privilege set="default" name="sys_ppp_config" ip-type="exclusive" />
<privilege set="prohibited" name="dtrace_kernel" />
<privilege set="prohibited" name="proc_zone" />
<privilege set="prohibited" name="sys_config" />
<privilege set="prohibited" name="sys_devices" />
<privilege set="prohibited" name="sys_ip_config" ip-type="shared" />
<privilege set="prohibited" name="sys_linkdir" />
<privilege set="prohibited" name="sys_net_config" />
<privilege set="prohibited" name="sys_res_config" />
<privilege set="prohibited" name="sys_suser_compat" />
<privilege set="prohibited" name="xvm_control" />
<privilege set="prohibited" name="virt_manage" />
<privilege set="prohibited" name="sys_ppp_config" ip-type="shared" />
<privilege set="required" name="proc_exec" />
<privilege set="required" name="proc_fork" />
<privilege set="required" name="sys_ip_config" ip-type="exclusive" />
<privilege set="required" name="sys_mount" />
</brand>
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
. /usr/lib/brand/solaris10/common.ksh
m_usage=$(gettext "solaris10 brand usage: detach [-n].")
EXIT_CODE=$ZONE_SUBPROC_USAGE
# If we weren't passed at least two arguments, exit now.
(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
ZONENAME="$1"
ZONEPATH="$2"
# XXX shared/common script currently uses lower case zonename & zonepath
zonename="$ZONENAME"
zonepath="$ZONEPATH"
shift; shift # remove ZONENAME and ZONEPATH from arguments array
noexecute=0
# Other brand attach options are invalid for this brand.
while getopts "n" opt; do
case $opt in
n) noexecute=1 ;;
?) printf "$m_usage\n"
exit $ZONE_SUBPROC_USAGE;;
*) printf "$m_usage\n"
exit $ZONE_SUBPROC_USAGE;;
esac
done
shift $((OPTIND-1))
if [[ $noexecute == 1 ]]; then
cat /etc/zones/$ZONENAME.xml
exit $ZONE_SUBPROC_OK
fi
get_zonepath_ds $ZONEPATH
get_active_ds $ZONEPATH_DS
zfs set zoned=off $ACTIVE_DS >/dev/null 2>&1
zfs set canmount=on $ACTIVE_DS >/dev/null 2>&1
zfs set mountpoint=$ZONEPATH/root $ACTIVE_DS >/dev/null 2>&1
cp /etc/zones/$ZONENAME.xml $ZONEPATH/SUNWdetached.xml
# Remove the service tag for this zone.
del_svc_tag "$ZONENAME"
exit $ZONE_SUBPROC_OK
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
. /usr/lib/brand/solaris10/common.ksh
m_usage=$(gettext "solaris10 brand usage:\n\tinstall -u | -p [-v | -s] -a archive | -d directory.\n\tThe -a archive option specifies an archive name which can be a flar,\n\ttar, pax or cpio archive.\n\tThe -d directory option specifies an existing directory.\n\tThe -u option unconfigures the zone, -p preserves the configuration.")
no_install=$(gettext "Could not create install directory '%s'")
product_vers=$(gettext " Product: %s")
install_vers=$(gettext " Installer: %s")
install_zone=$(gettext " Zone: %s")
install_path=$(gettext " Path: %s")
installing=$(gettext " Installing: This may take several minutes...")
no_installing=$(gettext " Installing: Using pre-existing data in zonepath")
install_prog=$(gettext " Installing: %s")
install_fail=$(gettext " Result: *** Installation FAILED ***")
install_log=$(gettext " Log File: %s")
install_good=$(gettext " Result: Installation completed successfully.")
sanity_ok=$(gettext " Sanity Check: Passed. Looks like a Solaris 10 system.")
sanity_fail=$(gettext " Sanity Check: FAILED (see log for details).")
p2ving=$(gettext "Postprocessing: This may take a while...")
p2v_prog=$(gettext " Postprocess: ")
p2v_done=$(gettext " Result: Postprocessing complete.")
p2v_fail=$(gettext " Result: Postprocessing failed.")
root_full=$(gettext "Zonepath root %s exists and contains data; remove or move aside prior to install.")
media_missing=\
$(gettext "you must specify an installation source using '-a', '-d' or '-r'.\n%s")
cfgchoice_missing=\
$(gettext "you must specify -u (sys-unconfig) or -p (preserve identity).\n%s")
mount_failed=$(gettext "ERROR: zonecfg(8) 'fs' mount failed")
not_flar=$(gettext "Input is not a flash archive")
bad_flar=$(gettext "Flash archive is a corrupt")
unknown_archiver=$(gettext "Archiver %s is not supported")
# Clean up on interrupt
trap_cleanup()
{
msg=$(gettext "Installation cancelled due to interrupt.")
log "$msg"
# umount any mounted file systems
umnt_fs
trap_exit
}
# If the install failed then clean up the ZFS datasets we created.
trap_exit()
{
if (( $EXIT_CODE != $ZONE_SUBPROC_OK )); then
/usr/lib/brand/solaris10/uninstall $ZONENAME $ZONEPATH -F
fi
exit $EXIT_CODE
}
#
# The main body of the script starts here.
#
# This script should never be called directly by a user but rather should
# only be called by zoneadm to install a s10 system image into a zone.
#
#
# Exit code to return if install is interrupted or exit code is otherwise
# unspecified.
#
EXIT_CODE=$ZONE_SUBPROC_USAGE
trap trap_cleanup INT
trap trap_exit EXIT
# If we weren't passed at least two arguments, exit now.
(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
ZONENAME="$1"
ZONEPATH="$2"
# XXX shared/common script currently uses lower case zonename & zonepath
zonename="$ZONENAME"
zonepath="$ZONEPATH"
ZONEROOT="$ZONEPATH/root"
logdir="$ZONEROOT/var/log"
shift; shift # remove ZONENAME and ZONEPATH from arguments array
unset inst_type
unset msg
unset silent_mode
unset OPT_V
#
# It is worth noting here that we require the end user to pick one of
# -u (sys-unconfig) or -p (preserve config). This is because we can't
# really know in advance which option makes a better default. Forcing
# the user to pick one or the other means that they will consider their
# choice and hopefully not be surprised or disappointed with the result.
#
unset unconfig_zone
unset preserve_zone
unset SANITY_SKIP
while getopts "a:d:Fpr:suv" opt
do
case "$opt" in
a)
if [[ -n "$inst_type" ]]; then
fatal "$incompat_options" "$m_usage"
fi
inst_type="archive"
install_media="$OPTARG"
;;
d)
if [[ -n "$inst_type" ]]; then
fatal "$incompat_options" "$m_usage"
fi
inst_type="directory"
install_media="$OPTARG"
;;
F) SANITY_SKIP=1;;
p) preserve_zone="-p";;
r)
if [[ -n "$inst_type" ]]; then
fatal "$incompat_options" "$m_usage"
fi
inst_type="stdin"
install_media="$OPTARG"
;;
s) silent_mode=1;;
u) unconfig_zone="-u";;
v) OPT_V="-v";;
*) printf "$m_usage\n"
exit $ZONE_SUBPROC_USAGE;;
esac
done
shift OPTIND-1
# The install can't be both verbose AND silent...
if [[ -n $silent_mode && -n $OPT_V ]]; then
fatal "$incompat_options" "$m_usage"
fi
if [[ -z $install_media ]]; then
fatal "$media_missing" "$m_usage"
fi
# The install can't both preserve and unconfigure
if [[ -n $unconfig_zone && -n $preserve_zone ]]; then
fatal "$incompat_options" "$m_usage"
fi
# Must pick one or the other.
if [[ -z $unconfig_zone && -z $preserve_zone ]]; then
fatal "$cfgchoice_missing" "$m_usage"
fi
LOGFILE=$(/usr/bin/mktemp -t -p /var/tmp $ZONENAME.install_log.XXXXXX)
if [[ -z "$LOGFILE" ]]; then
fatal "$e_tmpfile"
fi
zone_logfile="${logdir}/$ZONENAME.install$$.log"
exec 2>>"$LOGFILE"
log "$install_log" "$LOGFILE"
vlog "Starting pre-installation tasks."
#
# From here on out, an unspecified exit or interrupt should exit with
# ZONE_SUBPROC_NOTCOMPLETE, meaning a user will need to do an uninstall before
# attempting another install, as we've modified the directories we were going
# to install to in some way.
#
EXIT_CODE=$ZONE_SUBPROC_NOTCOMPLETE
create_active_ds
vlog "Installation started for zone \"$ZONENAME\""
install_image "$inst_type" "$install_media"
[[ "$SANITY_SKIP" == "1" ]] && touch $ZONEROOT/.sanity_skip
log "$p2ving"
vlog "running: p2v $OPT_V $unconfig_zone $ZONENAME $ZONEPATH"
#
# Run p2v.
#
# Getting the output to the right places is a little tricky because what
# we want is for p2v to output in the same way the installer does: verbose
# messages to the log file always, and verbose messages printed to the
# user if the user passes -v. This rules out simple redirection. And
# we can't use tee or other tricks because they cause us to lose the
# return value from the p2v script due to the way shell pipelines work.
#
# The simplest way to do this seems to be to hand off the management of
# the log file to the p2v script. So we run p2v with -l to tell it where
# to find the log file and then reopen the log (O_APPEND) when p2v is done.
#
/usr/lib/brand/solaris10/p2v -l "$LOGFILE" -m "$p2v_prog" \
$OPT_V $unconfig_zone $ZONENAME $ZONEPATH
p2v_result=$?
exec 2>>$LOGFILE
if (( $p2v_result == 0 )); then
vlog "$p2v_done"
else
log "$p2v_fail"
log ""
log "$install_fail"
log "$install_log" "$LOGFILE"
exit $ZONE_SUBPROC_FATAL
fi
# Add a service tag for this zone.
add_svc_tag "$ZONENAME" "install $inst_type `basename $install_media`"
log ""
log "$install_good" "$ZONENAME"
safe_dir /var
safe_dir /var/log
safe_copy $LOGFILE $zone_logfile
log "$install_log" "$zone_logfile"
rm -f $LOGFILE
# This needs to be set since the exit trap handler is going run.
EXIT_CODE=$ZONE_SUBPROC_OK
exit $ZONE_SUBPROC_OK
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
# NOTE: this script runs in the global zone and touches the non-global
# zone, so care should be taken to validate any modifications so that they
# are safe.
. /usr/lib/brand/solaris10/common.ksh
LOGFILE=
MSG_PREFIX="p2v: "
EXIT_CODE=1
usage()
{
echo "$0 [-s] [-m msgprefix] [-u] [-v] [-b patchid]* zonename" >&2
exit $EXIT_CODE
}
# Clean up on interrupt
trap_cleanup()
{
msg=$(gettext "Postprocessing cancelled due to interrupt.")
error "$msg"
if (( $zone_is_running != 0 )); then
error "$e_shutdown" "$ZONENAME"
/usr/sbin/zoneadm -z $ZONENAME halt
fi
#
# Delete temporary files created during the hollow package removal
# process.
#
rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list
exit $EXIT_CODE
}
#
# Disable any existing live-upgrade configuration.
# We have already called safe_dir to validate the etc/lu directory.
#
fix_lu()
{
ludir=$ZONEROOT/etc/lu
[[ ! -d $ludir ]] && return
safe_rm etc/lutab
safe_rm etc/lu/.BE_CONFIG
safe_rm etc/lu/.CURR_VARS
safe_rm etc/lu/ludb.local.xml
for i in $ludir/ICF* $ludir/vtoc* $ludir/GRUB*
do
nm=`basename $i`
safe_rm etc/lu/$nm
done
}
#
# For an exclusive stack zone, fix up the network configuration files.
# We need to do this even if unconfiguring the zone so sys-unconfig works
# correctly.
#
fix_net()
{
[[ "$STACK_TYPE" == "shared" ]] && return
NETIF_CNT=$(/bin/ls $ZONEROOT/etc/hostname.* 2>/dev/null | \
/usr/bin/wc -l)
if (( $NETIF_CNT != 1 )); then
vlog "$v_nonetfix"
return
fi
NET=$(LC_ALL=C /usr/sbin/zonecfg -z $ZONENAME info net)
if (( $? != 0 )); then
error "$e_badinfo" "net"
return
fi
NETIF=$(echo $NET | /bin/nawk '{
for (i = 1; i < NF; i++) {
if ($i == "physical:") {
if (length(net) == 0) {
i++
net = $i
} else {
multiple=1
}
}
}
}
END { if (!multiple)
print net
}')
if [[ -z "$NETIF" ]]; then
vlog "$v_nonetfix"
return
fi
OLD_HOSTNET=$(/bin/ls $ZONEROOT/etc/hostname.*)
if [[ "$OLD_HOSTNET" != "$ZONEROOT/etc/hostname.$NETIF" ]]; then
safe_move $OLD_HOSTNET $ZONEROOT/etc/hostname.$NETIF
fi
}
#
# Disable all of the shares since the zone cannot be an NFS server.
# Note that we disable the various instances of the svc:/network/shares/group
# SMF service in the fix_smf function.
#
fix_nfs()
{
zonedfs=$ZONEROOT/etc/dfs
[[ ! -d $zonedfs ]] && return
if [[ -h $zonedfs/dfstab || ! -f $zonedfs/dfstab ]]; then
error "$e_badfile" "/etc/dfs/dfstab"
return
fi
tmpfile=$(mktemp -t)
if [[ $? == 1 || -z "$tmpfile" ]]; then
error "$e_tmpfile"
return
fi
/bin/nawk '{
if (substr($1, 0, 1) == "#") {
print $0
} else {
print "#", $0
modified=1
}
}
END {
if (modified == 1) {
printf("# Modified by p2v ")
system("/bin/date")
exit 0
}
exit 1
}' $zonedfs/dfstab >>$tmpfile
if (( $? == 0 )); then
if [[ ! -f $zonedfs/dfstab.pre_p2v ]]; then
safe_copy $zonedfs/dfstab $zonedfs/dfstab.pre_p2v
fi
safe_copy $tmpfile $zonedfs/dfstab
chown root:sys $zonedfs/dfstab || \
fail_fatal "$f_chown" "$zonedfs/dfstab"
chmod 644 $zonedfs/dfstab || \
fail_fatal "$f_chmod" "$zonedfs/dfstab"
fi
/bin/rm -f $tmpfile
}
#
# Comment out most of the old mounts since they are either unneeded or
# likely incorrect within a zone. Specific mounts can be manually
# reenabled if the corresponding device is added to the zone.
#
fix_vfstab()
{
if [[ -h $ZONEROOT/etc/vfstab || ! -f $ZONEROOT/etc/vfstab ]]; then
error "$e_badfile" "/etc/vfstab"
return
fi
tmpfile=$(mktemp -t)
if [[ $? == 1 || -z "$tmpfile" ]]; then
error "$e_tmpfile"
return
fi
/bin/nawk '{
if (substr($1, 0, 1) == "#") {
print $0
} else if ($1 == "fd" || $1 == "/proc" || $1 == "swap" ||
$1 == "ctfs" || $1 == "objfs" || $1 == "sharefs" ||
$4 == "nfs" || $4 == "lofs") {
print $0
} else {
print "#", $0
modified=1
}
}
END {
if (modified == 1) {
printf("# Modified by p2v ")
system("/bin/date")
exit 0
}
exit 1
}' $ZONEROOT/etc/vfstab >>$tmpfile
if (( $? == 0 )); then
if [[ ! -f $ZONEROOT/etc/vfstab.pre_p2v ]]; then
safe_copy $ZONEROOT/etc/vfstab \
$ZONEROOT/etc/vfstab.pre_p2v
fi
safe_copy $tmpfile $ZONEROOT/etc/vfstab
chown root:sys $ZONEROOT/etc/vfstab || \
fail_fatal "$f_chown" "$ZONEROOT/etc/vfstab"
chmod 644 $ZONEROOT/etc/vfstab || \
fail_fatal "$f_chmod" "$ZONEROOT/etc/vfstab"
fi
/bin/rm -f $tmpfile
}
#
# Collect the data needed to delete SMF services. Since we're p2v-ing a
# physical image there are SMF services which must be deleted.
#
fix_smf_pre_uoa()
{
#
# Start by getting the svc manifests that are delivered by hollow
# pkgs then use 'svccfg inventory' to get the names of the svcs
# delivered by those manifests. The svc names are saved into a
# temporary file.
#
SMFTMPFILE=$(mktemp -t smf.XXXXXX)
if [[ $? == 1 || -z "$SMFTMPFILE" ]]; then
error "$e_tmpfile"
return
fi
for i in $ZONEROOT/var/sadm/pkg/*
do
pkg=$(/bin/basename $i)
[[ ! -f $ZONEROOT/var/sadm/pkg/$pkg/save/pspool/$pkg/pkgmap ]] \
&& continue
/bin/egrep -s "SUNW_PKG_HOLLOW=true" \
$ZONEROOT/var/sadm/pkg/$pkg/pkginfo || continue
for j in $(/bin/nawk '{if ($2 == "f" &&
substr($4, 1, 17) == "var/svc/manifest/") print $4}' \
$ZONEROOT/var/sadm/pkg/$pkg/save/pspool/$pkg/pkgmap)
do
svcs=$(SVCCFG_NOVALIDATE=1 \
SVCCFG_REPOSITORY=$ZONEROOT/etc/svc/repository.db \
/sbin/svccfg inventory $ZONEROOT/$j)
for k in $svcs
do
echo $k /$j >> $SMFTMPFILE
done
done
done
}
#
# Delete or disable SMF services.
# Zone is booted to milestone=none when this function is called.
# Use the SMF data collected by fix_smf_pre_uoa() to delete the services.
#
fix_smf()
{
#
# Zone was already booted to milestone=none, wait until SMF door exists.
#
for i in 0 1 2 3 4 5 6 7 8 9
do
[[ -r $ZONEROOT/etc/svc/volatile/repository_door ]] && break
sleep 5
done
if [[ $i -eq 9 && ! -r $ZONEROOT/etc/svc/volatile/repository_door ]];
then
#
# The zone never booted, something is wrong.
#
error "$e_nosmf"
error "$e_bootfail"
/bin/rm -f $SMFTMPFILE
return 1
fi
insttmpfile=$(mktemp -t instsmf.XXXXXX)
if [[ $? == 1 || -z "$insttmpfile" ]]; then
error "$e_tmpfile"
/bin/rm -f $SMFTMPFILE
return 1
fi
vlog "$v_rmhollowsvcs"
while read fmri mfst
do
# Delete the svc.
vlog "$v_delsvc" "$fmri"
echo "/sbin/svccfg delete -f $fmri"
echo "/sbin/svccfg delhash -d $mfst"
echo "rm -f $mfst"
done < $SMFTMPFILE > $ZONEROOT/tmp/smf_rm
/usr/sbin/zlogin -S $ZONENAME /bin/sh /tmp/smf_rm >/dev/null 2>&1
/bin/rm -f $SMFTMPFILE
# Get a list of the svcs that now exist in the zone.
LANG=C /usr/sbin/zlogin -S $ZONENAME /usr/bin/svcs -aH | \
/bin/nawk '{print $3}' >>$insttmpfile
[[ -n $LOGFILE ]] && \
printf "[$(date)] ${MSG_PREFIX}${v_svcsinzone}\n" >&2
[[ -n $LOGFILE ]] && cat $insttmpfile >&2
#
# Import ip-interface-management service in S10C, network
# loopback service requires ipmgmtd in exclusive stack zones.
#
/usr/sbin/zlogin -S $ZONENAME /sbin/svccfg import \
$ZONEROOT/var/svc/manifest/network/network-ipmgmt.xml
#
# Fix network services if shared stack.
#
if [[ "$STACK_TYPE" == "shared" ]]; then
vlog "$v_fixnetsvcs"
NETPHYSDEF="svc:/network/physical:default"
NETPHYSNWAM="svc:/network/physical:nwam"
/bin/egrep -s "$NETPHYSDEF" $insttmpfile
if (( $? == 0 )); then
vlog "$v_enblsvc" "$NETPHYSDEF"
/usr/sbin/zlogin -S $ZONENAME \
/sbin/svcadm enable $NETPHYSDEF || \
error "$e_dissvc" "$NETPHYSDEF"
fi
/bin/egrep -s "$NETPHYSNWAM" $insttmpfile
if (( $? == 0 )); then
vlog "$v_dissvc" "$NETPHYSNWAM"
/usr/sbin/zlogin -S $ZONENAME \
/sbin/svcadm disable $NETPHYSNWAM || \
error "$e_enblsvc" "$NETPHYSNWAM"
fi
for i in $(/bin/egrep network/routing $insttmpfile)
do
# Disable the svc.
vlog "$v_dissvc" "$i"
/usr/sbin/zlogin -S $ZONENAME \
/sbin/svcadm disable $i || \
error "$e_dissvc" $i
done
fi
#
# Disable well-known services that don't run in a zone.
#
vlog "$v_rminvalidsvcs"
for i in $(/bin/egrep -hv "^#" \
/usr/lib/brand/solaris10/smf_disable.lst \
/etc/brand/solaris10/smf_disable.conf)
do
# Skip svcs not installed in the zone.
/bin/egrep -s "$i:" $insttmpfile || continue
# Disable the svc.
vlog "$v_dissvc" "$i"
/usr/sbin/zlogin -S $ZONENAME /sbin/svcadm disable $i || \
error "$e_dissvc" $i
done
#
# Since zones can't be NFS servers, disable all of the instances of
# the shares svc.
#
for i in $(/bin/egrep network/shares/group $insttmpfile)
do
vlog "$v_dissvc" "$i"
/usr/sbin/zlogin -S $ZONENAME /sbin/svcadm disable $i || \
error "$e_dissvc" $i
done
/bin/rm -f $insttmpfile
return 0
}
#
# Remove well-known pkgs that do not work inside a zone.
#
rm_pkgs()
{
/bin/cat <<-EOF > $ZONEROOT/tmp/admin || fatal "$e_adminf"
mail=
instance=overwrite
partial=nocheck
runlevel=nocheck
idepend=nocheck
rdepend=nocheck
space=nocheck
setuid=nocheck
conflict=nocheck
action=nocheck
basedir=default
EOF
for i in $(/bin/egrep -hv "^#" /usr/lib/brand/solaris10/pkgrm.lst \
/etc/brand/solaris10/pkgrm.conf)
do
[[ ! -d $ZONEROOT/var/sadm/pkg/$i ]] && continue
vlog "$v_rmpkg" "$i"
/usr/sbin/zlogin -S $ZONENAME \
/usr/sbin/pkgrm -na /tmp/admin $i >&2 || error "$e_rmpkg" $i
done
}
#
# Zoneadmd writes a one-line index file into the zone when the zone boots,
# so any information about installed zones from the original system will
# be lost at that time. Here we'll warn the sysadmin about any pre-existing
# zones that they might want to clean up by hand, but we'll leave the zonepaths
# in place in case they're on shared storage and will be migrated to
# a new host.
#
warn_zones()
{
zoneconfig=$ZONEROOT/etc/zones
[[ ! -d $zoneconfig ]] && return
if [[ -h $zoneconfig/index || ! -f $zoneconfig/index ]]; then
error "$e_badfile" "/etc/zones/index"
return
fi
NGZ=$(/bin/nawk -F: '{
if (substr($1, 0, 1) == "#" || $1 == "global")
next
if ($2 == "installed")
printf("%s ", $1)
}' $zoneconfig/index)
# Return if there are no installed zones to warn about.
[[ -z "$NGZ" ]] && return
log "$v_rmzones" "$NGZ"
NGZP=$(/bin/nawk -F: '{
if (substr($1, 0, 1) == "#" || $1 == "global")
continue
if ($2 == "installed")
printf("%s ", $3)
}' $zoneconfig/index)
log "$v_rmzonepaths"
for i in $NGZP
do
log " %s" "$i"
done
}
#
# ^C Should cleanup; if the zone is running, it should try to halt it.
#
zone_is_running=0
trap trap_cleanup INT
#
# Parse the command line options.
#
OPT_U=
OPT_V=
OPT_M=
OPT_L=
while getopts "uvm:l:" opt
do
case "$opt" in
u) OPT_U="-u";;
v) OPT_V="-v";;
m) MSG_PREFIX="$OPTARG"; OPT_M="-m \"$OPTARG\"";;
l) LOGFILE="$OPTARG"; OPT_L="-l \"$OPTARG\"";;
*) usage;;
esac
done
shift OPTIND-1
(( $# < 1 )) && usage
(( $# > 2 )) && usage
[[ -n $LOGFILE ]] && exec 2>>$LOGFILE
ZONENAME=$1
ZONEPATH=$2
# XXX shared/common script currently uses lower case zonename & zonepath
zonename="$ZONENAME"
zonepath="$ZONEPATH"
ZONEROOT=$ZONEPATH/root
e_badinfo=$(gettext "Failed to get '%s' zone resource")
e_badfile=$(gettext "Invalid '%s' file within the zone")
v_mkdirs=$(gettext "Creating mount points")
v_nonetfix=$(gettext "Cannot update /etc/hostname.{net} file")
v_adjust=$(gettext "Updating the image to run within a zone")
v_stacktype=$(gettext "Stack type '%s'")
v_booting=$(gettext "Booting zone to single user mode")
e_bootfail=$(gettext "Failed to boot zone to single user mode.")
e_nosmf=$(gettext "SMF repository unavailable.")
v_svcsinzone=$(gettext "The following SMF services are installed:")
v_rmhollowsvcs=$(gettext "Deleting SMF services from hollow packages")
v_fixnetsvcs=$(gettext "Adjusting network SMF services")
v_rminvalidsvcs=$(gettext "Disabling invalid SMF services")
v_delsvc=$(gettext "Delete SMF svc '%s'")
e_delsvc=$(gettext "deleting SMF svc '%s'")
v_enblsvc=$(gettext "Enable SMF svc '%s'")
e_enblsvc=$(gettext "enabling SMF svc '%s'")
v_dissvc=$(gettext "Disable SMF svc '%s'")
e_dissvc=$(gettext "disabling SMF svc '%s'")
e_adminf=$(gettext "Unable to create admin file")
v_rmpkg=$(gettext "Remove package '%s'")
e_rmpkg=$(gettext "removing package '%s'")
v_rmzones=$(gettext "The following zones in this image will be unusable: %s")
v_rmzonepaths=$(gettext "These zonepaths could be removed from this image:")
v_halting=$(gettext "Halting zone")
e_shutdown=$(gettext "Shutting down zone %s...")
e_badhalt=$(gettext "Zone halt failed")
v_exitgood=$(gettext "Postprocessing successful.")
e_exitfail=$(gettext "Postprocessing failed.")
#
# Do some validation on the paths we'll be accessing
#
safe_dir /etc
safe_dir /var
safe_dir /var/sadm
safe_dir /var/sadm/install
safe_dir /var/sadm/pkg
safe_opt_dir /etc/dfs
safe_opt_dir /etc/lu
safe_opt_dir /etc/zones
mk_zone_dirs
# Now do the work to update the zone.
# Check for zones inside of image.
warn_zones
fix_smf_pre_uoa
log "$v_adjust"
#
# Any errors in these functions are not considered fatal. The zone can be
# be fixed up manually afterwards and it may need some additional manual
# cleanup in any case.
#
STACK_TYPE=$(/usr/sbin/zoneadm -z $ZONENAME list -p | \
/bin/nawk -F: '{print $7}')
if (( $? != 0 )); then
error "$e_badinfo" "stacktype"
fi
vlog "$v_stacktype" "$STACK_TYPE"
fix_lu
fix_net
fix_nfs
fix_vfstab
vlog "$v_booting"
#
# Boot the zone so that we can do all of the SMF updates needed on the zone's
# repository.
#
zone_is_running=1
/usr/sbin/zoneadm -z $ZONENAME boot -f -- -m milestone=none
if (( $? != 0 )); then
error "$e_badboot"
/bin/rm -f $SMFTMPFILE
fatal "$e_exitfail"
fi
#
# Remove all files and directories installed by hollow packages. Such files
# and directories shouldn't exist inside zones.
#
hollow_pkgs=$(mktemp -t .hollow.pkgs.XXXXXX)
hollow_file_list=$(mktemp $ZONEROOT/.hollow.pkgs.files.XXXXXX)
hollow_dir_list=$(mktemp $ZONEROOT/.hollow.pkgs.dirs.XXXXXX)
[ -f "$hollow_pkgs" -a -f "$hollow_file_list" -a -f "$hollow_dir_list" ] || {
error "$e_tmpfile"
rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list
fatal "$e_exitfail"
}
for pkg_name in $ZONEROOT/var/sadm/pkg/*; do
grep 'SUNW_PKG_HOLLOW=true' $pkg_name/pkginfo >/dev/null 2>&1 && \
basename $pkg_name >>$hollow_pkgs
done
/bin/nawk -v hollowpkgs=$hollow_pkgs -v filelist=$hollow_file_list \
-v dirlist=$hollow_dir_list '
BEGIN {
while (getline p <hollowpkgs > 0)
pkgs[p] = 1;
close(hollowpkgs);
}
{
# fld is the field where the pkg names begin.
# nm is the file/dir entry name.
if ($2 == "f") {
fld=10;
nm=$1;
} else if ($2 == "d") {
fld=7;
nm=$1;
} else if ($2 == "s" || $2 == "l") {
fld=4;
split($1, a, "=");
nm=a[1];
} else {
next;
}
# Determine whether the file or directory is delivered by any
# non-hollow packages. Files and directories can be
# delivered by multiple pkgs. The file or directory should only
# be removed if it is only delivered by hollow packages.
for (i = fld; i <= NF; i++) {
if (pkgs[get_pkg_name($i)] != 1) {
# We encountered a non-hollow package. Skip
# this entry.
next;
}
}
# The file or directory is only delivered by hollow packages.
# Mark it for removal.
if (fld != 7)
print nm >>filelist
else
print nm >>dirlist
}
# Get the clean pkg name from the fld entry.
function get_pkg_name(fld) {
# Remove any pkg control prefix (e.g. *, !)
first = substr(fld, 1, 1)
if (match(first, /[A-Za-z]/)) {
pname = fld
} else {
pname = substr(fld, 2)
}
# Then remove any class action script name
pos = index(pname, ":")
if (pos != 0)
pname = substr(pname, 1, pos - 1)
return (pname)
}
' $ZONEROOT/var/sadm/install/contents
/usr/sbin/zlogin -S $ZONENAME "cat /$(basename $hollow_file_list) | xargs rm -f"
/usr/sbin/zlogin -S $ZONENAME "sort -r /$(basename $hollow_dir_list) | \
xargs rmdir >/dev/null 2>&1"
rm -f $hollow_pkgs $hollow_file_list $hollow_dir_list
# cleanup SMF services
fix_smf || failed=1
# remove invalid pkgs
[[ -z $failed ]] && rm_pkgs
if [[ -z $failed && -n $OPT_U ]]; then
vlog "$v_unconfig"
sysunconfig_zone
if (( $? != 0 )); then
failed=1
fi
fi
vlog "$v_halting"
/usr/sbin/zoneadm -z $ZONENAME halt
if (( $? != 0 )); then
error "$e_badhalt"
failed=1
fi
zone_is_running=0
if [[ -n $failed ]]; then
fatal "$e_exitfail"
fi
vlog "$v_exitgood"
exit 0
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This is a list of SVr4 packages which should be removed when installing
# the zone. Site-specific packages which must be removed should be listed
# in this file. During the zone installation, the packages will be removed
# if they existed on the original physical system.
#
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This is a list of SVr4 packages which should be removed when installing
# the zone. Do not edit this file. Site-specific packages which must be
# removed should be listed in the /etc/brand/solaris10/pkgrm.conf file.
# During the zone installation, the packages will be removed if they existed
# on the original physical system.
#
VRTSvxvm
<?xml version="1.0"?>
<!--
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
DO NOT EDIT THIS FILE.
-->
<!DOCTYPE platform PUBLIC "-//Sun Microsystems Inc//Zones Platform//EN"
"file:///usr/share/lib/xml/dtd/zone_platform.dtd.1">
<platform name="solaris10" allow-exclusive-ip="true">
<!-- Global filesystems to mount when booting the zone -->
<global_mount special="/dev" directory="/dev" type="dev"
opt="attrdir=%R/dev"/>
<!--
Local filesystems to mount when booting the zone. The
/.SUNWnative/platform entry is needed so that we can symlink a
platform-specific libc_psr for platforms which were not delivered
with S10. The /.SUNWnative/sbin entry is needed so that we can
replace ifconfig with its native counterpart (this is required for
exclusive-stack S10 zones to work).
-->
<global_mount special="/usr" directory="/.SUNWnative/usr"
opt="ro,nodevices" type="lofs" />
<global_mount special="/lib" directory="/.SUNWnative/lib"
opt="ro,nodevices" type="lofs" />
<global_mount special="/platform" directory="/.SUNWnative/platform"
opt="ro,nodevices" type="lofs" />
<global_mount special="/sbin" directory="/.SUNWnative/sbin"
opt="ro,nodevices" type="lofs" />
<!-- Local filesystems to mount when booting the zone -->
<mount special="/proc" directory="/proc" type="proc" />
<mount special="ctfs" directory="/system/contract" type="ctfs" />
<mount special="mnttab" directory="/etc/mnttab" type="mntfs" />
<mount special="objfs" directory="/system/object" type="objfs" />
<mount special="swap" directory="/etc/svc/volatile" type="tmpfs" />
<!-- Devices to create under /dev -->
<device match="arp" />
<device match="bpf" />
<device match="conslog" />
<device match="cpu/self/cpuid" />
<device match="crypto" />
<device match="cryptoadm" />
<device match="dsk" />
<device match="dtrace/*" />
<device match="dtrace/provider/*" />
<device match="fd" />
<device match="full" />
<device match="ipnet" />
<device match="kstat" />
<device match="lo0" />
<device match="lofictl" />
<device match="lofi" />
<device match="log" />
<device match="logindmux" />
<device match="nsmb" />
<device match="net/*" />
<device match="null" />
<device match="openprom" arch="sparc" />
<device match="poll" />
<device match="pool" />
<device match="ptmx" />
<device match="pts/*" />
<device match="random" />
<device match="rdsk" />
<device match="rlofi" />
<device match="rmt" />
<device match="sad/user" />
<device match="svvslo0" />
<device match="svvslo1" />
<device match="svvslo2" />
<device match="svvslo3" />
<device match="swap" />
<device match="sysevent" />
<device match="tcp" />
<device match="tcp6" />
<device match="term" />
<device match="ticlts" />
<device match="ticots" />
<device match="ticotsord" />
<device match="tty" />
<device match="udp" />
<device match="udp6" />
<device match="urandom" />
<device match="zero" />
<device match="zfs" />
<!-- Devices to create in exclusive IP zone only -->
<device match="dld" ip-type="exclusive" />
<device match="icmp" ip-type="exclusive" />
<device match="icmp6" ip-type="exclusive" />
<device match="ip" ip-type="exclusive" />
<device match="ip6" ip-type="exclusive" />
<device match="ipauth" ip-type="exclusive" />
<device match="ipf" ip-type="exclusive" />
<device match="ipl" ip-type="exclusive" />
<device match="iplookup" ip-type="exclusive" />
<device match="ipmpstub" ip-type="exclusive" />
<device match="ipnat" ip-type="exclusive" />
<device match="ipscan" ip-type="exclusive" />
<device match="ipsecah" ip-type="exclusive" />
<device match="ipsecesp" ip-type="exclusive" />
<device match="ipstate" ip-type="exclusive" />
<device match="ipsync" ip-type="exclusive" />
<device match="keysock" ip-type="exclusive" />
<device match="rawip" ip-type="exclusive" />
<device match="rawip6" ip-type="exclusive" />
<device match="rts" ip-type="exclusive" />
<device match="sad/admin" ip-type="exclusive" />
<device match="sctp" ip-type="exclusive" />
<device match="sctp6" ip-type="exclusive" />
<device match="spdsock" ip-type="exclusive" />
<device match="sppp" ip-type="exclusive" />
<device match="sppptun" ip-type="exclusive" />
<device match="vni" ip-type="exclusive" />
<!-- Renamed devices to create under /dev -->
<device match="zcons/%z/zoneconsole" name="zconsole" />
<!-- Symlinks to create under /dev -->
<symlink source="console" target="zconsole" />
<symlink source="dtremote" target="/dev/null" />
<symlink source="msglog" target="zconsole" />
<symlink source="stderr" target="./fd/2" />
<symlink source="stdin" target="./fd/0" />
<symlink source="stdout" target="./fd/1" />
<symlink source="syscon" target="zconsole" />
<symlink source="sysmsg" target="zconsole" />
<symlink source="systty" target="zconsole" />
</platform>
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# This postattach hook adds the service tag for the zone.
# We need this in a postattach hook since the zone doesn't have
# a UUID when the attach hook is run.
#
. /usr/lib/brand/solaris10/common.ksh
install_media="-"
# If we weren't passed at least two arguments, exit now.
(( $# < 2 )) && exit $ZONE_SUBPROC_OK
ZONENAME="$1"
ZONEPATH="$2"
shift 2
noexecute=0
unset inst_type
#
# This hook will see the same options as the attach hook, so make sure
# we accept all of these.
#
while getopts "a:d:nr:" opt; do
case $opt in
a)
inst_type="archive"
install_media="$OPTARG"
;;
d)
inst_type="directory"
install_media="$OPTARG"
;;
n) noexecute=1 ;;
r)
inst_type="stdin"
install_media="$OPTARG"
;;
?) exit $ZONE_SUBPROC_OK;;
*) exit $ZONE_SUBPROC_OK;;
esac
done
shift $((OPTIND-1))
[ $noexecute -eq 1 ] && exit $ZONE_SUBPROC_OK
[[ -z "$inst_type" ]] && inst_type="directory"
# Add a service tag for this zone.
add_svc_tag "$ZONENAME" "attach $inst_type `basename $install_media`"
exit $ZONE_SUBPROC_OK
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
. /usr/lib/brand/solaris10/common.ksh
# States
# ZONE_STATE_CONFIGURED 0 (never see)
# ZONE_STATE_INCOMPLETE 1 (never see)
# ZONE_STATE_INSTALLED 2
# ZONE_STATE_READY 3
# ZONE_STATE_RUNNING 4
# ZONE_STATE_SHUTTING_DOWN 5
# ZONE_STATE_DOWN 6
# ZONE_STATE_MOUNTED 7
# cmd
#
# ready 0
# boot 1
# halt 4
zonename=$1
zonepath=$2
state=$3
cmd=$4
altroot=$5 # unused at this time for s10 branded zones
# If we're readying the zone, update the zone index file to look like this is
# the global zone.
if (( $cmd == 0 )); then
echo "global:installed:/" > $zonepath/root/etc/zones/index
fi
exit 0
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
#
. /usr/lib/brand/solaris10/common.ksh
# States
# ZONE_STATE_CONFIGURED 0 (never see)
# ZONE_STATE_INCOMPLETE 1 (never see)
# ZONE_STATE_INSTALLED 2
# ZONE_STATE_READY 3
# ZONE_STATE_RUNNING 4
# ZONE_STATE_SHUTTING_DOWN 5
# ZONE_STATE_DOWN 6
# ZONE_STATE_MOUNTED 7
# cmd
#
# ready 0
# boot 1
# halt 4
zonename=$1
zonepath=$2
state=$3
cmd=$4
altroot=$5 # unused at this time for s10 branded zones
# If we're not readying the zone, then just return.
if (( $cmd == 0 )); then
# Mount active dataset on the root.
mount_active_ds
fi
exit $ZONE_SUBPROC_OK
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# This preuninstall hook removes the service tag for the zone.
# We need this in a preuninstall hook since once the zone state is
# changed to 'incomplete' (which happens before we run the uninstall hook)
# then the zone gets a new UUID and we can no longer figure out which
# service tag instance to delete.
#
#
# common shell script functions
#
. /usr/lib/brand/solaris10/common.ksh
# If we weren't passed at least two arguments, exit now.
(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
ZONENAME=$1
ZONEPATH=$2
shift 2
#
# This hook will see the same options as the uninstall hook, so make sure
# we accept these even though all but -n are ignored.
#
options="FhHnv"
nop=""
# process options
OPTIND=1
while getopts :$options OPT ; do
case $OPT in
F ) ;;
h|H ) exit $ZONE_SUBPROC_OK ;;
n ) nop="echo" ;;
v ) ;;
esac
done
shift `expr $OPTIND - 1`
[ $# -gt 0 ] && exit $ZONE_SUBPROC_OK
# Remove the service tag for this zone.
$nop del_svc_tag "$ZONENAME"
exit $ZONE_SUBPROC_OK
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#
# s10 boot script.
#
# The arguments to this script are the zone name and the zonepath.
#
. /usr/lib/brand/solaris10/common.ksh
ZONENAME=$1
ZONEPATH=$2
ZONEROOT=$ZONEPATH/root
w_missing=$(gettext "Warning: \"%s\" is not installed in the global zone")
arch=`uname -p`
if [ "$arch" = "amd64" ] || [ "$arch" = "i386" ]; then
ARCH32=i86
ARCH64=amd64
elif [ "$arch" = "sparc" ]; then
# 32-bit SPARC not supported!
ARCH32=
ARCH64=sparcv9
else
echo "Unsupported architecture: $arch"
exit 2
fi
#
# Run the s10_support boot hook.
#
/usr/lib/brand/solaris10/s10_support boot $ZONENAME
if (( $? != 0 )) ; then
exit 1
fi
BRANDDIR=/.SUNWnative/usr/lib/brand/solaris10;
FILEDIR=$BRANDDIR/files;
EXIT_CODE=1
#
# Replace the specified file in the booting zone with a wrapper script that
# invokes s10_isaexec_wrapper. This is a convenience function that reduces
# clutter and code duplication.
#
# Parameters:
# $1 The full path of the file to replace (e.g., /sbin/ifconfig)
# $2 The access mode of the replacement file in hex (e.g., 0555)
# $3 The name of the replacement file's owner (e.g., root:bin)
#
# NOTE: The checks performed in the 'if' statement below are not generic: they
# depend on the success of the zone filesystem structure validation performed
# above to ensure that intermediate directories exist and aren't symlinks.
#
replace_with_native() {
path_dname=$ZONEROOT/`dirname $1`
[ ! -f $1 ] && printf "$w_missing" "$1"
if [ ! -h $path_dname -a -d $path_dname ]; then
safe_replace $ZONEROOT/$1 $BRANDDIR/s10_isaexec_wrapper $2 $3 \
remove
fi
}
#
# Create a new wrapper script that invokes s10_isaexec_wrapper in the
# brand (for a non-existing s10c file) pointing to the native brand file.
#
# Parameters:
# $1 The full path of the wrapper file to create
# $2 The access mode of the replacement file in hex (e.g., 0555)
# $3 The name of the replacement file's owner (e.g., root:bin)
#
wrap_with_native() {
[ ! -f $1 ] && printf "$w_missing" "$1"
path_dname=$ZONEROOT/`dirname $1`
if [ ! -h $path_dname -a -d $path_dname -a ! -f $ZONEROOT/$1 ]; then
safe_wrap $ZONEROOT/$1 $BRANDDIR/s10_isaexec_wrapper $2 $3
fi
}
#
# Before we boot we validate and fix, if necessary, the required files within
# the zone. These modifications can be lost if a patch is applied within the
# zone, so we validate and fix the zone every time it boots.
#
#
# BINARY REPLACEMENT
#
# This section of the boot script is responsible for replacing Solaris 10
# binaries within the booting zone with Nevada binaries. This is a two-step
# process: First, the directory structure of the zone is validated to ensure
# that binary replacement will proceed safely. Second, Solaris 10 binaries
# are replaced with Nevada binaries.
#
# Here's an example. Suppose that you want to replace /usr/bin/zcat with the
# Nevada /usr/bin/zcat binary. Then you should do the following:
#
# 1. Go to the section below labeled "STEP ONE" and add the following
# two lines:
#
# safe_dir /usr
# safe_dir /usr/bin
#
# These lines ensure that both /usr and /usr/bin are directories
# within the booting zone that can be safely accessed by the global
# zone.
# 2. Go to the section below labeled "STEP TWO" and add the following
# line:
#
# replace_with_native /usr/bin/zcat 0555 root:bin
#
# Details about the binary replacement procedure can be found in the Solaris 10
# Containers Developer Guide.
#
#
# STEP ONE
#
# Validate that the zone filesystem looks like we expect it to.
#
safe_dir /lib
safe_dir /lib/svc
safe_dir /lib/svc/method
safe_dir /lib/svc/share
safe_dir /usr
safe_dir /usr/bin
safe_dir /usr/lib
safe_dir /usr/lib/autofs
safe_dir /usr/lib/fs
safe_dir /usr/lib/fs/autofs
safe_dir /usr/lib/fs/ufs
safe_dir /usr/lib/fs/zfs
safe_dir /usr/lib/inet
safe_dir /usr/lib/zfs
safe_dir /usr/sbin
if [ -n "$ARCH32" ]; then
safe_dir /usr/lib/ipf/$ARCH32
safe_dir /usr/sbin/$ARCH32
fi
if [ -n "$ARCH64" ]; then
safe_dir /usr/lib/ipf/$ARCH64
safe_dir /usr/sbin/$ARCH64
fi
safe_dir /sbin
safe_dir /var
safe_dir /var/svc
safe_dir /var/svc/manifest
safe_dir /var/svc/manifest/network
#
# Some of the native networking daemons such as in.mpathd are
# expected under /lib/inet
#
mkdir -m 0755 -p $ZONEROOT/lib/inet
chown root:bin $ZONEROOT/lib/inet
safe_dir /lib/inet
#
# STEP TWO
#
# Replace Solaris 10 binaries with Nevada binaries.
#
#
# Replace various network-related programs with native wrappers.
#
replace_with_native /sbin/dhcpagent 0555 root:bin
replace_with_native /sbin/dhcpinfo 0555 root:bin
replace_with_native /sbin/ifconfig 0555 root:bin
replace_with_native /usr/bin/netstat 0555 root:bin
replace_with_native /usr/lib/inet/in.ndpd 0555 root:bin
replace_with_native /usr/sbin/in.routed 0555 root:bin
replace_with_native /usr/sbin/ndd 0555 root:bin
replace_with_native /usr/sbin/snoop 0555 root:bin
replace_with_native /usr/sbin/if_mpadm 0555 root:bin
#
# Replace IPFilter commands with native wrappers
#
replace_with_native /usr/lib/ipf/ipftest 0555 root:bin
replace_with_native /usr/sbin/ipf 0555 root:bin
replace_with_native /usr/sbin/ipfs 0555 root:bin
replace_with_native /usr/sbin/ipfstat 0555 root:bin
replace_with_native /usr/sbin/ipmon 0555 root:bin
replace_with_native /usr/sbin/ipnat 0555 root:bin
replace_with_native /usr/sbin/ippool 0555 root:bin
#
# Replace in.mpathd daemon at /usr/lib/inet by native wrapper
#
if [ ! -h $ZONEROOT/usr/lib/inet -a -d $ZONEROOT/usr/lib/inet ]; then
safe_replace $ZONEROOT/usr/lib/inet/in.mpathd \
/lib/inet/in.mpathd 0555 root:bin remove
fi
#
# Create wrapper at /lib/inet/in.mpathd as well because native ifconfig
# looks up in.mpathd under /lib/inet.
#
wrap_with_native /lib/inet/in.mpathd 0555 root:bin
# Create native wrapper for /sbin/ipmpstat
wrap_with_native /sbin/ipmpstat 0555 root:bin
#
# Create ipmgmtd wrapper to native binary in s10 container
# and copy ipmgmt service manifest and method.
#
wrap_with_native /lib/inet/ipmgmtd 0555 root:bin
safe_copy /lib/svc/manifest/network/network-ipmgmt.xml \
$ZONEROOT/var/svc/manifest/network/network-ipmgmt.xml
safe_copy /lib/svc/method/net-ipmgmt \
$ZONEROOT/lib/svc/method/net-ipmgmt
#
# To handle certain IPMP configurations, we need updated
# net-physical method script and native net_include.sh
#
filename=$ZONEROOT/lib/svc/method/net-physical
safe_backup $filename $filename.pre_p2v
safe_copy /usr/lib/brand/solaris10/s10_net_physical $filename
filename=$ZONEROOT/lib/svc/share/net_include.sh
safe_backup $filename $filename.pre_p2v
safe_copy /lib/svc/share/net_include.sh $filename
#
# PSARC 2009/306 removed the ND_SET/ND_GET ioctl's for modifying
# IP/TCP/UDP/SCTP/ICMP tunables. If S10 ndd(8) is used within an
# S10 container, the kernel will return EINVAL. So we need this.
#
replace_with_native /usr/sbin/ndd 0555 root:bin
#
# Replace various ZFS-related programs with native wrappers. These commands
# either link with libzfs, dlopen libzfs or link with libraries that link
# or dlopen libzfs. Commands which fall into these categories but which can
# only be used in the global zone are not wrapped. The libdiskmgt dm_in_use
# code uses libfs, but only the zpool_in_use() -> zpool_read_label() code path.
# That code does not issue ioctls on /dev/zfs and does not need wrapping.
#
replace_with_native /sbin/zfs 0555 root:bin
replace_with_native /sbin/zpool 0555 root:bin
replace_with_native /usr/lib/fs/ufs/quota 0555 root:bin
replace_with_native /usr/lib/fs/zfs/fstyp 0555 root:bin
replace_with_native /usr/lib/zfs/availdevs 0555 root:bin
replace_with_native /usr/sbin/df 0555 root:bin
replace_with_native /usr/sbin/zstreamdump 0555 root:bin
#
# Replace automount and automountd with native wrappers.
#
replace_with_native /usr/lib/fs/autofs/automount 0555 root:bin
replace_with_native /usr/lib/autofs/automountd 0555 root:bin
#
# The class-specific dispadmin(8) and priocntl(1) binaries must be native
# wrappers, and we must have all of the ones the native zone does. This
# allows new scheduling classes to appear without causing dispadmin and
# priocntl to be unhappy.
#
rm -rf $ZONEROOT/usr/lib/class
mkdir $ZONEROOT/usr/lib/class || exit 1
find /usr/lib/class -type d -o -type f | while read x; do
[ -d $x ] && mkdir -p -m 755 $ZONEROOT$x
[ -f $x ] && wrap_with_native $x 0555 root:bin
done
#
# END OF STEP TWO
#
#
# Replace add_drv and rem_drv with /bin/true so that pkgs/patches which
# install or remove drivers will work. NOTE: add_drv and rem_drv are hard
# linked to isaexec so we want to remove the current executable and
# then copy true so that we don't clobber isaexec.
#
filename=$ZONEROOT/sbin/add_drv
[ ! -f $filename.pre_p2v ] && safe_backup $filename $filename.pre_p2v
rm -f $filename
safe_copy $ZONEROOT/bin/true $filename
filename=$ZONEROOT/sbin/rem_drv
[ ! -f $filename.pre_p2v ] && safe_backup $filename $filename.pre_p2v
rm -f $filename
safe_copy $ZONEROOT/bin/true $filename
exit 0
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This is a list of SMF services which should be disabled when installing
# the zone. Site-specific services which must be disabled should be listed
# in this file. During the zone installation, the services will be disabled
# if they existed on the original physical system.
#
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This is a list of SMF services which should be disabled when installing
# the zone. Do not edit this file. Site-specific services which must be
# disabled should be listed in the /etc/brand/solaris10/smf_disable.conf
# file. During the zone installation, the services will be disabled if
# they existed on the original physical system.
#
svc:/network/smb/server
svc:/system/virtualbox/vboxservice
svc:/ldoms/ldmd
#!/bin/ksh93 -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# common shell script functions
#
. /usr/lib/brand/solaris10/common.ksh
. /usr/lib/brand/shared/uninstall.ksh
#
# options processing
#
# If we weren't passed at least two arguments, exit now.
(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
zonename=$1
zonepath=$2
shift 2
options="FhHnv"
options_repeat=""
options_seen=""
opt_F=""
opt_n=""
opt_v=""
# check for bad or duplicate options
OPTIND=1
while getopts $options OPT ; do
case $OPT in
\? ) usage_err ;; # invalid argument
: ) usage_err ;; # argument expected
* )
opt=`echo $OPT | sed 's/-\+//'`
if [ -n "$options_repeat" ]; then
echo $options_repeat | grep $opt >/dev/null
[ $? = 0 ] && break
fi
( echo $options_seen | grep $opt >/dev/null ) &&
usage_err
options_seen="${options_seen}${opt}"
;;
esac
done
# check for a help request
OPTIND=1
while getopts :$options OPT ; do
case $OPT in
h|H ) usage
esac
done
# process options
OPTIND=1
while getopts :$options OPT ; do
case $OPT in
F ) opt_F="-F" ;;
n ) opt_n="-n" ;;
v ) opt_v="-v" ;;
esac
done
shift `expr $OPTIND - 1`
[ $# -gt 0 ] && usage_err
#
# main
#
zoneroot=$zonepath/root
nop=""
if [[ -n "$opt_n" ]]; then
nop="echo"
#
# in '-n' mode we should never return success (since we haven't
# actually done anything). so override ZONE_SUBPROC_OK here.
#
ZONE_SUBPROC_OK=$ZONE_SUBPROC_FATAL
fi
#
# We want uninstall to work in the face of various problems, such as a
# zone with no delegated root dataset or multiple active datasets, so we
# don't use the common functions. Instead, we do our own work and
# are tolerant of errors.
#
uninstall_get_zonepath_ds
uninstall_get_zonepath_root_ds
# find all the zone BE datasets.
unset fs_all
(( fs_all_c = 0 ))
/sbin/zfs list -H -t filesystem -o name -r $ZONEPATH_RDS | while read fs; do
# only look at filesystems directly below $ZONEPATH_RDS
[[ "$fs" != ~()($ZONEPATH_RDS/+([^/])) ]] && continue
fs_all[$fs_all_c]=$fs
(( fs_all_c = $fs_all_c + 1 ))
done
destroy_zone_datasets
exit $ZONE_SUBPROC_OK
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# This is the current latest version of the solaris10 brand emulation. The
# version should be incremented if new capabilities are added to the
# emulation for new features backported to S10. The S10 required emulation
# version should also be incremented so that the enhanced version of S10
# won't be usable in an older version of the solaris10 brand.
#
0
|