View | Details | Raw Unified | Return to bug 195024 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (+1 lines)
Lines 2-7 Link Here
2
2
3
PORTNAME=	seafile
3
PORTNAME=	seafile
4
PORTVERSION=	3.1.4
4
PORTVERSION=	3.1.4
5
PORTREVISION=	1
5
CATEGORIES=	net-mgmt devel
6
CATEGORIES=	net-mgmt devel
6
7
7
MAINTAINER=	yan_jingfeng@yahoo.com
8
MAINTAINER=	yan_jingfeng@yahoo.com
(-)files/patch-controller_seafile-controller.c (-4 / +57 lines)
Lines 1-17 Link Here
1
--- controller/seafile-controller.c.orig	2014-08-05 01:28:35.000000000 -0400
1
--- controller/seafile-controller.c.orig	2014-08-05 01:28:35.000000000 -0400
2
+++ controller/seafile-controller.c	2014-08-30 09:11:34.868400091 -0400
2
+++ controller/seafile-controller.c	2014-11-11 19:29:27.352982983 -0500
3
@@ -18,6 +18,10 @@
3
@@ -18,6 +18,13 @@
4
 #include "log.h"
4
 #include "log.h"
5
 #include "seafile-controller.h"
5
 #include "seafile-controller.h"
6
 
6
 
7
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
7
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
8
+#include <sys/sysctl.h>
8
+#include <sys/sysctl.h>
9
+#include <sys/types.h>
10
+#include <sys/user.h>
11
+#include <limits.h>
9
+#endif
12
+#endif
10
+
13
+
11
 #define CHECK_PROCESS_INTERVAL 10        /* every 10 seconds */
14
 #define CHECK_PROCESS_INTERVAL 10        /* every 10 seconds */
12
 
15
 
13
 SeafileController *ctl;
16
 SeafileController *ctl;
14
@@ -273,7 +277,11 @@
17
@@ -273,7 +280,19 @@
15
 init_seafile_path ()
18
 init_seafile_path ()
16
 {
19
 {
17
     GError *error = NULL;
20
     GError *error = NULL;
Lines 18-25 Link Here
18
+#if defined(__linux__)
21
+#if defined(__linux__)
19
     char *executable = g_file_read_link ("/proc/self/exe", &error);
22
     char *executable = g_file_read_link ("/proc/self/exe", &error);
20
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
23
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
21
+    char *executable = g_file_read_link ("/proc/curproc/file", &error);
24
+    char executable[_POSIX_PATH_MAX];
25
+    int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, 0};
26
+    size_t len = _POSIX_PATH_MAX ;
27
+    mib[3] = (int)getpid();
28
+    memset(executable, _POSIX_PATH_MAX, 0);
29
+    if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), executable, &len, NULL, 0) == -1) {
30
+        seaf_warning ("Error: failed to get process entry\n");
31
+        return;    
32
+    }
22
+#endif
33
+#endif
23
     char *tmp = NULL;
34
     char *tmp = NULL;
24
     if (error != NULL) {
35
     if (error != NULL) {
25
         seaf_warning ("failed to readlink: %s\n", error->message);
36
         seaf_warning ("failed to readlink: %s\n", error->message);
37
@@ -287,7 +306,9 @@
38
 
39
     topdir = g_path_get_dirname (installpath);
40
 
41
+#if defined(__linux__)
42
     g_free (executable);
43
+#endif
44
     g_free (tmp);
45
 }
46
 
47
@@ -426,6 +447,7 @@
48
         seaf_warning ("failed to read pidfile %s: %s\n", ctl->pidfile[which], strerror(errno));
49
         return FALSE;
50
     } else {
51
+#ifdef __linux__
52
         char buf[256];
53
         snprintf (buf, sizeof(buf), "/proc/%d", pid);
54
         if (g_file_test (buf, G_FILE_TEST_IS_DIR)) {
55
@@ -433,7 +455,22 @@
56
         } else {
57
             return TRUE;
58
         }
59
-    }
60
+#endif
61
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
62
+#ifdef __OpenBSD__
63
+	int min[6] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), 1};
64
+#else
65
+        int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
66
+#endif
67
+        size_t len = sizeof(struct kinfo_proc);
68
+        struct kinfo_proc kp;
69
+        if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &kp, &len, NULL, 0) == -1) {
70
+            return FALSE;        
71
+        } else {
72
+	    return TRUE;
73
+        }
74
+    }    
75
+#endif
76
 }
77
 
78
 static gboolean
(-)files/patch-lib_Makfile.am (-2 / +11 lines)
Lines 1-5 Link Here
1
--- lib/Makefile.am.orig	2014-08-30 02:00:00.097346044 -0400
1
--- lib/Makefile.am.orig	2014-11-11 10:47:33.631976054 -0500
2
+++ lib/Makefile.am	2014-08-30 02:00:10.951213463 -0400
2
+++ lib/Makefile.am	2014-11-11 11:40:14.030311321 -0500
3
@@ -55,7 +55,7 @@
4
 libseafile_common_la_LDFLAGS = -no-undefined
5
 libseafile_common_la_LIBADD = @GLIB2_LIBS@  @GOBJECT_LIBS@ -lssl -lcrypto @LIB_GDI32@ \
6
 				     @LIB_UUID@ @LIB_WS32@ @LIB_PSAPI@ -lsqlite3 \
7
-					 -levent @SEARPC_LIBS@ @LIB_SHELL32@ \
8
+					 -levent -lkvm @SEARPC_LIBS@ @LIB_SHELL32@ \
9
 	@ZLIB_LIBS@
10
 
11
 searpc_gen = searpc-signature.h searpc-marshal.h
