Changeset View
Changeset View
Standalone View
Standalone View
net-mgmt/seafile/files/patch-controller_seafile-controller.c
--- controller/seafile-controller.c.orig 2015-01-28 13:03:24.000000000 -0500 | --- controller/seafile-controller.c.orig 2015-09-21 03:42:11 UTC | ||||
+++ controller/seafile-controller.c 2015-01-28 13:15:05.000000000 -0500 | +++ controller/seafile-controller.c | ||||
@@ -17,6 +17,19 @@ | @@ -17,6 +17,19 @@ | ||||
#include "log.h" | #include "log.h" | ||||
#include "seafile-controller.h" | #include "seafile-controller.h" | ||||
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) | +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) | ||||
+#include <sys/sysctl.h> | +#include <sys/sysctl.h> | ||||
+#include <sys/types.h> | +#include <sys/types.h> | ||||
+#include <sys/user.h> | +#include <sys/user.h> | ||||
+#include <limits.h> | +#include <limits.h> | ||||
+ | + | ||||
+#ifndef WITH_PROC_FS | +#ifndef WITH_PROC_FS | ||||
+#define WITH_PROC_FS g_file_test("/proc/curproc", G_FILE_TEST_EXISTS) | +#define WITH_PROC_FS g_file_test("/proc/curproc", G_FILE_TEST_EXISTS) | ||||
+#endif | +#endif | ||||
+ | + | ||||
+static char *command_name = NULL; | +static char *command_name = NULL; | ||||
+#endif | +#endif | ||||
+ | + | ||||
#define CHECK_PROCESS_INTERVAL 10 /* every 10 seconds */ | #define CHECK_PROCESS_INTERVAL 10 /* every 10 seconds */ | ||||
SeafileController *ctl; | SeafileController *ctl; | ||||
@@ -247,7 +260,20 @@ | @@ -247,7 +260,20 @@ static void | ||||
init_seafile_path () | init_seafile_path () | ||||
{ | { | ||||
GError *error = NULL; | GError *error = NULL; | ||||
+#if defined(__linux__) | +#if defined(__linux__) | ||||
char *executable = g_file_read_link ("/proc/self/exe", &error); | char *executable = g_file_read_link ("/proc/self/exe", &error); | ||||
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) | +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) | ||||
+ /* | + /* | ||||
+ * seafile.sh starts the process using abs path | + * seafile.sh starts the process using abs path | ||||
+ */ | + */ | ||||
+ char executable[_POSIX_PATH_MAX]; | + char executable[_POSIX_PATH_MAX]; | ||||
+ memset(executable, 0, _POSIX_PATH_MAX); | + memset(executable, 0, _POSIX_PATH_MAX); | ||||
+ char * rc = realpath(command_name, executable); | + char * rc = realpath(command_name, executable); | ||||
+ if (!rc) { | + if (!rc) { | ||||
+ seaf_warning ("failed to readpath: %s\n", executable); | + seaf_warning ("failed to readpath: %s\n", executable); | ||||
+ return; | + return; | ||||
+ } | + } | ||||
+#endif | +#endif | ||||
char *tmp = NULL; | char *tmp = NULL; | ||||
if (error != NULL) { | if (error != NULL) { | ||||
seaf_warning ("failed to readlink: %s\n", error->message); | seaf_warning ("failed to readlink: %s\n", error->message); | ||||
@@ -261,7 +287,9 @@ | @@ -261,7 +287,9 @@ init_seafile_path () | ||||
topdir = g_path_get_dirname (installpath); | topdir = g_path_get_dirname (installpath); | ||||
+#if defined(__linux__) | +#if defined(__linux__) | ||||
g_free (executable); | g_free (executable); | ||||
+#endif | +#endif | ||||
g_free (tmp); | g_free (tmp); | ||||
} | } | ||||
@@ -401,11 +429,40 @@ | @@ -402,11 +430,40 @@ need_restart (int which) | ||||
return FALSE; | return FALSE; | ||||
} else { | } else { | ||||
char buf[256]; | char buf[256]; | ||||
+ gboolean with_procfs; | + gboolean with_procfs; | ||||
+#if defined(__linux__) | +#if defined(__linux__) | ||||
+ with_procfs = g_file_test("/proc/self", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); | + with_procfs = g_file_test("/proc/self", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); | ||||
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) | +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) | ||||
+ with_procfs = g_file_test("/proc/curproc", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); | + with_procfs = g_file_test("/proc/curproc", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); | ||||
Show All 24 Lines | |||||
+ return TRUE; | + return TRUE; | ||||
+ } | + } | ||||
+#else | +#else | ||||
+ return FALSE; | + return FALSE; | ||||
+#endif | +#endif | ||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -852,6 +909,9 @@ | @@ -877,6 +934,9 @@ int main (int argc, char **argv) | ||||
exit (1); | exit (1); | ||||
} | } | ||||
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) | +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) | ||||
+ command_name = argv[0]; | + command_name = argv[0]; | ||||
+#endif | +#endif | ||||
char *config_dir = DEFAULT_CONFIG_DIR; | char *config_dir = DEFAULT_CONFIG_DIR; | ||||
char *seafile_dir = NULL; | char *seafile_dir = NULL; | ||||
char *logdir = NULL; | char *logdir = NULL; |