]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #1816 from tcreech/tcreech-for-illumos
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 4 Aug 2015 07:10:06 +0000 (00:10 -0700)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 4 Aug 2015 07:10:06 +0000 (00:10 -0700)
Changes for compiling i3 on Illumos

common.mk
i3-config-wizard/main.c
include/libi3.h
libi3/mkdirp.c
src/ipc.c
src/util.c

index c568fb60dba42d557e73ac33c167a46b7c6a2230..d28750426bd4864bf9830d7485dadbc3bed4e1b1 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -178,6 +178,10 @@ else ifneq ($(UNAME),OpenBSD)
 LIBS += -lrt
 endif
 
+ifeq ($(UNAME),SunOS)
+LIBS += -lsocket -liconv -lgen
+endif
+
 ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
 I3_CPPFLAGS += -D_GNU_SOURCE
 endif
index bd9aa28a4146d2404bbf3d174361b524c11c97ae..bd12cd815af594191df3e2f7c60f958d2a4bfbfc 100644 (file)
@@ -799,7 +799,7 @@ int main(int argc, char *argv[]) {
     struct stat stbuf;
     sasprintf(&config_dir, "%s/i3", xdg_config_home);
     if (stat(config_dir, &stbuf) != 0)
-        if (!mkdirp(config_dir))
+        if (mkdirp(config_dir, DEFAULT_DIR_MODE) != 0)
             err(EXIT_FAILURE, "mkdirp(%s) failed", config_dir);
     free(config_dir);
     free(xdg_config_home);
index 102ad533d57acc01c8ca424102bd8420f126f593..9e7ef133fb4ca3ce49d253fa2956adcec57186b7 100644 (file)
@@ -21,6 +21,8 @@
 #include <pango/pango.h>
 #endif
 
+#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
+
 /**
  * Opaque data structure for storing strings.
  *
@@ -471,8 +473,10 @@ char *resolve_tilde(const char *path);
  */
 char *get_config_path(const char *override_configpath, bool use_system_paths);
 
+#if !defined(__sun)
 /**
  * Emulates mkdir -p (creates any missing folders)
  *
  */
-bool mkdirp(const char *path);
+int mkdirp(const char *path, mode_t mode);
+#endif
index 95c31b59d5634bc6a1026195aaabad7d1b68942d..c64b80a3352b97de1ac5e1ec6f21558812e668b7 100644 (file)
@@ -8,24 +8,26 @@
  * Emulates mkdir -p (creates any missing folders)
  *
  */
-bool mkdirp(const char *path) {
-    if (mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0)
-        return true;
+
+#if !defined(__sun)
+int mkdirp(const char *path, mode_t mode) {
+    if (mkdir(path, mode) == 0)
+        return 0;
     if (errno == EEXIST) {
         struct stat st;
         /* Check that the named file actually is a directory. */
         if (stat(path, &st)) {
             ELOG("stat(%s) failed: %s\n", path, strerror(errno));
-            return false;
+            return -1;
         }
         if (!S_ISDIR(st.st_mode)) {
             ELOG("mkdir(%s) failed: %s\n", path, strerror(ENOTDIR));
-            return false;
+            return -1;
         }
-        return true;
+        return 0;
     } else if (errno != ENOENT) {
         ELOG("mkdir(%s) failed: %s\n", path, strerror(errno));
-        return false;
+        return -1;
     }
     char *copy = sstrdup(path);
     /* strip trailing slashes, if any */
@@ -38,13 +40,14 @@ bool mkdirp(const char *path) {
             free(copy);
             copy = NULL;
         }
-        return false;
+        return -1;
     }
     *sep = '\0';
-    bool result = false;
-    if (mkdirp(copy))
-        result = mkdirp(path);
+    int result = -1;
+    if (mkdirp(copy, mode) == 0)
+        result = mkdirp(path, mode);
     free(copy);
 
     return result;
 }
+#endif
index a4bc227896f4b5de41c1e33c27235de7118c041d..021bdd7bf1b2f57e5c989a807866d43232c1d43c 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -1087,7 +1087,7 @@ int ipc_create_socket(const char *filename) {
     char *copy = sstrdup(resolved);
     const char *dir = dirname(copy);
     if (!path_exists(dir))
-        mkdirp(dir);
+        mkdirp(dir, DEFAULT_DIR_MODE);
     free(copy);
 
     /* Unlink the unix domain socket before */
index 5a95e67cd401c6a0207e850734323c6e5b63387a..0edd471a2c247b7448ee54392dcecc86a08ae4c1 100644 (file)
@@ -222,7 +222,7 @@ char *store_restart_layout(void) {
     char *filenamecopy = sstrdup(filename);
     char *base = dirname(filenamecopy);
     DLOG("Creating \"%s\" for storing the restart layout\n", base);
-    if (!mkdirp(base))
+    if (mkdirp(base, DEFAULT_DIR_MODE) != 0)
         ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
     free(filenamecopy);