@@ -133,10 +133,11 @@ void usage(ostream& out)
133133" getomapval <obj-name> <key> [file] show the value for the specified key\n "
134134" in the object's object map\n "
135135" setomapval <obj-name> <key> <val | --input-file file>\n "
136- " rmomapkey <obj-name> <key> Remove key from the object map of <obj-name>\n "
136+ " rmomapkey <obj-name> <key> remove key from the object map of <obj-name>\n "
137137" clearomap <obj-name> [obj-name2 obj-name3...] clear all the omap keys for the specified objects\n "
138- " getomapheader <obj-name> [file] Dump the hexadecimal value of the object map header of <obj-name>\n "
139- " setomapheader <obj-name> <val> Set the value of the object map header of <obj-name>\n "
138+ " getomapheader <obj-name> [file] dump the hexadecimal value of the object map header of <obj-name>\n "
139+ " setomapheader <obj-name> <val | --input-file file>\n "
140+ " set the value of the object map header of <obj-name>\n "
140141" watch <obj-name> add watcher on this object\n "
141142" notify <obj-name> <message> notify watcher of this object with message\n "
142143" listwatchers <obj-name> list the watchers of this object\n "
@@ -2820,17 +2821,33 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
28202821 ret = 0 ;
28212822 }
28222823 } else if (strcmp (nargs[0 ], " setomapheader" ) == 0 ) {
2823- if (!pool_name || nargs.size () < (obj_name ? 2 : 3 )) {
2824+ uint32_t min_args = 3 ;
2825+ if (obj_name) {
2826+ min_args--;
2827+ }
2828+ if (!input_file.empty ()) {
2829+ min_args--;
2830+ }
2831+
2832+ if (!pool_name || nargs.size () < min_args) {
28242833 usage (cerr);
28252834 return 1 ;
28262835 }
28272836
2828- bufferlist bl;
28292837 if (!obj_name) {
28302838 obj_name = nargs[1 ];
2831- bl.append (nargs[2 ]); // val
2839+ }
2840+
2841+ bufferlist bl;
2842+ if (!input_file.empty ()) {
2843+ string err;
2844+ ret = bl.read_file (input_file.c_str (), &err);
2845+ if (ret < 0 ) {
2846+ cerr << " error reading file " << input_file.c_str () << " : " << err << std::endl;
2847+ return 1 ;
2848+ }
28322849 } else {
2833- bl.append (nargs[1 ]); // val
2850+ bl.append (nargs[min_args - 1 ]); // val
28342851 }
28352852 ret = io_ctx.omap_set_header (*obj_name, bl);
28362853 if (ret < 0 ) {
0 commit comments