zfs_main.c (207627) | zfs_main.c (209962) |
---|---|
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 --- 25 unchanged lines hidden (view full) --- 34#include <locale.h> 35#include <stddef.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <strings.h> 39#include <unistd.h> 40#include <fcntl.h> 41#include <zone.h> | 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 --- 25 unchanged lines hidden (view full) --- 34#include <locale.h> 35#include <stddef.h> 36#include <stdio.h> 37#include <stdlib.h> 38#include <strings.h> 39#include <unistd.h> 40#include <fcntl.h> 41#include <zone.h> |
42#include <grp.h> 43#include <pwd.h> |
|
42#include <sys/mntent.h> 43#include <sys/mnttab.h> 44#include <sys/mount.h> 45#include <sys/stat.h> | 44#include <sys/mntent.h> 45#include <sys/mnttab.h> 46#include <sys/mount.h> 47#include <sys/stat.h> |
46#include <sys/avl.h> | 48#include <sys/fs/zfs.h> |
47 48#include <libzfs.h> 49#include <libuutil.h> 50 51#include "zfs_iter.h" 52#include "zfs_util.h" 53 54libzfs_handle_t *g_zfs; 55 56static FILE *mnttab_file; 57static char history_str[HIS_MAX_RECORD_LEN]; | 49 50#include <libzfs.h> 51#include <libuutil.h> 52 53#include "zfs_iter.h" 54#include "zfs_util.h" 55 56libzfs_handle_t *g_zfs; 57 58static FILE *mnttab_file; 59static char history_str[HIS_MAX_RECORD_LEN]; |
60const char *pypath = "/usr/lib/zfs/pyzfs.py"; |
|
58 59static int zfs_do_clone(int argc, char **argv); 60static int zfs_do_create(int argc, char **argv); 61static int zfs_do_destroy(int argc, char **argv); 62static int zfs_do_get(int argc, char **argv); 63static int zfs_do_inherit(int argc, char **argv); 64static int zfs_do_list(int argc, char **argv); 65static int zfs_do_mount(int argc, char **argv); 66static int zfs_do_rename(int argc, char **argv); 67static int zfs_do_rollback(int argc, char **argv); 68static int zfs_do_set(int argc, char **argv); 69static int zfs_do_upgrade(int argc, char **argv); 70static int zfs_do_snapshot(int argc, char **argv); 71static int zfs_do_unmount(int argc, char **argv); 72static int zfs_do_share(int argc, char **argv); 73static int zfs_do_unshare(int argc, char **argv); 74static int zfs_do_send(int argc, char **argv); 75static int zfs_do_receive(int argc, char **argv); 76static int zfs_do_promote(int argc, char **argv); | 61 62static int zfs_do_clone(int argc, char **argv); 63static int zfs_do_create(int argc, char **argv); 64static int zfs_do_destroy(int argc, char **argv); 65static int zfs_do_get(int argc, char **argv); 66static int zfs_do_inherit(int argc, char **argv); 67static int zfs_do_list(int argc, char **argv); 68static int zfs_do_mount(int argc, char **argv); 69static int zfs_do_rename(int argc, char **argv); 70static int zfs_do_rollback(int argc, char **argv); 71static int zfs_do_set(int argc, char **argv); 72static int zfs_do_upgrade(int argc, char **argv); 73static int zfs_do_snapshot(int argc, char **argv); 74static int zfs_do_unmount(int argc, char **argv); 75static int zfs_do_share(int argc, char **argv); 76static int zfs_do_unshare(int argc, char **argv); 77static int zfs_do_send(int argc, char **argv); 78static int zfs_do_receive(int argc, char **argv); 79static int zfs_do_promote(int argc, char **argv); |
77static int zfs_do_allow(int argc, char **argv); 78static int zfs_do_unallow(int argc, char **argv); | 80static int zfs_do_userspace(int argc, char **argv); 81static int zfs_do_python(int argc, char **argv); |
79static int zfs_do_jail(int argc, char **argv); 80static int zfs_do_unjail(int argc, char **argv); 81 82/* 83 * Enable a reasonable set of defaults for libumem debugging on DEBUG builds. 84 */ 85 86#ifdef DEBUG --- 27 unchanged lines hidden (view full) --- 114 HELP_ROLLBACK, 115 HELP_SEND, 116 HELP_SET, 117 HELP_SHARE, 118 HELP_SNAPSHOT, 119 HELP_UNMOUNT, 120 HELP_UNSHARE, 121 HELP_ALLOW, | 82static int zfs_do_jail(int argc, char **argv); 83static int zfs_do_unjail(int argc, char **argv); 84 85/* 86 * Enable a reasonable set of defaults for libumem debugging on DEBUG builds. 87 */ 88 89#ifdef DEBUG --- 27 unchanged lines hidden (view full) --- 117 HELP_ROLLBACK, 118 HELP_SEND, 119 HELP_SET, 120 HELP_SHARE, 121 HELP_SNAPSHOT, 122 HELP_UNMOUNT, 123 HELP_UNSHARE, 124 HELP_ALLOW, |
122 HELP_UNALLOW | 125 HELP_UNALLOW, 126 HELP_USERSPACE, 127 HELP_GROUPSPACE |
123} zfs_help_t; 124 125typedef struct zfs_command { 126 const char *name; 127 int (*func)(int argc, char **argv); 128 zfs_help_t usage; 129} zfs_command_t; 130 --- 17 unchanged lines hidden (view full) --- 148 { "rename", zfs_do_rename, HELP_RENAME }, 149 { NULL }, 150 { "list", zfs_do_list, HELP_LIST }, 151 { NULL }, 152 { "set", zfs_do_set, HELP_SET }, 153 { "get", zfs_do_get, HELP_GET }, 154 { "inherit", zfs_do_inherit, HELP_INHERIT }, 155 { "upgrade", zfs_do_upgrade, HELP_UPGRADE }, | 128} zfs_help_t; 129 130typedef struct zfs_command { 131 const char *name; 132 int (*func)(int argc, char **argv); 133 zfs_help_t usage; 134} zfs_command_t; 135 --- 17 unchanged lines hidden (view full) --- 153 { "rename", zfs_do_rename, HELP_RENAME }, 154 { NULL }, 155 { "list", zfs_do_list, HELP_LIST }, 156 { NULL }, 157 { "set", zfs_do_set, HELP_SET }, 158 { "get", zfs_do_get, HELP_GET }, 159 { "inherit", zfs_do_inherit, HELP_INHERIT }, 160 { "upgrade", zfs_do_upgrade, HELP_UPGRADE }, |
161 { "userspace", zfs_do_userspace, HELP_USERSPACE }, 162 { "groupspace", zfs_do_userspace, HELP_GROUPSPACE }, |
|
156 { NULL }, 157 { "mount", zfs_do_mount, HELP_MOUNT }, 158 { "unmount", zfs_do_unmount, HELP_UNMOUNT }, 159 { "share", zfs_do_share, HELP_SHARE }, 160 { "unshare", zfs_do_unshare, HELP_UNSHARE }, 161 { NULL }, 162 { "send", zfs_do_send, HELP_SEND }, 163 { "receive", zfs_do_receive, HELP_RECEIVE }, 164 { NULL }, | 163 { NULL }, 164 { "mount", zfs_do_mount, HELP_MOUNT }, 165 { "unmount", zfs_do_unmount, HELP_UNMOUNT }, 166 { "share", zfs_do_share, HELP_SHARE }, 167 { "unshare", zfs_do_unshare, HELP_UNSHARE }, 168 { NULL }, 169 { "send", zfs_do_send, HELP_SEND }, 170 { "receive", zfs_do_receive, HELP_RECEIVE }, 171 { NULL }, |
165 { "allow", zfs_do_allow, HELP_ALLOW }, | 172 { "allow", zfs_do_python, HELP_ALLOW }, |
166 { NULL }, | 173 { NULL }, |
167 { "unallow", zfs_do_unallow, HELP_UNALLOW }, | 174 { "unallow", zfs_do_python, HELP_UNALLOW }, |
168 { NULL }, 169 { "jail", zfs_do_jail, HELP_JAIL }, 170 { "unjail", zfs_do_unjail, HELP_UNJAIL }, 171}; 172 173#define NCOMMAND (sizeof (command_table) / sizeof (command_table[0])) 174 175zfs_command_t *current_command; --- 79 unchanged lines hidden (view full) --- 255 "<\"everyone\"|user|group>[,...]\n" 256 "\t [<perm|@setname>[,...]] <filesystem|volume>\n" 257 "\tunallow [-rld] -e [<perm|@setname>[,...]] " 258 "<filesystem|volume>\n" 259 "\tunallow [-r] -c [<perm|@setname>[,...]] " 260 "<filesystem|volume>\n" 261 "\tunallow [-r] -s @setname [<perm|@setname>[,...]] " 262 "<filesystem|volume>\n")); | 175 { NULL }, 176 { "jail", zfs_do_jail, HELP_JAIL }, 177 { "unjail", zfs_do_unjail, HELP_UNJAIL }, 178}; 179 180#define NCOMMAND (sizeof (command_table) / sizeof (command_table[0])) 181 182zfs_command_t *current_command; --- 79 unchanged lines hidden (view full) --- 262 "<\"everyone\"|user|group>[,...]\n" 263 "\t [<perm|@setname>[,...]] <filesystem|volume>\n" 264 "\tunallow [-rld] -e [<perm|@setname>[,...]] " 265 "<filesystem|volume>\n" 266 "\tunallow [-r] -c [<perm|@setname>[,...]] " 267 "<filesystem|volume>\n" 268 "\tunallow [-r] -s @setname [<perm|@setname>[,...]] " 269 "<filesystem|volume>\n")); |
270 case HELP_USERSPACE: 271 return (gettext("\tuserspace [-hniHp] [-o field[,...]] " 272 "[-sS field] ... [-t type[,...]]\n" 273 "\t <filesystem|snapshot>\n")); 274 case HELP_GROUPSPACE: 275 return (gettext("\tgroupspace [-hniHpU] [-o field[,...]] " 276 "[-sS field] ... [-t type[,...]]\n" 277 "\t <filesystem|snapshot>\n")); |
|
263 } 264 265 abort(); 266 /* NOTREACHED */ 267} 268 269/* 270 * Utility function to guarantee malloc() success. --- 45 unchanged lines hidden (view full) --- 316 * that command. Otherwise, iterate over the entire command table and display 317 * a complete usage message. 318 */ 319static void 320usage(boolean_t requested) 321{ 322 int i; 323 boolean_t show_properties = B_FALSE; | 278 } 279 280 abort(); 281 /* NOTREACHED */ 282} 283 284/* 285 * Utility function to guarantee malloc() success. --- 45 unchanged lines hidden (view full) --- 331 * that command. Otherwise, iterate over the entire command table and display 332 * a complete usage message. 333 */ 334static void 335usage(boolean_t requested) 336{ 337 int i; 338 boolean_t show_properties = B_FALSE; |
324 boolean_t show_permissions = B_FALSE; | |
325 FILE *fp = requested ? stdout : stderr; 326 327 if (current_command == NULL) { 328 329 (void) fprintf(fp, gettext("usage: zfs command args ...\n")); 330 (void) fprintf(fp, 331 gettext("where 'command' is one of the following:\n\n")); 332 --- 14 unchanged lines hidden (view full) --- 347 348 if (current_command != NULL && 349 (strcmp(current_command->name, "set") == 0 || 350 strcmp(current_command->name, "get") == 0 || 351 strcmp(current_command->name, "inherit") == 0 || 352 strcmp(current_command->name, "list") == 0)) 353 show_properties = B_TRUE; 354 | 339 FILE *fp = requested ? stdout : stderr; 340 341 if (current_command == NULL) { 342 343 (void) fprintf(fp, gettext("usage: zfs command args ...\n")); 344 (void) fprintf(fp, 345 gettext("where 'command' is one of the following:\n\n")); 346 --- 14 unchanged lines hidden (view full) --- 361 362 if (current_command != NULL && 363 (strcmp(current_command->name, "set") == 0 || 364 strcmp(current_command->name, "get") == 0 || 365 strcmp(current_command->name, "inherit") == 0 || 366 strcmp(current_command->name, "list") == 0)) 367 show_properties = B_TRUE; 368 |
355 if (current_command != NULL && 356 (strcmp(current_command->name, "allow") == 0 || 357 strcmp(current_command->name, "unallow") == 0)) 358 show_permissions = B_TRUE; 359 | |
360 if (show_properties) { | 369 if (show_properties) { |
361 | |
362 (void) fprintf(fp, 363 gettext("\nThe following properties are supported:\n")); 364 365 (void) fprintf(fp, "\n\t%-14s %s %s %s\n\n", 366 "PROPERTY", "EDIT", "INHERIT", "VALUES"); 367 368 /* Iterate over all properties */ 369 (void) zprop_iter(usage_prop_cb, fp, B_FALSE, B_TRUE, 370 ZFS_TYPE_DATASET); 371 | 370 (void) fprintf(fp, 371 gettext("\nThe following properties are supported:\n")); 372 373 (void) fprintf(fp, "\n\t%-14s %s %s %s\n\n", 374 "PROPERTY", "EDIT", "INHERIT", "VALUES"); 375 376 /* Iterate over all properties */ 377 (void) zprop_iter(usage_prop_cb, fp, B_FALSE, B_TRUE, 378 ZFS_TYPE_DATASET); 379 |
380 (void) fprintf(fp, "\t%-15s ", "userused@..."); 381 (void) fprintf(fp, " NO NO <size>\n"); 382 (void) fprintf(fp, "\t%-15s ", "groupused@..."); 383 (void) fprintf(fp, " NO NO <size>\n"); 384 (void) fprintf(fp, "\t%-15s ", "userquota@..."); 385 (void) fprintf(fp, "YES NO <size> | none\n"); 386 (void) fprintf(fp, "\t%-15s ", "groupquota@..."); 387 (void) fprintf(fp, "YES NO <size> | none\n"); 388 |
|
372 (void) fprintf(fp, gettext("\nSizes are specified in bytes " 373 "with standard units such as K, M, G, etc.\n")); 374 (void) fprintf(fp, gettext("\nUser-defined properties can " 375 "be specified by using a name containing a colon (:).\n")); | 389 (void) fprintf(fp, gettext("\nSizes are specified in bytes " 390 "with standard units such as K, M, G, etc.\n")); 391 (void) fprintf(fp, gettext("\nUser-defined properties can " 392 "be specified by using a name containing a colon (:).\n")); |
376 377 } else if (show_permissions) { 378 (void) fprintf(fp, 379 gettext("\nThe following permissions are supported:\n")); 380 381 zfs_deleg_permissions(); | 393 (void) fprintf(fp, gettext("\nThe {user|group}{used|quota}@ " 394 "properties must be appended with\n" 395 "a user or group specifier of one of these forms:\n" 396 " POSIX name (eg: \"matt\")\n" 397 " POSIX id (eg: \"126829\")\n" 398 " SMB name@domain (eg: \"matt@sun\")\n" 399 " SMB SID (eg: \"S-1-234-567-89\")\n")); |
382 } else { | 400 } else { |
383 /* 384 * TRANSLATION NOTE: 385 * "zfs set|get" must not be localised this is the 386 * command name and arguments. 387 */ 388 | |
389 (void) fprintf(fp, | 401 (void) fprintf(fp, |
390 gettext("\nFor the property list, run: zfs set|get\n")); 391 | 402 gettext("\nFor the property list, run: %s\n"), 403 "zfs set|get"); |
392 (void) fprintf(fp, | 404 (void) fprintf(fp, |
393 gettext("\nFor the delegated permission list, run:" 394 " zfs allow|unallow\n")); | 405 gettext("\nFor the delegated permission list, run: %s\n"), 406 "zfs allow|unallow"); |
395 } 396 397 /* 398 * See comments at end of main(). 399 */ 400 if (getenv("ZFS_ABORT") != NULL) { 401 (void) printf("dumping core by request\n"); 402 abort(); --- 21 unchanged lines hidden (view full) --- 424 return (-1); 425 } 426 if (nvlist_add_string(props, propname, propval) != 0) { 427 (void) fprintf(stderr, gettext("internal " 428 "error: out of memory\n")); 429 return (-1); 430 } 431 return (0); | 407 } 408 409 /* 410 * See comments at end of main(). 411 */ 412 if (getenv("ZFS_ABORT") != NULL) { 413 (void) printf("dumping core by request\n"); 414 abort(); --- 21 unchanged lines hidden (view full) --- 436 return (-1); 437 } 438 if (nvlist_add_string(props, propname, propval) != 0) { 439 (void) fprintf(stderr, gettext("internal " 440 "error: out of memory\n")); 441 return (-1); 442 } 443 return (0); |
432 | |
433} 434 435static int 436parse_depth(char *opt, int *flags) 437{ 438 char *tmp; 439 int depth; 440 --- 655 unchanged lines hidden (view full) --- 1096 } 1097 sourcetype = ZPROP_SRC_NONE; 1098 (void) strlcpy(buf, "-", sizeof (buf)); 1099 } 1100 1101 zprop_print_one_property(zfs_get_name(zhp), cbp, 1102 zfs_prop_to_name(pl->pl_prop), 1103 buf, sourcetype, source); | 444} 445 446static int 447parse_depth(char *opt, int *flags) 448{ 449 char *tmp; 450 int depth; 451 --- 655 unchanged lines hidden (view full) --- 1107 } 1108 sourcetype = ZPROP_SRC_NONE; 1109 (void) strlcpy(buf, "-", sizeof (buf)); 1110 } 1111 1112 zprop_print_one_property(zfs_get_name(zhp), cbp, 1113 zfs_prop_to_name(pl->pl_prop), 1114 buf, sourcetype, source); |
1115 } else if (zfs_prop_userquota(pl->pl_user_prop)) { 1116 sourcetype = ZPROP_SRC_LOCAL; 1117 1118 if (zfs_prop_get_userquota(zhp, pl->pl_user_prop, 1119 buf, sizeof (buf), cbp->cb_literal) != 0) { 1120 sourcetype = ZPROP_SRC_NONE; 1121 (void) strlcpy(buf, "-", sizeof (buf)); 1122 } 1123 1124 zprop_print_one_property(zfs_get_name(zhp), cbp, 1125 pl->pl_user_prop, buf, sourcetype, source); |
|
1104 } else { 1105 if (nvlist_lookup_nvlist(userprop, 1106 pl->pl_user_prop, &propval) != 0) { 1107 if (pl->pl_all) 1108 continue; 1109 sourcetype = ZPROP_SRC_NONE; 1110 strval = "-"; 1111 } else { --- 360 unchanged lines hidden (view full) --- 1472 return (0); 1473} 1474 1475static int 1476upgrade_set_callback(zfs_handle_t *zhp, void *data) 1477{ 1478 upgrade_cbdata_t *cb = data; 1479 int version = zfs_prop_get_int(zhp, ZFS_PROP_VERSION); | 1126 } else { 1127 if (nvlist_lookup_nvlist(userprop, 1128 pl->pl_user_prop, &propval) != 0) { 1129 if (pl->pl_all) 1130 continue; 1131 sourcetype = ZPROP_SRC_NONE; 1132 strval = "-"; 1133 } else { --- 360 unchanged lines hidden (view full) --- 1494 return (0); 1495} 1496 1497static int 1498upgrade_set_callback(zfs_handle_t *zhp, void *data) 1499{ 1500 upgrade_cbdata_t *cb = data; 1501 int version = zfs_prop_get_int(zhp, ZFS_PROP_VERSION); |
1502 int i; 1503 static struct { int zplver; int spaver; } table[] = { 1504 {ZPL_VERSION_FUID, SPA_VERSION_FUID}, 1505 {ZPL_VERSION_USERSPACE, SPA_VERSION_USERSPACE}, 1506 {0, 0} 1507 }; |
|
1480 | 1508 |
1481 if (cb->cb_version >= ZPL_VERSION_FUID) { 1482 int spa_version; | |
1483 | 1509 |
1484 if (zfs_spa_version(zhp, &spa_version) < 0) 1485 return (-1); | 1510 for (i = 0; table[i].zplver; i++) { 1511 if (cb->cb_version >= table[i].zplver) { 1512 int spa_version; |
1486 | 1513 |
1487 if (spa_version < SPA_VERSION_FUID) { 1488 /* can't upgrade */ 1489 (void) printf(gettext("%s: can not be upgraded; " 1490 "the pool version needs to first be upgraded\nto " 1491 "version %d\n\n"), 1492 zfs_get_name(zhp), SPA_VERSION_FUID); 1493 cb->cb_numfailed++; 1494 return (0); | 1514 if (zfs_spa_version(zhp, &spa_version) < 0) 1515 return (-1); 1516 1517 if (spa_version < table[i].spaver) { 1518 /* can't upgrade */ 1519 (void) printf(gettext("%s: can not be " 1520 "upgraded; the pool version needs to first " 1521 "be upgraded\nto version %d\n\n"), 1522 zfs_get_name(zhp), table[i].spaver); 1523 cb->cb_numfailed++; 1524 return (0); 1525 } |
1495 } 1496 } 1497 1498 /* upgrade */ 1499 if (version < cb->cb_version) { 1500 char verstr[16]; 1501 (void) snprintf(verstr, sizeof (verstr), 1502 "%llu", cb->cb_version); --- 84 unchanged lines hidden (view full) --- 1587 "supported:\n\n")); 1588 (void) printf(gettext("VER DESCRIPTION\n")); 1589 (void) printf("--- -----------------------------------------" 1590 "---------------\n"); 1591 (void) printf(gettext(" 1 Initial ZFS filesystem version\n")); 1592 (void) printf(gettext(" 2 Enhanced directory entries\n")); 1593 (void) printf(gettext(" 3 Case insensitive and File system " 1594 "unique identifer (FUID)\n")); | 1526 } 1527 } 1528 1529 /* upgrade */ 1530 if (version < cb->cb_version) { 1531 char verstr[16]; 1532 (void) snprintf(verstr, sizeof (verstr), 1533 "%llu", cb->cb_version); --- 84 unchanged lines hidden (view full) --- 1618 "supported:\n\n")); 1619 (void) printf(gettext("VER DESCRIPTION\n")); 1620 (void) printf("--- -----------------------------------------" 1621 "---------------\n"); 1622 (void) printf(gettext(" 1 Initial ZFS filesystem version\n")); 1623 (void) printf(gettext(" 2 Enhanced directory entries\n")); 1624 (void) printf(gettext(" 3 Case insensitive and File system " 1625 "unique identifer (FUID)\n")); |
1626 (void) printf(gettext(" 4 userquota, groupquota " 1627 "properties\n")); |
|
1595 (void) printf(gettext("\nFor more information on a particular " 1596 "version, including supported releases, see:\n\n")); 1597 (void) printf("http://www.opensolaris.org/os/community/zfs/" 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 */ --- 32 unchanged lines hidden (view full) --- 1635 "formatted with the current version.\n")); 1636 } 1637 } 1638 1639 return (ret); 1640} 1641 1642/* | 1628 (void) printf(gettext("\nFor more information on a particular " 1629 "version, including supported releases, see:\n\n")); 1630 (void) printf("http://www.opensolaris.org/os/community/zfs/" 1631 "version/zpl/N\n\n"); 1632 (void) printf(gettext("Where 'N' is the version number.\n")); 1633 ret = 0; 1634 } else if (argc || all) { 1635 /* Upgrade filesystems */ --- 32 unchanged lines hidden (view full) --- 1668 "formatted with the current version.\n")); 1669 } 1670 } 1671 1672 return (ret); 1673} 1674 1675/* |
1676 * zfs userspace 1677 */ 1678static int 1679userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space) 1680{ 1681 zfs_userquota_prop_t *typep = arg; 1682 zfs_userquota_prop_t p = *typep; 1683 char *name = NULL; 1684 char *ug, *propname; 1685 char namebuf[32]; 1686 char sizebuf[32]; 1687 1688 if (domain == NULL || domain[0] == '\0') { 1689 if (p == ZFS_PROP_GROUPUSED || p == ZFS_PROP_GROUPQUOTA) { 1690 struct group *g = getgrgid(rid); 1691 if (g) 1692 name = g->gr_name; 1693 } else { 1694 struct passwd *p = getpwuid(rid); 1695 if (p) 1696 name = p->pw_name; 1697 } 1698 } 1699 1700 if (p == ZFS_PROP_GROUPUSED || p == ZFS_PROP_GROUPQUOTA) 1701 ug = "group"; 1702 else 1703 ug = "user"; 1704 1705 if (p == ZFS_PROP_USERUSED || p == ZFS_PROP_GROUPUSED) 1706 propname = "used"; 1707 else 1708 propname = "quota"; 1709 1710 if (name == NULL) { 1711 (void) snprintf(namebuf, sizeof (namebuf), 1712 "%llu", (longlong_t)rid); 1713 name = namebuf; 1714 } 1715 zfs_nicenum(space, sizebuf, sizeof (sizebuf)); 1716 1717 (void) printf("%s %s %s%c%s %s\n", propname, ug, domain, 1718 domain[0] ? '-' : ' ', name, sizebuf); 1719 1720 return (0); 1721} 1722 1723static int 1724zfs_do_userspace(int argc, char **argv) 1725{ 1726 zfs_handle_t *zhp; 1727 zfs_userquota_prop_t p; 1728 int error; 1729 1730 /* 1731 * Try the python version. If the execv fails, we'll continue 1732 * and do a simplistic implementation. 1733 */ 1734 (void) execv(pypath, argv-1); 1735 1736 (void) printf("internal error: %s not found\n" 1737 "falling back on built-in implementation, " 1738 "some features will not work\n", pypath); 1739 1740 if ((zhp = zfs_open(g_zfs, argv[argc-1], ZFS_TYPE_DATASET)) == NULL) 1741 return (1); 1742 1743 (void) printf("PROP TYPE NAME VALUE\n"); 1744 1745 for (p = 0; p < ZFS_NUM_USERQUOTA_PROPS; p++) { 1746 error = zfs_userspace(zhp, p, userspace_cb, &p); 1747 if (error) 1748 break; 1749 } 1750 return (error); 1751} 1752 1753/* |
|
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. --- 72 unchanged lines hidden (view full) --- 1723 if (scripted) 1724 (void) printf("\t"); 1725 else 1726 (void) printf(" "); 1727 } else { 1728 first = B_FALSE; 1729 } 1730 | 1754 * list [-r][-d max] [-H] [-o property[,property]...] [-t type[,type]...] 1755 * [-s property [-s property]...] [-S property [-S property]...] 1756 * <dataset> ... 1757 * 1758 * -r Recurse over all children 1759 * -d Limit recursion by depth. 1760 * -H Scripted mode; elide headers and separate columns by tabs 1761 * -o Control which fields to display. --- 72 unchanged lines hidden (view full) --- 1834 if (scripted) 1835 (void) printf("\t"); 1836 else 1837 (void) printf(" "); 1838 } else { 1839 first = B_FALSE; 1840 } 1841 |
1731 right_justify = B_FALSE; | |
1732 if (pl->pl_prop != ZPROP_INVAL) { 1733 if (zfs_prop_get(zhp, pl->pl_prop, property, 1734 sizeof (property), NULL, NULL, 0, B_FALSE) != 0) 1735 propstr = "-"; 1736 else 1737 propstr = property; 1738 1739 right_justify = zfs_prop_align_right(pl->pl_prop); | 1842 if (pl->pl_prop != ZPROP_INVAL) { 1843 if (zfs_prop_get(zhp, pl->pl_prop, property, 1844 sizeof (property), NULL, NULL, 0, B_FALSE) != 0) 1845 propstr = "-"; 1846 else 1847 propstr = property; 1848 1849 right_justify = zfs_prop_align_right(pl->pl_prop); |
1850 } else if (zfs_prop_userquota(pl->pl_user_prop)) { 1851 if (zfs_prop_get_userquota(zhp, pl->pl_user_prop, 1852 property, sizeof (property), B_FALSE) != 0) 1853 propstr = "-"; 1854 else 1855 propstr = property; 1856 right_justify = B_TRUE; |
|
1740 } else { 1741 if (nvlist_lookup_nvlist(userprops, 1742 pl->pl_user_prop, &propval) != 0) 1743 propstr = "-"; 1744 else 1745 verify(nvlist_lookup_string(propval, 1746 ZPROP_VALUE, &propstr) == 0); | 1857 } else { 1858 if (nvlist_lookup_nvlist(userprops, 1859 pl->pl_user_prop, &propval) != 0) 1860 propstr = "-"; 1861 else 1862 verify(nvlist_lookup_string(propval, 1863 ZPROP_VALUE, &propstr) == 0); |
1864 right_justify = B_FALSE; |
|
1747 } 1748 1749 width = pl->pl_width; 1750 1751 /* 1752 * If this is being called in scripted mode, or if this is the 1753 * last column and it is left-justified, don't include a width 1754 * format specifier. --- 521 unchanged lines hidden (view full) --- 2276 cb.cb_value++; 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 | 1865 } 1866 1867 width = pl->pl_width; 1868 1869 /* 1870 * If this is being called in scripted mode, or if this is the 1871 * last column and it is left-justified, don't include a width 1872 * format specifier. --- 521 unchanged lines hidden (view full) --- 2394 cb.cb_value++; 2395 2396 if (*cb.cb_propname == '\0') { 2397 (void) fprintf(stderr, 2398 gettext("missing property in property=value argument\n")); 2399 usage(B_FALSE); 2400 } 2401 |
2284 ret = zfs_for_each(argc - 2, argv + 2, NULL, | 2402 ret = zfs_for_each(argc - 2, argv + 2, 0, |
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 * --- 244 unchanged lines hidden (view full) --- 2537 return (1); 2538 } 2539 2540 err = zfs_receive(g_zfs, argv[0], flags, STDIN_FILENO, NULL); 2541 2542 return (err != 0); 2543} 2544 | 2403 ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, &cb); 2404 2405 return (ret); 2406} 2407 2408/* 2409 * zfs snapshot [-r] [-o prop=value] ... <fs@snap> 2410 * --- 244 unchanged lines hidden (view full) --- 2655 return (1); 2656 } 2657 2658 err = zfs_receive(g_zfs, argv[0], flags, STDIN_FILENO, NULL); 2659 2660 return (err != 0); 2661} 2662 |
2545typedef struct allow_cb { 2546 int a_permcnt; 2547 size_t a_treeoffset; 2548} allow_cb_t; 2549 2550static void 2551zfs_print_perms(avl_tree_t *tree) 2552{ 2553 zfs_perm_node_t *permnode; 2554 2555 permnode = avl_first(tree); 2556 while (permnode != NULL) { 2557 (void) printf("%s", permnode->z_pname); 2558 permnode = AVL_NEXT(tree, permnode); 2559 if (permnode) 2560 (void) printf(","); 2561 else 2562 (void) printf("\n"); 2563 } 2564} 2565 2566/* 2567 * Iterate over user/groups/everyone/... and the call perm_iter 2568 * function to print actual permission when tree has >0 nodes. 2569 */ 2570static void 2571zfs_iter_perms(avl_tree_t *tree, const char *banner, allow_cb_t *cb) 2572{ 2573 zfs_allow_node_t *item; 2574 avl_tree_t *ptree; 2575 2576 item = avl_first(tree); 2577 while (item) { 2578 ptree = (void *)((char *)item + cb->a_treeoffset); 2579 if (avl_numnodes(ptree)) { 2580 if (cb->a_permcnt++ == 0) 2581 (void) printf("%s\n", banner); 2582 (void) printf("\t%s", item->z_key); 2583 /* 2584 * Avoid an extra space being printed 2585 * for "everyone" which is keyed with a null 2586 * string 2587 */ 2588 if (item->z_key[0] != '\0') 2589 (void) printf(" "); 2590 zfs_print_perms(ptree); 2591 } 2592 item = AVL_NEXT(tree, item); 2593 } 2594} 2595 2596#define LINES "-------------------------------------------------------------\n" 2597static int 2598zfs_print_allows(char *ds) 2599{ 2600 zfs_allow_t *curperms, *perms; 2601 zfs_handle_t *zhp; 2602 allow_cb_t allowcb = { 0 }; 2603 char banner[MAXPATHLEN]; 2604 2605 if (ds[0] == '-') 2606 usage(B_FALSE); 2607 2608 if (strrchr(ds, '@')) { 2609 (void) fprintf(stderr, gettext("Snapshots don't have 'allow'" 2610 " permissions\n")); 2611 return (1); 2612 } 2613 if ((zhp = zfs_open(g_zfs, ds, ZFS_TYPE_DATASET)) == NULL) 2614 return (1); 2615 2616 if (zfs_perm_get(zhp, &perms)) { 2617 (void) fprintf(stderr, 2618 gettext("Failed to retrieve 'allows' on %s\n"), ds); 2619 zfs_close(zhp); 2620 return (1); 2621 } 2622 2623 zfs_close(zhp); 2624 2625 if (perms != NULL) 2626 (void) printf("%s", LINES); 2627 for (curperms = perms; curperms; curperms = curperms->z_next) { 2628 2629 (void) snprintf(banner, sizeof (banner), 2630 "Permission sets on (%s)", curperms->z_setpoint); 2631 allowcb.a_treeoffset = 2632 offsetof(zfs_allow_node_t, z_localdescend); 2633 allowcb.a_permcnt = 0; 2634 zfs_iter_perms(&curperms->z_sets, banner, &allowcb); 2635 2636 (void) snprintf(banner, sizeof (banner), 2637 "Create time permissions on (%s)", curperms->z_setpoint); 2638 allowcb.a_treeoffset = 2639 offsetof(zfs_allow_node_t, z_localdescend); 2640 allowcb.a_permcnt = 0; 2641 zfs_iter_perms(&curperms->z_crperms, banner, &allowcb); 2642 2643 2644 (void) snprintf(banner, sizeof (banner), 2645 "Local permissions on (%s)", curperms->z_setpoint); 2646 allowcb.a_treeoffset = offsetof(zfs_allow_node_t, z_local); 2647 allowcb.a_permcnt = 0; 2648 zfs_iter_perms(&curperms->z_user, banner, &allowcb); 2649 zfs_iter_perms(&curperms->z_group, banner, &allowcb); 2650 zfs_iter_perms(&curperms->z_everyone, banner, &allowcb); 2651 2652 (void) snprintf(banner, sizeof (banner), 2653 "Descendent permissions on (%s)", curperms->z_setpoint); 2654 allowcb.a_treeoffset = offsetof(zfs_allow_node_t, z_descend); 2655 allowcb.a_permcnt = 0; 2656 zfs_iter_perms(&curperms->z_user, banner, &allowcb); 2657 zfs_iter_perms(&curperms->z_group, banner, &allowcb); 2658 zfs_iter_perms(&curperms->z_everyone, banner, &allowcb); 2659 2660 (void) snprintf(banner, sizeof (banner), 2661 "Local+Descendent permissions on (%s)", 2662 curperms->z_setpoint); 2663 allowcb.a_treeoffset = 2664 offsetof(zfs_allow_node_t, z_localdescend); 2665 allowcb.a_permcnt = 0; 2666 zfs_iter_perms(&curperms->z_user, banner, &allowcb); 2667 zfs_iter_perms(&curperms->z_group, banner, &allowcb); 2668 zfs_iter_perms(&curperms->z_everyone, banner, &allowcb); 2669 2670 (void) printf("%s", LINES); 2671 } 2672 zfs_free_allows(perms); 2673 return (0); 2674} 2675 2676#define ALLOWOPTIONS "ldcsu:g:e" 2677#define UNALLOWOPTIONS "ldcsu:g:er" 2678 2679/* 2680 * Validate options, and build necessary datastructure to display/remove/add 2681 * permissions. 2682 * Returns 0 - If permissions should be added/removed 2683 * Returns 1 - If permissions should be displayed. 2684 * Returns -1 - on failure 2685 */ 2686int 2687parse_allow_args(int *argc, char **argv[], boolean_t unallow, 2688 char **ds, int *recurse, nvlist_t **zperms) 2689{ 2690 int c; 2691 char *options = unallow ? UNALLOWOPTIONS : ALLOWOPTIONS; 2692 zfs_deleg_inherit_t deleg_type = ZFS_DELEG_NONE; 2693 zfs_deleg_who_type_t who_type = ZFS_DELEG_WHO_UNKNOWN; 2694 char *who = NULL; 2695 char *perms = NULL; 2696 zfs_handle_t *zhp; 2697 2698 while ((c = getopt(*argc, *argv, options)) != -1) { 2699 switch (c) { 2700 case 'l': 2701 if (who_type == ZFS_DELEG_CREATE || 2702 who_type == ZFS_DELEG_NAMED_SET) 2703 usage(B_FALSE); 2704 2705 deleg_type |= ZFS_DELEG_PERM_LOCAL; 2706 break; 2707 case 'd': 2708 if (who_type == ZFS_DELEG_CREATE || 2709 who_type == ZFS_DELEG_NAMED_SET) 2710 usage(B_FALSE); 2711 2712 deleg_type |= ZFS_DELEG_PERM_DESCENDENT; 2713 break; 2714 case 'r': 2715 *recurse = B_TRUE; 2716 break; 2717 case 'c': 2718 if (who_type != ZFS_DELEG_WHO_UNKNOWN) 2719 usage(B_FALSE); 2720 if (deleg_type) 2721 usage(B_FALSE); 2722 who_type = ZFS_DELEG_CREATE; 2723 break; 2724 case 's': 2725 if (who_type != ZFS_DELEG_WHO_UNKNOWN) 2726 usage(B_FALSE); 2727 if (deleg_type) 2728 usage(B_FALSE); 2729 who_type = ZFS_DELEG_NAMED_SET; 2730 break; 2731 case 'u': 2732 if (who_type != ZFS_DELEG_WHO_UNKNOWN) 2733 usage(B_FALSE); 2734 who_type = ZFS_DELEG_USER; 2735 who = optarg; 2736 break; 2737 case 'g': 2738 if (who_type != ZFS_DELEG_WHO_UNKNOWN) 2739 usage(B_FALSE); 2740 who_type = ZFS_DELEG_GROUP; 2741 who = optarg; 2742 break; 2743 case 'e': 2744 if (who_type != ZFS_DELEG_WHO_UNKNOWN) 2745 usage(B_FALSE); 2746 who_type = ZFS_DELEG_EVERYONE; 2747 break; 2748 default: 2749 usage(B_FALSE); 2750 break; 2751 } 2752 } 2753 2754 if (deleg_type == 0) 2755 deleg_type = ZFS_DELEG_PERM_LOCALDESCENDENT; 2756 2757 *argc -= optind; 2758 *argv += optind; 2759 2760 if (unallow == B_FALSE && *argc == 1) { 2761 /* 2762 * Only print permissions if no options were processed 2763 */ 2764 if (optind == 1) 2765 return (1); 2766 else 2767 usage(B_FALSE); 2768 } 2769 2770 /* 2771 * initialize variables for zfs_build_perms based on number 2772 * of arguments. 2773 * 3 arguments ==> zfs [un]allow joe perm,perm,perm <dataset> or 2774 * zfs [un]allow -s @set1 perm,perm <dataset> 2775 * 2 arguments ==> zfs [un]allow -c perm,perm <dataset> or 2776 * zfs [un]allow -u|-g <name> perm <dataset> or 2777 * zfs [un]allow -e perm,perm <dataset> 2778 * zfs unallow joe <dataset> 2779 * zfs unallow -s @set1 <dataset> 2780 * 1 argument ==> zfs [un]allow -e <dataset> or 2781 * zfs [un]allow -c <dataset> 2782 */ 2783 2784 switch (*argc) { 2785 case 3: 2786 perms = (*argv)[1]; 2787 who = (*argv)[0]; 2788 *ds = (*argv)[2]; 2789 2790 /* 2791 * advance argc/argv for do_allow cases. 2792 * for do_allow case make sure who have a know who type 2793 * and its not a permission set. 2794 */ 2795 if (unallow == B_TRUE) { 2796 *argc -= 2; 2797 *argv += 2; 2798 } else if (who_type != ZFS_DELEG_WHO_UNKNOWN && 2799 who_type != ZFS_DELEG_NAMED_SET) 2800 usage(B_FALSE); 2801 break; 2802 2803 case 2: 2804 if (unallow == B_TRUE && (who_type == ZFS_DELEG_EVERYONE || 2805 who_type == ZFS_DELEG_CREATE || who != NULL)) { 2806 perms = (*argv)[0]; 2807 *ds = (*argv)[1]; 2808 } else { 2809 if (unallow == B_FALSE && 2810 (who_type == ZFS_DELEG_WHO_UNKNOWN || 2811 who_type == ZFS_DELEG_NAMED_SET)) 2812 usage(B_FALSE); 2813 else if (who_type == ZFS_DELEG_WHO_UNKNOWN || 2814 who_type == ZFS_DELEG_NAMED_SET) 2815 who = (*argv)[0]; 2816 else if (who_type != ZFS_DELEG_NAMED_SET) 2817 perms = (*argv)[0]; 2818 *ds = (*argv)[1]; 2819 } 2820 if (unallow == B_TRUE) { 2821 (*argc)--; 2822 (*argv)++; 2823 } 2824 break; 2825 2826 case 1: 2827 if (unallow == B_FALSE) 2828 usage(B_FALSE); 2829 if (who == NULL && who_type != ZFS_DELEG_CREATE && 2830 who_type != ZFS_DELEG_EVERYONE) 2831 usage(B_FALSE); 2832 *ds = (*argv)[0]; 2833 break; 2834 2835 default: 2836 usage(B_FALSE); 2837 } 2838 2839 if (strrchr(*ds, '@')) { 2840 (void) fprintf(stderr, 2841 gettext("Can't set or remove 'allow' permissions " 2842 "on snapshots.\n")); 2843 return (-1); 2844 } 2845 2846 if ((zhp = zfs_open(g_zfs, *ds, ZFS_TYPE_DATASET)) == NULL) 2847 return (-1); 2848 2849 if ((zfs_build_perms(zhp, who, perms, 2850 who_type, deleg_type, zperms)) != 0) { 2851 zfs_close(zhp); 2852 return (-1); 2853 } 2854 zfs_close(zhp); 2855 return (0); 2856} 2857 2858static int 2859zfs_do_allow(int argc, char **argv) 2860{ 2861 char *ds; 2862 nvlist_t *zperms = NULL; 2863 zfs_handle_t *zhp; 2864 int unused; 2865 int ret; 2866 2867 if ((ret = parse_allow_args(&argc, &argv, B_FALSE, &ds, 2868 &unused, &zperms)) == -1) 2869 return (1); 2870 2871 if (ret == 1) 2872 return (zfs_print_allows(argv[0])); 2873 2874 if ((zhp = zfs_open(g_zfs, ds, ZFS_TYPE_DATASET)) == NULL) 2875 return (1); 2876 2877 if (zfs_perm_set(zhp, zperms)) { 2878 zfs_close(zhp); 2879 nvlist_free(zperms); 2880 return (1); 2881 } 2882 nvlist_free(zperms); 2883 zfs_close(zhp); 2884 2885 return (0); 2886} 2887 2888static int 2889unallow_callback(zfs_handle_t *zhp, void *data) 2890{ 2891 nvlist_t *nvp = (nvlist_t *)data; 2892 int error; 2893 2894 error = zfs_perm_remove(zhp, nvp); 2895 if (error) { 2896 (void) fprintf(stderr, gettext("Failed to remove permissions " 2897 "on %s\n"), zfs_get_name(zhp)); 2898 } 2899 return (error); 2900} 2901 2902static int 2903zfs_do_unallow(int argc, char **argv) 2904{ 2905 int recurse = B_FALSE; 2906 char *ds; 2907 int error; 2908 nvlist_t *zperms = NULL; 2909 int flags = 0; 2910 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 { 2928 zfs_handle_t **cb_handles; 2929 size_t cb_alloc; 2930 size_t cb_used; 2931 uint_t cb_types; 2932 boolean_t cb_verbose; 2933} get_all_cbdata_t; 2934 --- 174 unchanged lines hidden (view full) --- 3109 * legacy share options. 3110 */ 3111 verify(zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, 3112 sizeof (mountpoint), NULL, NULL, 0, B_FALSE) == 0); 3113 verify(zfs_prop_get(zhp, ZFS_PROP_SHARENFS, shareopts, 3114 sizeof (shareopts), NULL, NULL, 0, B_FALSE) == 0); 3115 verify(zfs_prop_get(zhp, ZFS_PROP_SHARESMB, smbshareopts, 3116 sizeof (smbshareopts), NULL, NULL, 0, B_FALSE) == 0); | 2663typedef struct get_all_cbdata { 2664 zfs_handle_t **cb_handles; 2665 size_t cb_alloc; 2666 size_t cb_used; 2667 uint_t cb_types; 2668 boolean_t cb_verbose; 2669} get_all_cbdata_t; 2670 --- 174 unchanged lines hidden (view full) --- 2845 * legacy share options. 2846 */ 2847 verify(zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, 2848 sizeof (mountpoint), NULL, NULL, 0, B_FALSE) == 0); 2849 verify(zfs_prop_get(zhp, ZFS_PROP_SHARENFS, shareopts, 2850 sizeof (shareopts), NULL, NULL, 0, B_FALSE) == 0); 2851 verify(zfs_prop_get(zhp, ZFS_PROP_SHARESMB, smbshareopts, 2852 sizeof (smbshareopts), NULL, NULL, 0, B_FALSE) == 0); |
3117 canmount = zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT); | |
3118 3119 if (op == OP_SHARE && strcmp(shareopts, "off") == 0 && 3120 strcmp(smbshareopts, "off") == 0) { 3121 if (!explicit) 3122 return (0); 3123 3124 (void) fprintf(stderr, gettext("cannot share '%s': " 3125 "legacy share\n"), zfs_get_name(zhp)); 3126 (void) fprintf(stderr, gettext("use share(1M) to " | 2853 2854 if (op == OP_SHARE && strcmp(shareopts, "off") == 0 && 2855 strcmp(smbshareopts, "off") == 0) { 2856 if (!explicit) 2857 return (0); 2858 2859 (void) fprintf(stderr, gettext("cannot share '%s': " 2860 "legacy share\n"), zfs_get_name(zhp)); 2861 (void) fprintf(stderr, gettext("use share(1M) to " |
3127 "share this filesystem\n")); | 2862 "share this filesystem, or set " 2863 "sharenfs property on\n")); |
3128 return (1); 3129 } 3130 3131 /* 3132 * We cannot share or mount legacy filesystems. If the 3133 * shareopts is non-legacy but the mountpoint is legacy, we 3134 * treat it as a legacy share. 3135 */ --- 21 unchanged lines hidden (view full) --- 3157 * canmount explicit outcome 3158 * on no pass through 3159 * on yes pass through 3160 * off no return 0 3161 * off yes display error, return 1 3162 * noauto no return 0 3163 * noauto yes pass through 3164 */ | 2864 return (1); 2865 } 2866 2867 /* 2868 * We cannot share or mount legacy filesystems. If the 2869 * shareopts is non-legacy but the mountpoint is legacy, we 2870 * treat it as a legacy share. 2871 */ --- 21 unchanged lines hidden (view full) --- 2893 * canmount explicit outcome 2894 * on no pass through 2895 * on yes pass through 2896 * off no return 0 2897 * off yes display error, return 1 2898 * noauto no return 0 2899 * noauto yes pass through 2900 */ |
2901 canmount = zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT); |
|
3165 if (canmount == ZFS_CANMOUNT_OFF) { 3166 if (!explicit) 3167 return (0); 3168 3169 (void) fprintf(stderr, gettext("cannot %s '%s': " 3170 "'canmount' property is set to 'off'\n"), cmdname, 3171 zfs_get_name(zhp)); 3172 return (1); --- 877 unchanged lines hidden (view full) --- 4050/* ARGSUSED */ 4051static int 4052zfs_do_unjail(int argc, char **argv) 4053{ 4054 4055 return (do_jail(argc, argv, 0)); 4056} 4057 | 2902 if (canmount == ZFS_CANMOUNT_OFF) { 2903 if (!explicit) 2904 return (0); 2905 2906 (void) fprintf(stderr, gettext("cannot %s '%s': " 2907 "'canmount' property is set to 'off'\n"), cmdname, 2908 zfs_get_name(zhp)); 2909 return (1); --- 877 unchanged lines hidden (view full) --- 3787/* ARGSUSED */ 3788static int 3789zfs_do_unjail(int argc, char **argv) 3790{ 3791 3792 return (do_jail(argc, argv, 0)); 3793} 3794 |
3795/* ARGSUSED */ 3796static int 3797zfs_do_python(int argc, char **argv) 3798{ 3799 (void) execv(pypath, argv-1); 3800 (void) printf("internal error: %s not found\n", pypath); 3801 return (-1); 3802} 3803 |
|
4058/* 4059 * Called when invoked as /etc/fs/zfs/mount. Do the mount if the mountpoint is 4060 * 'legacy'. Otherwise, complain that use should be using 'zfs mount'. 4061 */ 4062static int 4063manual_mount(int argc, char **argv) 4064{ 4065 zfs_handle_t *zhp; --- 241 unchanged lines hidden (view full) --- 4307 if (strcmp(cmdname, "volinit") == 0) 4308 return (do_volcheck(B_TRUE)); 4309 else if (strcmp(cmdname, "volfini") == 0) 4310 return (do_volcheck(B_FALSE)); 4311 4312 /* 4313 * Run the appropriate command. 4314 */ | 3804/* 3805 * Called when invoked as /etc/fs/zfs/mount. Do the mount if the mountpoint is 3806 * 'legacy'. Otherwise, complain that use should be using 'zfs mount'. 3807 */ 3808static int 3809manual_mount(int argc, char **argv) 3810{ 3811 zfs_handle_t *zhp; --- 241 unchanged lines hidden (view full) --- 4053 if (strcmp(cmdname, "volinit") == 0) 4054 return (do_volcheck(B_TRUE)); 4055 else if (strcmp(cmdname, "volfini") == 0) 4056 return (do_volcheck(B_FALSE)); 4057 4058 /* 4059 * Run the appropriate command. 4060 */ |
4061 libzfs_mnttab_cache(g_zfs, B_TRUE); |
|
4315 if (find_command_idx(cmdname, &i) == 0) { 4316 current_command = &command_table[i]; 4317 ret = command_table[i].func(argc - 1, argv + 1); 4318 } else if (strchr(cmdname, '=') != NULL) { 4319 verify(find_command_idx("set", &i) == 0); 4320 current_command = &command_table[i]; 4321 ret = command_table[i].func(argc, argv); 4322 } else { 4323 (void) fprintf(stderr, gettext("unrecognized " 4324 "command '%s'\n"), cmdname); 4325 usage(B_FALSE); 4326 } | 4062 if (find_command_idx(cmdname, &i) == 0) { 4063 current_command = &command_table[i]; 4064 ret = command_table[i].func(argc - 1, argv + 1); 4065 } else if (strchr(cmdname, '=') != NULL) { 4066 verify(find_command_idx("set", &i) == 0); 4067 current_command = &command_table[i]; 4068 ret = command_table[i].func(argc, argv); 4069 } else { 4070 (void) fprintf(stderr, gettext("unrecognized " 4071 "command '%s'\n"), cmdname); 4072 usage(B_FALSE); 4073 } |
4074 libzfs_mnttab_cache(g_zfs, B_FALSE); |
|
4327 } 4328 4329 (void) fclose(mnttab_file); 4330 4331 libzfs_fini(g_zfs); 4332 4333 /* 4334 * The 'ZFS_ABORT' environment variable causes us to dump core on exit 4335 * for the purposes of running ::findleaks. 4336 */ 4337 if (getenv("ZFS_ABORT") != NULL) { 4338 (void) printf("dumping core by request\n"); 4339 abort(); 4340 } 4341 4342 return (ret); 4343} | 4075 } 4076 4077 (void) fclose(mnttab_file); 4078 4079 libzfs_fini(g_zfs); 4080 4081 /* 4082 * The 'ZFS_ABORT' environment variable causes us to dump core on exit 4083 * for the purposes of running ::findleaks. 4084 */ 4085 if (getenv("ZFS_ABORT") != NULL) { 4086 (void) printf("dumping core by request\n"); 4087 abort(); 4088 } 4089 4090 return (ret); 4091} |