mirror of
				https://github.com/davidgiven/fluxengine.git
				synced 2025-10-24 11:11:02 -07:00 
			
		
		
		
	Switch from using a oneof to an explicit enum for the flux source/sink
configurations, as this allows default options for multiple source/sink types.
This commit is contained in:
		| @@ -9,55 +9,85 @@ | ||||
|  | ||||
| std::unique_ptr<FluxSink> FluxSink::create(const FluxSinkProto& config) | ||||
| { | ||||
| 	switch (config.dest_case()) | ||||
| 	{ | ||||
| 		case FluxSinkProto::kDrive: | ||||
| 			return createHardwareFluxSink(config.drive()); | ||||
|     switch (config.type()) | ||||
|     { | ||||
|         case FluxSinkProto::DRIVE: | ||||
|             return createHardwareFluxSink(config.drive()); | ||||
|  | ||||
| 		case FluxSinkProto::kA2R: | ||||
| 			return createA2RFluxSink(config.a2r()); | ||||
|         case FluxSinkProto::A2R: | ||||
|             return createA2RFluxSink(config.a2r()); | ||||
|  | ||||
| 		case FluxSinkProto::kAu: | ||||
| 			return createAuFluxSink(config.au()); | ||||
|         case FluxSinkProto::AU: | ||||
|             return createAuFluxSink(config.au()); | ||||
|  | ||||
| 		case FluxSinkProto::kVcd: | ||||
| 			return createVcdFluxSink(config.vcd()); | ||||
|         case FluxSinkProto::VCD: | ||||
|             return createVcdFluxSink(config.vcd()); | ||||
|  | ||||
| 		case FluxSinkProto::kScp: | ||||
| 			return createScpFluxSink(config.scp()); | ||||
|         case FluxSinkProto::SCP: | ||||
|             return createScpFluxSink(config.scp()); | ||||
|  | ||||
| 		case FluxSinkProto::kFl2: | ||||
| 			return createFl2FluxSink(config.fl2()); | ||||
|         case FluxSinkProto::FLUX: | ||||
|             return createFl2FluxSink(config.fl2()); | ||||
|  | ||||
| 		default: | ||||
| 			Error() << "bad output disk config"; | ||||
| 			return std::unique_ptr<FluxSink>(); | ||||
| 	} | ||||
|         default: | ||||
|             Error() << "bad output disk config"; | ||||
|             return std::unique_ptr<FluxSink>(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void FluxSink::updateConfigForFilename(FluxSinkProto* proto, const std::string& filename) | ||||
| void FluxSink::updateConfigForFilename( | ||||
|     FluxSinkProto* proto, const std::string& filename) | ||||
| { | ||||
| 	static const std::vector<std::pair<std::regex, std::function<void(const std::string&, FluxSinkProto*)>>> formats = | ||||
| 	{ | ||||
| 		{ std::regex("^(.*\\.a2r)$"),  [](auto& s, auto* proto) { proto->mutable_a2r()->set_filename(s); }}, | ||||
| 		{ std::regex("^(.*\\.flux)$"), [](auto& s, auto* proto) { proto->mutable_fl2()->set_filename(s); }}, | ||||
| 		{ std::regex("^(.*\\.scp)$"),  [](auto& s, auto* proto) { proto->mutable_scp()->set_filename(s); }}, | ||||
| 		{ std::regex("^vcd:(.*)$"),    [](auto& s, auto* proto) { proto->mutable_vcd()->set_directory(s); }}, | ||||
| 		{ std::regex("^au:(.*)$"),     [](auto& s, auto* proto) { proto->mutable_au()->set_directory(s); }}, | ||||
| 		{ std::regex("^drive:(.*)"),   [](auto& s, auto* proto) { proto->mutable_drive(); config.mutable_drive()->set_drive(std::stoi(s)); }}, | ||||
| 	}; | ||||
|     static const std::vector<std::pair<std::regex, | ||||
|         std::function<void(const std::string&, FluxSinkProto*)>>> | ||||
|         formats = { | ||||
|             {std::regex("^(.*\\.a2r)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSinkProto::A2R); | ||||
|                     proto->mutable_a2r()->set_filename(s); | ||||
|                 }}, | ||||
|             {std::regex("^(.*\\.flux)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSinkProto::FLUX); | ||||
|                     proto->mutable_fl2()->set_filename(s); | ||||
|                 }}, | ||||
|             {std::regex("^(.*\\.scp)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSinkProto::SCP); | ||||
|                     proto->mutable_scp()->set_filename(s); | ||||
|                 }}, | ||||
|             {std::regex("^vcd:(.*)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSinkProto::VCD); | ||||
|                     proto->mutable_vcd()->set_directory(s); | ||||
|                 }}, | ||||
|             {std::regex("^au:(.*)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSinkProto::AU); | ||||
|                     proto->mutable_au()->set_directory(s); | ||||
|                 }}, | ||||
|             {std::regex("^drive:(.*)"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSinkProto::DRIVE); | ||||
|                     config.mutable_drive()->set_drive(std::stoi(s)); | ||||
|                 }}, | ||||
|     }; | ||||
|  | ||||
| 	for (const auto& it : formats) | ||||
| 	{ | ||||
| 		std::smatch match; | ||||
| 		if (std::regex_match(filename, match, it.first)) | ||||
| 		{ | ||||
| 			it.second(match[1], proto); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|     for (const auto& it : formats) | ||||
|     { | ||||
|         std::smatch match; | ||||
|         if (std::regex_match(filename, match, it.first)) | ||||
|         { | ||||
|             it.second(match[1], proto); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| 	Error() << fmt::format("unrecognised flux filename '{}'", filename); | ||||
|     Error() << fmt::format("unrecognised flux filename '{}'", filename); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -14,7 +14,7 @@ message A2RFluxSinkProto { | ||||
| } | ||||
|  | ||||
| message VcdFluxSinkProto { | ||||
| 	optional string directory = 1 [default = "vcdfiles", (help) = "directory to write .vcd files to"]; | ||||
| 	optional string directory = 1 	   [default = "vcdfiles", (help) = "directory to write .vcd files to"]; | ||||
| } | ||||
|  | ||||
| message ScpFluxSinkProto { | ||||
| @@ -27,15 +27,25 @@ message Fl2FluxSinkProto { | ||||
| 	optional string filename = 1       [default = "flux.fl2", (help) = ".fl2 file to write to"]; | ||||
| } | ||||
|  | ||||
| // Next: 9 | ||||
| // Next: 10 | ||||
| message FluxSinkProto { | ||||
| 	oneof dest { | ||||
| 		HardwareFluxSinkProto drive = 2; | ||||
| 		A2RFluxSinkProto a2r = 8; | ||||
| 		AuFluxSinkProto au = 3; | ||||
| 		VcdFluxSinkProto vcd = 4; | ||||
| 		ScpFluxSinkProto scp = 5; | ||||
| 		Fl2FluxSinkProto fl2 = 6; | ||||
| 	enum FluxSinkType { | ||||
| 		NOT_SET = 0; | ||||
| 		DRIVE = 1; | ||||
| 		A2R = 2; | ||||
| 		AU = 3; | ||||
| 		VCD = 4; | ||||
| 		SCP = 5; | ||||
| 		FLUX = 6; | ||||
| 	} | ||||
|  | ||||
| 	optional FluxSinkType type = 9 [default = NOT_SET, (help) = "flux sink type"]; | ||||
|  | ||||
| 	optional HardwareFluxSinkProto drive = 2; | ||||
| 	optional A2RFluxSinkProto a2r = 8; | ||||
| 	optional AuFluxSinkProto au = 3; | ||||
| 	optional VcdFluxSinkProto vcd = 4; | ||||
| 	optional ScpFluxSinkProto scp = 5; | ||||
| 	optional Fl2FluxSinkProto fl2 = 6; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -17,93 +17,128 @@ static bool ends_with(const std::string& value, const std::string& ending) | ||||
|  | ||||
| std::unique_ptr<FluxSource> FluxSource::create(const FluxSourceProto& config) | ||||
| { | ||||
| 	switch (config.source_case()) | ||||
| 	{ | ||||
| 		case FluxSourceProto::kDrive: | ||||
| 			return createHardwareFluxSource(config.drive()); | ||||
|     switch (config.type()) | ||||
|     { | ||||
|         case FluxSourceProto::DRIVE: | ||||
|             return createHardwareFluxSource(config.drive()); | ||||
|  | ||||
| 		case FluxSourceProto::kErase: | ||||
| 			return createEraseFluxSource(config.erase()); | ||||
|         case FluxSourceProto::ERASE: | ||||
|             return createEraseFluxSource(config.erase()); | ||||
|  | ||||
| 		case FluxSourceProto::kKryoflux: | ||||
| 			return createKryofluxFluxSource(config.kryoflux()); | ||||
|         case FluxSourceProto::KRYOFLUX: | ||||
|             return createKryofluxFluxSource(config.kryoflux()); | ||||
|  | ||||
| 		case FluxSourceProto::kTestPattern: | ||||
| 			return createTestPatternFluxSource(config.test_pattern()); | ||||
|         case FluxSourceProto::TEST_PATTERN: | ||||
|             return createTestPatternFluxSource(config.test_pattern()); | ||||
|  | ||||
| 		case FluxSourceProto::kScp: | ||||
| 			return createScpFluxSource(config.scp()); | ||||
|         case FluxSourceProto::SCP: | ||||
|             return createScpFluxSource(config.scp()); | ||||
|  | ||||
| 		case FluxSourceProto::kCwf: | ||||
| 			return createCwfFluxSource(config.cwf()); | ||||
|         case FluxSourceProto::CWF: | ||||
|             return createCwfFluxSource(config.cwf()); | ||||
|  | ||||
| 		case FluxSourceProto::kFl2: | ||||
| 			return createFl2FluxSource(config.fl2()); | ||||
|         case FluxSourceProto::FLUX: | ||||
|             return createFl2FluxSource(config.fl2()); | ||||
|  | ||||
| 		default: | ||||
| 			Error() << "bad input disk configuration"; | ||||
| 			return std::unique_ptr<FluxSource>(); | ||||
| 	} | ||||
|         default: | ||||
|             Error() << "bad input disk configuration"; | ||||
|             return std::unique_ptr<FluxSource>(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void FluxSource::updateConfigForFilename(FluxSourceProto* proto, const std::string& filename) | ||||
| void FluxSource::updateConfigForFilename( | ||||
|     FluxSourceProto* proto, const std::string& filename) | ||||
| { | ||||
|  | ||||
| 	static const std::vector<std::pair<std::regex, std::function<void(const std::string&, FluxSourceProto*)>>> formats = | ||||
| 	{ | ||||
| 		{ std::regex("^(.*\\.a2r)$"),  [](auto& s, auto* proto) { }}, | ||||
| 		{ std::regex("^(.*\\.flux)$"),     [](auto& s, auto* proto) { proto->mutable_fl2()->set_filename(s); }}, | ||||
| 		{ std::regex("^(.*\\.scp)$"),      [](auto& s, auto* proto) { proto->mutable_scp()->set_filename(s); }}, | ||||
| 		{ std::regex("^(.*\\.cwf)$"),      [](auto& s, auto* proto) { proto->mutable_cwf()->set_filename(s); }}, | ||||
| 		{ std::regex("^erase:$"),          [](auto& s, auto* proto) { proto->mutable_erase(); }}, | ||||
| 		{ std::regex("^kryoflux:(.*)$"),   [](auto& s, auto* proto) { proto->mutable_kryoflux()->set_directory(s); }}, | ||||
| 		{ std::regex("^testpattern:(.*)"), [](auto& s, auto* proto) { proto->mutable_test_pattern(); }}, | ||||
| 		{ std::regex("^drive:(.*)"),       [](auto& s, auto* proto) { proto->mutable_drive(); config.mutable_drive()->set_drive(std::stoi(s)); }}, | ||||
| 	}; | ||||
|     static const std::vector<std::pair<std::regex, | ||||
|         std::function<void(const std::string&, FluxSourceProto*)>>> | ||||
|         formats = { | ||||
|             {std::regex("^(.*\\.flux)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::FLUX); | ||||
|                     proto->mutable_fl2()->set_filename(s); | ||||
|                 }}, | ||||
|             {std::regex("^(.*\\.scp)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::SCP); | ||||
|                     proto->mutable_scp()->set_filename(s); | ||||
|                 }}, | ||||
|             {std::regex("^(.*\\.cwf)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::CWF); | ||||
|                     proto->mutable_cwf()->set_filename(s); | ||||
|                 }}, | ||||
|             {std::regex("^erase:$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::ERASE); | ||||
|                 }}, | ||||
|             {std::regex("^kryoflux:(.*)$"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::KRYOFLUX); | ||||
|                     proto->mutable_kryoflux()->set_directory(s); | ||||
|                 }}, | ||||
|             {std::regex("^testpattern:(.*)"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::TEST_PATTERN); | ||||
|                 }}, | ||||
|             {std::regex("^drive:(.*)"), | ||||
|              [](auto& s, auto* proto) | ||||
|                 { | ||||
|                     proto->set_type(FluxSourceProto::DRIVE); | ||||
|                     config.mutable_drive()->set_drive(std::stoi(s)); | ||||
|                 }}, | ||||
|     }; | ||||
|  | ||||
| 	for (const auto& it : formats) | ||||
| 	{ | ||||
| 		std::smatch match; | ||||
| 		if (std::regex_match(filename, match, it.first)) | ||||
| 		{ | ||||
| 			it.second(match[1], proto); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|     for (const auto& it : formats) | ||||
|     { | ||||
|         std::smatch match; | ||||
|         if (std::regex_match(filename, match, it.first)) | ||||
|         { | ||||
|             it.second(match[1], proto); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|  | ||||
| 	Error() << fmt::format("unrecognised flux filename '{}'", filename); | ||||
|     Error() << fmt::format("unrecognised flux filename '{}'", filename); | ||||
| } | ||||
|  | ||||
| class TrivialFluxSourceIterator : public FluxSourceIterator | ||||
| { | ||||
| public: | ||||
| 	TrivialFluxSourceIterator(TrivialFluxSource* fluxSource, int track, int head): | ||||
| 		_fluxSource(fluxSource), | ||||
| 		_track(track), | ||||
| 		_head(head) | ||||
| 	{} | ||||
|     TrivialFluxSourceIterator( | ||||
|         TrivialFluxSource* fluxSource, int track, int head): | ||||
|         _fluxSource(fluxSource), | ||||
|         _track(track), | ||||
|         _head(head) | ||||
|     { | ||||
|     } | ||||
|  | ||||
| 	bool hasNext() const override | ||||
| 	{ | ||||
| 		return !!_fluxSource; | ||||
| 	} | ||||
|     bool hasNext() const override | ||||
|     { | ||||
|         return !!_fluxSource; | ||||
|     } | ||||
|  | ||||
| 	std::unique_ptr<const Fluxmap> next() override | ||||
| 	{ | ||||
| 		auto fluxmap = _fluxSource->readSingleFlux(_track, _head); | ||||
| 		_fluxSource = nullptr; | ||||
| 		return fluxmap; | ||||
| 	} | ||||
|     std::unique_ptr<const Fluxmap> next() override | ||||
|     { | ||||
|         auto fluxmap = _fluxSource->readSingleFlux(_track, _head); | ||||
|         _fluxSource = nullptr; | ||||
|         return fluxmap; | ||||
|     } | ||||
|  | ||||
| private: | ||||
| 	TrivialFluxSource* _fluxSource; | ||||
| 	int _track; | ||||
| 	int _head; | ||||
|     TrivialFluxSource* _fluxSource; | ||||
|     int _track; | ||||
|     int _head; | ||||
| }; | ||||
|  | ||||
| std::unique_ptr<FluxSourceIterator> TrivialFluxSource::readFlux(int track, int head) | ||||
| std::unique_ptr<FluxSourceIterator> TrivialFluxSource::readFlux( | ||||
|     int track, int head) | ||||
| { | ||||
| 	return std::make_unique<TrivialFluxSourceIterator>(this, track, head); | ||||
|     return std::make_unique<TrivialFluxSourceIterator>(this, track, head); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -30,15 +30,27 @@ message Fl2FluxSourceProto { | ||||
| 		(help) = ".fl2 file to read flux from"]; | ||||
| } | ||||
|  | ||||
| // NEXT: 10 | ||||
| message FluxSourceProto { | ||||
| 	oneof source { | ||||
| 		HardwareFluxSourceProto drive = 2; | ||||
| 		TestPatternFluxSourceProto test_pattern = 3; | ||||
| 		EraseFluxSourceProto erase = 4; | ||||
| 		KryofluxFluxSourceProto kryoflux = 5; | ||||
| 		ScpFluxSourceProto scp = 6; | ||||
| 		CwfFluxSourceProto cwf = 7; | ||||
| 		Fl2FluxSourceProto fl2 = 8; | ||||
| 	enum FluxSourceType { | ||||
| 		NOT_SET = 0; | ||||
| 		DRIVE = 1; | ||||
| 		TEST_PATTERN = 2; | ||||
| 		ERASE = 3; | ||||
| 		KRYOFLUX = 4; | ||||
| 		SCP = 5; | ||||
| 		CWF = 6; | ||||
| 		FLUX = 7; | ||||
| 	} | ||||
|  | ||||
| 	optional FluxSourceType type = 9 [default = NOT_SET, (help) = "flux source type"]; | ||||
|  | ||||
| 	optional HardwareFluxSourceProto drive = 2; | ||||
| 	optional TestPatternFluxSourceProto test_pattern = 3; | ||||
| 	optional EraseFluxSourceProto erase = 4; | ||||
| 	optional KryofluxFluxSourceProto kryoflux = 5; | ||||
| 	optional ScpFluxSourceProto scp = 6; | ||||
| 	optional CwfFluxSourceProto cwf = 7; | ||||
| 	optional Fl2FluxSourceProto fl2 = 8; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -218,13 +218,13 @@ std::unique_ptr<Filesystem> Filesystem::createFilesystemFromConfig() | ||||
|         std::shared_ptr<Decoder> decoder; | ||||
|         std::shared_ptr<FluxSink> fluxSink; | ||||
|         std::shared_ptr<Encoder> encoder; | ||||
|         if (config.flux_source().source_case() != | ||||
|             FluxSourceProto::SOURCE_NOT_SET) | ||||
|         if (config.flux_source().type() != | ||||
|             FluxSourceProto::NOT_SET) | ||||
|         { | ||||
|             fluxSource = FluxSource::create(config.flux_source()); | ||||
|             decoder = Decoder::create(config.decoder()); | ||||
|         } | ||||
|         if (config.flux_sink().has_drive()) | ||||
|         if (config.flux_sink().type() == FluxSinkProto::DRIVE) | ||||
|         { | ||||
|             fluxSink = FluxSink::create(config.flux_sink()); | ||||
|             encoder = Encoder::create(config.encoder()); | ||||
|   | ||||
| @@ -211,10 +211,10 @@ static void draw_x_graticules(Agg2D& painter, double x1, double y1, double x2, d | ||||
|  | ||||
| int mainAnalyseDriveResponse(int argc, const char* argv[]) | ||||
| { | ||||
| 	config.mutable_flux_source()->mutable_drive(); | ||||
| 	config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|  | ||||
| 	if (!config.flux_sink().has_drive()) | ||||
| 	if (config.flux_sink().type() != FluxSinkProto::DRIVE) | ||||
| 		Error() << "this only makes sense with a real disk drive"; | ||||
|  | ||||
|     usbSetDrive(config.drive().drive(), | ||||
|   | ||||
| @@ -210,7 +210,7 @@ static nanoseconds_t guessClock(const Fluxmap& fluxmap) | ||||
|  | ||||
| int mainInspect(int argc, const char* argv[]) | ||||
| { | ||||
| 	config.mutable_flux_source()->mutable_drive(); | ||||
| 	config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|  | ||||
| 	std::unique_ptr<FluxSource> fluxSource(FluxSource::create(config.flux_source())); | ||||
|   | ||||
| @@ -61,10 +61,10 @@ int mainRawRead(int argc, const char* argv[]) | ||||
|  | ||||
| 	if (argc == 1) | ||||
| 		showProfiles("rawread", formats); | ||||
| 	config.mutable_flux_source()->mutable_drive(); | ||||
| 	config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
| 	if (config.flux_sink().has_drive()) | ||||
| 	if (config.flux_sink().type() == FluxSinkProto::DRIVE) | ||||
| 		Error() << "you can't use rawread to write to hardware"; | ||||
|  | ||||
| 	std::unique_ptr<FluxSource> fluxSource(FluxSource::create(config.flux_source())); | ||||
|   | ||||
| @@ -54,7 +54,7 @@ static ActionFlag eraseFlag( | ||||
| 	"erases the destination", | ||||
| 	[]() | ||||
| 	{ | ||||
| 		config.mutable_flux_source()->mutable_erase(); | ||||
| 		config.mutable_flux_source()->set_type(FluxSourceProto::ERASE); | ||||
| 	}); | ||||
|  | ||||
| int mainRawWrite(int argc, const char* argv[]) | ||||
| @@ -64,10 +64,10 @@ int mainRawWrite(int argc, const char* argv[]) | ||||
|  | ||||
| 	if (argc == 1) | ||||
| 		showProfiles("rawwrite", formats); | ||||
| 	config.mutable_flux_sink()->mutable_drive(); | ||||
| 	config.mutable_flux_sink()->set_type(FluxSinkProto::DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
| 	if (config.flux_source().has_drive()) | ||||
| 	if (config.flux_source().type() == FluxSourceProto::DRIVE) | ||||
| 		Error() << "you can't use rawwrite to read from hardware"; | ||||
|  | ||||
| 	std::unique_ptr<FluxSource> fluxSource(FluxSource::create(config.flux_source())); | ||||
|   | ||||
| @@ -67,7 +67,7 @@ int mainRead(int argc, const char* argv[]) | ||||
| { | ||||
| 	if (argc == 1) | ||||
| 		showProfiles("read", formats); | ||||
| 	config.mutable_flux_source()->mutable_drive(); | ||||
| 	config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
| 	if (config.decoder().copy_flux_to().has_drive()) | ||||
|   | ||||
| @@ -20,7 +20,7 @@ int mainRpm(int argc, const char* argv[]) | ||||
| { | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|  | ||||
| 	if (!config.flux_source().has_drive()) | ||||
| 	if (!config.flux_source().type() != FluxSourceProto::DRIVE) | ||||
| 		Error() << "this only makes sense with a real disk drive"; | ||||
|  | ||||
|     usbSetDrive(config.drive().drive(), false, config.drive().index_mode()); | ||||
|   | ||||
| @@ -27,7 +27,7 @@ int mainSeek(int argc, const char* argv[]) | ||||
| { | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, {}); | ||||
|  | ||||
| 	if (!config.flux_source().has_drive()) | ||||
| 	if (config.flux_source().type() != FluxSourceProto::DRIVE) | ||||
| 		Error() << "this only makes sense with a real disk drive"; | ||||
|  | ||||
|     usbSetDrive(config.drive().drive(), false, config.drive().index_mode()); | ||||
|   | ||||
| @@ -67,9 +67,9 @@ int mainWrite(int argc, const char* argv[]) | ||||
| { | ||||
| 	if (argc == 1) | ||||
| 		showProfiles("write", formats); | ||||
| 	config.mutable_flux_sink()->mutable_drive(); | ||||
| 	config.mutable_flux_sink()->set_type(FluxSinkProto::DRIVE); | ||||
| 	if (verify) | ||||
| 		config.mutable_flux_source()->mutable_drive(); | ||||
| 		config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE); | ||||
|     flags.parseFlagsWithConfigFiles(argc, argv, formats); | ||||
|  | ||||
| 	std::unique_ptr<ImageReader> reader(ImageReader::create(config.image_reader())); | ||||
| @@ -83,7 +83,7 @@ int mainWrite(int argc, const char* argv[]) | ||||
| 		decoder = Decoder::create(config.decoder()); | ||||
|  | ||||
| 	std::unique_ptr<FluxSource> fluxSource; | ||||
| 	if (verify && config.has_flux_source() && config.flux_source().has_drive()) | ||||
| 	if (verify && (config.flux_source().type() == FluxSourceProto::DRIVE)) | ||||
| 		fluxSource = FluxSource::create(config.flux_source()); | ||||
|  | ||||
| 	writeDiskCommand(*image, *encoder, *fluxSink, decoder.get(), fluxSource.get()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user