[dconf] on NFS create a temp dir for the shm file
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] on NFS create a temp dir for the shm file
- Date: Sat, 17 Jul 2010 16:43:35 +0000 (UTC)
commit d03bd6b443a6b98430eed983cb1996bebb302d9e
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Jul 17 12:42:44 2010 -0400
on NFS create a temp dir for the shm file
dconf should be vaguely NFS-safe now
common/dconf-shmdir.c | 17 ++++++++++-------
engine/dconf-engine.c | 2 +-
service/dconf-writer.c | 12 +++++++-----
3 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/common/dconf-shmdir.c b/common/dconf-shmdir.c
index d94f5c3..4eaa376 100644
--- a/common/dconf-shmdir.c
+++ b/common/dconf-shmdir.c
@@ -1,4 +1,5 @@
#include "dconf-shmdir.h"
+
#include <sys/statfs.h>
#include <sys/vfs.h>
#include <errno.h>
@@ -41,13 +42,15 @@ dconf_shmdir_from_environment (void)
const gchar *cache = g_get_user_cache_dir ();
if (is_local (cache))
- result = g_build_filename (cache, "dconf", NULL);
- }
-
- if (g_mkdir_with_parents (result, 0700))
- {
- g_free (result);
- result = NULL;
+ {
+ result = g_build_filename (cache, "dconf", NULL);
+
+ if (g_mkdir_with_parents (result, 0700) != 0)
+ {
+ g_free (result);
+ result = NULL;
+ }
+ }
}
return result;
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index 43d73f2..a48701d 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -53,7 +53,7 @@ dconf_engine_get_session_dir (void)
g_variant_get (result, "(v)", &str);
if (g_variant_is_of_type (str, G_VARIANT_TYPE_STRING))
- session_dir = g_variant_get_string (str, NULL);
+ session_dir = g_variant_dup_string (str, NULL);
else
g_critical ("dconf service sent invalid reply");
diff --git a/service/dconf-writer.c b/service/dconf-writer.c
index 7f7ff7f..03a2975 100644
--- a/service/dconf-writer.c
+++ b/service/dconf-writer.c
@@ -3,6 +3,7 @@
#include "dconf-shmdir.h"
#include "dconf-rebuilder.h"
+#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -119,7 +120,6 @@ void
dconf_writer_init (void)
{
const gchar *config_dir = g_get_user_config_dir ();
- const gchar *cache_dir = g_get_user_cache_dir ();
dconf_writer_db_dir = g_build_filename (config_dir, "dconf", NULL);
@@ -163,10 +163,12 @@ dconf_writer_init (void)
if (dconf_writer_shm_dir == NULL)
{
- dconf_writer_shm_dir = g_build_filename (cache_dir, "dconf", NULL);
+ const gchar *tmpdir = g_get_tmp_dir ();
+ gchar *shmdir;
- if (g_mkdir_with_parents (dconf_writer_shm_dir, 0700))
- g_error ("Can not create directory '%s': %s",
- dconf_writer_shm_dir, g_strerror (errno));
+ shmdir = g_build_filename (tmpdir, "dconf.XXXXXX", NULL);
+
+ if ((dconf_writer_shm_dir = mkdtemp (shmdir)) == NULL)
+ g_error ("Can not create reasonable shm directory");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]