1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 176 unchanged lines hidden (view full) --- 185 return (gettext("\tcreate [-p] [-o property=value] ... " 186 "<filesystem>\n" 187 "\tcreate [-ps] [-b blocksize] [-o property=value] ... " 188 "-V <size> <volume>\n")); 189 case HELP_DESTROY: 190 return (gettext("\tdestroy [-rRf] " 191 "<filesystem|volume|snapshot>\n")); 192 case HELP_GET: |
193 return (gettext("\tget [-rHp] [-d max] " 194 "[-o field[,...]] [-s source[,...]]\n" |
195 "\t <\"all\" | property[,...]> " 196 "[filesystem|volume|snapshot] ...\n")); 197 case HELP_INHERIT: 198 return (gettext("\tinherit [-r] <property> " 199 "<filesystem|volume|snapshot> ...\n")); 200 case HELP_UPGRADE: 201 return (gettext("\tupgrade [-v]\n" 202 "\tupgrade [-r] [-V version] <-a | filesystem ...>\n")); 203 case HELP_JAIL: 204 return (gettext("\tjail <jailid> <filesystem>\n")); 205 case HELP_UNJAIL: 206 return (gettext("\tunjail <jailid> <filesystem>\n")); 207 case HELP_LIST: |
208 return (gettext("\tlist [-rH][-d max] " 209 "[-o property[,...]] [-t type[,...]] [-s property] ...\n" |
210 "\t [-S property] ... " 211 "[filesystem|volume|snapshot] ...\n")); 212 case HELP_MOUNT: 213 return (gettext("\tmount\n" 214 "\tmount [-vO] [-o opts] <-a | filesystem>\n")); 215 case HELP_PROMOTE: 216 return (gettext("\tpromote <clone-filesystem>\n")); 217 case HELP_RECEIVE: --- 209 unchanged lines hidden (view full) --- 427 (void) fprintf(stderr, gettext("internal " 428 "error: out of memory\n")); 429 return (-1); 430 } 431 return (0); 432 433} 434 |
435static int 436parse_depth(char *opt, int *flags) 437{ 438 char *tmp; 439 int depth; 440 441 depth = (int)strtol(opt, &tmp, 0); 442 if (*tmp) { 443 (void) fprintf(stderr, 444 gettext("%s is not an integer\n"), optarg); 445 usage(B_FALSE); 446 } 447 if (depth < 0) { 448 (void) fprintf(stderr, 449 gettext("Depth can not be negative.\n")); 450 usage(B_FALSE); 451 } 452 *flags |= (ZFS_ITER_DEPTH_LIMIT|ZFS_ITER_RECURSE); 453 return (depth); 454} 455 |
456/* 457 * zfs clone [-p] [-o prop=value] ... <snap> <fs | vol> 458 * 459 * Given an existing dataset, create a writable copy whose initial contents 460 * are the same as the source. The newly created dataset maintains a 461 * dependency on the original; the original cannot be destroyed so long as 462 * the clone exists. 463 * --- 671 unchanged lines hidden (view full) --- 1135 1136static int 1137zfs_do_get(int argc, char **argv) 1138{ 1139 zprop_get_cbdata_t cb = { 0 }; 1140 int i, c, flags = 0; 1141 char *value, *fields; 1142 int ret; |
1143 int limit = 0; |
1144 zprop_list_t fake_name = { 0 }; 1145 1146 /* 1147 * Set up default columns and sources. 1148 */ 1149 cb.cb_sources = ZPROP_SRC_ALL; 1150 cb.cb_columns[0] = GET_COL_NAME; 1151 cb.cb_columns[1] = GET_COL_PROPERTY; 1152 cb.cb_columns[2] = GET_COL_VALUE; 1153 cb.cb_columns[3] = GET_COL_SOURCE; 1154 cb.cb_type = ZFS_TYPE_DATASET; 1155 1156 /* check options */ |
1157 while ((c = getopt(argc, argv, ":d:o:s:rHp")) != -1) { |
1158 switch (c) { 1159 case 'p': 1160 cb.cb_literal = B_TRUE; 1161 break; |
1162 case 'd': 1163 limit = parse_depth(optarg, &flags); 1164 break; |
1165 case 'r': 1166 flags |= ZFS_ITER_RECURSE; 1167 break; 1168 case 'H': 1169 cb.cb_scripted = B_TRUE; 1170 break; 1171 case ':': 1172 (void) fprintf(stderr, gettext("missing argument for " --- 114 unchanged lines hidden (view full) --- 1287 fake_name.pl_next = cb.cb_proplist; 1288 cb.cb_proplist = &fake_name; 1289 } 1290 1291 cb.cb_first = B_TRUE; 1292 1293 /* run for each object */ 1294 ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, NULL, |
1295 &cb.cb_proplist, limit, get_callback, &cb); |
1296 1297 if (cb.cb_proplist == &fake_name) 1298 zprop_free_list(fake_name.pl_next); 1299 else 1300 zprop_free_list(cb.cb_proplist); 1301 1302 return (ret); 1303} --- 96 unchanged lines hidden (view full) --- 1400 } else if (!zfs_prop_user(propname)) { 1401 (void) fprintf(stderr, gettext("invalid property '%s'\n"), 1402 propname); 1403 usage(B_FALSE); 1404 } 1405 1406 if (flags & ZFS_ITER_RECURSE) { 1407 ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, |
1408 NULL, NULL, 0, inherit_recurse_cb, propname); |
1409 } else { 1410 ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_DATASET, |
1411 NULL, NULL, 0, inherit_cb, propname); |
1412 } 1413 1414 return (ret); 1415} 1416 1417typedef struct upgrade_cbdata { 1418 uint64_t cb_numupgraded; 1419 uint64_t cb_numsamegraded; --- 178 unchanged lines hidden (view full) --- 1598 "version/zpl/N\n\n"); 1599 (void) printf(gettext("Where 'N' is the version number.\n")); 1600 ret = 0; 1601 } else if (argc || all) { 1602 /* Upgrade filesystems */ 1603 if (cb.cb_version == 0) 1604 cb.cb_version = ZPL_VERSION; 1605 ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM, |
1606 NULL, NULL, 0, upgrade_set_callback, &cb); |
1607 (void) printf(gettext("%llu filesystems upgraded\n"), 1608 cb.cb_numupgraded); 1609 if (cb.cb_numsamegraded) { 1610 (void) printf(gettext("%llu filesystems already at " 1611 "this version\n"), 1612 cb.cb_numsamegraded); 1613 } 1614 if (cb.cb_numfailed != 0) 1615 ret = 1; 1616 } else { 1617 /* List old-version filesytems */ 1618 boolean_t found; 1619 (void) printf(gettext("This system is currently running " 1620 "ZFS filesystem version %llu.\n\n"), ZPL_VERSION); 1621 1622 flags |= ZFS_ITER_RECURSE; 1623 ret = zfs_for_each(0, NULL, flags, ZFS_TYPE_FILESYSTEM, |
1624 NULL, NULL, 0, upgrade_list_callback, &cb); |
1625 1626 found = cb.cb_foundone; 1627 cb.cb_foundone = B_FALSE; 1628 cb.cb_newer = B_TRUE; 1629 1630 ret = zfs_for_each(0, NULL, flags, ZFS_TYPE_FILESYSTEM, |
1631 NULL, NULL, 0, upgrade_list_callback, &cb); |
1632 1633 if (!cb.cb_foundone && !found) { 1634 (void) printf(gettext("All filesystems are " 1635 "formatted with the current version.\n")); 1636 } 1637 } 1638 1639 return (ret); 1640} 1641 1642/* |
1643 * list [-r][-d max] [-H] [-o property[,property]...] [-t type[,type]...] |
1644 * [-s property [-s property]...] [-S property [-S property]...] 1645 * <dataset> ... 1646 * 1647 * -r Recurse over all children |
1648 * -d Limit recursion by depth. |
1649 * -H Scripted mode; elide headers and separate columns by tabs 1650 * -o Control which fields to display. 1651 * -t Control which object types to display. 1652 * -s Specify sort columns, descending order. 1653 * -S Specify sort columns, ascending order. 1654 * 1655 * When given no arguments, lists all filesystems in the system. 1656 * Otherwise, list the specified datasets, optionally recursing down them if --- 133 unchanged lines hidden (view full) --- 1790 boolean_t scripted = B_FALSE; 1791 static char default_fields[] = 1792 "name,used,available,referenced,mountpoint"; 1793 int types = ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME; 1794 boolean_t types_specified = B_FALSE; 1795 char *fields = NULL; 1796 list_cbdata_t cb = { 0 }; 1797 char *value; |
1798 int limit = 0; |
1799 int ret; 1800 zfs_sort_column_t *sortcol = NULL; 1801 int flags = ZFS_ITER_PROP_LISTSNAPS | ZFS_ITER_ARGS_CAN_BE_PATHS; 1802 1803 /* check options */ |
1804 while ((c = getopt(argc, argv, ":d:o:rt:Hs:S:")) != -1) { |
1805 switch (c) { 1806 case 'o': 1807 fields = optarg; 1808 break; |
1809 case 'd': 1810 limit = parse_depth(optarg, &flags); 1811 break; |
1812 case 'r': 1813 flags |= ZFS_ITER_RECURSE; 1814 break; 1815 case 'H': 1816 scripted = B_TRUE; 1817 break; 1818 case 's': 1819 if (zfs_add_sort_column(&sortcol, optarg, --- 74 unchanged lines hidden (view full) --- 1894 if (zprop_get_list(g_zfs, fields, &cb.cb_proplist, ZFS_TYPE_DATASET) 1895 != 0) 1896 usage(B_FALSE); 1897 1898 cb.cb_scripted = scripted; 1899 cb.cb_first = B_TRUE; 1900 1901 ret = zfs_for_each(argc, argv, flags, types, sortcol, &cb.cb_proplist, |
1902 limit, list_callback, &cb); |
1903 1904 zprop_free_list(cb.cb_proplist); 1905 zfs_free_sort_columns(sortcol); 1906 1907 if (ret == 0 && cb.cb_first && !cb.cb_scripted) 1908 (void) printf(gettext("no datasets available\n")); 1909 1910 return (ret); --- 366 unchanged lines hidden (view full) --- 2277 2278 if (*cb.cb_propname == '\0') { 2279 (void) fprintf(stderr, 2280 gettext("missing property in property=value argument\n")); 2281 usage(B_FALSE); 2282 } 2283 2284 ret = zfs_for_each(argc - 2, argv + 2, NULL, |
2285 ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, &cb); |
2286 2287 return (ret); 2288} 2289 2290/* 2291 * zfs snapshot [-r] [-o prop=value] ... <fs@snap> 2292 * 2293 * Creates a snapshot with the given name. While functionally equivalent to --- 617 unchanged lines hidden (view full) --- 2911 if (parse_allow_args(&argc, &argv, B_TRUE, 2912 &ds, &recurse, &zperms) == -1) 2913 return (1); 2914 2915 if (recurse) 2916 flags |= ZFS_ITER_RECURSE; 2917 error = zfs_for_each(argc, argv, flags, 2918 ZFS_TYPE_FILESYSTEM|ZFS_TYPE_VOLUME, NULL, |
2919 NULL, 0, unallow_callback, (void *)zperms); |
2920 2921 if (zperms) 2922 nvlist_free(zperms); 2923 2924 return (error); 2925} 2926 2927typedef struct get_all_cbdata { --- 1416 unchanged lines hidden --- |