[PATCH] Adding version check for plugins.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marcel,

As per the discussion on IRC, I am attaching a version check patch for plugins.

Let me know if anything needs modifications.

Cheers,
Alok.
From cc8b1da3701bdd29363fef4cc796de3ad6943c6a Mon Sep 17 00:00:00 2001
From: Alok Barsode <alokbarsode@xxxxxxxxx>
Date: Tue, 17 Mar 2009 15:36:14 +0530
Subject: [PATCH] Adding version check for plugins.

---
 audio/main.c      |    2 +-
 input/main.c      |    2 +-
 network/main.c    |    2 +-
 plugins/echo.c    |    2 +-
 plugins/hal.c     |    2 +-
 plugins/netlink.c |    2 +-
 plugins/service.c |    2 +-
 plugins/storage.c |    2 +-
 serial/main.c     |    2 +-
 src/main.c        |    2 +-
 src/plugin.c      |    5 +++++
 src/plugin.h      |    5 +++--
 12 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/audio/main.c b/audio/main.c
index 1678b58..f5eb7dd 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -171,4 +171,4 @@ static void audio_exit(void)
 	dbus_connection_unref(connection);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("audio", audio_init, audio_exit)
+BLUETOOTH_PLUGIN_DEFINE("audio", VERSION, audio_init, audio_exit)
diff --git a/input/main.c b/input/main.c
index 31e2ef6..010b731 100644
--- a/input/main.c
+++ b/input/main.c
@@ -82,4 +82,4 @@ static void input_exit(void)
 	dbus_connection_unref(connection);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("input", input_init, input_exit)
+BLUETOOTH_PLUGIN_DEFINE("input", VERSION, input_init, input_exit)
diff --git a/network/main.c b/network/main.c
index 4744185..5f96d4b 100644
--- a/network/main.c
+++ b/network/main.c
@@ -55,4 +55,4 @@ static void network_exit(void)
 	dbus_connection_unref(connection);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("network", network_init, network_exit)
+BLUETOOTH_PLUGIN_DEFINE("network", VERSION, network_init, network_exit)
diff --git a/plugins/echo.c b/plugins/echo.c
index 3486ef1..832bf8b 100644
--- a/plugins/echo.c
+++ b/plugins/echo.c
@@ -163,4 +163,4 @@ static void echo_exit(void)
 	btd_unregister_adapter_driver(&echo_server);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("echo", echo_init, echo_exit)
+BLUETOOTH_PLUGIN_DEFINE("echo", VERSION, echo_init, echo_exit)
diff --git a/plugins/hal.c b/plugins/hal.c
index f066a5a..219b46e 100644
--- a/plugins/hal.c
+++ b/plugins/hal.c
@@ -158,4 +158,4 @@ static void hal_exit(void)
 	btd_unregister_adapter_driver(&hal_driver);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("hal", hal_init, hal_exit)
+BLUETOOTH_PLUGIN_DEFINE("hal", VERSION, hal_init, hal_exit)
diff --git a/plugins/netlink.c b/plugins/netlink.c
index 78a18aa..f777cf9 100644
--- a/plugins/netlink.c
+++ b/plugins/netlink.c
@@ -123,4 +123,4 @@ static void netlink_exit(void)
 	nl_handle_destroy(handle);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("netlink", netlink_init, netlink_exit)
+BLUETOOTH_PLUGIN_DEFINE("netlink", VERSION, netlink_init, netlink_exit)
diff --git a/plugins/service.c b/plugins/service.c
index 4a87234..b4d405b 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -859,4 +859,4 @@ static void service_exit(void)
 	dbus_connection_unref(connection);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("service", service_init, service_exit)
+BLUETOOTH_PLUGIN_DEFINE("service", VERSION, service_init, service_exit)
diff --git a/plugins/storage.c b/plugins/storage.c
index 733c479..c4dbe16 100644
--- a/plugins/storage.c
+++ b/plugins/storage.c
@@ -39,4 +39,4 @@ static void storage_exit(void)
 {
 }
 
-BLUETOOTH_PLUGIN_DEFINE("storage", storage_init, storage_exit)
+BLUETOOTH_PLUGIN_DEFINE("storage", VERSION, storage_init, storage_exit)
diff --git a/serial/main.c b/serial/main.c
index bb2a28c..5db389c 100644
--- a/serial/main.c
+++ b/serial/main.c
@@ -55,4 +55,4 @@ static void serial_exit(void)
 	dbus_connection_unref(connection);
 }
 
-BLUETOOTH_PLUGIN_DEFINE("serial", serial_init, serial_exit)
+BLUETOOTH_PLUGIN_DEFINE("serial", VERSION, serial_init, serial_exit)
diff --git a/src/main.c b/src/main.c
index 3c7d70b..5303444 100644
--- a/src/main.c
+++ b/src/main.c
@@ -695,7 +695,7 @@ int main(int argc, char *argv[])
 
 	umask(0077);
 
-	start_logging("bluetoothd", "Bluetooth daemon");
+	start_logging("bluetoothd", "Bluetooth daemon %s", VERSION);
 
 	memset(&sa, 0, sizeof(sa));
 	sa.sa_flags = SA_NOCLDSTOP;
diff --git a/src/plugin.c b/src/plugin.c
index 4559c77..cebebfd 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -52,6 +52,11 @@ static gboolean add_plugin(void *handle, struct bluetooth_plugin_desc *desc)
 
 	if (desc->init == NULL)
 		return FALSE;
+	
+	if (g_str_equal(desc->version, VERSION) == FALSE) {
+		DBG("version mismatch for %s", desc->name);
+		return FALSE;
+	}    
 
 	plugin = g_try_new0(struct bluetooth_plugin, 1);
 	if (plugin == NULL)
diff --git a/src/plugin.h b/src/plugin.h
index 31bcce8..62d5f75 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -23,13 +23,14 @@
 
 struct bluetooth_plugin_desc {
 	const char *name;
+	const char *version;
 	int (*init) (void);
 	void (*exit) (void);
 };
 
-#define BLUETOOTH_PLUGIN_DEFINE(name,init,exit) \
+#define BLUETOOTH_PLUGIN_DEFINE(name,version,init,exit) \
 		extern struct bluetooth_plugin_desc bluetooth_plugin_desc \
 				__attribute__ ((visibility("default"))); \
 		struct bluetooth_plugin_desc bluetooth_plugin_desc = { \
-			name, init, exit \
+			name, version, init, exit \
 		};
-- 
1.5.6.3


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux