Codebase list i3-gaps / 419b73b
Merge pull request #1816 from tcreech/tcreech-for-illumos Changes for compiling i3 on Illumos Michael Stapelberg 8 years ago
6 changed file(s) with 26 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
177177 LIBS += -lrt
178178 endif
179179
180 ifeq ($(UNAME),SunOS)
181 LIBS += -lsocket -liconv -lgen
182 endif
183
180184 ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
181185 I3_CPPFLAGS += -D_GNU_SOURCE
182186 endif
798798 struct stat stbuf;
799799 sasprintf(&config_dir, "%s/i3", xdg_config_home);
800800 if (stat(config_dir, &stbuf) != 0)
801 if (!mkdirp(config_dir))
801 if (mkdirp(config_dir, DEFAULT_DIR_MODE) != 0)
802802 err(EXIT_FAILURE, "mkdirp(%s) failed", config_dir);
803803 free(config_dir);
804804 free(xdg_config_home);
1919 #if PANGO_SUPPORT
2020 #include <pango/pango.h>
2121 #endif
22
23 #define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
2224
2325 /**
2426 * Opaque data structure for storing strings.
470472 */
471473 char *get_config_path(const char *override_configpath, bool use_system_paths);
472474
475 #if !defined(__sun)
473476 /**
474477 * Emulates mkdir -p (creates any missing folders)
475478 *
476479 */
477 bool mkdirp(const char *path);
480 int mkdirp(const char *path, mode_t mode);
481 #endif
77 * Emulates mkdir -p (creates any missing folders)
88 *
99 */
10 bool mkdirp(const char *path) {
11 if (mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 0)
12 return true;
10
11 #if !defined(__sun)
12 int mkdirp(const char *path, mode_t mode) {
13 if (mkdir(path, mode) == 0)
14 return 0;
1315 if (errno == EEXIST) {
1416 struct stat st;
1517 /* Check that the named file actually is a directory. */
1618 if (stat(path, &st)) {
1719 ELOG("stat(%s) failed: %s\n", path, strerror(errno));
18 return false;
20 return -1;
1921 }
2022 if (!S_ISDIR(st.st_mode)) {
2123 ELOG("mkdir(%s) failed: %s\n", path, strerror(ENOTDIR));
22 return false;
24 return -1;
2325 }
24 return true;
26 return 0;
2527 } else if (errno != ENOENT) {
2628 ELOG("mkdir(%s) failed: %s\n", path, strerror(errno));
27 return false;
29 return -1;
2830 }
2931 char *copy = sstrdup(path);
3032 /* strip trailing slashes, if any */
3739 free(copy);
3840 copy = NULL;
3941 }
40 return false;
42 return -1;
4143 }
4244 *sep = '\0';
43 bool result = false;
44 if (mkdirp(copy))
45 result = mkdirp(path);
45 int result = -1;
46 if (mkdirp(copy, mode) == 0)
47 result = mkdirp(path, mode);
4648 free(copy);
4749
4850 return result;
4951 }
52 #endif
10861086 char *copy = sstrdup(resolved);
10871087 const char *dir = dirname(copy);
10881088 if (!path_exists(dir))
1089 mkdirp(dir);
1089 mkdirp(dir, DEFAULT_DIR_MODE);
10901090 free(copy);
10911091
10921092 /* Unlink the unix domain socket before */
221221 char *filenamecopy = sstrdup(filename);
222222 char *base = dirname(filenamecopy);
223223 DLOG("Creating \"%s\" for storing the restart layout\n", base);
224 if (!mkdirp(base))
224 if (mkdirp(base, DEFAULT_DIR_MODE) != 0)
225225 ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
226226 free(filenamecopy);
227227