378 |
378 |
379 (void) fprintf(fp, "\n\t%-13s %s %s %s\n\n", |
379 (void) fprintf(fp, "\n\t%-13s %s %s %s\n\n", |
380 "PROPERTY", "EDIT", "INHERIT", "VALUES"); |
380 "PROPERTY", "EDIT", "INHERIT", "VALUES"); |
381 |
381 |
382 /* Iterate over all properties */ |
382 /* Iterate over all properties */ |
383 (void) zfs_prop_iter_ordered(usage_prop_cb, fp, B_FALSE); |
383 (void) zfs_prop_iter_ordered(usage_prop_cb, fp); |
384 |
384 |
385 (void) fprintf(fp, gettext("\nSizes are specified in bytes " |
385 (void) fprintf(fp, gettext("\nSizes are specified in bytes " |
386 "with standard units such as K, M, G, etc.\n")); |
386 "with standard units such as K, M, G, etc.\n")); |
387 (void) fprintf(fp, gettext("\n\nUser-defined properties can " |
387 (void) fprintf(fp, gettext("\n\nUser-defined properties can " |
388 "be specified by using a name containing a colon (:).\n")); |
388 "be specified by using a name containing a colon (:).\n")); |
3827 } |
3827 } |
3828 } |
3828 } |
3829 return (1); |
3829 return (1); |
3830 } |
3830 } |
3831 |
3831 |
3832 zfs_prop_t |
|
3833 propset_cb(zfs_prop_t prop, void *data) |
|
3834 { |
|
3835 char *cmdname = (char *)data; |
|
3836 |
|
3837 if (strcmp(cmdname, zfs_prop_to_name(prop)) == 0) |
|
3838 return (prop); |
|
3839 |
|
3840 return (ZFS_PROP_CONT); |
|
3841 } |
|
3842 |
|
3843 int |
3832 int |
3844 main(int argc, char **argv) |
3833 main(int argc, char **argv) |
3845 { |
3834 { |
3846 int ret; |
3835 int ret; |
3847 int i; |
3836 int i; |
3848 char *progname; |
3837 char *progname; |
3849 char *cmdname; |
3838 char *cmdname; |
3850 char *str; |
|
3851 boolean_t found = B_FALSE; |
|
3852 |
3839 |
3853 (void) setlocale(LC_ALL, ""); |
3840 (void) setlocale(LC_ALL, ""); |
3854 (void) textdomain(TEXT_DOMAIN); |
3841 (void) textdomain(TEXT_DOMAIN); |
3855 |
3842 |
3856 opterr = 0; |
3843 opterr = 0; |
3925 * Run the appropriate command. |
3912 * Run the appropriate command. |
3926 */ |
3913 */ |
3927 if (find_command_idx(cmdname, &i) == 0) { |
3914 if (find_command_idx(cmdname, &i) == 0) { |
3928 current_command = &command_table[i]; |
3915 current_command = &command_table[i]; |
3929 ret = command_table[i].func(argc - 1, argv + 1); |
3916 ret = command_table[i].func(argc - 1, argv + 1); |
3930 found = B_TRUE; |
3917 } else if (strchr(cmdname, '=') != NULL) { |
3931 } |
3918 verify(find_command_idx("set", &i) == 0); |
3932 |
3919 current_command = &command_table[i]; |
3933 /* |
3920 ret = command_table[i].func(argc, argv); |
3934 * Check and see if they are doing property=value |
3921 } else { |
3935 */ |
|
3936 if (found == B_FALSE && |
|
3937 ((str = strchr(cmdname, '=')) != NULL)) { |
|
3938 *str = '\0'; |
|
3939 if (zfs_prop_iter(propset_cb, cmdname, |
|
3940 B_FALSE) != ZFS_PROP_INVAL) |
|
3941 found = B_TRUE; |
|
3942 |
|
3943 if (found == B_FALSE && zfs_prop_user(cmdname)) |
|
3944 found = B_TRUE; |
|
3945 |
|
3946 if (found == B_TRUE && |
|
3947 find_command_idx("set", &i) == 0) { |
|
3948 *str = '='; |
|
3949 current_command = &command_table[i]; |
|
3950 ret = command_table[i].func(argc, argv); |
|
3951 } else { |
|
3952 (void) fprintf(stderr, |
|
3953 gettext("invalid property '%s'\n"), |
|
3954 cmdname); |
|
3955 found = B_TRUE; |
|
3956 ret = 1; |
|
3957 } |
|
3958 |
|
3959 } |
|
3960 |
|
3961 if (found == B_FALSE) { |
|
3962 (void) fprintf(stderr, gettext("unrecognized " |
3922 (void) fprintf(stderr, gettext("unrecognized " |
3963 "command '%s'\n"), cmdname); |
3923 "command '%s'\n"), cmdname); |
3964 usage(B_FALSE); |
3924 usage(B_FALSE); |
3965 } |
3925 } |
3966 } |
3926 } |