/** * g_dbus_object_manager_server_set_connection: * @manager: A #GDBusObjectManagerServer. * @connection: (allow-none): A #GDBusConnection or %NULL. * * Exports all objects managed by @manager on @connection. If * @connection is %NULL, stops exporting objects. */ void g_dbus_object_manager_server_set_connection (GDBusObjectManagerServer *manager, GDBusConnection *connection) { g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_SERVER (manager)); g_return_if_fail (connection == NULL || G_IS_DBUS_CONNECTION (connection)); if (manager->priv->connection == connection) goto out; if (manager->priv->connection != NULL) { unexport_all (manager, FALSE); g_object_unref (manager->priv->connection); manager->priv->connection = NULL; } manager->priv->connection = connection != NULL ? g_object_ref (connection) : NULL; if (manager->priv->connection != NULL) export_all (manager); g_object_notify (G_OBJECT (manager), "connection"); out: ; }
static void g_dbus_object_manager_server_constructed (GObject *object) { GDBusObjectManagerServer *manager = G_DBUS_OBJECT_MANAGER_SERVER (object); if (manager->priv->connection != NULL) export_all (manager); if (G_OBJECT_CLASS (g_dbus_object_manager_server_parent_class)->constructed != NULL) G_OBJECT_CLASS (g_dbus_object_manager_server_parent_class)->constructed (object); }
int main(int argc, char **argv) { char *options = NULL; char *progname = NULL; int f_export = 1; int f_all = 0; int f_verbose = 0; int f_export_format = 0; int f_reexport = 0; int f_ignore = 0; int i, c; int new_cache = 0; int force_flush = 0; if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; xlog_open(progname); xlog_stderr(1); xlog_syslog(0); while ((c = getopt(argc, argv, "afhio:ruvs")) != EOF) { switch(c) { case 'a': f_all = 1; break; case 'f': force_flush = 1; break; case 'h': usage(progname, 0); break; case 'i': f_ignore = 1; break; case 'o': options = optarg; break; case 'r': f_reexport = 1; f_all = 1; break; case 'u': f_export = 0; break; case 'v': f_verbose = 1; break; case 's': f_export_format = 1; break; default: usage(progname, 1); break; } } if (optind != argc && f_all) { xlog(L_ERROR, "extra arguments are not permitted with -a or -r"); return 1; } if (f_ignore && (f_all || ! f_export)) { xlog(L_ERROR, "-i not meaningful with -a, -r or -u"); return 1; } if (f_reexport && ! f_export) { xlog(L_ERROR, "-r and -u are incompatible"); return 1; } new_cache = check_new_cache(); if (optind == argc && ! f_all) { if (force_flush) { if (new_cache) cache_flush(1); else { xlog(L_ERROR, "-f is available only " "with new cache controls. " "Mount /proc/fs/nfsd first"); return 1; } return 0; } else { xtab_export_read(); dump(f_verbose, f_export_format); return 0; } } /* * Serialize things as best we can */ grab_lockfile(); atexit(release_lockfile); if (f_export && ! f_ignore) { export_read(_PATH_EXPORTS); export_d_read(_PATH_EXPORTS_D); } if (f_export) { if (f_all) export_all(f_verbose); else for (i = optind; i < argc ; i++) exportfs(argv[i], options, f_verbose); } /* If we are unexporting everything, then * don't care about what should be exported, as that * may require DNS lookups.. */ if (! ( !f_export && f_all)) { /* note: xtab_*_read does not update entries if they already exist, * so this will not lose new options */ if (!f_reexport) xtab_export_read(); if (!f_export) for (i = optind ; i < argc ; i++) unexportfs(argv[i], f_verbose); if (!new_cache) rmtab_read(); } if (!new_cache) { xtab_mount_read(); exports_update(f_verbose); } xtab_export_write(); if (new_cache) cache_flush(force_flush); if (!new_cache) xtab_mount_write(); return export_errno; }