Patchwork [06/18] petitboot: Discover unmount inactive devices

login
register
mail settings
Submitter Geoff Levand
Date March 25, 2009, 10:35 p.m.
Message ID <20090325223547.239121818@am.sony.com>>
Download mbox | patch
Permalink /patch/25110/
State Accepted
Delegated to: Jeremy Kerr
Headers show

Comments

Geoff Levand - March 25, 2009, 10:35 p.m.
Unmount devices with no bootloader conf files.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
---
 discover/device-handler.c |    9 ++++++---
 discover/parser.c         |    6 +++---
 discover/parser.h         |    2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)
Jeremy Kerr - March 30, 2009, 8:33 a.m.
Geoff,

> Unmount devices with no bootloader conf files.

Config files may refer to kernels/icons/etc on other devices, so we need 
to keep them mounted, even if we didn't find anything...

Granted, we're probably not going to see any references to resources 
that aren't on the same media - they'll probably be on a different 
partition of the same device.

You're trying to work-around the can't-eject-mounted-CD problem, right?

Cheers,

Jeremy

Patch

--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -321,7 +321,6 @@  static int handle_add_event(struct devic
 		return 0;
 	}
 
-	handler->n_devices++;
 	list_add(&handler->contexts, &ctx->list);
 	talloc_set_destructor(ctx, destroy_context);
 
@@ -331,9 +330,13 @@  static int handle_add_event(struct devic
 	list_init(&ctx->device->boot_options);
 
 	/* run the parsers */
-	iterate_parsers(ctx);
+	rc = iterate_parsers(ctx);
 
-	discover_server_notify_add(handler->server, ctx->device);
+	if (rc) {
+		handler->n_devices++;
+		discover_server_notify_add(handler->server, ctx->device);
+	} else
+		talloc_free(ctx);
 
 	return 0;
 }
--- a/discover/parser.c
+++ b/discover/parser.c
@@ -10,7 +10,7 @@ 
 
 extern struct parser __start_parsers[], __stop_parsers[];
 
-void iterate_parsers(struct discover_context *ctx)
+int iterate_parsers(struct discover_context *ctx)
 {
 	struct parser *parser;
 
@@ -18,11 +18,11 @@  void iterate_parsers(struct discover_con
 
 	for (parser = __start_parsers; parser < __stop_parsers; parser++) {
 		pb_log("\ttrying parser '%s'\n", parser->name);
-		/* just use a dummy device path for now */
 		if (parser->parse(ctx))
-			return;
+			return 1;
 	}
 	pb_log("\tno boot_options found\n");
+	return 0;
 }
 
 static int compare_parsers(const void *a, const void *b)
--- a/discover/parser.h
+++ b/discover/parser.h
@@ -22,6 +22,6 @@  enum generic_icon_type {
 
 void parser_init(void);
 
-void iterate_parsers(struct discover_context *ctx);
+int iterate_parsers(struct discover_context *ctx);
 
 #endif /* _PARSER_H */