3
@@ -72,8 +72,4 @@
12
@@ -72,8 +72,4 @@
4
 	rm -f $(top_srcdir)/lib/rpc_table.pyc
13
 	rm -f $(top_srcdir)/lib/rpc_table.pyc
5
 
14
 
(-)files/patch-lib_utils.c (-18 / +90 lines)
Lines 1-23 Link Here
1
--- lib/utils.c.orig	2014-06-05 02:25:50.000000000 -0400
1
--- lib/utils.c.orig	2014-08-05 01:28:35.000000000 -0400
2
+++ lib/utils.c	2014-07-30 22:56:37.000000000 -0400
2
+++ lib/utils.c	2014-11-11 12:13:18.496411804 -0500
3
@@ -1756,14 +1756,19 @@
3
@@ -46,6 +46,15 @@
4
 
4
 
5
 #endif  /* ifdef WIN32 */
5
 #include <zlib.h>
6
 
6
 
7
-#ifdef __linux__
7
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
8
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
8
+#include <stdlib.h>
9
 /* read the link of /proc/123/exe and compare with `process_name' */
9
+#include <kvm.h>
10
 static int
10
+#include <paths.h>
11
 find_process_in_dirent(struct dirent *dir, const char *process_name)
11
+#include <sys/param.h>
12
 {
12
+#include <sys/sysctl.h>
13
     char path[512];
13
+#include <sys/user.h>
14
     /* fisrst construct a path like /proc/123/exe */
15
+#ifdef __linux__
16
     if (sprintf (path, "/proc/%s/exe", dir->d_name) < 0) {
17
+#endif
14
+#endif
15
+
16
 extern int inet_pton(int af, const char *src, void *dst);
17
 
18
 
19
@@ -1846,6 +1855,76 @@
20
 }
21
 #endif
22
 
18
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
23
+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
19
+    if (sprintf (path, "/proc/%s/file", dir->d_name) < 0) {
24
+
25
+#define PSKIP(kp) ((kp)->ki_pid == mypid ||               \
26
+                   (!kthreads && ((kp)->ki_flag & P_KTHREAD) != 0))
27
+
28
+static int 
29
+count_running_process(const char *process_name) {
30
+    
31
+    static kvm_t    *kd;
32
+    static struct    kinfo_proc *plist;
33
+    static int    nproc;
34
+    static pid_t    mypid;
35
+    static int      kthreads;
36
+
37
+    char buf[_POSIX2_LINE_MAX]; 
38
+    const char * execf, *coref;
39
+    char **pargv;
40
+    int i, selected_nproc;
41
+    struct kinfo_proc *kp;
42
+
43
+    selected_nproc = 0;
44
+    execf = NULL;
45
+    coref = _PATH_DEVNULL;
46
+    
47
+    mypid = getpid();
48
+    kd = kvm_openfiles(execf, coref, NULL, O_RDONLY, buf);
49
+    kd = kvm_openfiles(execf, coref, NULL, O_RDONLY, buf);
50
+    if (kd == NULL) {
51
+        fprintf(stderr, "Error: Cannot open kernel files (%s)", buf);
52
+        exit(1);
53
+    }
54
+
55
+    plist = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc);
56
+    if (plist == NULL) {
57
+        fprintf(stderr, "Error: Cannot get process list (%s)", kvm_geterr(kd));
58
+        exit(1);
59
+    }
60
+
61
+    for(i = 0, kp = plist; i < nproc; i++, kp++) {
62
+        if (PSKIP(kp)) {
63
+            continue;
64
+        }
65
+        if ((pargv = kvm_getargv(kd, kp, 0)) != NULL) {
66
+            if (strstr(pargv[0], process_name) != NULL) {
67
+                selected_nproc += 1;
68
+            }
69
+        }
70
+    }
71
+    kvm_close(kd);
72
+    kvm_close(kd);
73
+
74
+    return selected_nproc;
75
+}
76
+
77
+int
78
+count_process(const char * process_name) {
79
+	return count_running_process(process_name);
80
+}
81
+
82
+gboolean
83
+process_is_running(const char * process_name) {
84
+    if (count_running_process(process_name) > 0) {
85
+        return TRUE;
86
+    } else {
87
+        return FALSE;
88
+    }
89
+}
20
+#endif
90
+#endif
21
         return -1;
91
+
22
     }
92
+
23
 
93
 char*
94
 ccnet_object_type_from_id (const char *object_id)
95
 {
(-)files/patch-lib_utils.h (-2 / +13 lines)
Lines 1-5 Link Here
1
--- lib/utils.h.orig	2014-06-05 02:25:50.000000000 -0400
1
--- lib/utils.h.orig	2014-08-05 01:28:35.000000000 -0400
2
+++ lib/utils.h	2014-07-27 01:48:52.000000000 -0400
2
+++ lib/utils.h	2014-11-11 11:30:51.843637061 -0500
3
@@ -3,6 +3,9 @@
3
@@ -3,6 +3,9 @@
4
 #ifndef CCNET_UTILS_H
4
 #ifndef CCNET_UTILS_H
5
 #define CCNET_UTILS_H
5
 #define CCNET_UTILS_H
Lines 10-12 Link Here
10
 #include <sys/time.h>
10
 #include <sys/time.h>
11
 #include <time.h>
11
 #include <time.h>
12
 #include <stdint.h>
12
 #include <stdint.h>
13
@@ -13,7 +16,9 @@
14
 #include <stdlib.h>
15
 #include <sys/stat.h>
16
 
17
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
18
+#if defined(__FreeBSD__) || defined(__DragonFly__) 
19
+#include <evutil.h>
20
+#elif (__NetBSD__) || defined(__OpenBSD__)
21
 #include <event2/util.h>
22
 #else
23
 #include <evutil.h>

Return to bug 195024