[maemo-commits] [maemo-commits] r17522 - projects/haf/trunk/libosso/src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Feb 26 10:36:03 EET 2009
Author: kihamala
Date: 2009-02-26 10:36:02 +0200 (Thu, 26 Feb 2009)
New Revision: 17522

Modified:
   projects/haf/trunk/libosso/src/osso-state.c
Log:
use g_mkdir_with_parents instead of mkdir to fix problem when the state saving dir is not there


Modified: projects/haf/trunk/libosso/src/osso-state.c
===================================================================
--- projects/haf/trunk/libosso/src/osso-state.c	2009-02-26 07:15:09 UTC (rev 17521)
+++ projects/haf/trunk/libosso/src/osso-state.c	2009-02-26 08:36:02 UTC (rev 17522)
@@ -293,13 +293,20 @@
 	  return OSSO_ERROR;
 	}
     }
-    else if (mkdir(statedir, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
-	if(errno != EEXIST) {
-	    ULOG_ERR_F("Could not create plugin state directory '%s': %s",
-		       statedir, strerror(errno));
-	    g_free(statedir);
-	    return OSSO_ERROR;
-	}
+    else {
+        mode_t old_mask = umask(0);
+        if (g_mkdir_with_parents(statedir, S_IRUSR | S_IRGRP | S_IROTH
+                          | S_IWUSR | S_IWGRP | S_IWOTH
+                          | S_IXUSR | S_IXGRP | S_IXOTH) != 0) {
+	    if (errno != EEXIST) {
+                umask(old_mask);
+	        ULOG_ERR_F("Could not create plugin state directory '%s': %s",
+		           statedir, strerror(errno));
+	        g_free(statedir);
+	        return OSSO_ERROR;
+	    }
+        }
+        umask(old_mask);
     }
     g_free(statedir);
     


More information about the maemo-commits mailing list