From 8d6cb50fb7b747262fba0aa4903c461b9db5fbf1 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Tue, 19 May 2009 13:16:42 +0000 Subject: [PATCH] Allow only one instance of emountd --- emountd/emountd.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/emountd/emountd.cpp b/emountd/emountd.cpp index e1870e2..a5f916e 100644 --- a/emountd/emountd.cpp +++ b/emountd/emountd.cpp @@ -373,6 +373,15 @@ int main(int argc, char** argv) { bus_connection = session_conn; + /* + * make sure we are running only one instance; this is done by requesting ownership + * of the interface name + */ + if(dbus_bus_request_name(bus_connection, EMOUNTD_INTERFACE, 0, 0) != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + printf("One instance of emountd is already running! Balling out...\n"); + goto error; + } + /* let libhal use our system bus connection */ libhal_ctx_set_dbus_connection(ctx, conn);