diff options
author | Mark McLoughlin <mark@skynet.ie> | 2004-04-19 10:09:30 +0000 |
---|---|---|
committer | Mark McLoughlin <markmc@src.gnome.org> | 2004-04-19 10:09:30 +0000 |
commit | aa2990d07ad1e636ab527574a1dea458c565e98e (patch) | |
tree | 45fa9838e1757164053fa75ca503199e00afe7b6 | |
parent | 76a479e3d2c01ddc0e3b4135cdf3f821b40222ef (diff) | |
download | gconf-aa2990d07ad1e636ab527574a1dea458c565e98e.tar.gz |
Based on a patch from Ryan Lovett <ryan@ocf.berkeley.edu> in bug #95198.
2004-04-19 Mark McLoughlin <mark@skynet.ie>
Based on a patch from Ryan Lovett <ryan@ocf.berkeley.edu>
in bug #95198.
* backends/markup-backend.c: (resolve_address):
backends/xml-backend.c: (resolve_address): check to see
if the dir exists before trying to create it rather than
relying on EEXIST from mkdir.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | backends/markup-backend.c | 36 | ||||
-rw-r--r-- | backends/xml-backend.c | 36 |
3 files changed, 42 insertions, 40 deletions
@@ -1,3 +1,13 @@ +2004-04-19 Mark McLoughlin <mark@skynet.ie> + + Based on a patch from Ryan Lovett <ryan@ocf.berkeley.edu> + in bug #95198. + + * backends/markup-backend.c: (resolve_address): + backends/xml-backend.c: (resolve_address): check to see + if the dir exists before trying to create it rather than + relying on EEXIST from mkdir. + 2004-04-16 Colin Walters <walters@redhat.com> * gconf/gconf-internals.c (gconf_activate_server): Move temporary diff --git a/backends/markup-backend.c b/backends/markup-backend.c index 18e7f702..b7c069c0 100644 --- a/backends/markup-backend.c +++ b/backends/markup-backend.c @@ -248,6 +248,7 @@ resolve_address (const char *address, GError **err) { char* root_dir; + struct stat statbuf; MarkupSource* xsource; GConfSource *source; gint flags = 0; @@ -262,27 +263,22 @@ resolve_address (const char *address, if (root_dir == NULL) return NULL; - if (mkdir (root_dir, dir_mode) < 0) + if (stat (root_dir, &statbuf) == 0) { - if (errno != EEXIST) - { - gconf_set_error (err, GCONF_ERROR_FAILED, - _("Could not make directory `%s': %s"), - root_dir, g_strerror (errno)); - g_free (root_dir); - return NULL; - } - else - { - /* Already exists, base our dir_mode on it */ - struct stat statbuf; - if (stat (root_dir, &statbuf) == 0) - { - dir_mode = _gconf_mode_t_to_mode (statbuf.st_mode); - /* dir_mode without search bits */ - file_mode = dir_mode & (~0111); - } - } + /* Already exists, base our dir_mode on it */ + dir_mode = _gconf_mode_t_to_mode (statbuf.st_mode); + + /* dir_mode without search bits */ + file_mode = dir_mode & (~0111); + } + else if (mkdir (root_dir, dir_mode) < 0) + { + /* Error out even on EEXIST - shouldn't happen anyway */ + gconf_set_error (err, GCONF_ERROR_FAILED, + _("Could not make directory `%s': %s"), + root_dir, g_strerror (errno)); + g_free (root_dir); + return NULL; } force_readonly = FALSE; diff --git a/backends/xml-backend.c b/backends/xml-backend.c index ec209cb0..a1e52939 100644 --- a/backends/xml-backend.c +++ b/backends/xml-backend.c @@ -309,6 +309,7 @@ get_lock_dir_from_root_dir (const char *root_dir) static GConfSource* resolve_address (const gchar* address, GError** err) { + struct stat statbuf; gchar* root_dir; XMLSource* xsource; GConfSource* source; @@ -324,27 +325,22 @@ resolve_address (const gchar* address, GError** err) if (root_dir == NULL) return NULL; - if (mkdir(root_dir, dir_mode) < 0) + if (stat (root_dir, &statbuf) == 0) { - if (errno != EEXIST) - { - gconf_set_error(err, GCONF_ERROR_FAILED, - _("Could not make directory `%s': %s"), - (gchar*)root_dir, strerror(errno)); - g_free(root_dir); - return NULL; - } - else - { - /* Already exists, base our dir_mode on it */ - struct stat statbuf; - if (stat(root_dir, &statbuf) == 0) - { - dir_mode = _gconf_mode_t_to_mode (statbuf.st_mode); - /* dir_mode without search bits */ - file_mode = dir_mode & (~0111); - } - } + /* Already exists, base our dir_mode on it */ + dir_mode = _gconf_mode_t_to_mode (statbuf.st_mode); + + /* dir_mode without search bits */ + file_mode = dir_mode & (~0111); + } + else if (mkdir (root_dir, dir_mode) < 0) + { + /* Error out even on EEXIST - shouldn't happen anyway */ + gconf_set_error (err, GCONF_ERROR_FAILED, + _("Could not make directory `%s': %s"), + (gchar *)root_dir, g_strerror (errno)); + g_free (root_dir); + return NULL; } force_readonly = FALSE; |