@@ -249,8 +249,9 @@ get_usage(zfs_help_t idx)
249
249
return (gettext ("\tpromote <clone-filesystem>\n" ));
250
250
case HELP_RECEIVE :
251
251
return (gettext ("\treceive [-vnFu] <filesystem|volume|"
252
- "snapshot>\n"
253
- "\treceive [-vnFu] [-d | -e] <filesystem>\n" ));
252
+ "snapshot>\n"
253
+ "\treceive [-vnFu] [-o origin=<snapshot>] [-d | -e] "
254
+ "<filesystem>\n" ));
254
255
case HELP_RENAME :
255
256
return (gettext ("\trename [-f] <filesystem|volume|snapshot> "
256
257
"<filesystem|volume|snapshot>\n"
@@ -793,7 +794,7 @@ zfs_do_create(int argc, char **argv)
793
794
nomem ();
794
795
break ;
795
796
case 'o' :
796
- if (parseprop (props , optarg ))
797
+ if (parseprop (props , optarg ) != 0 )
797
798
goto error ;
798
799
break ;
799
800
case 's' :
@@ -3622,7 +3623,7 @@ zfs_do_snapshot(int argc, char **argv)
3622
3623
while ((c = getopt (argc , argv , "ro:" )) != -1 ) {
3623
3624
switch (c ) {
3624
3625
case 'o' :
3625
- if (parseprop (props , optarg ))
3626
+ if (parseprop (props , optarg ) != 0 )
3626
3627
return (1 );
3627
3628
break ;
3628
3629
case 'r' :
@@ -3881,10 +3882,19 @@ zfs_do_receive(int argc, char **argv)
3881
3882
{
3882
3883
int c , err ;
3883
3884
recvflags_t flags = { 0 };
3885
+ nvlist_t * props ;
3886
+ nvpair_t * nvp = NULL ;
3887
+
3888
+ if (nvlist_alloc (& props , NV_UNIQUE_NAME , 0 ) != 0 )
3889
+ nomem ();
3884
3890
3885
3891
/* check options */
3886
- while ((c = getopt (argc , argv , ":denuvF" )) != -1 ) {
3892
+ while ((c = getopt (argc , argv , ":o: denuvF" )) != -1 ) {
3887
3893
switch (c ) {
3894
+ case 'o' :
3895
+ if (parseprop (props , optarg ) != 0 )
3896
+ return (1 );
3897
+ break ;
3888
3898
case 'd' :
3889
3899
flags .isprefix = B_TRUE ;
3890
3900
break ;
@@ -3929,6 +3939,13 @@ zfs_do_receive(int argc, char **argv)
3929
3939
usage (B_FALSE );
3930
3940
}
3931
3941
3942
+ while ((nvp = nvlist_next_nvpair (props , nvp ))) {
3943
+ if (strcmp (nvpair_name (nvp ), "origin" ) != 0 ) {
3944
+ (void ) fprintf (stderr , gettext ("invalid option" ));
3945
+ usage (B_FALSE );
3946
+ }
3947
+ }
3948
+
3932
3949
if (isatty (STDIN_FILENO )) {
3933
3950
(void ) fprintf (stderr ,
3934
3951
gettext ("Error: Backup stream can not be read "
@@ -3937,7 +3954,7 @@ zfs_do_receive(int argc, char **argv)
3937
3954
return (1 );
3938
3955
}
3939
3956
3940
- err = zfs_receive (g_zfs , argv [0 ], & flags , STDIN_FILENO , NULL );
3957
+ err = zfs_receive (g_zfs , argv [0 ], props , & flags , STDIN_FILENO , NULL );
3941
3958
3942
3959
return (err != 0 );
3943
3960
}
0 commit comments