Merge pull request #1816 from tcreech/tcreech-for-illumos
Changes for compiling i3 on Illumos
Michael Stapelberg
8 years ago
798 | 798 |
struct stat stbuf;
|
799 | 799 |
sasprintf(&config_dir, "%s/i3", xdg_config_home);
|
800 | 800 |
if (stat(config_dir, &stbuf) != 0)
|
801 | |
if (!mkdirp(config_dir))
|
|
801 |
if (mkdirp(config_dir, DEFAULT_DIR_MODE) != 0)
|
802 | 802 |
err(EXIT_FAILURE, "mkdirp(%s) failed", config_dir);
|
803 | 803 |
free(config_dir);
|
804 | 804 |
free(xdg_config_home);
|
19 | 19 |
#if PANGO_SUPPORT
|
20 | 20 |
#include <pango/pango.h>
|
21 | 21 |
#endif
|
|
22 |
|
|
23 |
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
22 | 24 |
|
23 | 25 |
/**
|
24 | 26 |
* Opaque data structure for storing strings.
|
|
470 | 472 |
*/
|
471 | 473 |
char *get_config_path(const char *override_configpath, bool use_system_paths);
|
472 | 474 |
|
|
475 |
#if !defined(__sun)
|
473 | 476 |
/**
|
474 | 477 |
* Emulates mkdir -p (creates any missing folders)
|
475 | 478 |
*
|
476 | 479 |
*/
|
477 | |
bool mkdirp(const char *path);
|
|
480 |
int mkdirp(const char *path, mode_t mode);
|
|
481 |
#endif
|
7 | 7 |
* Emulates mkdir -p (creates any missing folders)
|
8 | 8 |
*
|
9 | 9 |
*/
|
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;
|
13 | 15 |
if (errno == EEXIST) {
|
14 | 16 |
struct stat st;
|
15 | 17 |
/* Check that the named file actually is a directory. */
|
16 | 18 |
if (stat(path, &st)) {
|
17 | 19 |
ELOG("stat(%s) failed: %s\n", path, strerror(errno));
|
18 | |
return false;
|
|
20 |
return -1;
|
19 | 21 |
}
|
20 | 22 |
if (!S_ISDIR(st.st_mode)) {
|
21 | 23 |
ELOG("mkdir(%s) failed: %s\n", path, strerror(ENOTDIR));
|
22 | |
return false;
|
|
24 |
return -1;
|
23 | 25 |
}
|
24 | |
return true;
|
|
26 |
return 0;
|
25 | 27 |
} else if (errno != ENOENT) {
|
26 | 28 |
ELOG("mkdir(%s) failed: %s\n", path, strerror(errno));
|
27 | |
return false;
|
|
29 |
return -1;
|
28 | 30 |
}
|
29 | 31 |
char *copy = sstrdup(path);
|
30 | 32 |
/* strip trailing slashes, if any */
|
|
37 | 39 |
free(copy);
|
38 | 40 |
copy = NULL;
|
39 | 41 |
}
|
40 | |
return false;
|
|
42 |
return -1;
|
41 | 43 |
}
|
42 | 44 |
*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);
|
46 | 48 |
free(copy);
|
47 | 49 |
|
48 | 50 |
return result;
|
49 | 51 |
}
|
|
52 |
#endif
|
221 | 221 |
char *filenamecopy = sstrdup(filename);
|
222 | 222 |
char *base = dirname(filenamecopy);
|
223 | 223 |
DLOG("Creating \"%s\" for storing the restart layout\n", base);
|
224 | |
if (!mkdirp(base))
|
|
224 |
if (mkdirp(base, DEFAULT_DIR_MODE) != 0)
|
225 | 225 |
ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
|
226 | 226 |
free(filenamecopy);
|
227 | 227 |
|