Merge pull request #1816 from tcreech/tcreech-for-illumos
Changes for compiling i3 on Illumos
This commit is contained in:
commit
419b73be9e
@ -178,6 +178,10 @@ else ifneq ($(UNAME),OpenBSD)
|
|||||||
LIBS += -lrt
|
LIBS += -lrt
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(UNAME),SunOS)
|
||||||
|
LIBS += -lsocket -liconv -lgen
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
|
ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
|
||||||
I3_CPPFLAGS += -D_GNU_SOURCE
|
I3_CPPFLAGS += -D_GNU_SOURCE
|
||||||
endif
|
endif
|
||||||
|
@ -799,7 +799,7 @@ int main(int argc, char *argv[]) {
|
|||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
sasprintf(&config_dir, "%s/i3", xdg_config_home);
|
sasprintf(&config_dir, "%s/i3", xdg_config_home);
|
||||||
if (stat(config_dir, &stbuf) != 0)
|
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);
|
err(EXIT_FAILURE, "mkdirp(%s) failed", config_dir);
|
||||||
free(config_dir);
|
free(config_dir);
|
||||||
free(xdg_config_home);
|
free(xdg_config_home);
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opaque data structure for storing strings.
|
* 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);
|
char *get_config_path(const char *override_configpath, bool use_system_paths);
|
||||||
|
|
||||||
|
#if !defined(__sun)
|
||||||
/**
|
/**
|
||||||
* Emulates mkdir -p (creates any missing folders)
|
* Emulates mkdir -p (creates any missing folders)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool mkdirp(const char *path);
|
int mkdirp(const char *path, mode_t mode);
|
||||||
|
#endif
|
||||||
|
@ -8,24 +8,26 @@
|
|||||||
* Emulates mkdir -p (creates any missing folders)
|
* 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)
|
#if !defined(__sun)
|
||||||
return true;
|
int mkdirp(const char *path, mode_t mode) {
|
||||||
|
if (mkdir(path, mode) == 0)
|
||||||
|
return 0;
|
||||||
if (errno == EEXIST) {
|
if (errno == EEXIST) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
/* Check that the named file actually is a directory. */
|
/* Check that the named file actually is a directory. */
|
||||||
if (stat(path, &st)) {
|
if (stat(path, &st)) {
|
||||||
ELOG("stat(%s) failed: %s\n", path, strerror(errno));
|
ELOG("stat(%s) failed: %s\n", path, strerror(errno));
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!S_ISDIR(st.st_mode)) {
|
if (!S_ISDIR(st.st_mode)) {
|
||||||
ELOG("mkdir(%s) failed: %s\n", path, strerror(ENOTDIR));
|
ELOG("mkdir(%s) failed: %s\n", path, strerror(ENOTDIR));
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
return true;
|
return 0;
|
||||||
} else if (errno != ENOENT) {
|
} else if (errno != ENOENT) {
|
||||||
ELOG("mkdir(%s) failed: %s\n", path, strerror(errno));
|
ELOG("mkdir(%s) failed: %s\n", path, strerror(errno));
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
char *copy = sstrdup(path);
|
char *copy = sstrdup(path);
|
||||||
/* strip trailing slashes, if any */
|
/* strip trailing slashes, if any */
|
||||||
@ -38,13 +40,14 @@ bool mkdirp(const char *path) {
|
|||||||
free(copy);
|
free(copy);
|
||||||
copy = NULL;
|
copy = NULL;
|
||||||
}
|
}
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
*sep = '\0';
|
*sep = '\0';
|
||||||
bool result = false;
|
int result = -1;
|
||||||
if (mkdirp(copy))
|
if (mkdirp(copy, mode) == 0)
|
||||||
result = mkdirp(path);
|
result = mkdirp(path, mode);
|
||||||
free(copy);
|
free(copy);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -1087,7 +1087,7 @@ int ipc_create_socket(const char *filename) {
|
|||||||
char *copy = sstrdup(resolved);
|
char *copy = sstrdup(resolved);
|
||||||
const char *dir = dirname(copy);
|
const char *dir = dirname(copy);
|
||||||
if (!path_exists(dir))
|
if (!path_exists(dir))
|
||||||
mkdirp(dir);
|
mkdirp(dir, DEFAULT_DIR_MODE);
|
||||||
free(copy);
|
free(copy);
|
||||||
|
|
||||||
/* Unlink the unix domain socket before */
|
/* Unlink the unix domain socket before */
|
||||||
|
@ -222,7 +222,7 @@ char *store_restart_layout(void) {
|
|||||||
char *filenamecopy = sstrdup(filename);
|
char *filenamecopy = sstrdup(filename);
|
||||||
char *base = dirname(filenamecopy);
|
char *base = dirname(filenamecopy);
|
||||||
DLOG("Creating \"%s\" for storing the restart layout\n", base);
|
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);
|
ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
|
||||||
free(filenamecopy);
|
free(filenamecopy);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user