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
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "xml_convert.h"
#include <errno.h>
#include <string.h>
#include <libintl.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include <locale.h>
#include <unistd.h>
#include "volume_error.h"
#include "volume_output.h"
#include "volume_string.h"
/*
* IDs for localized messages in the generated command script
*/
#define CMD_MSG_ENVIRONMENT "Environment"
#define CMD_MSG_AMEND_PATH "Amend PATH"
#define CMD_MSG_DISK_SET_NAME "Disk set name"
#define CMD_MSG_FUNCTIONS "Functions"
/* CSTYLED */
#define CMD_MSG_ECHO_AND_EXEC "Echo (verbose) and exec given command, exit on error"
#define CMD_MSG_GET_FULL_PATH "Get full /dev/rdsk path of given slice"
/* CSTYLED */
#define CMD_MSG_FMTHARD_SPECIAL "Run fmthard, ignore partboot error, error if output"
#define CMD_MSG_MAIN "Main"
#define CMD_MSG_VERIFY_ROOT "Verify root"
#define CMD_MSG_RUN_AS_ROOT "This script must be run as root."
#define CMD_MSG_CHECK_FOR_VERBOSE "Check for verbose option"
#define CMD_MSG_DOES_DISK_SET_EXIST "Does the disk set exist?"
#define CMD_MSG_TAKE_DISK_SET "Take control of disk set"
#define CMD_MSG_CREATE_THE_DISK_SET "Create the disk set"
#define CMD_MSG_ADD_DISKS_TO_SET "Add disks to set"
#define CMD_MSG_FORMAT_SLICES "Format slices"
#define CMD_MSG_CREATE "Create {1} {2}"
#define CMD_MSG_DOES_EXIST "Does {1} exist?"
#define CMD_MSG_ADD_SLICES_TO "Add slices to {1}"
/* CSTYLED */
#define CMD_MSG_ASSOCIATE_WITH_HSP "Associate {1} {2} with hot spare pool {3}"
/*
* ******************************************************************
*
* Data types
*
* ******************************************************************
*/
/*
* Encapsulates the parsing of an XML attribute
*/
typedef struct {
/* The name of the attribute */
char *name;
/*
* A function to validate and set the XML attribute value in
* the given devconfig_t structure.
*
* @param name
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 if the given value was valid and set
* successfully, non-zero otherwise.
*/
int (*validate_set)(devconfig_t *device, char *name, char *value);
/*
* A function to get the XML attribute value in the given
* devconfig_t structure.
*
* @param name
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 if the given value was retrieved
* successfully, non-zero otherwise.
*/
int (*get_as_string)(devconfig_t *device, char *name, char **value);
} attr_t;
/*
* Encapsulates the parsing of an XML element
*/
typedef struct {
/* The name of the element */
char *name;
/* The type of element to set in the devconfig_t */
component_type_t type;
/*
* When converting from XML to a devconfig_t hierarchy,
* indicates whether to create a new devconfig_t structure in
* the hierarchy when this XML element is encountered.
*/
boolean_t is_hierarchical;
/*
* If is_hierarchical is B_TRUE, whether to use an existing
* devconfig_t structure of this type when this element is
* encountered
*/
boolean_t singleton;
/* The valid XML attributes for this element */
attr_t *attributes;
} element_t;
typedef struct {
char *msgid;
char *message;
} l10nmessage_t;
/*
* ******************************************************************
*
* Function prototypes
*
* ******************************************************************
*/
static int validate_doc(xmlDocPtr doc, const char *name, const char *systemID);
static int devconfig_to_xml(
xmlNodePtr parent, element_t elements[], devconfig_t *device);
static int xml_to_devconfig(
xmlNodePtr cur, element_t elements[], devconfig_t *device);
static int compare_is_a_diskset(void *obj1, void *obj2);
static xmlNodePtr xml_find_node(
xmlNodePtr node, xmlChar *element, xmlChar *name);
static xmlDocPtr create_localized_message_doc();
static int create_localized_message_file(char **tmpfile);
static int strtobool(char *str, boolean_t *value);
static int ofprintf_terse(void *unused, char *fmt, ...);
static int ofprintf_verbose(void *unused, char *fmt, ...);
static int validate_set_size(
devconfig_t *volume, char *attr, char *value);
static int validate_set_size_in_blocks(
devconfig_t *slice, char *attr, char *value);
static int validate_set_diskset_name(
devconfig_t *diskset, char *attr, char *name);
static int validate_add_available_name(
devconfig_t *device, char *attr, char *name);
static int validate_add_unavailable_name(
devconfig_t *device, char *attr, char *name);
static int validate_set_hsp_name(
devconfig_t *hsp, char *attr, char *name);
static int validate_set_disk_name(
devconfig_t *disk, char *attr, char *name);
static int validate_set_slice_name(
devconfig_t *slice, char *attr, char *name);
static int validate_set_slice_start_block(
devconfig_t *slice, char *attr, char *value);
static int validate_set_volume_name(
devconfig_t *volume, char *attr, char *name);
static int validate_set_stripe_interlace(
devconfig_t *stripe, char *attr, char *value);
static int validate_set_stripe_mincomp(
devconfig_t *stripe, char *attr, char *value);
static int validate_set_stripe_maxcomp(
devconfig_t *stripe, char *attr, char *value);
static int validate_set_volume_usehsp(
devconfig_t *volume, char *attr, char *value);
static int validate_set_mirror_nsubmirrors(
devconfig_t *mirror, char *attr, char *value);
static int validate_set_mirror_read(
devconfig_t *mirror, char *attr, char *value);
static int validate_set_mirror_write(
devconfig_t *mirror, char *attr, char *value);
static int validate_set_mirror_passnum(
devconfig_t *mirror, char *attr, char *value);
static int validate_set_volume_redundancy(
devconfig_t *volume, char *attr, char *value);
static int validate_set_volume_datapaths(
devconfig_t *volume, char *attr, char *value);
static int get_as_string_name(
devconfig_t *device, char *attr, char **value);
static int get_as_string_mirror_passnum(
devconfig_t *mirror, char *attr, char **value);
static int get_as_string_mirror_read(
devconfig_t *mirror, char *attr, char **value);
static int get_as_string_mirror_write(
devconfig_t *mirror, char *attr, char **value);
static int get_as_string_size_in_blocks(
devconfig_t *device, char *attr, char **value);
static int get_as_string_slice_start_block(
devconfig_t *slice, char *attr, char **value);
static int get_as_string_stripe_interlace(
devconfig_t *stripe, char *attr, char **value);
/*
* ******************************************************************
*
* Data
*
* ******************************************************************
*/
/* Valid units for the size attribute */
units_t size_units[] = {
{UNIT_KILOBYTES, BYTES_PER_KILOBYTE},
{UNIT_MEGABYTES, BYTES_PER_MEGABYTE},
{UNIT_GIGABYTES, BYTES_PER_GIGABYTE},
{UNIT_TERABYTES, BYTES_PER_TERABYTE},
{NULL, 0}
};
/* Valid units for the interlace attribute */
units_t interlace_units[] = {
{UNIT_BLOCKS, BYTES_PER_BLOCK},
{UNIT_KILOBYTES, BYTES_PER_KILOBYTE},
{UNIT_MEGABYTES, BYTES_PER_MEGABYTE},
{NULL, 0}
};
/* <diskset> attributes */
static attr_t diskset_attrs[] = {
{ ATTR_NAME, validate_set_diskset_name, get_as_string_name },
{ NULL, NULL, NULL }
};
/* <available> attributes */
static attr_t available_attrs[] = {
{ ATTR_NAME, validate_add_available_name, NULL },
{ NULL, NULL, NULL }
};
/* <unavailable> attributes */
static attr_t unavailable_attrs[] = {
{ ATTR_NAME, validate_add_unavailable_name, NULL },
{ NULL, NULL, NULL }
};
/* <hsp> attributes */
static attr_t hsp_attrs[] = {
{ ATTR_NAME, validate_set_hsp_name, get_as_string_name },
{ NULL, NULL, NULL }
};
/* <disk> attributes */
static attr_t disk_attrs[] = {
{ ATTR_NAME, validate_set_disk_name, get_as_string_name },
{ NULL, NULL, NULL }
};
/* <slice> attributes */
static attr_t slice_attrs[] = {
{ ATTR_NAME, validate_set_slice_name, get_as_string_name },
{ ATTR_SIZEINBLOCKS, validate_set_size_in_blocks,
get_as_string_size_in_blocks },
{ ATTR_SLICE_STARTSECTOR, validate_set_slice_start_block,
get_as_string_slice_start_block },
{ NULL, NULL, NULL }
};
/* <stripe> attributes */
static attr_t stripe_attrs[] = {
{ ATTR_NAME, validate_set_volume_name, get_as_string_name },
{ ATTR_SIZEINBYTES, validate_set_size, NULL },
{ ATTR_STRIPE_MINCOMP, validate_set_stripe_mincomp, NULL },
{ ATTR_STRIPE_MAXCOMP, validate_set_stripe_maxcomp, NULL },
{ ATTR_STRIPE_INTERLACE, validate_set_stripe_interlace,
get_as_string_stripe_interlace },
{ ATTR_VOLUME_USEHSP, validate_set_volume_usehsp, NULL },
{ NULL, NULL, NULL }
};
/* <concat> attributes */
static attr_t concat_attrs[] = {
{ ATTR_NAME, validate_set_volume_name, get_as_string_name },
{ ATTR_SIZEINBYTES, validate_set_size, NULL },
{ ATTR_VOLUME_USEHSP, validate_set_volume_usehsp, NULL },
{ NULL, NULL, NULL }
};
/* <mirror> attributes */
static attr_t mirror_attrs[] = {
{ ATTR_NAME, validate_set_volume_name, get_as_string_name },
{ ATTR_MIRROR_NSUBMIRRORS, validate_set_mirror_nsubmirrors, NULL },
{ ATTR_SIZEINBYTES, validate_set_size, NULL },
{ ATTR_MIRROR_READ, validate_set_mirror_read,
get_as_string_mirror_read },
{ ATTR_MIRROR_WRITE, validate_set_mirror_write,
get_as_string_mirror_write },
{ ATTR_MIRROR_PASSNUM, validate_set_mirror_passnum,
get_as_string_mirror_passnum },
{ ATTR_VOLUME_USEHSP, validate_set_volume_usehsp, NULL },
{ NULL, NULL, NULL }
};
/* <volume> attributes */
static attr_t volume_attrs[] = {
{ ATTR_NAME, validate_set_volume_name, get_as_string_name },
{ ATTR_SIZEINBYTES, validate_set_size, NULL },
{ ATTR_VOLUME_REDUNDANCY, validate_set_volume_redundancy, NULL },
{ ATTR_VOLUME_FAULTRECOVERY, validate_set_volume_usehsp, NULL },
{ ATTR_VOLUME_DATAPATHS, validate_set_volume_datapaths, NULL },
{ NULL, NULL, NULL }
};
/* volume-request elements */
static element_t request_elements[] = {
{ ELEMENT_DISKSET, TYPE_DISKSET, B_FALSE, B_FALSE, diskset_attrs },
{ ELEMENT_AVAILABLE, TYPE_UNKNOWN, B_FALSE, B_FALSE, available_attrs },
{ ELEMENT_UNAVAILABLE, TYPE_UNKNOWN, B_FALSE, B_FALSE,
unavailable_attrs },
{ ELEMENT_HSP, TYPE_HSP, B_TRUE, B_FALSE, hsp_attrs },
{ ELEMENT_SLICE, TYPE_SLICE, B_TRUE, B_FALSE, slice_attrs },
{ ELEMENT_STRIPE, TYPE_STRIPE, B_TRUE, B_FALSE, stripe_attrs },
{ ELEMENT_CONCAT, TYPE_CONCAT, B_TRUE, B_FALSE, concat_attrs },
{ ELEMENT_MIRROR, TYPE_MIRROR, B_TRUE, B_FALSE, mirror_attrs },
{ ELEMENT_VOLUME, TYPE_VOLUME, B_TRUE, B_FALSE, volume_attrs },
{ NULL, NULL, B_FALSE, B_FALSE, NULL }
};
/* volume-defaults elements */
static element_t default_elements[] = {
{ ELEMENT_DISKSET, TYPE_DISKSET, B_TRUE, B_FALSE, diskset_attrs },
{ ELEMENT_AVAILABLE, TYPE_UNKNOWN, B_FALSE, B_TRUE, available_attrs },
{ ELEMENT_UNAVAILABLE, TYPE_UNKNOWN, B_FALSE, B_TRUE,
unavailable_attrs },
{ ELEMENT_HSP, TYPE_HSP, B_TRUE, B_TRUE, hsp_attrs },
{ ELEMENT_SLICE, TYPE_SLICE, B_TRUE, B_TRUE, slice_attrs },
{ ELEMENT_STRIPE, TYPE_STRIPE, B_TRUE, B_TRUE, stripe_attrs },
{ ELEMENT_CONCAT, TYPE_CONCAT, B_TRUE, B_TRUE, concat_attrs },
{ ELEMENT_MIRROR, TYPE_MIRROR, B_TRUE, B_TRUE, mirror_attrs },
{ ELEMENT_VOLUME, TYPE_VOLUME, B_TRUE, B_TRUE, volume_attrs },
{ NULL, NULL, B_FALSE, B_FALSE, NULL }
};
/* volume-config elements */
static element_t config_elements[] = {
{ ELEMENT_DISKSET, TYPE_DISKSET, B_FALSE, B_FALSE, diskset_attrs },
{ ELEMENT_DISK, TYPE_DRIVE, B_TRUE, B_FALSE, disk_attrs },
{ ELEMENT_SLICE, TYPE_SLICE, B_TRUE, B_FALSE, slice_attrs },
{ ELEMENT_HSP, TYPE_HSP, B_TRUE, B_FALSE, hsp_attrs },
{ ELEMENT_STRIPE, TYPE_STRIPE, B_TRUE, B_FALSE, stripe_attrs },
{ ELEMENT_CONCAT, TYPE_CONCAT, B_TRUE, B_FALSE, concat_attrs },
{ ELEMENT_MIRROR, TYPE_MIRROR, B_TRUE, B_FALSE, mirror_attrs },
{ NULL, NULL, B_FALSE, B_FALSE, NULL }
};
/*
* ******************************************************************
*
* External functions
*
* ******************************************************************
*/
/*
* Initialize the XML parser, setting defaults across all XML
* routines.
*/
void
init_xml()
{
/* COMPAT: Do not generate nodes for formatting spaces */
LIBXML_TEST_VERSION
xmlKeepBlanksDefault(0);
/* Turn on line numbers for debugging */
xmlLineNumbersDefault(1);
/* Substitute entities as files are parsed */
xmlSubstituteEntitiesDefault(1);
/* Don't load external entity subsets */
xmlLoadExtDtdDefaultValue = 0;
/* Don't validate against DTD by default */
xmlDoValidityCheckingDefaultValue = 0;
/* Set up output handlers for XML parsing */
xmlDefaultSAXHandler.warning = (warningSAXFunc)ofprintf_verbose;
xmlDefaultSAXHandler.error = (errorSAXFunc)ofprintf_terse;
xmlDefaultSAXHandler.fatalError = (fatalErrorSAXFunc)ofprintf_terse;
}
/*
* Clean up any remaining structures before exiting.
*/
void
cleanup_xml()
{
xsltCleanupGlobals();
xmlCleanupParser();
}
/*
* Converts a volume-request XML document into a request_t.
*
* @param doc
* an existing volume-request XML document
*
* @param request
* RETURN: a new request_t which must be freed via
* free_request
*
* @return 0 on success, non-zero otherwise.
*/
int
xml_to_request(
xmlDocPtr doc,
request_t **request)
{
int error = 0;
*request = NULL;
/* Validate doc against known DTD */
if ((error = validate_doc(
doc, ELEMENT_VOLUMEREQUEST, VOLUME_REQUEST_DTD_LOC)) == 0) {
/* Create a request */
if ((error = new_request(request)) == 0) {
/* Convert the XML doc into a request_t */
error = xml_to_devconfig(xmlDocGetRootElement(doc),
request_elements, request_get_diskset_req(*request));
}
}
return (error);
}
/*
* Converts a volume-defaults XML document into a defaults_t.
*
* @param doc
* an existing volume-defaults XML document
*
* @param defaults
* RETURN: a new defaults_t which must be freed via
* free_defaults
*
* @return 0 on success, non-zero otherwise.
*/
int
xml_to_defaults(
xmlDocPtr doc,
defaults_t **defaults)
{
int error = 0;
*defaults = NULL;
/* Validate doc against known DTD */
if ((error = validate_doc(doc, ELEMENT_VOLUMEDEFAULTS,
VOLUME_DEFAULTS_DTD_LOC)) == 0) {
/* Create request defaults */
if ((error = new_defaults(defaults)) == 0) {
devconfig_t *global;
/* Get defaults for all disk sets */
if ((error = defaults_get_diskset_by_name(
*defaults, NULL, &global)) == 0) {
/* Populate the global devconfig_t from the XML doc */
if ((error = xml_to_devconfig(xmlDocGetRootElement(doc),
default_elements, global)) == 0) {
/* Get the components of the global devconfig_t */
dlist_t *list = devconfig_get_components(global);
/*
* Move all named disk set settings out from
* under global settings
*/
/* CONSTANTCONDITION */
while (1) {
dlist_t *removed = NULL;
devconfig_t *component;
/* Remove named disk set from under global */
list = dlist_remove_equivalent_item(
list, NULL, compare_is_a_diskset, &removed);
if (removed == NULL) {
/* No named disk set found */
break;
}
component = removed->obj;
/* Append named disk set to disk set list */
defaults_set_disksets(*defaults,
dlist_append(dlist_new_item(component),
defaults_get_disksets(*defaults), AT_TAIL));
}
}
}
}
}
return (error);
}
/*
* Converts a volume-config XML document into a devconfig_t.
*
* @param doc
* an existing volume-config XML document
*
* @param config
* RETURN: a new devconfig_t which must be freed via
* free_devconfig
*
* @return 0 on success, non-zero otherwise.
*/
int
xml_to_config(
xmlDocPtr doc,
devconfig_t **config)
{
int error = 0;
*config = NULL;
/* Validate doc against known DTD */
if ((error = validate_doc(
doc, ELEMENT_VOLUMECONFIG, VOLUME_CONFIG_DTD_LOC)) == 0) {
/* Create a devconfig_t */
if ((error = new_devconfig(config, TYPE_DISKSET)) == 0) {
/* Populate the devconfig_t from the XML doc */
error = xml_to_devconfig(
xmlDocGetRootElement(doc), config_elements, *config);
}
}
return (error);
}
/*
* Converts a devconfig_t into a volume-config XML document.
*
* @param config
* an existing devconfig_t representing a volume
* configuration.
*
* @param doc
* RETURN: a new volume-config XML document which must be
* freed via xmlFreeDoc
*
* @return 0 on success, non-zero otherwise.
*/
int
config_to_xml(
devconfig_t *config,
xmlDocPtr *doc)
{
xmlNodePtr root;
int error = 0;
/* Create the XML document */
*doc = xmlNewDoc((xmlChar *)"1.0");
/* Create the root node */
root = xmlNewDocNode(
*doc, NULL, (xmlChar *)ELEMENT_VOLUMECONFIG, NULL);
xmlAddChild((xmlNodePtr)*doc, (xmlNodePtr)root);
/* Create sub-nodes from the config devconfig_t */
if ((error = devconfig_to_xml(root, config_elements, config)) == 0) {
/* Add DTD node and validate */
error = validate_doc(
*doc, ELEMENT_VOLUMECONFIG, VOLUME_CONFIG_DTD_LOC);
}
if (error) {
xmlFreeDoc(*doc);
}
return (error);
}
/*
* Converts a volume-config XML document into a Bourne shell script.
*
* @param doc
* an existing volume-config XML document
*
* @param commands
* RETURN: a new char* which must be freed
*
* @return 0 on success, non-zero otherwise.
*/
int
xml_to_commands(
xmlDocPtr doc,
char **commands)
{
char *tmpfile = NULL;
int error = 0;
xsltStylesheetPtr style = NULL;
/* Read in XSL stylesheet as a normal XML document */
xmlDocPtr xsl_doc = xmlSAXParseFile((xmlSAXHandlerPtr)
&xmlDefaultSAXHandler, VOLUME_COMMAND_XSL_LOC, 0);
if (xsl_doc != NULL && xsl_doc->xmlChildrenNode != NULL) {
/*
* Find the "msgfile" variable node. This is where
* we'll set the location of the file we'll create
* containing the localized messages.
*/
xmlNodePtr msgfile_node = xml_find_node(
xmlDocGetRootElement(xsl_doc), (xmlChar *)ELEMENT_VARIABLE,
(xmlChar *)NAME_L10N_MESSAGE_FILE);
/*
* Find the "lang" node. This is where we'll set the
* current locale.
*/
xmlNodePtr lang_node = xml_find_node(xmlDocGetRootElement(xsl_doc),
(xmlChar *)ELEMENT_PARAM, (xmlChar *)NAME_LANG);
/*
* Ignore if the nodes are not found -- the script
* will default to the C locale.
*/
if (msgfile_node != NULL && lang_node != NULL) {
/* Get/set current locale in the "lang" node */
char *locale = setlocale(LC_MESSAGES, NULL);
xmlNodeSetContent(lang_node, (xmlChar *)locale);
/* Write localized messages to a temporary file */
if ((error = create_localized_message_file(&tmpfile)) == 0) {
char *newsel;
/* Clear current value of select attribute, if any */
xmlChar *cursel = xmlGetProp(
msgfile_node, (xmlChar *)ATTR_SELECT);
if (cursel != NULL) {
xmlFree(cursel);
}
/*
* The select attribute calls the XSLT function
* document() to load an external XML file
*/
newsel = stralloccat(3, "document('", tmpfile, "')");
if (newsel == NULL) {
volume_set_error(gettext("out of memory"));
error = -1;
} else {
/* Set the new value of the select attribute */
xmlSetProp(msgfile_node,
(xmlChar *)ATTR_SELECT, (xmlChar *)newsel);
free(newsel);
}
}
}
if (error == 0) {
style = xsltParseStylesheetDoc(xsl_doc);
}
}
if (style == NULL) {
volume_set_error(
gettext("could not load stylesheet from %s"),
VOLUME_COMMAND_XSL_LOC);
error = -1;
} else {
xmlDocPtr result = xsltApplyStylesheet(style, doc, NULL);
if (result == NULL) {
volume_set_error(
gettext("could not apply stylesheet to volume-config"));
error = -1;
} else {
int length;
if (xsltSaveResultToString((xmlChar **)commands,
&length, result, style) == -1) {
error = ENOMEM;
}
}
xsltFreeStylesheet(style);
}
if (tmpfile != NULL) {
/* Ignore failure */
unlink(tmpfile);
free(tmpfile);
}
return (error);
}
/*
* ******************************************************************
*
* Static functions
*
* ******************************************************************
*/
/*
* Sets the external DTD node in the given XML document and then
* validates it.
*
* @param doc
* an existing XML document
*
* @param name
* the expected root element name of the XML document
*
* @param systemID
* the location of the DTD
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_doc(
xmlDocPtr doc,
const char *name,
const char *systemID)
{
xmlValidCtxt context;
xmlDtdPtr dtd;
if (doc == NULL) {
volume_set_error(gettext("NULL %s document"), name);
return (-1);
}
/*
* Assume that we can't trust any DTD but our own.
*/
/* Was a DTD (external or internal) included in the document? */
if ((dtd = xmlGetIntSubset(doc)) != NULL) {
/* Remove the DTD node */
oprintf(OUTPUT_DEBUG, gettext("Removing DTD from %s\n"), name);
xmlUnlinkNode((xmlNodePtr)dtd);
xmlFreeDtd(dtd);
}
/* Create the (external) DTD node */
oprintf(OUTPUT_DEBUG,
gettext("Creating new external DTD for %s\n"), name);
dtd = xmlCreateIntSubset(
doc, (xmlChar *)name, NULL, (xmlChar *)systemID);
if (dtd == NULL) {
volume_set_error(
gettext("could not create DTD node from %s"), systemID);
return (-1);
}
/* Validate against DTD */
oprintf(OUTPUT_DEBUG, gettext("Validating %s against DTD\n"), name);
context.userData = NULL;
context.error = (xmlValidityErrorFunc)ofprintf_terse;
context.warning = (xmlValidityWarningFunc)ofprintf_terse;
if (!xmlValidateDocument(&context, doc)) {
volume_set_error(gettext("invalid %s"), name);
return (-1);
}
return (0);
}
/*
* Converts a devconfig_t into an XML node subject to the rules in
* the given element_t array.
*
* @param parent
* the XML node to which to add new XML nodes resulting
* from conversion of the given devconfig_t
*
* @param elements
* the element_ts that describe the structure of the XML
* document and govern the conversion of the given
* devconfig_t
*
* @param device
* the devconfig_t to convert
*
* @return 0 on success, non-zero otherwise.
*/
static int
devconfig_to_xml(
xmlNodePtr parent,
element_t elements[],
devconfig_t *device)
{
int i;
int error = 0;
xmlNodePtr node = NULL;
/* Get device type */
component_type_t type;
if ((error = devconfig_get_type(device, &type)) != 0) {
return (error);
}
/* Search for this element definition */
for (i = 0; elements[i].name != NULL; i++) {
element_t *element = &(elements[i]);
if (element->type == type) {
int j;
char **array;
dlist_t *components;
oprintf(OUTPUT_DEBUG, gettext("Element: %s\n"),
devconfig_type_to_str(type));
/* Create the XML node */
node = xmlNewChild(
parent, NULL, (xmlChar *)element->name, NULL);
/* For each attribute defined for this element... */
for (j = 0; element->attributes[j].name != NULL; j++) {
attr_t *attribute = &(element->attributes[j]);
char *value;
/* Is there a valid accessor for this attribute? */
if (attribute->get_as_string != NULL) {
/* Get the attribute value from the device */
switch (error = attribute->get_as_string(
device, attribute->name, &value)) {
/* Attribute is set in this device */
case 0:
oprintf(OUTPUT_DEBUG, " %s: %s\n",
attribute->name, value);
/* Set the value in the XML node */
xmlSetProp(node, (uchar_t *)attribute->name,
(uchar_t *)value);
free(value);
/* FALLTHROUGH */
/* Attribute is not set in this device */
case ERR_ATTR_UNSET:
error = 0;
break;
/* Error */
default:
return (error);
}
}
}
/* Is this node hierarchical? */
if (element->is_hierarchical == B_FALSE) {
node = parent;
}
/* Create <available> nodes */
array = devconfig_get_available(device);
if (array != NULL) {
for (j = 0; array[j] != NULL; j++) {
xmlNodePtr child = xmlNewChild(
node, NULL, (xmlChar *)ELEMENT_AVAILABLE, NULL);
xmlSetProp(child,
(xmlChar *)ATTR_NAME, (xmlChar *)array[j]);
}
}
/* Create <unavailable> nodes */
array = devconfig_get_unavailable(device);
if (array != NULL) {
for (j = 0; array[j] != NULL; j++) {
xmlNodePtr child = xmlNewChild(
node, NULL, (xmlChar *)ELEMENT_UNAVAILABLE, NULL);
xmlSetProp(child,
(xmlChar *)ATTR_NAME, (xmlChar *)array[j]);
}
}
/*
* Recursively convert subcomponents of this device to
* XML, taking care to encode them in the order
* specified in the element_t list (which should
* mirror what's expected by the DTD).
*/
/* For each element type... */
for (j = 0; elements[j].name != NULL; j++) {
/* For each component of this device... */
for (components = devconfig_get_components(device);
components != NULL && error == 0;
components = components->next) {
devconfig_t *component = (devconfig_t *)components->obj;
component_type_t t;
/* Are the types the same? */
if ((error = devconfig_get_type(component, &t)) != 0) {
return (error);
} else {
if (elements[j].type == t) {
/* Encode child */
error = devconfig_to_xml(
node, elements, component);
}
}
}
}
/* Element found */
break;
}
}
/* Was this device successfully converted? */
if (node == NULL) {
volume_set_error(
gettext("can't convert device of type \"%s\" to XML element"),
devconfig_type_to_str(type));
error = -1;
}
return (error);
}
/*
* Converts an XML node into a devconfig_t subject to the rules in
* the given element_t array.
*
* @param cure
* the existing XML node to convert
*
* @param elements
* the element_ts that describe the structure of the XML
* document and govern the conversion of the given XML
* node
*
* @param device
* the devconfig_t node to which to add new devconfig_ts
* resulting from conversion of the given XML node
*
* @return 0 on success, non-zero otherwise.
*/
static int
xml_to_devconfig(
xmlNodePtr cur,
element_t elements[],
devconfig_t *device)
{
int error = 0;
/* For each child node... */
for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
int i;
boolean_t parsed_elem = B_FALSE;
/* Search for this element definition */
for (i = 0; elements[i].name != NULL; i++) {
element_t *element = &(elements[i]);
if (xmlStrcmp(cur->name, (xmlChar *)element->name) == 0) {
int j;
devconfig_t *component = NULL;
/* Flag that this element has been parsed */
parsed_elem = B_TRUE;
oprintf(OUTPUT_DEBUG, gettext("line %d: Element <%s>\n"),
XML_GET_LINE(cur), cur->name);
/* Should a new device be created for this element? */
if (element->is_hierarchical == B_TRUE) {
/* Should we use an existing device of this type? */
if (element->singleton) {
devconfig_get_component(
device, element->type, &component, B_FALSE);
}
if (component == NULL) {
oprintf(OUTPUT_DEBUG,
gettext("Creating new device\n"));
/* Create device of this type */
if ((error = new_devconfig(
&component, element->type)) != 0) {
return (error);
}
/* Add component to the toplevel device */
devconfig_set_components(
device, dlist_append(dlist_new_item(component),
devconfig_get_components(device), AT_TAIL));
}
} else {
component = device;
}
/* For each attribute defined for this element... */
for (j = 0; element->attributes[j].name != NULL; j++) {
attr_t *attribute = &(element->attributes[j]);
/* Get the value of this attribute */
char *value = (char *)
xmlGetProp(cur, (xmlChar *)attribute->name);
/* Was this attribute specified? */
if (value != NULL) {
oprintf(OUTPUT_DEBUG,
gettext("line %d:\tAttribute %s=%s\n"),
XML_GET_LINE(cur), attribute->name, value);
/* Set this value in the device */
if ((error = attribute->validate_set(
component, attribute->name, value)) != 0) {
return (error);
}
}
}
/* Get recursive sub-elements */
if ((error = xml_to_devconfig(
cur, elements, component)) != 0) {
return (error);
}
/* Element found */
break;
}
}
/* Make sure all non-text/comment elements were parsed */
if (parsed_elem == B_FALSE &&
xmlStrcmp(cur->name, (xmlChar *)ELEMENT_TEXT) != 0 &&
xmlStrcmp(cur->name, (xmlChar *)ELEMENT_COMMENT) != 0) {
oprintf(OUTPUT_DEBUG, gettext("Element <%s> NOT PARSED!!!\n"),
cur->name);
}
}
return (0);
}
/*
* Returns 0 if obj2 (devconfig_t *) is a disk set, 1 otherwise.
*/
static int
compare_is_a_diskset(
void *obj1,
void *obj2)
{
return (devconfig_isA(
(devconfig_t *)obj2, TYPE_DISKSET) == B_TRUE ? 0 : 1);
}
/*
* Recursively searches the given xmlNodePtr for an element of the
* specified type and name.
*
* @param node
* the root node to search
*
* @param element
* the name of the element type
*
* @param name
* the value of the name attribute
*
* @return a valid xmlNodePtr if an element of the specified
* type and name was found, NULL otherwise.
*/
static xmlNodePtr
xml_find_node(
xmlNodePtr node,
xmlChar *element,
xmlChar *name)
{
xmlNodePtr child;
/* Is the element the right type? */
if (xmlStrcmp(element, node->name) == 0 &&
/* Does this element's name attribute match? */
xmlStrcmp(name, xmlGetProp(node, (xmlChar *)ATTR_NAME)) == 0) {
return (node);
}
/* Check child nodes */
for (child = node->xmlChildrenNode; child != NULL;
child = child->next) {
xmlNodePtr found = xml_find_node(child, element, name);
if (found != NULL) {
return (found);
}
}
return (NULL);
}
/*
* Creates an XML document containing all of the localized message
* strings for the generated command script.
*
* @return a xmlDocPtr which must be freed via xmlFreeDoc
*/
static xmlDocPtr
create_localized_message_doc()
{
int i;
char *locale;
xmlDocPtr doc;
xmlNodePtr root;
l10nmessage_t _cmd_messages[21];
/* Create the XML document */
doc = xmlNewDoc((xmlChar *)"1.0");
/* Create the root node */
root = xmlNewDocNode(
doc, NULL, (xmlChar *)ELEMENT_L10N, NULL);
xmlAddChild((xmlNodePtr) doc, (xmlNodePtr)root);
_cmd_messages[0].msgid = CMD_MSG_ENVIRONMENT;
_cmd_messages[0].message = gettext(CMD_MSG_ENVIRONMENT);
_cmd_messages[1].msgid = CMD_MSG_AMEND_PATH;
_cmd_messages[1].message = gettext(CMD_MSG_AMEND_PATH);
_cmd_messages[2].msgid = CMD_MSG_DISK_SET_NAME;
_cmd_messages[2].message = gettext(CMD_MSG_DISK_SET_NAME);
_cmd_messages[3].msgid = CMD_MSG_FUNCTIONS;
_cmd_messages[3].message = gettext(CMD_MSG_FUNCTIONS);
_cmd_messages[4].msgid = CMD_MSG_ECHO_AND_EXEC;
_cmd_messages[4].message = gettext(CMD_MSG_ECHO_AND_EXEC);
_cmd_messages[5].msgid = CMD_MSG_FMTHARD_SPECIAL;
_cmd_messages[5].message = gettext(CMD_MSG_FMTHARD_SPECIAL);
_cmd_messages[6].msgid = CMD_MSG_GET_FULL_PATH;
_cmd_messages[6].message = gettext(CMD_MSG_GET_FULL_PATH);
_cmd_messages[7].msgid = CMD_MSG_MAIN;
_cmd_messages[7].message = gettext(CMD_MSG_MAIN);
_cmd_messages[8].msgid = CMD_MSG_VERIFY_ROOT;
_cmd_messages[8].message = gettext(CMD_MSG_VERIFY_ROOT);
_cmd_messages[9].msgid = CMD_MSG_RUN_AS_ROOT;
_cmd_messages[9].message = gettext(CMD_MSG_RUN_AS_ROOT);
_cmd_messages[10].msgid = CMD_MSG_CHECK_FOR_VERBOSE;
_cmd_messages[10].message = gettext(CMD_MSG_CHECK_FOR_VERBOSE);
_cmd_messages[11].msgid = (CMD_MSG_DOES_DISK_SET_EXIST);
_cmd_messages[11].message = gettext(CMD_MSG_DOES_DISK_SET_EXIST);
_cmd_messages[12].msgid = (CMD_MSG_TAKE_DISK_SET);
_cmd_messages[12].message = gettext(CMD_MSG_TAKE_DISK_SET);
_cmd_messages[13].msgid = (CMD_MSG_CREATE_THE_DISK_SET);
_cmd_messages[13].message = gettext(CMD_MSG_CREATE_THE_DISK_SET);
_cmd_messages[14].msgid = (CMD_MSG_ADD_DISKS_TO_SET);
_cmd_messages[14].message = gettext(CMD_MSG_ADD_DISKS_TO_SET);
_cmd_messages[15].msgid = (CMD_MSG_FORMAT_SLICES);
_cmd_messages[15].message = gettext(CMD_MSG_FORMAT_SLICES);
_cmd_messages[16].msgid = (CMD_MSG_CREATE);
_cmd_messages[16].message = gettext(CMD_MSG_CREATE);
_cmd_messages[17].msgid = (CMD_MSG_DOES_EXIST);
_cmd_messages[17].message = gettext(CMD_MSG_DOES_EXIST);
_cmd_messages[18].msgid = (CMD_MSG_ADD_SLICES_TO);
_cmd_messages[18].message = gettext(CMD_MSG_ADD_SLICES_TO);
_cmd_messages[19].msgid = (CMD_MSG_ASSOCIATE_WITH_HSP);
_cmd_messages[19].message = gettext(CMD_MSG_ASSOCIATE_WITH_HSP);
_cmd_messages[20].msgid = NULL;
/* Get/set current locale in the "lang" node */
locale = setlocale(LC_MESSAGES, NULL);
/* Add localized <message> elements to stylesheet */
for (i = 0; _cmd_messages[i].msgid != NULL; i++) {
xmlNsPtr ns = xmlNewNs(NULL, NULL, NULL);
xmlNodePtr node = xmlNewTextChild(
root, ns, (xmlChar *)ELEMENT_MESSAGE,
(xmlChar *)_cmd_messages[i].message);
/* Lang attribute */
xmlSetProp(node,
(xmlChar *)ATTR_LANG, (xmlChar *)locale);
/* Message ID attribute */
xmlSetProp(node, (xmlChar *)ATTR_MESSAGEID,
(xmlChar *)_cmd_messages[i].msgid);
}
if (get_max_verbosity() >= OUTPUT_DEBUG) {
xmlChar *text;
/* Get the text dump */
xmlDocDumpFormatMemory(doc, &text, NULL, 1);
oprintf(OUTPUT_DEBUG,
gettext("Generated message file:\n%s"), text);
xmlFree(text);
}
return (doc);
}
/*
* Creates a temporary XML file containing all of the localized
* message strings for the generated command script.
*
* @param tmpfile
* RETURN: the name of the temporary XML file
*
* @return 0 on success, non-zero otherwise.
*/
static int
create_localized_message_file(
char **tmpfile)
{
int error = 0;
/*
* Create temporary file name -- "XXXXXX" is replaced with
* unique char sequence by mkstemp()
*/
*tmpfile = stralloccat(3, "/tmp/", ELEMENT_L10N, "XXXXXX");
if (*tmpfile == NULL) {
volume_set_error(gettext("out of memory"));
error = -1;
} else {
int fildes;
FILE *msgfile = NULL;
/* Open temp file */
if ((fildes = mkstemp(*tmpfile)) != -1) {
msgfile = fdopen(fildes, "w");
}
if (msgfile == NULL) {
volume_set_error(gettext(
"could not open file for writing: %s"), *tmpfile);
error = -1;
} else {
xmlChar *text;
xmlDocPtr message_doc = create_localized_message_doc();
xmlDocDumpFormatMemory(message_doc, &text, NULL, 1);
if (fprintf(msgfile, "%s", text) < 0) {
volume_set_error(gettext(
"could not create localized message file: %s"),
*tmpfile);
error = -1;
}
xmlFree(text);
xmlFreeDoc(message_doc);
}
fclose(msgfile);
}
return (error);
}
/*
* Converts the given string into a boolean. The string must be
* either VALID_ATTR_TRUE or VALID_ATTR_FALSE.
*
* @param str
* the string to convert
*
* @param bool
* the addr of the boolean_t
*
* @return 0 if the given string could be converted to a boolean
* non-zero otherwise.
*/
static int
strtobool(
char *str,
boolean_t *value)
{
int error = 0;
if (strcmp(str, VALID_ATTR_TRUE) == 0) {
*value = B_TRUE;
} else
if (strcmp(str, VALID_ATTR_FALSE) == 0) {
*value = B_FALSE;
} else
error = -1;
return (error);
}
/*
* Wrapper for oprintf with a OUTPUT_TERSE level of verbosity.
* Provides an fprintf-like syntax to enable use as substitute output
* handler for man of the XML commands.
*
* @param unused
* unused, in favor of the FILE* passed to
* set_max_verbosity().
*
* @param fmt
* a printf-style format string
*
* @return the number of characters output
*/
static int
ofprintf_terse(
void *unused,
char *fmt,
...)
{
int ret;
va_list ap;
va_start(ap, fmt);
ret = oprintf_va(OUTPUT_TERSE, fmt, ap);
va_end(ap);
return (ret);
}
/*
* Wrapper for oprintf with a OUTPUT_VERBOSE level of verbosity.
* Provides an fprintf-like syntax to enable use as substitute output
* handler for man of the XML commands.
*
* @param unused
* unused, in favor of the FILE* passed to
* set_max_verbosity().
*
* @param fmt
* a printf-style format string
*
* @return the number of characters output
*/
static int
ofprintf_verbose(
void *unused,
char *fmt,
...)
{
int ret;
va_list ap;
va_start(ap, fmt);
ret = oprintf_va(OUTPUT_VERBOSE, fmt, ap);
va_end(ap);
return (ret);
}
/*
* ******************************************************************
*
* XML attribute validators/mutators
*
* These functions convert the given XML attribute string to the
* appropriate data type, and then pass it on to the appropriate
* devconfig_t mutator. A non-zero status is returned if the given
* string could not be converted or was invalid.
*
* ******************************************************************
*/
/*
* Validate and set the size attribute in the given volume
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the size
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_size(
devconfig_t *volume,
char *attr,
char *value)
{
int error;
uint64_t size = 0;
/* Convert size string to bytes */
if ((error = sizestr_to_bytes(value, &size, size_units)) != 0) {
return (error);
}
/* Set size in volume */
return (devconfig_set_size(volume, size));
}
/*
* Validate and set the size_in_blocks attribute in the given slice
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the size_in_blocks
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_size_in_blocks(
devconfig_t *slice,
char *attr,
char *value)
{
long long size;
/* Convert string to long long */
if (sscanf(value, "%lld", &size) != 1) {
volume_set_error(gettext("%s: invalid size in blocks"), value);
return (-1);
}
/* Set the number of submirrors in the slice */
return (devconfig_set_size_in_blocks(slice, (uint64_t)size));
}
/*
* Validate and set the name attribute in the given diskset
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the name
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_diskset_name(
devconfig_t *diskset,
char *attr,
char *name)
{
return (devconfig_set_diskset_name(diskset, name));
}
/*
* Validate and add the given name to the list of available devices in
* the given volume devconfig_t.
*
* @param device
* the devconfig_t whose available device list to modify
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_add_available_name(
devconfig_t *device,
char *attr,
char *name)
{
char **available;
/* Get available devices for this device */
available = devconfig_get_available(device);
/* Try to add name to array via realloc */
if ((available = append_to_string_array(available, name)) == NULL) {
return (ENOMEM);
}
/* Set available devices in the device */
devconfig_set_available(device, available);
return (0);
}
/*
* Validate and add the given name to the list of unavailable devices
* in the given volume devconfig_t.
*
* @param device
* the devconfig_t whose unavailable device list to modify
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_add_unavailable_name(
devconfig_t *device,
char *attr,
char *name)
{
char **unavailable;
/* Get unavailable devices for this device */
unavailable = devconfig_get_unavailable(device);
/* Try to add name to array via realloc */
if ((unavailable = append_to_string_array(unavailable, name)) == NULL) {
return (ENOMEM);
}
/* Set unavailable devices in the device */
devconfig_set_unavailable(device, unavailable);
return (0);
}
/*
* Validate and set the name attribute in the given hsp devconfig_t.
*
* @param volume
* the devconfig_t in which to set the name
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_hsp_name(
devconfig_t *hsp,
char *attr,
char *name)
{
return (devconfig_set_hsp_name(hsp, name));
}
/*
* Validate and set the name attribute in the given disk devconfig_t.
*
* @param volume
* the devconfig_t in which to set the name
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_disk_name(
devconfig_t *disk,
char *attr,
char *name)
{
return (devconfig_set_name(disk, name));
}
/*
* Validate and set the name attribute in the given slice devconfig_t.
*
* @param volume
* the devconfig_t in which to set the name
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_slice_name(
devconfig_t *slice,
char *attr,
char *name)
{
return (devconfig_set_name(slice, name));
}
/*
* Validate and set the start_block attribute in the given slice
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the start_block
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_slice_start_block(
devconfig_t *slice,
char *attr,
char *value)
{
long long startsector;
/* Convert string to long long */
if (sscanf(value, "%lld", &startsector) != 1) {
volume_set_error(gettext("%s: invalid start sector"), value);
return (-1);
}
/* Set the number of submirrors in the slice */
return (devconfig_set_slice_start_block(slice, (uint64_t)startsector));
}
/*
* Validate and set the name attribute in the given volume
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the name
*
* @param attr
* the name of the XML attribute
*
* @param name
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_volume_name(
devconfig_t *volume,
char *attr,
char *name)
{
return (devconfig_set_volume_name(volume, name));
}
/*
* Validate and set the interlace attribute in the given stripe
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the interlace
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_stripe_interlace(
devconfig_t *stripe,
char *attr,
char *value)
{
int error;
uint64_t interlace = 0;
/* Convert interlace string to bytes */
if ((error = sizestr_to_bytes(
value, &interlace, interlace_units)) != 0) {
return (error);
}
/* Set interlace in stripe */
return (devconfig_set_stripe_interlace(stripe, interlace));
}
/*
* Validate and set the mincomp attribute in the given stripe
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the mincomp
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_stripe_mincomp(
devconfig_t *stripe,
char *attr,
char *value)
{
uint16_t mincomp;
/* Convert string to a uint16_t */
if (str_to_uint16(value, &mincomp) != 0) {
volume_set_error(
gettext("invalid minimum stripe components (%s): %s"),
attr, value);
return (-1);
}
/* Set in stripe */
return (devconfig_set_stripe_mincomp(stripe, mincomp));
}
/*
* Validate and set the maxcomp attribute in the given stripe
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the maxcomp
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_stripe_maxcomp(
devconfig_t *stripe,
char *attr,
char *value)
{
uint16_t maxcomp;
/* Convert string to a uint16_t */
if (str_to_uint16(value, &maxcomp) != 0) {
volume_set_error(
gettext("invalid maximum stripe components (%s): %s"),
attr, value);
return (-1);
}
/* Set in stripe */
return (devconfig_set_stripe_maxcomp(stripe, maxcomp));
}
/*
* Validate and set the usehsp attribute in the given volume
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the usehsp
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_volume_usehsp(
devconfig_t *volume,
char *attr,
char *value)
{
boolean_t usehsp;
/* Get boolean value */
if (strtobool(value, &usehsp) != 0) {
volume_set_error(
gettext("%s: invalid boolean value for \"%s\" attribute"),
value, attr);
return (-1);
}
/* Set in volume */
return (devconfig_set_volume_usehsp(volume, usehsp));
}
/*
* Validate and set the nsubmirrors attribute in the given mirror
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the nsubmirrors
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_mirror_nsubmirrors(
devconfig_t *mirror,
char *attr,
char *value)
{
uint16_t nsubmirrors;
/* Convert string to a uint16_t */
if (str_to_uint16(value, &nsubmirrors) != 0) {
volume_set_error(
gettext("invalid number of submirrors (%s): %s"),
attr, value);
return (-1);
}
/* Set in stripe */
return (devconfig_set_mirror_nsubs(mirror, nsubmirrors));
}
/*
* Validate and set the read attribute in the given mirror
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the read
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_mirror_read(
devconfig_t *mirror,
char *attr,
char *value)
{
mirror_read_strategy_t strategy;
if (strcmp(value, VALID_MIRROR_READ_ROUNDROBIN) == 0) {
strategy = MIRROR_READ_ROUNDROBIN;
} else
if (strcmp(value, VALID_MIRROR_READ_GEOMETRIC) == 0) {
strategy = MIRROR_READ_GEOMETRIC;
} else
if (strcmp(value, VALID_MIRROR_READ_FIRST) == 0) {
strategy = MIRROR_READ_FIRST;
} else
{
volume_set_error(gettext("%s: invalid mirror read value"), value);
return (-1);
}
return (devconfig_set_mirror_read(mirror, strategy));
}
/*
* Validate and set the write attribute in the given mirror
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the write
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_mirror_write(
devconfig_t *mirror,
char *attr,
char *value)
{
mirror_write_strategy_t strategy;
if (strcmp(value, VALID_MIRROR_WRITE_PARALLEL) == 0) {
strategy = MIRROR_WRITE_PARALLEL;
} else
if (strcmp(value, VALID_MIRROR_WRITE_SERIAL) == 0) {
strategy = MIRROR_WRITE_SERIAL;
} else
{
volume_set_error(gettext("%s: invalid mirror write value"), value);
return (-1);
}
return (devconfig_set_mirror_write(mirror, strategy));
}
/*
* Validate and set the passnum attribute in the given mirror
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the passnum
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_mirror_passnum(
devconfig_t *mirror,
char *attr,
char *value)
{
uint16_t passnum;
/* Convert string to a uint16_t */
if (str_to_uint16(value, &passnum) != 0) {
volume_set_error(
gettext("invalid mirror pass number (%s): %s"),
attr, value);
return (-1);
}
/* Set in stripe */
return (devconfig_set_mirror_pass(mirror, passnum));
}
/*
* Validate and set the redundancy attribute in the given volume
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the redundancy
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_volume_redundancy(
devconfig_t *volume,
char *attr,
char *value)
{
uint16_t redundancy;
/* Convert string to a uint16_t */
if (str_to_uint16(value, &redundancy) != 0) {
volume_set_error(
gettext("invalid redundancy level (%s): %s"),
attr, value);
return (-1);
}
/* Set in stripe */
return (devconfig_set_volume_redundancy_level(volume, redundancy));
}
/*
* Validate and set the datapaths attribute in the given volume
* devconfig_t.
*
* @param volume
* the devconfig_t in which to set the datapaths
*
* @param attr
* the name of the XML attribute
*
* @param value
* the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
validate_set_volume_datapaths(
devconfig_t *volume,
char *attr,
char *value)
{
uint16_t redundancy;
/* Convert string to a uint16_t */
if (str_to_uint16(value, &redundancy) != 0) {
volume_set_error(
gettext("invalid number of data paths (%s): %s"),
attr, value);
return (-1);
}
/* Set in stripe */
return (devconfig_set_volume_npaths(volume, redundancy));
}
/*
* ******************************************************************
*
* XML attribute accessors/converters
*
* These functions get a value from the appropriate devconfig_t
* accessor, and then convert it to a string.
*
* ******************************************************************
*/
/*
* Get, as a string, the value of the name attribute of the given
* devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the name
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_name(
devconfig_t *device,
char *attr,
char **value)
{
int error;
char *name;
/* Get name */
if ((error = devconfig_get_name(device, &name)) == 0) {
if ((*value = strdup(name)) == NULL) {
error = ENOMEM;
}
}
return (error);
}
/*
* Get, as a string, the value of the passnum attribute of the given
* mirror devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the passnum
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_mirror_passnum(
devconfig_t *mirror,
char *attr,
char **value)
{
int error;
uint16_t passnum;
/* Get mirror pass number */
if ((error = devconfig_get_mirror_pass(mirror, &passnum)) == 0) {
error = ll_to_str(passnum, value);
}
return (error);
}
/*
* Get, as a string, the value of the read attribute of the given
* mirror devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the read
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_mirror_read(
devconfig_t *mirror,
char *attr,
char **value)
{
int error;
mirror_read_strategy_t read;
/* Get mirror read strategy */
if ((error = devconfig_get_mirror_read(mirror, &read)) == 0) {
if ((*value = strdup(
devconfig_read_strategy_to_str(read))) == NULL) {
error = ENOMEM;
}
}
return (error);
}
/*
* Get, as a string, the value of the write attribute of the given
* mirror devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the write
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_mirror_write(
devconfig_t *mirror,
char *attr,
char **value)
{
int error;
mirror_write_strategy_t write;
/* Get mirror write strategy */
if ((error = devconfig_get_mirror_write(mirror, &write)) == 0) {
if ((*value = strdup(
devconfig_write_strategy_to_str(write))) == NULL) {
error = ENOMEM;
}
}
return (error);
}
/*
* Get, as a string, the value of the in_blocks attribute of the given
* device devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the in_blocks
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_size_in_blocks(
devconfig_t *device,
char *attr,
char **value)
{
int error;
uint64_t size;
/* Get size in blocks */
if ((error = devconfig_get_size_in_blocks(device, &size)) == 0) {
error = ll_to_str(size, value);
}
return (error);
}
/*
* Get, as a string, the value of the start_block attribute of the
* given slice devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the start_block
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_slice_start_block(
devconfig_t *slice,
char *attr,
char **value)
{
int error;
uint64_t start;
/* Get slice start block */
if ((error = devconfig_get_slice_start_block(slice, &start)) == 0) {
error = ll_to_str(start, value);
}
return (error);
}
/*
* Get, as a string, the value of the interlace attribute of the given
* stripe devconfig_t. This data must be freed.
*
* @param device
* the devconfig_t from which to retrieve the interlace
*
* @param attr
* the name of the XML attribute
*
* @param value
* RETURN: the value of the XML attribute
*
* @return 0 on success, non-zero otherwise.
*/
static int
get_as_string_stripe_interlace(
devconfig_t *stripe,
char *attr,
char **value)
{
int error;
uint64_t interlace;
/* Get interlace */
if ((error = devconfig_get_stripe_interlace(
stripe, &interlace)) == 0) {
error = bytes_to_sizestr(interlace, value, interlace_units, B_TRUE);
}
return (error);
}
|