dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59c)
-AC_INIT(udisks, 1.0.2, http://bugs.freedesktop.org/enter_bug.cgi?product=udisks)
-AM_INIT_AUTOMAKE(udisks, 1.0.2)
+AC_INIT(udisks, 1.1.0, http://bugs.freedesktop.org/enter_bug.cgi?product=udisks)
+AM_INIT_AUTOMAKE(udisks, 1.1.0)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<interface name="org.freedesktop.UDisks">
+ <annotation name="org.gtk.GDBus.Name" value="Daemon"/>
<!-- ************************************************************ -->
NULL =
INCLUDES = \
- -I$(top_builddir)/src -I$(top_srcdir)/src \
- -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
- -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
- -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
- -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
- -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\" \
- -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
- -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
- -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
- $(DBUS_GLIB_CFLAGS) \
- $(POLKIT_GOBJECT_1_CFLAGS) \
- $(GUDEV_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GIO_CFLAGS)
-
-BUILT_SOURCES = \
- daemon-glue.h \
- device-glue.h \
- adapter-glue.h \
- port-glue.h \
- expander-glue.h \
- marshal.h marshal.c
-
-marshal.h: marshal.list
- glib-genmarshal $< --prefix=marshal --header > $@
-
-marshal.c: marshal.list
- echo "#include \"marshal.h\"" > $@ && glib-genmarshal $< --prefix=marshal --body >> $@
-
-daemon-glue.h: $(top_srcdir)/data/org.freedesktop.UDisks.xml Makefile.am
- dbus-binding-tool --prefix=daemon --mode=glib-server --output=daemon-glue.h $(top_srcdir)/data/org.freedesktop.UDisks.xml
-
-device-glue.h: $(top_srcdir)/data/org.freedesktop.UDisks.Device.xml Makefile.am
- dbus-binding-tool --prefix=device --mode=glib-server --output=device-glue.h $(top_srcdir)/data/org.freedesktop.UDisks.Device.xml
-
-adapter-glue.h: $(top_srcdir)/data/org.freedesktop.UDisks.Adapter.xml Makefile.am
- dbus-binding-tool --prefix=adapter --mode=glib-server --output=adapter-glue.h $(top_srcdir)/data/org.freedesktop.UDisks.Adapter.xml
-
-expander-glue.h: $(top_srcdir)/data/org.freedesktop.UDisks.Expander.xml Makefile.am
- dbus-binding-tool --prefix=expander --mode=glib-server --output=expander-glue.h $(top_srcdir)/data/org.freedesktop.UDisks.Expander.xml
-
-port-glue.h: $(top_srcdir)/data/org.freedesktop.UDisks.Port.xml Makefile.am
- dbus-binding-tool --prefix=port --mode=glib-server --output=port-glue.h $(top_srcdir)/data/org.freedesktop.UDisks.Port.xml
+ -I$(top_builddir)/src -I$(top_srcdir)/src \
+ -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
+ -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
+ -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+ -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
+ -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\" \
+ -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
+ -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
+ -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
+ $(DBUS_GLIB_CFLAGS) \
+ $(POLKIT_GOBJECT_1_CFLAGS) \
+ $(GUDEV_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(NULL)
+
+generated-bindings.stamp : Makefile.am $(top_srcdir)/data/org.freedesktop.UDisks.xml $(top_srcdir)/data/org.freedesktop.UDisks.Device.xml
+ gdbus-binding-tool \
+ --strip-prefix org.freedesktop.UDisks. \
+ --output-prefix generated \
+ $(top_srcdir)/data/org.freedesktop.UDisks.xml \
+ $(top_srcdir)/data/org.freedesktop.UDisks.Device.xml \
+ $(NULL)
+
+BUILT_SOURCES = \
+ generated-bindings.stamp \
+ generated-bindings.h \
+ generated-daemon.h generated-daemon.c \
+ generated-device.h generated-device.c \
+ generated-marshallers.h generated-marshallers.c \
+ generated-typemappers.h \
+ $(NULL)
libexec_PROGRAMS = udisks-daemon
udisks_daemon_SOURCES = \
types.h \
+ error.h error.c \
+ main.c \
+ linuxdaemon.h linuxdaemon.c \
private.h \
profile.h \
- daemon.h daemon.c \
- device.h device.c \
- device-private.h device-private.c \
- adapter.h adapter.c \
- adapter-private.h adapter-private.c \
- expander.h expander.c \
- expander-private.h expander-private.c \
- port.h port.c \
- port-private.h port-private.c \
- mount-file.h mount-file.c \
- mount.h mount.c \
- mount-monitor.h mount-monitor.c \
- inhibitor.h inhibitor.c \
- poller.h poller.c \
- main.c \
- $(BUILT_SOURCES)
+ $(BUILT_SOURCES) \
+ $(NULL)
+
+#udisks_daemon_SOURCES = \
+# types.h \
+# private.h \
+# profile.h \
+# daemon.h daemon.c \
+# device.h device.c \
+# device-private.h device-private.c \
+# adapter.h adapter.c \
+# adapter-private.h adapter-private.c \
+# expander.h expander.c \
+# expander-private.h expander-private.c \
+# port.h port.c \
+# port-private.h port-private.c \
+# mount-file.h mount-file.c \
+# mount.h mount.c \
+# mount-monitor.h mount-monitor.c \
+# inhibitor.h inhibitor.c \
+# poller.h poller.c \
+# main.c \
+# $(BUILT_SOURCES) \
+# $(NULL)
+#
udisks_daemon_CPPFLAGS = \
-I$(top_srcdir)/src \
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2007-2010 David Zeuthen <david@fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "config.h"
+
+#include "error.h"
+
+static const GDBusErrorEntry error_entries[] =
+{
+ {ERROR_FAILED, "org.freedesktop.UDisks.Error.Failed"},
+ {ERROR_PERMISSION_DENIED, "org.freedesktop.UDisks.Error.PermissionDenied"},
+ {ERROR_BUSY, "org.freedesktop.UDisks.Error.Busy"},
+ {ERROR_CANCELLED, "org.freedesktop.UDisks.Error.Cancelled"},
+ {ERROR_INHIBITED, "org.freedesktop.UDisks.Error.Inhibited"},
+ {ERROR_INVALID_OPTION, "org.freedesktop.UDisks.Error.InvalidOption"},
+ {ERROR_NOT_SUPPORTED, "org.freedesktop.UDisks.Error.NotSupported"},
+ {ERROR_ATA_SMART_WOULD_WAKEUP, "org.freedesktop.UDisks.Error.AtaSmartWouldWakeup"},
+ {ERROR_FILESYSTEM_DRIVER_MISSING, "org.freedesktop.UDisks.Error.FilesystemDriverMissing"},
+ {ERROR_FILESYSTEM_TOOLS_MISSING, "org.freedesktop.UDisks.Error.FilesystemToolsMissing"}
+};
+
+GQuark
+error_quark (void)
+{
+ static volatile gsize quark_volatile = 0;
+ g_dbus_error_register_error_domain ("udisks-error-quark",
+ &quark_volatile,
+ error_entries,
+ G_N_ELEMENTS (error_entries));
+ G_STATIC_ASSERT (G_N_ELEMENTS (error_entries) - 1 == ERROR_FILESYSTEM_TOOLS_MISSING);
+ return (GQuark) quark_volatile;
+}
+
+
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2007-2010 David Zeuthen <david@fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+
+#ifndef __ERROR_H__
+#define __ERROR_H__
+
+#include "types.h"
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ ERROR_FAILED,
+ ERROR_PERMISSION_DENIED,
+ ERROR_BUSY,
+ ERROR_CANCELLED,
+ ERROR_INHIBITED,
+ ERROR_INVALID_OPTION,
+ ERROR_NOT_SUPPORTED,
+ ERROR_ATA_SMART_WOULD_WAKEUP,
+ ERROR_FILESYSTEM_DRIVER_MISSING,
+ ERROR_FILESYSTEM_TOOLS_MISSING
+} Error;
+
+#define ERROR (error_quark ())
+GQuark error_quark (void);
+
+G_END_DECLS
+
+#endif /* __ERROR_H__ */
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2008 David Zeuthen <david@fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "config.h"
+
+#include <gudev/gudev.h>
+
+#include "linuxdaemon.h"
+
+struct _LinuxDaemonPrivate
+{
+ GUdevClient *udev_client;
+};
+
+static void daemon_iface_init (DaemonIface *iface);
+G_DEFINE_TYPE_WITH_CODE (LinuxDaemon, linux_daemon, TYPE_DAEMON_STUB,
+ G_IMPLEMENT_INTERFACE (TYPE_DAEMON, daemon_iface_init));
+
+
+static void
+linux_daemon_finalize (GObject *object)
+{
+ LinuxDaemon *daemon = LINUX_DAEMON (object);
+
+ g_object_unref (daemon->priv->udev_client);
+
+ if (G_OBJECT_CLASS (linux_daemon_parent_class)->finalize != NULL)
+ G_OBJECT_CLASS (linux_daemon_parent_class)->finalize (object);
+}
+
+static void
+linux_daemon_init (LinuxDaemon *daemon)
+{
+ const gchar *subsystems[] = {"block", NULL};
+
+ daemon->priv = G_TYPE_INSTANCE_GET_PRIVATE (daemon, TYPE_LINUX_DAEMON, LinuxDaemonPrivate);
+
+ daemon->priv->udev_client = g_udev_client_new (subsystems);
+}
+
+static void
+linux_daemon_class_init (LinuxDaemonClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = linux_daemon_finalize;
+
+ g_type_class_add_private (klass, sizeof (LinuxDaemonPrivate));
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static gboolean
+handle_enumerate_device_files (Daemon *_daemon,
+ GDBusMethodInvocation *invocation)
+{
+ /* LinuxDaemon *daemon = LINUX_DAEMON (_daemon); */
+ const gchar *ret[] = {"/dev/sda", "/dev/sda1", NULL};
+
+ daemon_complete_enumerate_device_files (_daemon, invocation, ret);
+
+ return TRUE;
+}
+
+static void
+daemon_iface_init (DaemonIface *iface)
+{
+ iface->handle_enumerate_device_files = handle_enumerate_device_files;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2008 David Zeuthen <david@fubar.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __LINUX_DAEMON_H__
+#define __LINUX_DAEMON_H__
+
+#include "types.h"
+
+G_BEGIN_DECLS
+
+#define TYPE_LINUX_DAEMON (linux_daemon_get_type ())
+#define LINUX_DAEMON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_LINUX_DAEMON, LinuxDaemon))
+#define LINUX_DAEMON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TYPE_DAEMON, LinuxDaemonClass))
+#define IS_LINUX_DAEMON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_LINUX_DAEMON))
+#define IS_LINUX_DAEMON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_LINUX_DAEMON))
+#define LINUX_DAEMON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_LINUX_DAEMON, LinuxDaemonClass))
+
+typedef struct _LinuxDaemonClass LinuxDaemonClass;
+typedef struct _LinuxDaemonPrivate LinuxDaemonPrivate;
+
+struct _LinuxDaemon
+{
+ DaemonStub parent;
+ LinuxDaemonPrivate *priv;
+};
+
+struct _LinuxDaemonClass
+{
+ DaemonStubClass parent_class;
+};
+
+GType linux_daemon_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __LINUX_DAEMON_H__ */
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
- * Copyright (C) 2007 David Zeuthen <david@fubar.dk>
+ * Copyright (C) 2007-2010 David Zeuthen <david@fubar.dk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <grp.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <glib-object.h>
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include "config.h"
-#include "poller.h"
-#include "daemon.h"
+#include <gio/gio.h>
#include "profile.h"
-#define NAME_TO_CLAIM "org.freedesktop.UDisks"
+#include "linuxdaemon.h"
-static GMainLoop *loop;
+static Daemon *the_daemon = NULL;
+static GMainLoop *loop = NULL;
+static gchar *opt_helper_dir = NULL;
+static gboolean opt_replace = FALSE;
+static GOptionEntry opt_entries[] = {
+ {"replace", 0, 0, G_OPTION_ARG_NONE, &opt_replace, "Replace existing daemon", NULL},
+ {"helper-dir", 0, G_OPTION_FLAG_FILENAME, G_OPTION_ARG_STRING, &opt_helper_dir, "Directory for helper tools", NULL},
+ {NULL }
+};
static void
-name_lost (DBusGProxy *system_bus_proxy,
- const char *name_which_was_lost,
- gpointer user_data)
-{
- g_warning ("got NameLost, exiting");
- g_main_loop_quit (loop);
-}
-
-static gboolean
-acquire_name_on_proxy (DBusGProxy *system_bus_proxy,
- gboolean replace)
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
{
GError *error;
- guint result;
- gboolean res;
- gboolean ret;
- guint flags;
- ret = FALSE;
+ PROFILE ("Connected to the system bus");
+ g_print ("Connected to the system bus\n");
- flags = DBUS_NAME_FLAG_ALLOW_REPLACEMENT;
- if (replace)
- flags |= DBUS_NAME_FLAG_REPLACE_EXISTING;
-
- if (system_bus_proxy == NULL)
- {
- goto out;
- }
+ g_assert (the_daemon == NULL);
+ the_daemon = g_object_new (TYPE_LINUX_DAEMON,
+ "daemon-version", PACKAGE_VERSION,
+ NULL);
error = NULL;
- res = dbus_g_proxy_call (system_bus_proxy,
- "RequestName",
- &error,
- G_TYPE_STRING,
- NAME_TO_CLAIM,
- G_TYPE_UINT,
- flags,
- G_TYPE_INVALID,
- G_TYPE_UINT,
- &result,
- G_TYPE_INVALID);
- if (!res)
- {
- if (error != NULL)
- {
- g_warning ("Failed to acquire %s: %s", NAME_TO_CLAIM, error->message);
- g_error_free (error);
- }
- else
- {
- g_warning ("Failed to acquire %s", NAME_TO_CLAIM);
- }
- goto out;
- }
-
- if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+ daemon_register_object (the_daemon,
+ connection,
+ "/org/freedesktop/UDisks",
+ &error);
+ if (error != NULL)
{
- if (error != NULL)
- {
- g_warning ("Failed to acquire %s: %s", NAME_TO_CLAIM, error->message);
- g_error_free (error);
- }
- else
- {
- g_warning ("Failed to acquire %s", NAME_TO_CLAIM);
- }
- goto out;
+ g_printerr ("Error registering object at /org/freedesktop/UDisks: %s", error->message);
+ g_error_free (error);
+ g_main_loop_quit (loop); /* exit */
}
+}
- dbus_g_proxy_add_signal (system_bus_proxy, "NameLost", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (system_bus_proxy, "NameLost", G_CALLBACK (name_lost), NULL, NULL);
-
- ret = TRUE;
+static void
+on_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ PROFILE ("Lost the name org.freedesktop.UDisks - exiting");
+ g_print ("Lost the name org.freedesktop.UDisks - exiting\n");
+ g_main_loop_quit (loop);
+}
- out:
- return ret;
+static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ PROFILE ("Acquired the name org.freedesktop.UDisks on the system bus");
+ g_print ("Acquired the name org.freedesktop.UDisks on the system bus\n");
}
int
-main (int argc,
+main (int argc,
char **argv)
{
GError *error;
- Daemon *daemon;
- GOptionContext *context;
- DBusGProxy *system_bus_proxy;
- DBusGConnection *bus;
- static char *helper_dir = NULL;
- char *path;
- int ret;
- static gboolean replace;
- static GOptionEntry entries[] =
- {
- { "replace", 0, 0, G_OPTION_ARG_NONE, &replace, "Replace existing daemon", NULL },
- { "helper-dir", 0, G_OPTION_FLAG_FILENAME, G_OPTION_ARG_STRING,
- &helper_dir, "Directory for helper tools", NULL },
- { NULL } };
+ GOptionContext *opt_context;
+ gchar *s;
+ gint ret;
+ guint name_owner_id;
PROFILE ("main(): start");
ret = 1;
- error = NULL;
+ loop = NULL;
+ opt_context = NULL;
+ name_owner_id = 0;
g_type_init ();
+#if 0
/* fork the polling process early */
if (!poller_setup (argc, argv))
{
goto out;
}
+#endif
/* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
if (!g_setenv ("GIO_USE_VFS", "local", TRUE))
{
- g_warning ("Couldn't set GIO_USE_GVFS");
- goto out;
- }
-
- context = g_option_context_new ("udisks storage daemon");
- g_option_context_add_main_entries (context, entries, NULL);
- g_option_context_parse (context, &argc, &argv, NULL);
- g_option_context_free (context);
-
- /* run with a controlled path */
- if (helper_dir != NULL)
- path = g_strdup_printf ("%s:" PACKAGE_LIBEXEC_DIR ":/sbin:/bin:/usr/sbin:/usr/bin", helper_dir);
- else
- path = g_strdup (PACKAGE_LIBEXEC_DIR ":/sbin:/bin:/usr/sbin:/usr/bin");
-
- if (!g_setenv ("PATH", path, TRUE))
- {
- g_warning ("Couldn't set PATH");
+ g_printerr ("Error setting GIO_USE_GVFS");
goto out;
}
- g_free (path);
- PROFILE ("main(): basic initialization done");
-
- bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (bus == NULL)
+ opt_context = g_option_context_new ("udisks storage daemon");
+ g_option_context_add_main_entries (opt_context, opt_entries, NULL);
+ error = NULL;
+ if (!g_option_context_parse (opt_context, &argc, &argv, &error))
{
- g_warning ("Couldn't connect to system bus: %s", error->message);
+ g_printerr ("Error parsing options: %s", error->message);
g_error_free (error);
goto out;
}
- system_bus_proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- if (system_bus_proxy == NULL)
- {
- g_warning ("Could not construct system_bus_proxy object; bailing out");
- goto out;
- }
-
- if (!acquire_name_on_proxy (system_bus_proxy, replace))
- {
- g_warning ("Could not acquire name; bailing out");
- goto out;
- }
-
- PROFILE ("main(): D-Bus initialization done");
-
- g_debug ("Starting daemon version %s", VERSION);
-
- daemon = daemon_new ();
-
- if (daemon == NULL)
+ /* run with a controlled path */
+ if (opt_helper_dir != NULL)
+ s = g_strdup_printf ("%s:" PACKAGE_LIBEXEC_DIR ":/sbin:/bin:/usr/sbin:/usr/bin", opt_helper_dir);
+ else
+ s = g_strdup (PACKAGE_LIBEXEC_DIR ":/sbin:/bin:/usr/sbin:/usr/bin");
+ if (!g_setenv ("PATH", s, TRUE))
{
+ g_printerr ("Error setting PATH\n");
goto out;
}
+ g_free (s);
+
+ name_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
+ "org.freedesktop.UDisks",
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+ (opt_replace ? G_BUS_NAME_OWNER_FLAGS_REPLACE : 0),
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ NULL,
+ NULL);
PROFILE ("main(): starting main loop");
+
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
- g_object_unref (daemon);
- g_main_loop_unref (loop);
ret = 0;
out:
+ if (name_owner_id != 0)
+ g_bus_unown_name (name_owner_id);
+ if (the_daemon != NULL)
+ g_object_unref (the_daemon);
+ if (loop != NULL)
+ g_main_loop_unref (loop);
+ if (opt_context != NULL)
+ g_option_context_free (opt_context);
return ret;
}
#ifndef __TYPES_H__
#define __TYPES_H__
-#include <glib-object.h>
+#include <gio/gio.h>
+#include "generated-bindings.h"
G_BEGIN_DECLS
-typedef struct Daemon Daemon;
-typedef struct Device Device;
-typedef struct Adapter Adapter;
-typedef struct Expander Expander;
-typedef struct Port Port;
+typedef struct _LinuxDaemon LinuxDaemon;
typedef struct Mount Mount;
typedef struct MountMonitor MountMonitor;