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
|
#
# 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) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2018, Joyent, Inc. All rights reserved.
#
# cmd/fs.d/nfs/mount/Makefile
FSTYPE= nfs
LIBPROG= mount
ROOTFS_PROG= $(LIBPROG)
# duplicate ROOTLIBFSTYPE value needed for installation rule
# we must define this before including Makefile.fstype
ROOTLIBFSTYPE = $(ROOT)/usr/lib/fs/$(FSTYPE)
$(ROOTLIBFSTYPE)/%: $(ROOTLIBFSTYPE) %
$(RM) $@; $(SYMLINK) ../../../../etc/fs/$(FSTYPE)/$(LIBPROG) $@
include ../../Makefile.fstype
COMMON= $(FSLIB) nfs_sec.o replica.o nfs_subr.o selfcheck.o smfcfg.o
OBJS= $(LIBPROG).o $(COMMON) webnfs_client.o webnfs_xdr.o
SRCS= $(LIBPROG).c $(FSLIBSRC) ../lib/nfs_sec.c ../lib/replica.c \
../lib/nfs_subr.c webnfs_xdr.c webnfs_client.c ../lib/selfcheck.c \
../lib/smfcfg.c
UNCHECKED_HDRS= webnfs.h
CERRWARN += -Wno-parentheses
CERRWARN += -Wno-switch
CERRWARN += -Wno-unused-variable
CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -Wno-address
CERRWARN += -Wno-unused-function
# unknown type for func
SMATCH=off
#
# Message catalog
#
POFILE= mount.po
LDLIBS += -lrpcsvc -lnsl -lsocket -lscf
CPPFLAGS += -I. -I../.. -I../lib
CFLAGS += $(CCVERBOSE)
nfs_sec.o : CPPFLAGS += -DWNFS_SEC_NEGO
ROOTETCPROG = $(LIBPROG:%=$(ROOTETCFSTYPE)/%)
CLOBBERFILES += $(LIBPROG)
.KEEP_STATE:
all: $(ROOTFS_PROG)
$(LIBPROG): webnfs.h $(OBJS)
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
$(POST_PROCESS)
nfs_sec.o: ../lib/nfs_sec.c
$(COMPILE.c) ../lib/nfs_sec.c
replica.o: ../lib/replica.c
$(COMPILE.c) ../lib/replica.c
nfs_subr.o: ../lib/nfs_subr.c
$(COMPILE.c) ../lib/nfs_subr.c
selfcheck.o: ../lib/selfcheck.c
$(COMPILE.c) ../lib/selfcheck.c
nfs_tbind.o: ../lib/nfs_tbind.c
$(COMPILE.c) ../lib/nfs_tbind.c
smfcfg.o: ../lib/smfcfg.c
$(COMPILE.c) ../lib/smfcfg.c
# Hammerhead: pre-generated (rpcgen + GNU cpp truncation bug)
# webnfs.h, webnfs_xdr.c, webnfs_client.c are now committed source files.
webnfs.x: ../lib/webnfs.x
$(RM) webnfs.x
cp ../lib/webnfs.x .
#
# message catalog
#
catalog: $(POFILE)
$(POFILE): $(SRCS) webnfs.h
$(RM) $@
$(COMPILE.cpp) $(SRCS) > $(POFILE).i
$(XGETTEXT) $(XGETFLAGS) $(POFILE).i
sed "/^domain/d" messages.po > $@
$(RM) $(POFILE).i messages.po
install: $(ROOTETCPROG)
clean:
$(RM) $(OBJS) webnfs.x
@# Hammerhead: do not delete pre-generated webnfs.h webnfs_xdr.c webnfs_client.c
/*
* 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) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
/*
* nfs mount
*/
#define NFSCLIENT
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <stdarg.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/param.h>
#include <rpc/rpc.h>
#include <errno.h>
#include <sys/stat.h>
#include <netdb.h>
#include <sys/mount.h>
#include <sys/mntent.h>
#include <sys/mnttab.h>
#include <nfs/nfs.h>
#include <nfs/mount.h>
#include <rpcsvc/mount.h>
#include <sys/pathconf.h>
#include <netdir.h>
#include <netconfig.h>
#include <sys/sockio.h>
#include <net/if.h>
#include <syslog.h>
#include <fslib.h>
#include <deflt.h>
#include <sys/wait.h>
#include "replica.h"
#include <netinet/in.h>
#include <nfs/nfs_sec.h>
#include <rpcsvc/daemon_utils.h>
#include <priv.h>
#include <tsol/label.h>
#include "nfs_subr.h"
#include "webnfs.h"
#include <rpcsvc/nfs4_prot.h>
#include <limits.h>
#include <libscf.h>
#include <libshare.h>
#include "smfcfg.h"
#include <nfs/nfssys.h>
extern int _nfssys(enum nfssys_op, void *);
#ifndef NFS_VERSMAX
#define NFS_VERSMAX 4
#endif
#ifndef NFS_VERSMIN
#define NFS_VERSMIN 2
#endif
#define RET_OK 0
#define RET_RETRY 32
#define RET_ERR 33
#define RET_MNTERR 1000
#define ERR_PROTO_NONE 0
#define ERR_PROTO_INVALID 901
#define ERR_PROTO_UNSUPP 902
#define ERR_NETPATH 903
#define ERR_NOHOST 904
#define ERR_RPCERROR 905
typedef struct err_ret {
int error_type;
int error_value;
} err_ret_t;
#define SET_ERR_RET(errst, etype, eval) \
if (errst) { \
(errst)->error_type = etype; \
(errst)->error_value = eval; \
}
/* number of transports to try */
#define MNT_PREF_LISTLEN 2
#define FIRST_TRY 1
#define SECOND_TRY 2
#define BIGRETRY 10000
/* maximum length of RPC header for NFS messages */
#define NFS_RPC_HDR 432
#define NFS_ARGS_EXTB_secdata(args, secdata) \
{ (args)->nfs_args_ext = NFS_ARGS_EXTB, \
(args)->nfs_ext_u.nfs_extB.secdata = secdata; }
extern int __clnt_bindresvport(CLIENT *);
extern char *nfs_get_qop_name();
extern AUTH * nfs_create_ah();
extern enum snego_stat nfs_sec_nego();
static void usage(void);
static int retry(struct mnttab *, int);
static int set_args(int *, struct nfs_args *, char *, struct mnttab *);
static int get_fh_via_pub(struct nfs_args *, char *, char *, bool_t, bool_t,
int *, struct netconfig **, ushort_t);
static int get_fh(struct nfs_args *, char *, char *, int *, bool_t,
struct netconfig **, ushort_t);
static int make_secure(struct nfs_args *, char *, struct netconfig *,
bool_t, rpcvers_t);
static int mount_nfs(struct mnttab *, int, err_ret_t *);
static int getaddr_nfs(struct nfs_args *, char *, struct netconfig **,
bool_t, char *, ushort_t, err_ret_t *, bool_t);
static void pr_err(const char *fmt, ...);
static void usage(void);
static struct netbuf *get_addr(char *, rpcprog_t, rpcvers_t,
struct netconfig **, char *, ushort_t, struct t_info *,
caddr_t *, bool_t, char *, err_ret_t *);
static struct netbuf *get_the_addr(char *, rpcprog_t, rpcvers_t,
struct netconfig *, ushort_t, struct t_info *, caddr_t *,
bool_t, char *, err_ret_t *);
extern int self_check(char *);
static void read_default(void);
static char typename[64];
static int bg = 0;
static int backgrounded = 0;
static int posix = 0;
static int retries = BIGRETRY;
static ushort_t nfs_port = 0;
static char *nfs_proto = NULL;
static int mflg = 0;
static int Oflg = 0; /* Overlay mounts */
static int qflg = 0; /* quiet - don't print warnings on bad options */
static char *fstype = MNTTYPE_NFS;
static seconfig_t nfs_sec;
static int sec_opt = 0; /* any security option ? */
static bool_t snego_done;
static void sigusr1(int);
extern void set_nfsv4_ephemeral_mount_to(void);
/*
* list of support services needed
*/
static char *service_list[] = { STATD, LOCKD, NULL };
static char *service_list_v4[] = { STATD, LOCKD, NFS4CBD, NFSMAPID, NULL };
/*
* These two variables control the NFS version number to be used.
*
* nfsvers defaults to 0 which means to use the highest number that
* both the client and the server support. It can also be set to
* a particular value, either 2, 3, or 4 to indicate the version
* number of choice. If the server (or the client) do not support
* the version indicated, then the mount attempt will be failed.
*
* nfsvers_to_use is the actual version number found to use. It
* is determined in get_fh by pinging the various versions of the
* NFS service on the server to see which responds positively.
*
* nfsretry_vers is the version number set when we retry the mount
* command with the version decremented from nfsvers_to_use.
* nfsretry_vers is set from nfsvers_to_use when we retry the mount
* for errors other than RPC errors; it helps un know why we are
* retrying. It is an indication that the retry is due to
* non-RPC errors.
*/
static rpcvers_t nfsvers = 0;
static rpcvers_t nfsvers_to_use = 0;
static rpcvers_t nfsretry_vers = 0;
/*
* There are the defaults (range) for the client when determining
* which NFS version to use when probing the server (see above).
* These will only be used when the vers mount option is not used and
* these may be reset if NFS SMF is configured to do so.
*/
static rpcvers_t vers_max_default = NFS_VERSMAX_DEFAULT;
static rpcvers_t vers_min_default = NFS_VERSMIN_DEFAULT;
/*
* This variable controls whether to try the public file handle.
*/
static bool_t public_opt;
int
main(int argc, char *argv[])
{
struct mnttab mnt;
extern char *optarg;
extern int optind;
char optbuf[MAX_MNTOPT_STR];
int ro = 0;
int r;
int c;
char *myname;
err_ret_t retry_error;
(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
myname = strrchr(argv[0], '/');
myname = myname ? myname + 1 : argv[0];
(void) snprintf(typename, sizeof (typename), "%s %s",
MNTTYPE_NFS, myname);
argv[0] = typename;
mnt.mnt_mntopts = optbuf;
(void) strcpy(optbuf, "rw");
/*
* Set options
*/
while ((c = getopt(argc, argv, "ro:mOq")) != EOF) {
switch (c) {
case 'r':
ro++;
break;
case 'o':
if (strlen(optarg) >= MAX_MNTOPT_STR) {
pr_err(gettext("option string too long"));
return (RET_ERR);
}
(void) strcpy(mnt.mnt_mntopts, optarg);
#ifdef LATER /* XXX */
if (strstr(optarg, MNTOPT_REMOUNT)) {
/*
* If remount is specified, only rw is allowed.
*/
if ((strcmp(optarg, MNTOPT_REMOUNT) != 0) &&
(strcmp(optarg, "remount,rw") != 0) &&
(strcmp(optarg, "rw,remount") != 0)) {
pr_err(gettext("Invalid options\n"));
exit(RET_ERR);
}
}
#endif /* LATER */ /* XXX */
break;
case 'm':
mflg++;
break;
case 'O':
Oflg++;
break;
case 'q':
qflg++;
break;
default:
usage();
exit(RET_ERR);
}
}
if (argc - optind != 2) {
usage();
exit(RET_ERR);
}
mnt.mnt_special = argv[optind];
mnt.mnt_mountp = argv[optind+1];
if (!priv_ineffect(PRIV_SYS_MOUNT) ||
!priv_ineffect(PRIV_NET_PRIVADDR)) {
pr_err(gettext("insufficient privileges\n"));
exit(RET_ERR);
}
/*
* On a labeled system, allow read-down nfs mounts if privileged
* (PRIV_NET_MAC_AWARE) to do so. Otherwise, ignore the error
* and "mount equal label only" behavior will result.
*/
if (is_system_labeled())
(void) setpflags(NET_MAC_AWARE, 1);
/*
* Read the NFS SMF defaults to see if the min/max versions have
* been set and therefore would override the encoded defaults.
* Then check to make sure that if they were set that the
* values are reasonable.
*/
read_default();
if (vers_min_default > vers_max_default ||
vers_min_default < NFS_VERSMIN ||
vers_max_default > NFS_VERSMAX) {
pr_err("%s\n%s %s\n",
gettext("Incorrect configuration of client\'s"),
gettext("client_versmin or client_versmax"),
gettext("is either out of range or overlaps."));
}
SET_ERR_RET(&retry_error, ERR_PROTO_NONE, 0);
r = mount_nfs(&mnt, ro, &retry_error);
if (r == RET_RETRY && retries) {
/*
* Check the error code from the last mount attempt if it was
* an RPC error, then retry as is. Otherwise we retry with the
* nfsretry_vers set. It is set by decrementing nfsvers_to_use.
* If we are retrying with nfsretry_vers then we don't print any
* retry messages, since we are not retrying due to an RPC
* error.
*/
if (retry_error.error_type) {
if (retry_error.error_type != ERR_RPCERROR) {
nfsretry_vers = nfsvers_to_use =
nfsvers_to_use - 1;
if (nfsretry_vers < NFS_VERSMIN)
return (r);
}
}
r = retry(&mnt, ro);
}
/*
* exit(r);
*/
return (r);
}
static void
pr_err(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (backgrounded != 0) {
(void) vsyslog(LOG_ERR, fmt, ap);
} else {
(void) fprintf(stderr, "%s: ", typename);
(void) vfprintf(stderr, fmt, ap);
(void) fflush(stderr);
}
va_end(ap);
}
static void
usage()
{
(void) fprintf(stderr,
gettext("Usage: nfs mount [-r] [-o opts] [server:]path dir\n"));
exit(RET_ERR);
}
static int
mount_nfs(struct mnttab *mntp, int ro, err_ret_t *retry_error)
{
struct nfs_args *args = NULL, *argp = NULL, *prev_argp = NULL;
struct netconfig *nconf = NULL;
struct replica *list = NULL;
int mntflags = 0;
int i, r, n;
int oldvers = 0, vers = 0;
int last_error = RET_OK;
int replicated = 0;
char *p;
bool_t url;
bool_t use_pubfh;
char *special = NULL;
char *oldpath = NULL;
char *newpath = NULL;
char *service;
pid_t pi;
struct flock f;
char *saveopts = NULL;
char **sl = NULL;
mntp->mnt_fstype = MNTTYPE_NFS;
if (ro) {
mntflags |= MS_RDONLY;
/* convert "rw"->"ro" */
if (p = strstr(mntp->mnt_mntopts, "rw")) {
if (*(p+2) == ',' || *(p+2) == '\0')
*(p+1) = 'o';
}
}
if (Oflg)
mntflags |= MS_OVERLAY;
list = parse_replica(mntp->mnt_special, &n);
if (list == NULL) {
if (n < 0)
pr_err(gettext("nfs file system; use [host:]path\n"));
else
pr_err(gettext("no memory\n"));
return (RET_ERR);
}
replicated = (n > 1);
/*
* There are some free() calls at the bottom of this loop, so be
* careful about adding continue statements.
*/
for (i = 0; i < n; i++) {
char *path;
char *host;
ushort_t port;
argp = (struct nfs_args *)malloc(sizeof (*argp));
if (argp == NULL) {
pr_err(gettext("no memory\n"));
last_error = RET_ERR;
goto out;
}
memset(argp, 0, sizeof (*argp));
memset(&nfs_sec, 0, sizeof (nfs_sec));
sec_opt = 0;
use_pubfh = FALSE;
url = FALSE;
port = 0;
snego_done = FALSE;
/*
* Looking for resources of the form
* nfs://server_host[:port_number]/path_name
*/
if (strcmp(list[i].host, "nfs") == 0 && strncmp(list[i].path,
"//", 2) == 0) {
char *sport, *cb;
url = TRUE;
oldpath = strdup(list[i].path);
if (oldpath == NULL) {
pr_err(gettext("memory allocation failure\n"));
last_error = RET_ERR;
goto out;
}
host = list[i].path+2;
path = strchr(host, '/');
if (path == NULL) {
pr_err(gettext(
"illegal nfs url syntax\n"));
last_error = RET_ERR;
goto out;
}
*path = '\0';
if (*host == '[') {
cb = strchr(host, ']');
if (cb == NULL) {
pr_err(gettext(
"illegal nfs url syntax\n"));
last_error = RET_ERR;
goto out;
} else {
*cb = '\0';
host++;
cb++;
if (*cb == ':')
port = htons((ushort_t)
atoi(cb+1));
}
} else {
sport = strchr(host, ':');
if (sport != NULL && sport < path) {
*sport = '\0';
port = htons((ushort_t)atoi(sport+1));
}
}
path++;
if (*path == '\0')
path = ".";
} else {
host = list[i].host;
path = list[i].path;
}
if (r = set_args(&mntflags, argp, host, mntp)) {
last_error = r;
goto out;
}
if (public_opt == TRUE)
use_pubfh = TRUE;
if (port == 0) {
port = nfs_port;
} else if (nfs_port != 0 && nfs_port != port) {
pr_err(gettext(
"port (%u) in nfs URL not the same"
" as port (%u) in port option\n"),
(unsigned int)ntohs(port),
(unsigned int)ntohs(nfs_port));
last_error = RET_ERR;
goto out;
}
if (replicated && !(mntflags & MS_RDONLY)) {
pr_err(gettext(
"replicated mounts must be read-only\n"));
last_error = RET_ERR;
goto out;
}
if (replicated && (argp->flags & NFSMNT_SOFT)) {
pr_err(gettext(
"replicated mounts must not be soft\n"));
last_error = RET_ERR;
goto out;
}
oldvers = vers;
nconf = NULL;
r = RET_ERR;
/*
* If -o public was specified, and/or a URL was specified,
* then try the public file handle method.
*/
if ((use_pubfh == TRUE) || (url == TRUE)) {
r = get_fh_via_pub(argp, host, path, url, use_pubfh,
&vers, &nconf, port);
if (r != RET_OK) {
/*
* If -o public was specified, then return the
* error now.
*/
if (use_pubfh == TRUE) {
last_error = r;
goto out;
}
} else
use_pubfh = TRUE;
argp->flags |= NFSMNT_PUBLIC;
}
if ((r != RET_OK) || (vers == NFS_V4)) {
bool_t loud_on_mnt_err;
/*
* This can happen if -o public is not specified,
* special is a URL, and server doesn't support
* public file handle.
*/
if (url) {
URLparse(path);
}
/*
* If the path portion of the URL didn't have
* a leading / then there is good possibility
* that a mount without a leading slash will
* fail.
*/
if (url == TRUE && *path != '/')
loud_on_mnt_err = FALSE;
else
loud_on_mnt_err = TRUE;
r = get_fh(argp, host, path, &vers,
loud_on_mnt_err, &nconf, port);
if (r != RET_OK) {
/*
* If there was no leading / and the path was
* derived from a URL, then try again
* with a leading /.
*/
if ((r == RET_MNTERR) &&
(loud_on_mnt_err == FALSE)) {
newpath = malloc(strlen(path)+2);
if (newpath == NULL) {
pr_err(gettext("memory "
"allocation failure\n"));
last_error = RET_ERR;
goto out;
}
strcpy(newpath, "/");
strcat(newpath, path);
r = get_fh(argp, host, newpath, &vers,
TRUE, &nconf, port);
if (r == RET_OK)
path = newpath;
}
/*
* map exit code back to RET_ERR.
*/
if (r == RET_MNTERR)
r = RET_ERR;
if (r != RET_OK) {
if (replicated) {
if (argp->fh)
free(argp->fh);
if (argp->pathconf)
free(argp->pathconf);
free(argp);
goto cont;
}
last_error = r;
goto out;
}
}
}
if (oldvers && vers != oldvers) {
pr_err(
gettext("replicas must have the same version\n"));
last_error = RET_ERR;
goto out;
}
/*
* decide whether to use remote host's
* lockd or do local locking
*/
if (!(argp->flags & NFSMNT_LLOCK) && vers == NFS_VERSION &&
remote_lock(host, argp->fh)) {
(void) fprintf(stderr, gettext(
"WARNING: No network locking on %s:%s:"),
host, path);
(void) fprintf(stderr, gettext(
" contact admin to install server change\n"));
argp->flags |= NFSMNT_LLOCK;
}
if (self_check(host))
argp->flags |= NFSMNT_LOOPBACK;
if (use_pubfh == FALSE) {
/*
* Call to get_fh() above may have obtained the
* netconfig info and NULL proc'd the server.
* This would be the case with v4
*/
if (!(argp->flags & NFSMNT_KNCONF)) {
nconf = NULL;
if (r = getaddr_nfs(argp, host, &nconf,
FALSE, path, port, retry_error,
TRUE)) {
last_error = r;
goto out;
}
}
}
if (make_secure(argp, host, nconf, use_pubfh, vers) < 0) {
last_error = RET_ERR;
goto out;
}
if ((url == TRUE) && (use_pubfh == FALSE)) {
/*
* Convert the special from
* nfs://host/path
* to
* host:path
*/
if (convert_special(&special, host, oldpath, path,
mntp->mnt_special) == -1) {
(void) fprintf(stderr, gettext(
"could not convert URL nfs:%s to %s:%s\n"),
oldpath, host, path);
last_error = RET_ERR;
goto out;
} else {
mntp->mnt_special = special;
}
}
if (prev_argp == NULL)
args = argp;
else
prev_argp->nfs_ext_u.nfs_extB.next = argp;
prev_argp = argp;
cont:
if (oldpath != NULL) {
free(oldpath);
oldpath = NULL;
}
if (newpath != NULL) {
free(newpath);
newpath = NULL;
}
}
argp = NULL;
if (args == NULL) {
last_error = RET_RETRY;
goto out;
}
/* Determine which services are appropriate for the NFS version */
if (strcmp(fstype, MNTTYPE_NFS4) == 0)
sl = service_list_v4;
else
sl = service_list;
/*
* enable services as needed.
*/
_check_services(sl);
mntflags |= MS_DATA | MS_OPTIONSTR;
if (mflg)
mntflags |= MS_NOMNTTAB;
if (!qflg)
saveopts = strdup(mntp->mnt_mntopts);
/*
* And make sure that we have the ephemeral mount_to
* set for this zone.
*/
set_nfsv4_ephemeral_mount_to();
if (mount(mntp->mnt_special, mntp->mnt_mountp, mntflags, fstype, args,
sizeof (*args), mntp->mnt_mntopts, MAX_MNTOPT_STR) < 0) {
if (errno != ENOENT) {
pr_err(gettext("mount: %s: %s\n"),
mntp->mnt_mountp, strerror(errno));
} else {
struct stat sb;
if (stat(mntp->mnt_mountp, &sb) < 0 && errno == ENOENT)
pr_err(gettext("mount: %s: %s\n"),
mntp->mnt_mountp, strerror(ENOENT));
else
pr_err("%s: %s\n", mntp->mnt_special,
strerror(ENOENT));
}
last_error = RET_ERR;
goto out;
}
if (!qflg && saveopts != NULL) {
cmp_requested_to_actual_options(saveopts, mntp->mnt_mntopts,
mntp->mnt_special, mntp->mnt_mountp);
}
out:
if (saveopts != NULL)
free(saveopts);
if (special != NULL)
free(special);
if (oldpath != NULL)
free(oldpath);
if (newpath != NULL)
free(newpath);
free_replica(list, n);
if (argp != NULL) {
/*
* If we had a new entry which was not added to the
* list yet, then add it now that it can be freed.
*/
if (prev_argp == NULL)
args = argp;
else
prev_argp->nfs_ext_u.nfs_extB.next = argp;
}
argp = args;
while (argp != NULL) {
if (argp->fh)
free(argp->fh);
if (argp->pathconf)
free(argp->pathconf);
if (argp->knconf)
free(argp->knconf);
if (argp->addr) {
free(argp->addr->buf);
free(argp->addr);
}
nfs_free_secdata(argp->nfs_ext_u.nfs_extB.secdata);
if (argp->syncaddr) {
free(argp->syncaddr->buf);
free(argp->syncaddr);
}
if (argp->netname)
free(argp->netname);
prev_argp = argp;
argp = argp->nfs_ext_u.nfs_extB.next;
free(prev_argp);
}
return (last_error);
}
/*
* These options are duplicated in uts/common/fs/nfs/nfs_dlinet.c
* Changes must be made to both lists.
*/
static char *optlist[] = {
#define OPT_RO 0
MNTOPT_RO,
#define OPT_RW 1
MNTOPT_RW,
#define OPT_QUOTA 2
MNTOPT_QUOTA,
#define OPT_NOQUOTA 3
MNTOPT_NOQUOTA,
#define OPT_SOFT 4
MNTOPT_SOFT,
#define OPT_HARD 5
MNTOPT_HARD,
#define OPT_SUID 6
MNTOPT_SUID,
#define OPT_NOSUID 7
MNTOPT_NOSUID,
#define OPT_GRPID 8
MNTOPT_GRPID,
#define OPT_REMOUNT 9
MNTOPT_REMOUNT,
#define OPT_NOSUB 10
MNTOPT_NOSUB,
#define OPT_INTR 11
MNTOPT_INTR,
#define OPT_NOINTR 12
MNTOPT_NOINTR,
#define OPT_PORT 13
MNTOPT_PORT,
#define OPT_SECURE 14
MNTOPT_SECURE,
#define OPT_RSIZE 15
MNTOPT_RSIZE,
#define OPT_WSIZE 16
MNTOPT_WSIZE,
#define OPT_TIMEO 17
MNTOPT_TIMEO,
#define OPT_RETRANS 18
MNTOPT_RETRANS,
#define OPT_ACTIMEO 19
MNTOPT_ACTIMEO,
#define OPT_ACREGMIN 20
MNTOPT_ACREGMIN,
#define OPT_ACREGMAX 21
MNTOPT_ACREGMAX,
#define OPT_ACDIRMIN 22
MNTOPT_ACDIRMIN,
#define OPT_ACDIRMAX 23
MNTOPT_ACDIRMAX,
#define OPT_BG 24
MNTOPT_BG,
#define OPT_FG 25
MNTOPT_FG,
#define OPT_RETRY 26
MNTOPT_RETRY,
#define OPT_NOAC 27
MNTOPT_NOAC,
#define OPT_NOCTO 28
MNTOPT_NOCTO,
#define OPT_LLOCK 29
MNTOPT_LLOCK,
#define OPT_POSIX 30
MNTOPT_POSIX,
#define OPT_VERS 31
MNTOPT_VERS,
#define OPT_PROTO 32
MNTOPT_PROTO,
#define OPT_SEMISOFT 33
MNTOPT_SEMISOFT,
#define OPT_NOPRINT 34
MNTOPT_NOPRINT,
#define OPT_SEC 35
MNTOPT_SEC,
#define OPT_LARGEFILES 36
MNTOPT_LARGEFILES,
#define OPT_NOLARGEFILES 37
MNTOPT_NOLARGEFILES,
#define OPT_PUBLIC 38
MNTOPT_PUBLIC,
#define OPT_DIRECTIO 39
MNTOPT_FORCEDIRECTIO,
#define OPT_NODIRECTIO 40
MNTOPT_NOFORCEDIRECTIO,
#define OPT_XATTR 41
MNTOPT_XATTR,
#define OPT_NOXATTR 42
MNTOPT_NOXATTR,
#define OPT_DEVICES 43
MNTOPT_DEVICES,
#define OPT_NODEVICES 44
MNTOPT_NODEVICES,
#define OPT_SETUID 45
MNTOPT_SETUID,
#define OPT_NOSETUID 46
MNTOPT_NOSETUID,
#define OPT_EXEC 47
MNTOPT_EXEC,
#define OPT_NOEXEC 48
MNTOPT_NOEXEC,
NULL
};
static int
convert_int(int *val, char *str)
{
long lval;
if (str == NULL || !isdigit(*str))
return (-1);
lval = strtol(str, &str, 10);
if (*str != '\0' || lval > INT_MAX)
return (-2);
*val = (int)lval;
return (0);
}
static int
set_args(int *mntflags, struct nfs_args *args, char *fshost, struct mnttab *mnt)
{
char *saveopt, *optstr, *opts, *newopts, *val;
int num;
int largefiles = 0;
int invalid = 0;
int attrpref = 0;
int optlen;
args->flags = NFSMNT_INT; /* default is "intr" */
args->flags |= NFSMNT_HOSTNAME;
args->flags |= NFSMNT_NEWARGS; /* using extented nfs_args structure */
args->hostname = fshost;
optstr = opts = strdup(mnt->mnt_mntopts);
/* sizeof (MNTOPT_XXX) includes one extra byte we may need for "," */
optlen = strlen(mnt->mnt_mntopts) + sizeof (MNTOPT_XATTR) + 1;
if (optlen > MAX_MNTOPT_STR) {
pr_err(gettext("option string too long"));
return (RET_ERR);
}
newopts = malloc(optlen);
if (opts == NULL || newopts == NULL) {
pr_err(gettext("no memory"));
if (opts)
free(opts);
if (newopts)
free(newopts);
return (RET_ERR);
}
newopts[0] = '\0';
while (*opts) {
invalid = 0;
saveopt = opts;
switch (getsubopt(&opts, optlist, &val)) {
case OPT_RO:
*mntflags |= MS_RDONLY;
break;
case OPT_RW:
*mntflags &= ~(MS_RDONLY);
break;
case OPT_QUOTA:
case OPT_NOQUOTA:
break;
case OPT_SOFT:
args->flags |= NFSMNT_SOFT;
args->flags &= ~(NFSMNT_SEMISOFT);
break;
case OPT_SEMISOFT:
args->flags |= NFSMNT_SOFT;
args->flags |= NFSMNT_SEMISOFT;
break;
case OPT_HARD:
args->flags &= ~(NFSMNT_SOFT);
args->flags &= ~(NFSMNT_SEMISOFT);
break;
case OPT_SUID:
*mntflags &= ~(MS_NOSUID);
break;
case OPT_NOSUID:
*mntflags |= MS_NOSUID;
break;
case OPT_GRPID:
args->flags |= NFSMNT_GRPID;
break;
case OPT_REMOUNT:
*mntflags |= MS_REMOUNT;
break;
case OPT_INTR:
args->flags |= NFSMNT_INT;
break;
case OPT_NOINTR:
args->flags &= ~(NFSMNT_INT);
break;
case OPT_NOAC:
args->flags |= NFSMNT_NOAC;
break;
case OPT_PORT:
if (convert_int(&num, val) != 0)
goto badopt;
nfs_port = htons((ushort_t)num);
break;
case OPT_SECURE:
if (nfs_getseconfig_byname("dh", &nfs_sec)) {
pr_err(gettext("can not get \"dh\" from %s\n"),
NFSSEC_CONF);
goto badopt;
}
sec_opt++;
break;
case OPT_NOCTO:
args->flags |= NFSMNT_NOCTO;
break;
case OPT_RSIZE:
if (convert_int(&args->rsize, val) != 0)
goto badopt;
args->flags |= NFSMNT_RSIZE;
break;
case OPT_WSIZE:
if (convert_int(&args->wsize, val) != 0)
goto badopt;
args->flags |= NFSMNT_WSIZE;
break;
case OPT_TIMEO:
if (convert_int(&args->timeo, val) != 0)
goto badopt;
args->flags |= NFSMNT_TIMEO;
break;
case OPT_RETRANS:
if (convert_int(&args->retrans, val) != 0)
goto badopt;
args->flags |= NFSMNT_RETRANS;
break;
case OPT_ACTIMEO:
if (convert_int(&args->acregmax, val) != 0)
goto badopt;
args->acdirmin = args->acregmin = args->acdirmax
= args->acregmax;
args->flags |= NFSMNT_ACDIRMAX;
args->flags |= NFSMNT_ACREGMAX;
args->flags |= NFSMNT_ACDIRMIN;
args->flags |= NFSMNT_ACREGMIN;
break;
case OPT_ACREGMIN:
if (convert_int(&args->acregmin, val) != 0)
goto badopt;
args->flags |= NFSMNT_ACREGMIN;
break;
case OPT_ACREGMAX:
if (convert_int(&args->acregmax, val) != 0)
goto badopt;
args->flags |= NFSMNT_ACREGMAX;
break;
case OPT_ACDIRMIN:
if (convert_int(&args->acdirmin, val) != 0)
goto badopt;
args->flags |= NFSMNT_ACDIRMIN;
break;
case OPT_ACDIRMAX:
if (convert_int(&args->acdirmax, val) != 0)
goto badopt;
args->flags |= NFSMNT_ACDIRMAX;
break;
case OPT_BG:
bg++;
break;
case OPT_FG:
bg = 0;
break;
case OPT_RETRY:
if (convert_int(&retries, val) != 0)
goto badopt;
break;
case OPT_LLOCK:
args->flags |= NFSMNT_LLOCK;
break;
case OPT_POSIX:
posix = 1;
break;
case OPT_VERS:
if (convert_int(&num, val) != 0)
goto badopt;
nfsvers = (rpcvers_t)num;
break;
case OPT_PROTO:
if (val == NULL)
goto badopt;
nfs_proto = (char *)malloc(strlen(val)+1);
if (!nfs_proto) {
pr_err(gettext("no memory"));
return (RET_ERR);
}
(void) strncpy(nfs_proto, val, strlen(val)+1);
break;
case OPT_NOPRINT:
args->flags |= NFSMNT_NOPRINT;
break;
case OPT_LARGEFILES:
largefiles = 1;
break;
case OPT_NOLARGEFILES:
pr_err(gettext("NFS can't support \"nolargefiles\"\n"));
free(optstr);
return (RET_ERR);
case OPT_SEC:
if (val == NULL) {
pr_err(gettext(
"\"sec\" option requires argument\n"));
return (RET_ERR);
}
if (nfs_getseconfig_byname(val, &nfs_sec)) {
pr_err(gettext("can not get \"%s\" from %s\n"),
val, NFSSEC_CONF);
return (RET_ERR);
}
sec_opt++;
break;
case OPT_PUBLIC:
public_opt = TRUE;
break;
case OPT_DIRECTIO:
args->flags |= NFSMNT_DIRECTIO;
break;
case OPT_NODIRECTIO:
args->flags &= ~(NFSMNT_DIRECTIO);
break;
case OPT_XATTR:
case OPT_NOXATTR:
/*
* VFS options; just need to get them into the
* new mount option string and note we've seen them
*/
attrpref = 1;
break;
default:
/*
* Note that this could be a valid OPT_* option so
* we can't use "val" but need to use "saveopt".
*/
if (fsisstdopt(saveopt))
break;
invalid = 1;
if (!qflg)
(void) fprintf(stderr, gettext(
"mount: %s on %s - WARNING unknown option"
" \"%s\"\n"), mnt->mnt_special,
mnt->mnt_mountp, saveopt);
break;
}
if (!invalid) {
if (newopts[0])
strcat(newopts, ",");
strcat(newopts, saveopt);
}
}
/* Default is to turn extended attrs on */
if (!attrpref) {
if (newopts[0])
strcat(newopts, ",");
strcat(newopts, MNTOPT_XATTR);
}
strcpy(mnt->mnt_mntopts, newopts);
free(newopts);
free(optstr);
/* ensure that only one secure mode is requested */
if (sec_opt > 1) {
pr_err(gettext("Security options conflict\n"));
return (RET_ERR);
}
/* ensure that the user isn't trying to get large files over V2 */
if (nfsvers == NFS_VERSION && largefiles) {
pr_err(gettext("NFS V2 can't support \"largefiles\"\n"));
return (RET_ERR);
}
if (nfsvers == NFS_V4 &&
nfs_proto != NULL &&
strncasecmp(nfs_proto, NC_UDP, strlen(NC_UDP)) == 0) {
pr_err(gettext("NFS V4 does not support %s\n"), nfs_proto);
return (RET_ERR);
}
return (RET_OK);
badopt:
pr_err(gettext("invalid option: \"%s\"\n"), saveopt);
free(optstr);
return (RET_ERR);
}
static int
make_secure(struct nfs_args *args, char *hostname, struct netconfig *nconf,
bool_t use_pubfh, rpcvers_t vers)
{
sec_data_t *secdata;
int flags;
struct netbuf *syncaddr = NULL;
struct nd_addrlist *retaddrs = NULL;
char netname[MAXNETNAMELEN+1];
/*
* check to see if any secure mode is requested.
* if not, use default security mode.
*/
if (!snego_done && !sec_opt) {
/*
* Get default security mode.
* AUTH_UNIX has been the default choice for a long time.
* The better NFS security service becomes, the better chance
* we will set stronger security service as the default NFS
* security mode.
*/
if (nfs_getseconfig_default(&nfs_sec)) {
pr_err(gettext("error getting default"
" security entry\n"));
return (-1);
}
args->flags |= NFSMNT_SECDEFAULT;
}
/*
* Get the network address for the time service on the server.
* If an RPC based time service is not available then try the
* IP time service.
*
* This is for AUTH_DH processing. We will also pass down syncaddr
* and netname for NFS V4 even if AUTH_DH is not requested right now.
* NFS V4 does security negotiation in the kernel via SECINFO.
* These information might be needed later in the kernel.
*
* Eventurally, we want to move this code to nfs_clnt_secdata()
* when autod_nfs.c and mount.c can share the same get_the_addr()
* routine.
*/
flags = 0;
syncaddr = NULL;
if (nfs_sec.sc_rpcnum == AUTH_DH || vers == NFS_V4) {
/*
* If using the public fh or nfsv4, we will not contact the
* remote RPCBINDer, since it is possibly behind a firewall.
*/
if (use_pubfh == FALSE && vers != NFS_V4)
syncaddr = get_the_addr(hostname, RPCBPROG, RPCBVERS,
nconf, 0, NULL, NULL, FALSE, NULL, NULL);
if (syncaddr != NULL) {
/* for flags in sec_data */
flags |= AUTH_F_RPCTIMESYNC;
} else {
struct nd_hostserv hs;
int error;
hs.h_host = hostname;
hs.h_serv = "timserver";
error = netdir_getbyname(nconf, &hs, &retaddrs);
if (error != ND_OK && (nfs_sec.sc_rpcnum == AUTH_DH)) {
pr_err(gettext("%s: secure: no time service\n"),
hostname);
return (-1);
}
if (error == ND_OK)
syncaddr = retaddrs->n_addrs;
/*
* For NFS_V4 if AUTH_DH is negotiated later in the
* kernel thru SECINFO, it will need syncaddr
* and netname data.
*/
if (vers == NFS_V4 && syncaddr &&
host2netname(netname, hostname, NULL)) {
args->syncaddr = malloc(sizeof (struct netbuf));
args->syncaddr->buf = malloc(syncaddr->len);
(void) memcpy(args->syncaddr->buf,
syncaddr->buf, syncaddr->len);
args->syncaddr->len = syncaddr->len;
args->syncaddr->maxlen = syncaddr->maxlen;
args->netname = strdup(netname);
args->flags |= NFSMNT_SECURE;
}
}
}
/*
* For the initial chosen flavor (any flavor defined in nfssec.conf),
* the data will be stored in the sec_data structure via
* nfs_clnt_secdata() and be passed to the kernel via nfs_args_*
* extended data structure.
*/
if (!(secdata = nfs_clnt_secdata(&nfs_sec, hostname, args->knconf,
syncaddr, flags))) {
pr_err(gettext("errors constructing security related data\n"));
if (flags & AUTH_F_RPCTIMESYNC) {
free(syncaddr->buf);
free(syncaddr);
} else if (retaddrs)
netdir_free((void *)retaddrs, ND_ADDRLIST);
return (-1);
}
NFS_ARGS_EXTB_secdata(args, secdata);
if (flags & AUTH_F_RPCTIMESYNC) {
free(syncaddr->buf);
free(syncaddr);
} else if (retaddrs)
netdir_free((void *)retaddrs, ND_ADDRLIST);
return (0);
}
/*
* Get the network address on "hostname" for program "prog"
* with version "vers" by using the nconf configuration data
* passed in.
*
* If the address of a netconfig pointer is null then
* information is not sufficient and no netbuf will be returned.
*
* Finally, ping the null procedure of that service.
*
* A similar routine is also defined in ../../autofs/autod_nfs.c.
* This is a potential routine to move to ../lib for common usage.
*/
/* Hammerhead: Use rpcprog_t/rpcvers_t to match forward declaration */
static struct netbuf *
get_the_addr(char *hostname, rpcprog_t prog, rpcvers_t vers,
struct netconfig *nconf, ushort_t port, struct t_info *tinfo,
caddr_t *fhp, bool_t get_pubfh, char *fspath, err_ret_t *error)
{
struct netbuf *nb = NULL;
struct t_bind *tbind = NULL;
CLIENT *cl = NULL;
struct timeval tv;
int fd = -1;
AUTH *ah = NULL;
AUTH *new_ah = NULL;
struct snego_t snego;
if (nconf == NULL)
return (NULL);
if ((fd = t_open(nconf->nc_device, O_RDWR, tinfo)) == -1)
goto done;
/* LINTED pointer alignment */
if ((tbind = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR))
== NULL)
goto done;
/*
* In the case of public filehandle usage or NFSv4 we want to
* avoid use of the rpcbind/portmap protocol
*/
if ((get_pubfh == TRUE) || (vers == NFS_V4)) {
struct nd_hostserv hs;
struct nd_addrlist *retaddrs;
int retval;
hs.h_host = hostname;
/* NFS where vers==4 does not support UDP */
if (vers == NFS_V4 &&
strncasecmp(nconf->nc_proto, NC_UDP,
strlen(NC_UDP)) == 0) {
SET_ERR_RET(error, ERR_PROTO_UNSUPP, 0);
goto done;
}
if (port == 0)
hs.h_serv = "nfs";
else
hs.h_serv = NULL;
if ((retval = netdir_getbyname(nconf, &hs, &retaddrs))
!= ND_OK) {
/*
* Carefully set the error value here. Want to signify
* that the error was an unknown host.
*/
if (retval == ND_NOHOST) {
SET_ERR_RET(error, ERR_NOHOST, retval);
}
goto done;
}
memcpy(tbind->addr.buf, retaddrs->n_addrs->buf,
retaddrs->n_addrs->len);
tbind->addr.len = retaddrs->n_addrs->len;
netdir_free((void *)retaddrs, ND_ADDRLIST);
(void) netdir_options(nconf, ND_SET_RESERVEDPORT, fd, NULL);
} else {
if (rpcb_getaddr(prog, vers, nconf, &tbind->addr,
hostname) == FALSE) {
goto done;
}
}
if (port) {
/* LINTED pointer alignment */
if (strcmp(nconf->nc_protofmly, NC_INET) == 0)
((struct sockaddr_in *)tbind->addr.buf)->sin_port
= port;
else if (strcmp(nconf->nc_protofmly, NC_INET6) == 0)
((struct sockaddr_in6 *)tbind->addr.buf)->sin6_port
= port;
}
cl = clnt_tli_create(fd, nconf, &tbind->addr, prog, vers, 0, 0);
if (cl == NULL) {
/*
* clnt_tli_create() returns either RPC_SYSTEMERROR,
* RPC_UNKNOWNPROTO or RPC_TLIERROR. The RPC_TLIERROR translates
* to "Misc. TLI error". This is not too helpful. Most likely
* the connection to the remote server timed out, so this
* error is at least less perplexing.
* See: usr/src/cmd/rpcinfo/rpcinfo.c
*/
if (rpc_createerr.cf_stat == RPC_TLIERROR) {
SET_ERR_RET(error, ERR_RPCERROR, RPC_PMAPFAILURE);
} else {
SET_ERR_RET(error, ERR_RPCERROR, rpc_createerr.cf_stat);
}
goto done;
}
ah = authsys_create_default();
if (ah != NULL)
cl->cl_auth = ah;
tv.tv_sec = 5;
tv.tv_usec = 0;
(void) clnt_control(cl, CLSET_TIMEOUT, (char *)&tv);
if ((get_pubfh == TRUE) && (vers != NFS_V4)) {
enum snego_stat sec;
if (!snego_done) {
/*
* negotiate sec flavor.
*/
snego.cnt = 0;
if ((sec = nfs_sec_nego(vers, cl, fspath, &snego)) ==
SNEGO_SUCCESS) {
int jj;
/*
* check if server supports the one
* specified in the sec= option.
*/
if (sec_opt) {
for (jj = 0; jj < snego.cnt; jj++) {
if (snego.array[jj] ==
nfs_sec.sc_nfsnum) {
snego_done = TRUE;
break;
}
}
}
/*
* find a common sec flavor
*/
if (!snego_done) {
if (sec_opt) {
pr_err(gettext(
"Server does not support"
" the security flavor"
" specified.\n"));
}
for (jj = 0; jj < snego.cnt; jj++) {
if (!nfs_getseconfig_bynumber(
snego.array[jj],
&nfs_sec)) {
snego_done = TRUE;
#define EMSG80SUX "Security flavor %d was negotiated and will be used.\n"
if (sec_opt)
pr_err(gettext(
EMSG80SUX),
nfs_sec.
sc_nfsnum);
break;
}
}
}
if (!snego_done)
return (NULL);
/*
* Now that the flavor has been
* negotiated, get the fh.
*
* First, create an auth handle using the
* negotiated sec flavor in the next lookup to
* fetch the filehandle.
*/
new_ah = nfs_create_ah(cl, hostname, &nfs_sec);
if (new_ah == NULL)
goto done;
cl->cl_auth = new_ah;
} else if (sec == SNEGO_ARRAY_TOO_SMALL || sec ==
SNEGO_FAILURE) {
goto done;
}
/*
* Note that if sec == SNEGO_DEF_VALID
* default sec flavor is acceptable.
* Use it to get the filehandle.
*/
}
if (vers == NFS_VERSION) {
wnl_diropargs arg;
wnl_diropres res;
memset((char *)&arg.dir, 0, sizeof (wnl_fh));
arg.name = fspath;
memset((char *)&res, 0, sizeof (wnl_diropres));
if (wnlproc_lookup_2(&arg, &res, cl) !=
RPC_SUCCESS || res.status != WNL_OK)
goto done;
*fhp = malloc(sizeof (wnl_fh));
if (*fhp == NULL) {
pr_err(gettext("no memory\n"));
goto done;
}
memcpy((char *)*fhp,
(char *)&res.wnl_diropres_u.wnl_diropres.file,
sizeof (wnl_fh));
} else {
WNL_LOOKUP3args arg;
WNL_LOOKUP3res res;
nfs_fh3 *fh3p;
memset((char *)&arg.what.dir, 0, sizeof (wnl_fh3));
arg.what.name = fspath;
memset((char *)&res, 0, sizeof (WNL_LOOKUP3res));
if (wnlproc3_lookup_3(&arg, &res, cl) !=
RPC_SUCCESS || res.status != WNL3_OK)
goto done;
fh3p = (nfs_fh3 *)malloc(sizeof (*fh3p));
if (fh3p == NULL) {
pr_err(gettext("no memory\n"));
goto done;
}
fh3p->fh3_length =
res.WNL_LOOKUP3res_u.res_ok.object.data.data_len;
memcpy(fh3p->fh3_u.data,
res.WNL_LOOKUP3res_u.res_ok.object.data.data_val,
fh3p->fh3_length);
*fhp = (caddr_t)fh3p;
}
} else {
struct rpc_err r_err;
enum clnt_stat rc;
/*
* NULL procedures need not have an argument or
* result param.
*/
if (vers == NFS_VERSION)
rc = wnlproc_null_2(NULL, NULL, cl);
else if (vers == NFS_V3)
rc = wnlproc3_null_3(NULL, NULL, cl);
else
rc = wnlproc4_null_4(NULL, NULL, cl);
if (rc != RPC_SUCCESS) {
clnt_geterr(cl, &r_err);
if (strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) {
switch (r_err.re_status) {
case RPC_TLIERROR:
case RPC_CANTRECV:
case RPC_CANTSEND:
r_err.re_status = RPC_PROGVERSMISMATCH;
}
}
SET_ERR_RET(error, ERR_RPCERROR, r_err.re_status);
goto done;
}
}
/*
* Make a copy of the netbuf to return
*/
nb = (struct netbuf *)malloc(sizeof (*nb));
if (nb == NULL) {
pr_err(gettext("no memory\n"));
goto done;
}
*nb = tbind->addr;
nb->buf = (char *)malloc(nb->maxlen);
if (nb->buf == NULL) {
pr_err(gettext("no memory\n"));
free(nb);
nb = NULL;
goto done;
}
(void) memcpy(nb->buf, tbind->addr.buf, tbind->addr.len);
done:
if (cl) {
if (ah != NULL) {
if (new_ah != NULL)
AUTH_DESTROY(ah);
AUTH_DESTROY(cl->cl_auth);
cl->cl_auth = NULL;
}
clnt_destroy(cl);
cl = NULL;
}
if (tbind) {
t_free((char *)tbind, T_BIND);
tbind = NULL;
}
if (fd >= 0)
(void) t_close(fd);
return (nb);
}
static int
check_nconf(struct netconfig *nconf, int nthtry, int *valid_proto)
{
int try_test = 0;
int valid_family;
char *proto = NULL;
if (nthtry == FIRST_TRY) {
try_test = ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
(nconf->nc_semantics == NC_TPI_COTS));
proto = NC_TCP;
} else if (nthtry == SECOND_TRY) {
try_test = (nconf->nc_semantics == NC_TPI_CLTS);
proto = NC_UDP;
}
if (proto &&
(strcmp(nconf->nc_protofmly, NC_INET) == 0 ||
strcmp(nconf->nc_protofmly, NC_INET6) == 0) &&
(strcmp(nconf->nc_proto, proto) == 0))
*valid_proto = TRUE;
else
*valid_proto = FALSE;
return (try_test);
}
/*
* Get a network address on "hostname" for program "prog"
* with version "vers". If the port number is specified (non zero)
* then try for a TCP/UDP transport and set the port number of the
* resulting IP address.
*
* If the address of a netconfig pointer was passed and
* if it's not null, use it as the netconfig otherwise
* assign the address of the netconfig that was used to
* establish contact with the service.
*
* A similar routine is also defined in ../../autofs/autod_nfs.c.
* This is a potential routine to move to ../lib for common usage.
*
* "error" refers to a more descriptive term when get_addr fails
* and returns NULL: ERR_PROTO_NONE if no error introduced by
* -o proto option, ERR_NETPATH if error found in NETPATH
* environment variable, ERR_PROTO_INVALID if an unrecognized
* protocol is specified by user, and ERR_PROTO_UNSUPP for a
* recognized but invalid protocol (eg. ticlts, ticots, etc.).
* "error" is ignored if get_addr returns non-NULL result.
*
*/
/* Hammerhead: Use rpcprog_t/rpcvers_t to match forward declaration */
static struct netbuf *
get_addr(char *hostname, rpcprog_t prog, rpcvers_t vers, struct netconfig **nconfp,
char *proto, ushort_t port, struct t_info *tinfo, caddr_t *fhp,
bool_t get_pubfh, char *fspath, err_ret_t *error)
{
struct netbuf *nb = NULL;
struct netconfig *nconf = NULL;
NCONF_HANDLE *nc = NULL;
int nthtry = FIRST_TRY;
err_ret_t errsave_nohost, errsave_rpcerr;
SET_ERR_RET(&errsave_nohost, ERR_PROTO_NONE, 0);
SET_ERR_RET(&errsave_rpcerr, ERR_PROTO_NONE, 0);
SET_ERR_RET(error, ERR_PROTO_NONE, 0);
if (nconfp && *nconfp)
return (get_the_addr(hostname, prog, vers, *nconfp, port,
tinfo, fhp, get_pubfh, fspath, error));
/*
* No nconf passed in.
*
* Try to get a nconf from /etc/netconfig filtered by
* the NETPATH environment variable.
* First search for COTS, second for CLTS unless proto
* is specified. When we retry, we reset the
* netconfig list so that we would search the whole list
* all over again.
*/
if ((nc = setnetpath()) == NULL) {
/* should only return an error if problems with NETPATH */
/* In which case you are hosed */
SET_ERR_RET(error, ERR_NETPATH, 0);
goto done;
}
/*
* If proto is specified, then only search for the match,
* otherwise try COTS first, if failed, try CLTS.
*/
if (proto) {
/* no matching proto name */
SET_ERR_RET(error, ERR_PROTO_INVALID, 0);
while (nconf = getnetpath(nc)) {
if (strcmp(nconf->nc_netid, proto))
continue;
/* may be unsupported */
SET_ERR_RET(error, ERR_PROTO_UNSUPP, 0);
if ((port != 0) &&
((strcmp(nconf->nc_protofmly, NC_INET) == 0 ||
strcmp(nconf->nc_protofmly, NC_INET6) == 0) &&
(strcmp(nconf->nc_proto, NC_TCP) != 0 &&
strcmp(nconf->nc_proto, NC_UDP) != 0))) {
continue;
} else {
nb = get_the_addr(hostname, prog,
vers, nconf, port, tinfo,
fhp, get_pubfh, fspath, error);
if (nb != NULL)
break;
/* nb is NULL - deal with errors */
if (error) {
if (error->error_type == ERR_NOHOST)
SET_ERR_RET(&errsave_nohost,
error->error_type,
error->error_value);
if (error->error_type == ERR_RPCERROR)
SET_ERR_RET(&errsave_rpcerr,
error->error_type,
error->error_value);
}
/*
* continue with same protocol
* selection
*/
continue;
}
} /* end of while */
if (nconf == NULL)
goto done;
if ((nb = get_the_addr(hostname, prog, vers, nconf, port,
tinfo, fhp, get_pubfh, fspath, error)) == NULL)
goto done;
} else {
retry:
SET_ERR_RET(error, ERR_NETPATH, 0);
while (nconf = getnetpath(nc)) {
SET_ERR_RET(error, ERR_PROTO_NONE, 0);
if (nconf->nc_flag & NC_VISIBLE) {
int valid_proto;
if (check_nconf(nconf,
nthtry, &valid_proto)) {
if (port == 0)
break;
if (valid_proto == TRUE)
break;
}
}
} /* while */
if (nconf == NULL) {
if (++nthtry <= MNT_PREF_LISTLEN) {
endnetpath(nc);
if ((nc = setnetpath()) == NULL)
goto done;
goto retry;
} else
goto done;
} else {
if ((nb = get_the_addr(hostname, prog, vers, nconf,
port, tinfo, fhp, get_pubfh, fspath, error))
== NULL) {
/* nb is NULL - deal with errors */
if (error) {
if (error->error_type == ERR_NOHOST)
SET_ERR_RET(&errsave_nohost,
error->error_type,
error->error_value);
if (error->error_type == ERR_RPCERROR)
SET_ERR_RET(&errsave_rpcerr,
error->error_type,
error->error_value);
}
/*
* Continue the same search path in the
* netconfig db until no more matched
* nconf (nconf == NULL).
*/
goto retry;
}
}
}
SET_ERR_RET(error, ERR_PROTO_NONE, 0);
/*
* Got nconf and nb. Now dup the netconfig structure (nconf)
* and return it thru nconfp.
*/
*nconfp = getnetconfigent(nconf->nc_netid);
if (*nconfp == NULL) {
syslog(LOG_ERR, "no memory\n");
free(nb);
nb = NULL;
}
done:
if (nc)
endnetpath(nc);
if (nb == NULL) {
/*
* Check the saved errors. The RPC error has *
* precedence over the no host error.
*/
if (errsave_nohost.error_type != ERR_PROTO_NONE)
SET_ERR_RET(error, errsave_nohost.error_type,
errsave_nohost.error_value);
if (errsave_rpcerr.error_type != ERR_PROTO_NONE)
SET_ERR_RET(error, errsave_rpcerr.error_type,
errsave_rpcerr.error_value);
}
return (nb);
}
/*
* Get a file handle usinging multi-component lookup with the public
* file handle.
*/
static int
get_fh_via_pub(struct nfs_args *args, char *fshost, char *fspath, bool_t url,
bool_t loud, int *versp, struct netconfig **nconfp, ushort_t port)
{
uint_t vers_min;
uint_t vers_max;
int r;
char *path;
if (nfsvers != 0) {
vers_max = vers_min = nfsvers;
} else {
vers_max = vers_max_default;
vers_min = vers_min_default;
}
if (url == FALSE) {
path = malloc(strlen(fspath) + 2);
if (path == NULL) {
if (loud == TRUE)
pr_err(gettext("no memory\n"));
return (RET_ERR);
}
path[0] = (char)WNL_NATIVEPATH;
(void) strcpy(&path[1], fspath);
} else {
path = fspath;
}
for (nfsvers_to_use = vers_max; nfsvers_to_use >= vers_min;
nfsvers_to_use--) {
/*
* getaddr_nfs will also fill in the fh for us.
*/
r = getaddr_nfs(args, fshost, nconfp,
TRUE, path, port, NULL, FALSE);
if (r == RET_OK) {
/*
* Since we are using the public fh, and NLM is
* not firewall friendly, use local locking.
* Not the case for v4.
*/
*versp = nfsvers_to_use;
switch (nfsvers_to_use) {
case NFS_V4:
fstype = MNTTYPE_NFS4;
break;
case NFS_V3:
fstype = MNTTYPE_NFS3;
/* FALLTHROUGH */
default:
args->flags |= NFSMNT_LLOCK;
break;
}
if (fspath != path)
free(path);
return (r);
}
}
if (fspath != path)
free(path);
if (loud == TRUE) {
pr_err(gettext("Could not use public filehandle in request to"
" server %s\n"), fshost);
}
return (r);
}
/*
* get fhandle of remote path from server's mountd
*/
static int
get_fh(struct nfs_args *args, char *fshost, char *fspath, int *versp,
bool_t loud_on_mnt_err, struct netconfig **nconfp, ushort_t port)
{
static struct fhstatus fhs;
static struct mountres3 mountres3;
static struct pathcnf p;
nfs_fh3 *fh3p;
struct timeval timeout = { 25, 0};
CLIENT *cl;
enum clnt_stat rpc_stat;
rpcvers_t outvers = 0;
rpcvers_t vers_to_try;
rpcvers_t vers_min;
static int printed = 0;
int count, i, *auths;
char *msg;
switch (nfsvers) {
case 2: /* version 2 specified try that only */
vers_to_try = MOUNTVERS_POSIX;
vers_min = MOUNTVERS;
break;
case 3: /* version 3 specified try that only */
vers_to_try = MOUNTVERS3;
vers_min = MOUNTVERS3;
break;
case 4: /* version 4 specified try that only */
/*
* This assignment is in the wrong version sequence.
* The above are MOUNT program and this is NFS
* program. However, it happens to work out since the
* two don't collide for NFSv4.
*/
vers_to_try = NFS_V4;
vers_min = NFS_V4;
break;
default: /* no version specified, start with default */
/*
* If the retry version is set, use that. This will
* be set if the last mount attempt returned any other
* besides an RPC error.
*/
if (nfsretry_vers)
vers_to_try = nfsretry_vers;
else {
vers_to_try = vers_max_default;
vers_min = vers_min_default;
}
break;
}
/*
* In the case of version 4, just NULL proc the server since
* there is no MOUNT program. If this fails, then decrease
* vers_to_try and continue on with regular MOUNT program
* processing.
*/
if (vers_to_try == NFS_V4) {
int savevers = nfsvers_to_use;
err_ret_t error;
int retval;
SET_ERR_RET(&error, ERR_PROTO_NONE, 0);
/* Let's hope for the best */
nfsvers_to_use = NFS_V4;
retval = getaddr_nfs(args, fshost, nconfp, FALSE,
fspath, port, &error, vers_min == NFS_V4);
if (retval == RET_OK) {
*versp = nfsvers_to_use = NFS_V4;
fstype = MNTTYPE_NFS4;
args->fh = strdup(fspath);
if (args->fh == NULL) {
pr_err(gettext("no memory\n"));
*versp = nfsvers_to_use = savevers;
return (RET_ERR);
}
return (RET_OK);
}
nfsvers_to_use = savevers;
vers_to_try--;
/* If no more versions to try, let the user know. */
if (vers_to_try < vers_min)
return (retval);
/*
* If we are here, there are more versions to try but
* there has been an error of some sort. If it is not
* an RPC error (e.g. host unknown), we just stop and
* return the error since the other versions would see
* the same error as well.
*/
if (retval == RET_ERR && error.error_type != ERR_RPCERROR)
return (retval);
}
while ((cl = clnt_create_vers(fshost, MOUNTPROG, &outvers,
vers_min, vers_to_try, "datagram_v")) == NULL) {
if (rpc_createerr.cf_stat == RPC_UNKNOWNHOST) {
pr_err(gettext("%s: %s\n"), fshost,
clnt_spcreateerror(""));
return (RET_ERR);
}
/*
* We don't want to downgrade version on lost packets
*/
if ((rpc_createerr.cf_stat == RPC_TIMEDOUT) ||
(rpc_createerr.cf_stat == RPC_PMAPFAILURE)) {
pr_err(gettext("%s: %s\n"), fshost,
clnt_spcreateerror(""));
return (RET_RETRY);
}
/*
* back off and try the previous version - patch to the
* problem of version numbers not being contigous and
* clnt_create_vers failing (SunOS4.1 clients & SGI servers)
* The problem happens with most non-Sun servers who
* don't support mountd protocol #2. So, in case the
* call fails, we re-try the call anyway.
*/
vers_to_try--;
if (vers_to_try < vers_min) {
if (rpc_createerr.cf_stat == RPC_PROGVERSMISMATCH) {
if (nfsvers == 0) {
pr_err(gettext(
"%s:%s: no applicable versions of NFS supported\n"),
fshost, fspath);
} else {
pr_err(gettext(
"%s:%s: NFS Version %d not supported\n"),
fshost, fspath, nfsvers);
}
return (RET_ERR);
}
if (!printed) {
pr_err(gettext("%s: %s\n"), fshost,
clnt_spcreateerror(""));
printed = 1;
}
return (RET_RETRY);
}
}
if (posix && outvers < MOUNTVERS_POSIX) {
pr_err(gettext("%s: %s: no pathconf info\n"),
fshost, clnt_sperror(cl, ""));
clnt_destroy(cl);
return (RET_ERR);
}
if (__clnt_bindresvport(cl) < 0) {
pr_err(gettext("Couldn't bind to reserved port\n"));
clnt_destroy(cl);
return (RET_RETRY);
}
if ((cl->cl_auth = authsys_create_default()) == NULL) {
pr_err(
gettext("Couldn't create default authentication handle\n"));
clnt_destroy(cl);
return (RET_RETRY);
}
switch (outvers) {
case MOUNTVERS:
case MOUNTVERS_POSIX:
*versp = nfsvers_to_use = NFS_VERSION;
rpc_stat = clnt_call(cl, MOUNTPROC_MNT, xdr_dirpath,
(caddr_t)&fspath, xdr_fhstatus, (caddr_t)&fhs, timeout);
if (rpc_stat != RPC_SUCCESS) {
pr_err(gettext("%s:%s: server not responding %s\n"),
fshost, fspath, clnt_sperror(cl, ""));
clnt_destroy(cl);
return (RET_RETRY);
}
if ((errno = fhs.fhs_status) != MNT_OK) {
if (loud_on_mnt_err) {
if (errno == EACCES) {
pr_err(gettext(
"%s:%s: access denied\n"),
fshost, fspath);
} else {
pr_err(gettext("%s:%s: %s\n"), fshost,
fspath, errno >= 0 ?
strerror(errno) : "invalid error "
"returned by server");
}
}
clnt_destroy(cl);
return (RET_MNTERR);
}
args->fh = malloc(sizeof (fhs.fhstatus_u.fhs_fhandle));
if (args->fh == NULL) {
pr_err(gettext("no memory\n"));
return (RET_ERR);
}
memcpy((caddr_t)args->fh, (caddr_t)&fhs.fhstatus_u.fhs_fhandle,
sizeof (fhs.fhstatus_u.fhs_fhandle));
if (!errno && posix) {
rpc_stat = clnt_call(cl, MOUNTPROC_PATHCONF,
xdr_dirpath, (caddr_t)&fspath, xdr_ppathcnf,
(caddr_t)&p, timeout);
if (rpc_stat != RPC_SUCCESS) {
pr_err(gettext(
"%s:%s: server not responding %s\n"),
fshost, fspath, clnt_sperror(cl, ""));
free(args->fh);
clnt_destroy(cl);
return (RET_RETRY);
}
if (_PC_ISSET(_PC_ERROR, p.pc_mask)) {
pr_err(gettext(
"%s:%s: no pathconf info\n"),
fshost, fspath);
free(args->fh);
clnt_destroy(cl);
return (RET_ERR);
}
args->flags |= NFSMNT_POSIX;
args->pathconf = malloc(sizeof (p));
if (args->pathconf == NULL) {
pr_err(gettext("no memory\n"));
free(args->fh);
clnt_destroy(cl);
return (RET_ERR);
}
memcpy((caddr_t)args->pathconf, (caddr_t)&p,
sizeof (p));
}
break;
case MOUNTVERS3:
*versp = nfsvers_to_use = NFS_V3;
rpc_stat = clnt_call(cl, MOUNTPROC_MNT, xdr_dirpath,
(caddr_t)&fspath, xdr_mountres3, (caddr_t)&mountres3,
timeout);
if (rpc_stat != RPC_SUCCESS) {
pr_err(gettext("%s:%s: server not responding %s\n"),
fshost, fspath, clnt_sperror(cl, ""));
clnt_destroy(cl);
return (RET_RETRY);
}
/*
* Assume here that most of the MNT3ERR_*
* codes map into E* errors.
*/
if ((errno = mountres3.fhs_status) != MNT_OK) {
if (loud_on_mnt_err) {
switch (errno) {
case MNT3ERR_NAMETOOLONG:
msg = "path name is too long";
break;
case MNT3ERR_NOTSUPP:
msg = "operation not supported";
break;
case MNT3ERR_SERVERFAULT:
msg = "server fault";
break;
default:
if (errno >= 0)
msg = strerror(errno);
else
msg = "invalid error returned "
"by server";
break;
}
pr_err(gettext("%s:%s: %s\n"), fshost,
fspath, msg);
}
clnt_destroy(cl);
return (RET_MNTERR);
}
fh3p = (nfs_fh3 *)malloc(sizeof (*fh3p));
if (fh3p == NULL) {
pr_err(gettext("no memory\n"));
return (RET_ERR);
}
fh3p->fh3_length =
mountres3.mountres3_u.mountinfo.fhandle.fhandle3_len;
(void) memcpy(fh3p->fh3_u.data,
mountres3.mountres3_u.mountinfo.fhandle.fhandle3_val,
fh3p->fh3_length);
args->fh = (caddr_t)fh3p;
fstype = MNTTYPE_NFS3;
/*
* Check the security flavor to be used.
*
* If "secure" or "sec=flavor" is a mount
* option, check if the server supports the "flavor".
* If the server does not support the flavor, return
* error.
*
* If no mount option is given then look for default auth
* (default auth entry in /etc/nfssec.conf) in the auth list
* returned from server. If default auth not found, then use
* the first supported security flavor (by the client) in the
* auth list returned from the server.
*
*/
auths =
mountres3.mountres3_u.mountinfo.auth_flavors
.auth_flavors_val;
count =
mountres3.mountres3_u.mountinfo.auth_flavors
.auth_flavors_len;
if (count <= 0) {
pr_err(gettext(
"server %s did not return any security mode\n"),
fshost);
clnt_destroy(cl);
return (RET_ERR);
}
if (sec_opt) {
for (i = 0; i < count; i++) {
if (auths[i] == nfs_sec.sc_nfsnum)
break;
}
if (i == count)
goto autherr;
} else {
seconfig_t default_sec;
/*
* Get client configured default auth.
*/
nfs_sec.sc_nfsnum = -1;
default_sec.sc_nfsnum = -1;
(void) nfs_getseconfig_default(&default_sec);
/*
* Look for clients default auth in servers list.
*/
if (default_sec.sc_nfsnum != -1) {
for (i = 0; i < count; i++) {
if (auths[i] == default_sec.sc_nfsnum) {
sec_opt++;
nfs_sec = default_sec;
break;
}
}
}
/*
* Could not find clients default auth in servers list.
* Pick the first auth from servers list that is
* also supported on the client.
*/
if (nfs_sec.sc_nfsnum == -1) {
for (i = 0; i < count; i++) {
if (!nfs_getseconfig_bynumber(auths[i],
&nfs_sec)) {
sec_opt++;
break;
}
}
}
if (i == count)
goto autherr;
}
break;
default:
pr_err(gettext("%s:%s: Unknown MOUNT version %d\n"),
fshost, fspath, outvers);
clnt_destroy(cl);
return (RET_ERR);
}
clnt_destroy(cl);
return (RET_OK);
autherr:
pr_err(gettext(
"security mode does not match the server exporting %s:%s\n"),
fshost, fspath);
clnt_destroy(cl);
return (RET_ERR);
}
/*
* Fill in the address for the server's NFS service and
* fill in a knetconfig structure for the transport that
* the service is available on.
*/
static int
getaddr_nfs(struct nfs_args *args, char *fshost, struct netconfig **nconfp,
bool_t get_pubfh, char *fspath, ushort_t port, err_ret_t *error,
bool_t print_rpcerror)
{
struct stat sb;
struct netconfig *nconf;
struct knetconfig *knconfp;
static int printed = 0;
struct t_info tinfo;
err_ret_t addr_error;
SET_ERR_RET(error, ERR_PROTO_NONE, 0);
SET_ERR_RET(&addr_error, ERR_PROTO_NONE, 0);
if (nfs_proto) {
/*
* If a proto is specified and its rdma try this. The kernel
* will later do the reachablity test and fail form there
* if rdma transport is not available to kernel rpc
*/
if (strcmp(nfs_proto, "rdma") == 0) {
args->addr = get_addr(fshost, NFS_PROGRAM,
nfsvers_to_use, nconfp, NULL, port, &tinfo,
&args->fh, get_pubfh, fspath, &addr_error);
args->flags |= NFSMNT_DORDMA;
} else {
args->addr = get_addr(fshost, NFS_PROGRAM,
nfsvers_to_use, nconfp, nfs_proto, port, &tinfo,
&args->fh, get_pubfh, fspath, &addr_error);
}
} else {
args->addr = get_addr(fshost, NFS_PROGRAM, nfsvers_to_use,
nconfp, nfs_proto, port, &tinfo, &args->fh, get_pubfh,
fspath, &addr_error);
/*
* If no proto is specified set this flag.
* Kernel mount code will try to use RDMA if its on the
* system, otherwise it will keep on using the protocol
* selected here, through the above get_addr call.
*/
if (nfs_proto == NULL)
args->flags |= NFSMNT_TRYRDMA;
}
if (args->addr == NULL) {
/*
* We could have failed because the server had no public
* file handle support. So don't print a message and don't
* retry.
*/
if (get_pubfh == TRUE)
return (RET_ERR);
if (!printed) {
switch (addr_error.error_type) {
case 0:
printed = 1;
break;
case ERR_RPCERROR:
if (!print_rpcerror)
/* no error print at this time */
break;
pr_err(gettext("%s NFS service not"
" available %s\n"), fshost,
clnt_sperrno(addr_error.error_value));
printed = 1;
break;
case ERR_NETPATH:
pr_err(gettext("%s: Error in NETPATH.\n"),
fshost);
printed = 1;
break;
case ERR_PROTO_INVALID:
pr_err(gettext("%s: NFS service does not"
" recognize protocol: %s.\n"), fshost,
nfs_proto);
printed = 1;
break;
case ERR_PROTO_UNSUPP:
if (nfsvers || nfsvers_to_use == NFS_VERSMIN) {
/*
* Don't set "printed" here. Since we
* have to keep checking here till we
* exhaust transport errors on all vers.
*
* Print this message if:
* 1. After we have tried all versions
* of NFS and none support the asked
* transport.
*
* 2. If a version is specified and it
* does'nt support the asked
* transport.
*
* Otherwise we decrement the version
* and retry below.
*/
pr_err(gettext("%s: NFS service does"
" not support protocol: %s.\n"),
fshost, nfs_proto);
}
break;
case ERR_NOHOST:
pr_err("%s: %s\n", fshost, "Unknown host");
printed = 1;
break;
default:
/* case ERR_PROTO_NONE falls through */
pr_err(gettext("%s: NFS service not responding"
"\n"), fshost);
printed = 1;
break;
}
}
SET_ERR_RET(error,
addr_error.error_type, addr_error.error_value);
if (addr_error.error_type == ERR_PROTO_NONE)
return (RET_RETRY);
else if (addr_error.error_type == ERR_RPCERROR &&
!IS_UNRECOVERABLE_RPC(addr_error.error_value)) {
return (RET_RETRY);
} else if (nfsvers == 0 && addr_error.error_type ==
ERR_PROTO_UNSUPP && nfsvers_to_use != NFS_VERSMIN) {
/*
* If no version is specified, and the error is due
* to an unsupported transport, then decrement the
* version and retry.
*/
return (RET_RETRY);
} else
return (RET_ERR);
}
nconf = *nconfp;
if (stat(nconf->nc_device, &sb) < 0) {
pr_err(gettext("getaddr_nfs: couldn't stat: %s: %s\n"),
nconf->nc_device, strerror(errno));
return (RET_ERR);
}
knconfp = (struct knetconfig *)malloc(sizeof (*knconfp));
if (!knconfp) {
pr_err(gettext("no memory\n"));
return (RET_ERR);
}
knconfp->knc_semantics = nconf->nc_semantics;
knconfp->knc_protofmly = nconf->nc_protofmly;
knconfp->knc_proto = nconf->nc_proto;
knconfp->knc_rdev = sb.st_rdev;
/* make sure we don't overload the transport */
if (tinfo.tsdu > 0 && tinfo.tsdu < NFS_MAXDATA + NFS_RPC_HDR) {
args->flags |= (NFSMNT_RSIZE | NFSMNT_WSIZE);
if (args->rsize == 0 || args->rsize > tinfo.tsdu - NFS_RPC_HDR)
args->rsize = tinfo.tsdu - NFS_RPC_HDR;
if (args->wsize == 0 || args->wsize > tinfo.tsdu - NFS_RPC_HDR)
args->wsize = tinfo.tsdu - NFS_RPC_HDR;
}
args->flags |= NFSMNT_KNCONF;
args->knconf = knconfp;
return (RET_OK);
}
static int
retry(struct mnttab *mntp, int ro)
{
int delay = 5;
int count = retries;
int r;
/*
* Please see comments on nfsretry_vers in the beginning of this file
* and in main() routine.
*/
if (bg) {
if (fork() > 0)
return (RET_OK);
backgrounded = 1;
pr_err(gettext("backgrounding: %s\n"), mntp->mnt_mountp);
} else {
if (!nfsretry_vers)
pr_err(gettext("retrying: %s\n"), mntp->mnt_mountp);
}
while (count--) {
if ((r = mount_nfs(mntp, ro, NULL)) == RET_OK) {
pr_err(gettext("%s: mounted OK\n"), mntp->mnt_mountp);
return (RET_OK);
}
if (r != RET_RETRY)
break;
if (count > 0) {
(void) sleep(delay);
delay *= 2;
if (delay > 120)
delay = 120;
}
}
if (!nfsretry_vers)
pr_err(gettext("giving up on: %s\n"), mntp->mnt_mountp);
return (RET_ERR);
}
/*
* Read the NFS SMF Parameters to determine if the
* client has been configured for a new min/max for the NFS version to
* use.
*/
static void
read_default(void)
{
char value[4];
int errno;
int tmp = 0, bufsz = 0, ret = 0;
/* Maximum number of bytes expected. */
bufsz = 4;
ret = nfs_smf_get_prop("client_versmin", value, DEFAULT_INSTANCE,
SCF_TYPE_INTEGER, SVC_NFS_CLIENT, &bufsz);
if (ret == SA_OK) {
errno = 0;
tmp = strtol(value, (char **)NULL, 10);
if (errno == 0) {
vers_min_default = tmp;
}
}
/* Maximum number of bytes expected. */
bufsz = 4;
ret = nfs_smf_get_prop("client_versmax", value, DEFAULT_INSTANCE,
SCF_TYPE_INTEGER, SVC_NFS_CLIENT, &bufsz);
if (ret == SA_OK) {
errno = 0;
tmp = strtol(value, (char **)NULL, 10);
if (errno == 0) {
vers_max_default = tmp;
}
}
}
static void
sigusr1(int s)
{
}
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#ifndef _NFSMOUNT_WEBNFS_H_RPCGEN
#define _NFSMOUNT_WEBNFS_H_RPCGEN
#include <rpc/rpc.h>
#ifndef _KERNEL
#include <synch.h>
#include <thread.h>
#endif /* !_KERNEL */
#ifdef __cplusplus
extern "C" {
#endif
#define WNL_PORT 2049
#define WNL_MAXDATA 8192
#define WNL_MAXNAMLEN 255
#define WNL_FHSIZE 32
#define WNL_FIFO_DEV -1
#define WNL_NATIVEPATH 0x80
#define WNL_SEC_NEGO 0x81
#define WNLMODE_FMT 0170000
#define WNLMODE_DIR 0040000
#define WNLMODE_CHR 0020000
#define WNLMODE_BLK 0060000
#define WNLMODE_REG 0100000
#define WNLMODE_LNK 0120000
#define WNLMODE_SOCK 0140000
#define WNLMODE_FIFO 0010000
enum wnl_stat {
WNL_OK = 0,
WNLERR_PERM = 1,
WNLERR_NOENT = 2,
WNLERR_IO = 5,
WNLERR_NXIO = 6,
WNLERR_ACCES = 13,
WNLERR_EXIST = 17,
WNLERR_XDEV = 18,
WNLERR_NODEV = 19,
WNLERR_NOTDIR = 20,
WNLERR_ISDIR = 21,
WNLERR_INVAL = 22,
WNLERR_FBIG = 27,
WNLERR_NOSPC = 28,
WNLERR_ROFS = 30,
WNLERR_OPNOTSUPP = 45,
WNLERR_NAMETOOLONG = 63,
WNLERR_NOTEMPTY = 66,
WNLERR_DQUOT = 69,
WNLERR_STALE = 70,
WNLERR_REMOTE = 71,
WNLERR_WFLUSH = 72
};
typedef enum wnl_stat wnl_stat;
enum wnl_ftype {
WNL_NON = 0,
WNL_REG = 1,
WNL_DIR = 2,
WNL_BLK = 3,
WNL_CHR = 4,
WNL_LNK = 5,
WNL_SOCK = 6,
WNL_BAD = 7,
WNL_FIFO = 8
};
typedef enum wnl_ftype wnl_ftype;
struct wnl_fh {
char data[WNL_FHSIZE];
};
typedef struct wnl_fh wnl_fh;
struct wnl_time {
u_int seconds;
u_int useconds;
};
typedef struct wnl_time wnl_time;
struct wnl_fattr {
wnl_ftype type;
u_int mode;
u_int nlink;
u_int uid;
u_int gid;
u_int size;
u_int blocksize;
u_int rdev;
u_int blocks;
u_int fsid;
u_int fileid;
wnl_time atime;
wnl_time mtime;
wnl_time ctime;
};
typedef struct wnl_fattr wnl_fattr;
typedef char *wnl_filename;
struct wnl_diropargs {
wnl_fh dir;
wnl_filename name;
};
typedef struct wnl_diropargs wnl_diropargs;
struct wnl_diropokres {
wnl_fh file;
wnl_fattr attributes;
};
typedef struct wnl_diropokres wnl_diropokres;
struct wnl_diropres {
wnl_stat status;
union {
wnl_diropokres wnl_diropres;
} wnl_diropres_u;
};
typedef struct wnl_diropres wnl_diropres;
#define WNL3_FHSIZE 64
typedef u_longlong_t wnl_uint64;
typedef longlong_t wnl_int64;
typedef u_int wnl_uint32;
typedef char *wnl_filename3;
typedef wnl_uint64 wnl_fileid3;
typedef wnl_uint32 wnl_uid3;
typedef wnl_uint32 wnl_gid3;
typedef wnl_uint64 wnl_size3;
typedef wnl_uint32 wnl_mode3;
enum wnl_stat3 {
WNL3_OK = 0,
WNL3ERR_PERM = 1,
WNL3ERR_NOENT = 2,
WNL3ERR_IO = 5,
WNL3ERR_NXIO = 6,
WNL3ERR_ACCES = 13,
WNL3ERR_EXIST = 17,
WNL3ERR_XDEV = 18,
WNL3ERR_NODEV = 19,
WNL3ERR_NOTDIR = 20,
WNL3ERR_ISDIR = 21,
WNL3ERR_INVAL = 22,
WNL3ERR_FBIG = 27,
WNL3ERR_NOSPC = 28,
WNL3ERR_ROFS = 30,
WNL3ERR_MLINK = 31,
WNL3ERR_NAMETOOLONG = 63,
WNL3ERR_NOTEMPTY = 66,
WNL3ERR_DQUOT = 69,
WNL3ERR_STALE = 70,
WNL3ERR_REMOTE = 71,
WNL3ERR_BADHANDLE = 10001,
WNL3ERR_NOT_SYNC = 10002,
WNL3ERR_BAD_COOKIE = 10003,
WNL3ERR_NOTSUPP = 10004,
WNL3ERR_TOOSMALL = 10005,
WNL3ERR_SERVERFAULT = 10006,
WNL3ERR_BADTYPE = 10007,
WNL3ERR_JUKEBOX = 10008
};
typedef enum wnl_stat3 wnl_stat3;
enum wnl_ftype3 {
WNL_3REG = 1,
WNL_3DIR = 2,
WNL_3BLK = 3,
WNL_3CHR = 4,
WNL_3LNK = 5,
WNL_3SOCK = 6,
WNL_3FIFO = 7
};
typedef enum wnl_ftype3 wnl_ftype3;
struct wnl_specdata3 {
wnl_uint32 specdata1;
wnl_uint32 specdata2;
};
typedef struct wnl_specdata3 wnl_specdata3;
struct wnl_fh3 {
struct {
u_int data_len;
char *data_val;
} data;
};
typedef struct wnl_fh3 wnl_fh3;
struct wnl_time3 {
wnl_uint32 seconds;
wnl_uint32 nseconds;
};
typedef struct wnl_time3 wnl_time3;
struct wnl_fattr3 {
wnl_ftype3 type;
wnl_mode3 mode;
wnl_uint32 nlink;
wnl_uid3 uid;
wnl_gid3 gid;
wnl_size3 size;
wnl_size3 used;
wnl_specdata3 rdev;
wnl_uint64 fsid;
wnl_fileid3 fileid;
wnl_time3 atime;
wnl_time3 mtime;
wnl_time3 ctime;
};
typedef struct wnl_fattr3 wnl_fattr3;
struct wnl_post_op_attr {
bool_t attributes_follow;
union {
wnl_fattr3 attributes;
} wnl_post_op_attr_u;
};
typedef struct wnl_post_op_attr wnl_post_op_attr;
struct wln_post_op_fh3 {
bool_t handle_follows;
union {
wnl_fh3 handle;
} wln_post_op_fh3_u;
};
typedef struct wln_post_op_fh3 wln_post_op_fh3;
struct wnl_diropargs3 {
wnl_fh3 dir;
wnl_filename3 name;
};
typedef struct wnl_diropargs3 wnl_diropargs3;
struct WNL_LOOKUP3args {
wnl_diropargs3 what;
};
typedef struct WNL_LOOKUP3args WNL_LOOKUP3args;
struct WNL_LOOKUP3resok {
wnl_fh3 object;
wnl_post_op_attr obj_attributes;
wnl_post_op_attr dir_attributes;
};
typedef struct WNL_LOOKUP3resok WNL_LOOKUP3resok;
struct WNL_LOOKUP3resfail {
wnl_post_op_attr dir_attributes;
};
typedef struct WNL_LOOKUP3resfail WNL_LOOKUP3resfail;
struct WNL_LOOKUP3res {
wnl_stat3 status;
union {
WNL_LOOKUP3resok res_ok;
WNL_LOOKUP3resfail res_fail;
} WNL_LOOKUP3res_u;
};
typedef struct WNL_LOOKUP3res WNL_LOOKUP3res;
#define MAX_FLAVORS 128
struct snego_t {
int cnt;
int array[MAX_FLAVORS];
};
typedef struct snego_t snego_t;
enum snego_stat {
SNEGO_SUCCESS = 0,
SNEGO_DEF_VALID = 1,
SNEGO_ARRAY_TOO_SMALL = 2,
SNEGO_FAILURE = 3
};
typedef enum snego_stat snego_stat;
#define WNL_PROGRAM 100003
#define WNL_V2 2
#if defined(__STDC__) || defined(__cplusplus)
#define WNLPROC_NULL 0
extern enum clnt_stat wnlproc_null_2(void *, void *, CLIENT *);
extern bool_t wnlproc_null_2_svc(void *, void *, struct svc_req *);
#define WNLPROC_LOOKUP 4
extern enum clnt_stat wnlproc_lookup_2(wnl_diropargs *, wnl_diropres *, CLIENT *);
extern bool_t wnlproc_lookup_2_svc(wnl_diropargs *, wnl_diropres *, struct svc_req *);
extern int wnl_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define WNLPROC_NULL 0
extern enum clnt_stat wnlproc_null_2();
extern bool_t wnlproc_null_2_svc();
#define WNLPROC_LOOKUP 4
extern enum clnt_stat wnlproc_lookup_2();
extern bool_t wnlproc_lookup_2_svc();
extern int wnl_program_2_freeresult();
#endif /* K&R C */
#define WNL_V3 3
#if defined(__STDC__) || defined(__cplusplus)
#define WNLPROC3_NULL 0
extern enum clnt_stat wnlproc3_null_3(void *, void *, CLIENT *);
extern bool_t wnlproc3_null_3_svc(void *, void *, struct svc_req *);
#define WNLPROC3_LOOKUP 3
extern enum clnt_stat wnlproc3_lookup_3(WNL_LOOKUP3args *, WNL_LOOKUP3res *, CLIENT *);
extern bool_t wnlproc3_lookup_3_svc(WNL_LOOKUP3args *, WNL_LOOKUP3res *, struct svc_req *);
extern int wnl_program_3_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define WNLPROC3_NULL 0
extern enum clnt_stat wnlproc3_null_3();
extern bool_t wnlproc3_null_3_svc();
#define WNLPROC3_LOOKUP 3
extern enum clnt_stat wnlproc3_lookup_3();
extern bool_t wnlproc3_lookup_3_svc();
extern int wnl_program_3_freeresult();
#endif /* K&R C */
#define WNL_V4 4
#if defined(__STDC__) || defined(__cplusplus)
#define WNLPROC4_NULL 0
extern enum clnt_stat wnlproc4_null_4(void *, void *, CLIENT *);
extern bool_t wnlproc4_null_4_svc(void *, void *, struct svc_req *);
extern int wnl_program_4_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
#else /* K&R C */
#define WNLPROC4_NULL 0
extern enum clnt_stat wnlproc4_null_4();
extern bool_t wnlproc4_null_4_svc();
extern int wnl_program_4_freeresult();
#endif /* K&R C */
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_wnl_stat(XDR *, wnl_stat*);
extern bool_t xdr_wnl_ftype(XDR *, wnl_ftype*);
extern bool_t xdr_wnl_fh(XDR *, wnl_fh*);
extern bool_t xdr_wnl_time(XDR *, wnl_time*);
extern bool_t xdr_wnl_fattr(XDR *, wnl_fattr*);
extern bool_t xdr_wnl_filename(XDR *, wnl_filename*);
extern bool_t xdr_wnl_diropargs(XDR *, wnl_diropargs*);
extern bool_t xdr_wnl_diropokres(XDR *, wnl_diropokres*);
extern bool_t xdr_wnl_diropres(XDR *, wnl_diropres*);
extern bool_t xdr_wnl_uint64(XDR *, wnl_uint64*);
extern bool_t xdr_wnl_int64(XDR *, wnl_int64*);
extern bool_t xdr_wnl_uint32(XDR *, wnl_uint32*);
extern bool_t xdr_wnl_filename3(XDR *, wnl_filename3*);
extern bool_t xdr_wnl_fileid3(XDR *, wnl_fileid3*);
extern bool_t xdr_wnl_uid3(XDR *, wnl_uid3*);
extern bool_t xdr_wnl_gid3(XDR *, wnl_gid3*);
extern bool_t xdr_wnl_size3(XDR *, wnl_size3*);
extern bool_t xdr_wnl_mode3(XDR *, wnl_mode3*);
extern bool_t xdr_wnl_stat3(XDR *, wnl_stat3*);
extern bool_t xdr_wnl_ftype3(XDR *, wnl_ftype3*);
extern bool_t xdr_wnl_specdata3(XDR *, wnl_specdata3*);
extern bool_t xdr_wnl_fh3(XDR *, wnl_fh3*);
extern bool_t xdr_wnl_time3(XDR *, wnl_time3*);
extern bool_t xdr_wnl_fattr3(XDR *, wnl_fattr3*);
extern bool_t xdr_wnl_post_op_attr(XDR *, wnl_post_op_attr*);
extern bool_t xdr_wln_post_op_fh3(XDR *, wln_post_op_fh3*);
extern bool_t xdr_wnl_diropargs3(XDR *, wnl_diropargs3*);
extern bool_t xdr_WNL_LOOKUP3args(XDR *, WNL_LOOKUP3args*);
extern bool_t xdr_WNL_LOOKUP3resok(XDR *, WNL_LOOKUP3resok*);
extern bool_t xdr_WNL_LOOKUP3resfail(XDR *, WNL_LOOKUP3resfail*);
extern bool_t xdr_WNL_LOOKUP3res(XDR *, WNL_LOOKUP3res*);
extern bool_t xdr_snego_t(XDR *, snego_t*);
extern bool_t xdr_snego_stat(XDR *, snego_stat*);
#else /* K&R C */
extern bool_t xdr_wnl_stat();
extern bool_t xdr_wnl_ftype();
extern bool_t xdr_wnl_fh();
extern bool_t xdr_wnl_time();
extern bool_t xdr_wnl_fattr();
extern bool_t xdr_wnl_filename();
extern bool_t xdr_wnl_diropargs();
extern bool_t xdr_wnl_diropokres();
extern bool_t xdr_wnl_diropres();
extern bool_t xdr_wnl_uint64();
extern bool_t xdr_wnl_int64();
extern bool_t xdr_wnl_uint32();
extern bool_t xdr_wnl_filename3();
extern bool_t xdr_wnl_fileid3();
extern bool_t xdr_wnl_uid3();
extern bool_t xdr_wnl_gid3();
extern bool_t xdr_wnl_size3();
extern bool_t xdr_wnl_mode3();
extern bool_t xdr_wnl_stat3();
extern bool_t xdr_wnl_ftype3();
extern bool_t xdr_wnl_specdata3();
extern bool_t xdr_wnl_fh3();
extern bool_t xdr_wnl_time3();
extern bool_t xdr_wnl_fattr3();
extern bool_t xdr_wnl_post_op_attr();
extern bool_t xdr_wln_post_op_fh3();
extern bool_t xdr_wnl_diropargs3();
extern bool_t xdr_WNL_LOOKUP3args();
extern bool_t xdr_WNL_LOOKUP3resok();
extern bool_t xdr_WNL_LOOKUP3resfail();
extern bool_t xdr_WNL_LOOKUP3res();
extern bool_t xdr_snego_t();
extern bool_t xdr_snego_stat();
#endif /* K&R C */
#ifdef __cplusplus
}
#endif
#endif /* !_NFSMOUNT_WEBNFS_H_RPCGEN */
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include <memory.h> /* for memset */
#include "webnfs.h"
#ifndef _KERNEL
#include <stdio.h>
#include <stdlib.h> /* getenv, exit */
#endif /* !_KERNEL */
/* Default timeout can be changed using clnt_control() */
static struct timeval TIMEOUT = { 25, 0 };
enum clnt_stat
wnlproc_null_2(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, WNLPROC_NULL,
(xdrproc_t)xdr_void, (caddr_t)argp,
(xdrproc_t)xdr_void, (caddr_t)clnt_res,
TIMEOUT));
}
enum clnt_stat
wnlproc_lookup_2(wnl_diropargs *argp, wnl_diropres *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, WNLPROC_LOOKUP,
(xdrproc_t)xdr_wnl_diropargs, (caddr_t)argp,
(xdrproc_t)xdr_wnl_diropres, (caddr_t)clnt_res,
TIMEOUT));
}
enum clnt_stat
wnlproc3_null_3(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, WNLPROC3_NULL,
(xdrproc_t)xdr_void, (caddr_t)argp,
(xdrproc_t)xdr_void, (caddr_t)clnt_res,
TIMEOUT));
}
enum clnt_stat
wnlproc3_lookup_3(WNL_LOOKUP3args *argp, WNL_LOOKUP3res *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, WNLPROC3_LOOKUP,
(xdrproc_t)xdr_WNL_LOOKUP3args, (caddr_t)argp,
(xdrproc_t)xdr_WNL_LOOKUP3res, (caddr_t)clnt_res,
TIMEOUT));
}
enum clnt_stat
wnlproc4_null_4(void *argp, void *clnt_res, CLIENT *clnt)
{
return (clnt_call(clnt, WNLPROC4_NULL,
(xdrproc_t)xdr_void, (caddr_t)argp,
(xdrproc_t)xdr_void, (caddr_t)clnt_res,
TIMEOUT));
}
/*
* Please do not edit this file.
* It was generated using rpcgen.
*/
#include "webnfs.h"
#ifndef _KERNEL
#include <stdlib.h>
#endif /* !_KERNEL */
bool_t
xdr_wnl_stat(XDR *xdrs, wnl_stat *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_enum(xdrs, (enum_t *)objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_ftype(XDR *xdrs, wnl_ftype *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_enum(xdrs, (enum_t *)objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_fh(XDR *xdrs, wnl_fh *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_opaque(xdrs, objp->data, WNL_FHSIZE))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_time(XDR *xdrs, wnl_time *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_u_int(xdrs, &objp->seconds))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->useconds))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_fattr(XDR *xdrs, wnl_fattr *objp)
{
rpc_inline_t *buf __unused;
if (xdrs->x_op == XDR_ENCODE) {
if (!xdr_wnl_ftype(xdrs, &objp->type))
return (FALSE);
buf = XDR_INLINE(xdrs, 10 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_u_int(xdrs, &objp->mode))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->nlink))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->uid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->gid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->size))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->blocksize))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->rdev))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->blocks))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->fsid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->fileid))
return (FALSE);
} else {
#if defined(_LP64) || defined(_KERNEL)
IXDR_PUT_U_INT32(buf, objp->mode);
IXDR_PUT_U_INT32(buf, objp->nlink);
IXDR_PUT_U_INT32(buf, objp->uid);
IXDR_PUT_U_INT32(buf, objp->gid);
IXDR_PUT_U_INT32(buf, objp->size);
IXDR_PUT_U_INT32(buf, objp->blocksize);
IXDR_PUT_U_INT32(buf, objp->rdev);
IXDR_PUT_U_INT32(buf, objp->blocks);
IXDR_PUT_U_INT32(buf, objp->fsid);
IXDR_PUT_U_INT32(buf, objp->fileid);
#else
IXDR_PUT_U_LONG(buf, objp->mode);
IXDR_PUT_U_LONG(buf, objp->nlink);
IXDR_PUT_U_LONG(buf, objp->uid);
IXDR_PUT_U_LONG(buf, objp->gid);
IXDR_PUT_U_LONG(buf, objp->size);
IXDR_PUT_U_LONG(buf, objp->blocksize);
IXDR_PUT_U_LONG(buf, objp->rdev);
IXDR_PUT_U_LONG(buf, objp->blocks);
IXDR_PUT_U_LONG(buf, objp->fsid);
IXDR_PUT_U_LONG(buf, objp->fileid);
#endif
}
if (!xdr_wnl_time(xdrs, &objp->atime))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->mtime))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->ctime))
return (FALSE);
return (TRUE);
} else if (xdrs->x_op == XDR_DECODE) {
if (!xdr_wnl_ftype(xdrs, &objp->type))
return (FALSE);
buf = XDR_INLINE(xdrs, 10 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_u_int(xdrs, &objp->mode))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->nlink))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->uid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->gid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->size))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->blocksize))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->rdev))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->blocks))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->fsid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->fileid))
return (FALSE);
} else {
#if defined(_LP64) || defined(_KERNEL)
objp->mode = IXDR_GET_U_INT32(buf);
objp->nlink = IXDR_GET_U_INT32(buf);
objp->uid = IXDR_GET_U_INT32(buf);
objp->gid = IXDR_GET_U_INT32(buf);
objp->size = IXDR_GET_U_INT32(buf);
objp->blocksize = IXDR_GET_U_INT32(buf);
objp->rdev = IXDR_GET_U_INT32(buf);
objp->blocks = IXDR_GET_U_INT32(buf);
objp->fsid = IXDR_GET_U_INT32(buf);
objp->fileid = IXDR_GET_U_INT32(buf);
#else
objp->mode = IXDR_GET_U_LONG(buf);
objp->nlink = IXDR_GET_U_LONG(buf);
objp->uid = IXDR_GET_U_LONG(buf);
objp->gid = IXDR_GET_U_LONG(buf);
objp->size = IXDR_GET_U_LONG(buf);
objp->blocksize = IXDR_GET_U_LONG(buf);
objp->rdev = IXDR_GET_U_LONG(buf);
objp->blocks = IXDR_GET_U_LONG(buf);
objp->fsid = IXDR_GET_U_LONG(buf);
objp->fileid = IXDR_GET_U_LONG(buf);
#endif
}
if (!xdr_wnl_time(xdrs, &objp->atime))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->mtime))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->ctime))
return (FALSE);
return (TRUE);
}
if (!xdr_wnl_ftype(xdrs, &objp->type))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->mode))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->nlink))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->uid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->gid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->size))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->blocksize))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->rdev))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->blocks))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->fsid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->fileid))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->atime))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->mtime))
return (FALSE);
if (!xdr_wnl_time(xdrs, &objp->ctime))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_filename(XDR *xdrs, wnl_filename *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_string(xdrs, objp, WNL_MAXNAMLEN))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_diropargs(XDR *xdrs, wnl_diropargs *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_fh(xdrs, &objp->dir))
return (FALSE);
if (!xdr_wnl_filename(xdrs, &objp->name))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_diropokres(XDR *xdrs, wnl_diropokres *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_fh(xdrs, &objp->file))
return (FALSE);
if (!xdr_wnl_fattr(xdrs, &objp->attributes))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_diropres(XDR *xdrs, wnl_diropres *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_stat(xdrs, &objp->status))
return (FALSE);
switch (objp->status) {
case WNL_OK:
if (!xdr_wnl_diropokres(xdrs, &objp->wnl_diropres_u.wnl_diropres))
return (FALSE);
break;
default:
break;
}
return (TRUE);
}
bool_t
xdr_wnl_uint64(XDR *xdrs, wnl_uint64 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_u_longlong_t(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_int64(XDR *xdrs, wnl_int64 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_longlong_t(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_uint32(XDR *xdrs, wnl_uint32 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_u_int(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_filename3(XDR *xdrs, wnl_filename3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_string(xdrs, objp, ~0))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_fileid3(XDR *xdrs, wnl_fileid3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint64(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_uid3(XDR *xdrs, wnl_uid3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint32(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_gid3(XDR *xdrs, wnl_gid3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint32(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_size3(XDR *xdrs, wnl_size3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint64(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_mode3(XDR *xdrs, wnl_mode3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint32(xdrs, objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_stat3(XDR *xdrs, wnl_stat3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_enum(xdrs, (enum_t *)objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_ftype3(XDR *xdrs, wnl_ftype3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_enum(xdrs, (enum_t *)objp))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_specdata3(XDR *xdrs, wnl_specdata3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint32(xdrs, &objp->specdata1))
return (FALSE);
if (!xdr_wnl_uint32(xdrs, &objp->specdata2))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_fh3(XDR *xdrs, wnl_fh3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, WNL3_FHSIZE))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_time3(XDR *xdrs, wnl_time3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_uint32(xdrs, &objp->seconds))
return (FALSE);
if (!xdr_wnl_uint32(xdrs, &objp->nseconds))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_fattr3(XDR *xdrs, wnl_fattr3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_ftype3(xdrs, &objp->type))
return (FALSE);
if (!xdr_wnl_mode3(xdrs, &objp->mode))
return (FALSE);
if (!xdr_wnl_uint32(xdrs, &objp->nlink))
return (FALSE);
if (!xdr_wnl_uid3(xdrs, &objp->uid))
return (FALSE);
if (!xdr_wnl_gid3(xdrs, &objp->gid))
return (FALSE);
if (!xdr_wnl_size3(xdrs, &objp->size))
return (FALSE);
if (!xdr_wnl_size3(xdrs, &objp->used))
return (FALSE);
if (!xdr_wnl_specdata3(xdrs, &objp->rdev))
return (FALSE);
if (!xdr_wnl_uint64(xdrs, &objp->fsid))
return (FALSE);
if (!xdr_wnl_fileid3(xdrs, &objp->fileid))
return (FALSE);
if (!xdr_wnl_time3(xdrs, &objp->atime))
return (FALSE);
if (!xdr_wnl_time3(xdrs, &objp->mtime))
return (FALSE);
if (!xdr_wnl_time3(xdrs, &objp->ctime))
return (FALSE);
return (TRUE);
}
bool_t
xdr_wnl_post_op_attr(XDR *xdrs, wnl_post_op_attr *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_bool(xdrs, &objp->attributes_follow))
return (FALSE);
switch (objp->attributes_follow) {
case TRUE:
if (!xdr_wnl_fattr3(xdrs, &objp->wnl_post_op_attr_u.attributes))
return (FALSE);
break;
case FALSE:
break;
default:
return (FALSE);
}
return (TRUE);
}
bool_t
xdr_wln_post_op_fh3(XDR *xdrs, wln_post_op_fh3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_bool(xdrs, &objp->handle_follows))
return (FALSE);
switch (objp->handle_follows) {
case TRUE:
if (!xdr_wnl_fh3(xdrs, &objp->wln_post_op_fh3_u.handle))
return (FALSE);
break;
case FALSE:
break;
default:
return (FALSE);
}
return (TRUE);
}
bool_t
xdr_wnl_diropargs3(XDR *xdrs, wnl_diropargs3 *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_fh3(xdrs, &objp->dir))
return (FALSE);
if (!xdr_wnl_filename3(xdrs, &objp->name))
return (FALSE);
return (TRUE);
}
bool_t
xdr_WNL_LOOKUP3args(XDR *xdrs, WNL_LOOKUP3args *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_diropargs3(xdrs, &objp->what))
return (FALSE);
return (TRUE);
}
bool_t
xdr_WNL_LOOKUP3resok(XDR *xdrs, WNL_LOOKUP3resok *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_fh3(xdrs, &objp->object))
return (FALSE);
if (!xdr_wnl_post_op_attr(xdrs, &objp->obj_attributes))
return (FALSE);
if (!xdr_wnl_post_op_attr(xdrs, &objp->dir_attributes))
return (FALSE);
return (TRUE);
}
bool_t
xdr_WNL_LOOKUP3resfail(XDR *xdrs, WNL_LOOKUP3resfail *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_post_op_attr(xdrs, &objp->dir_attributes))
return (FALSE);
return (TRUE);
}
bool_t
xdr_WNL_LOOKUP3res(XDR *xdrs, WNL_LOOKUP3res *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_wnl_stat3(xdrs, &objp->status))
return (FALSE);
switch (objp->status) {
case WNL3_OK:
if (!xdr_WNL_LOOKUP3resok(xdrs, &objp->WNL_LOOKUP3res_u.res_ok))
return (FALSE);
break;
default:
if (!xdr_WNL_LOOKUP3resfail(xdrs, &objp->WNL_LOOKUP3res_u.res_fail))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_snego_t(XDR *xdrs, snego_t *objp)
{
rpc_inline_t *buf __unused;
int i;
if (xdrs->x_op == XDR_ENCODE) {
buf = XDR_INLINE(xdrs, (1 + (MAX_FLAVORS)) * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_int(xdrs, &objp->cnt))
return (FALSE);
if (!xdr_vector(xdrs, (char *)objp->array, MAX_FLAVORS,
sizeof (int), (xdrproc_t)xdr_int))
return (FALSE);
} else {
#if defined(_LP64) || defined(_KERNEL)
IXDR_PUT_INT32(buf, objp->cnt);
{
int *genp;
for (i = 0, genp = objp->array;
i < MAX_FLAVORS; i++) {
IXDR_PUT_INT32(buf, *genp++);
}
}
#else
IXDR_PUT_LONG(buf, objp->cnt);
{
int *genp;
for (i = 0, genp = objp->array;
i < MAX_FLAVORS; i++) {
IXDR_PUT_LONG(buf, *genp++);
}
}
#endif
}
return (TRUE);
} else if (xdrs->x_op == XDR_DECODE) {
buf = XDR_INLINE(xdrs, (1 + (MAX_FLAVORS)) * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_int(xdrs, &objp->cnt))
return (FALSE);
if (!xdr_vector(xdrs, (char *)objp->array, MAX_FLAVORS,
sizeof (int), (xdrproc_t)xdr_int))
return (FALSE);
} else {
#if defined(_LP64) || defined(_KERNEL)
objp->cnt = IXDR_GET_INT32(buf);
{
int *genp;
for (i = 0, genp = objp->array;
i < MAX_FLAVORS; i++) {
*genp++ = IXDR_GET_INT32(buf);
}
}
#else
objp->cnt = IXDR_GET_LONG(buf);
{
int *genp;
for (i = 0, genp = objp->array;
i < MAX_FLAVORS; i++) {
*genp++ = IXDR_GET_LONG(buf);
}
}
#endif
}
return (TRUE);
}
if (!xdr_int(xdrs, &objp->cnt))
return (FALSE);
if (!xdr_vector(xdrs, (char *)objp->array, MAX_FLAVORS,
sizeof (int), (xdrproc_t)xdr_int))
return (FALSE);
return (TRUE);
}
bool_t
xdr_snego_stat(XDR *xdrs, snego_stat *objp)
{
rpc_inline_t *buf __unused;
if (!xdr_enum(xdrs, (enum_t *)objp))
return (FALSE);
return (TRUE);
}
|