author | jurikm |
Mon, 25 Apr 2011 08:06:00 +0000 | |
changeset 3430 | 0f8554f505cf |
child 8804 | 600b122292ed |
permissions | -rw-r--r-- |
3430
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
1 |
--- a/src/xfpm-polkit.c |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
2 |
+++ b/src/xfpm-polkit.c |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
3 |
@@ -32,12 +32,15 @@ |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
4 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
5 |
#include <sys/types.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
6 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
7 |
-#if defined(__FreeBSD__) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
8 |
-#include <sys/stat.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
9 |
-#else |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
10 |
+#if defined(__linux) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
11 |
#include <sys/param.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
12 |
#include <sys/sysctl.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
13 |
#include <sys/user.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
14 |
+#elif defined(__FreeBSD__) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
15 |
+#include <sys/stat.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
16 |
+#elif defined(__SVR4) || defined(__sun) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
17 |
+#include <fcntl.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
18 |
+#include <procfs.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
19 |
#endif |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
20 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
21 |
#include <errno.h> |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
22 |
@@ -115,7 +118,7 @@ static guint64 |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
23 |
get_start_time_for_pid (pid_t pid) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
24 |
{ |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
25 |
guint64 start_time; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
26 |
-#if !defined(__FreeBSD__) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
27 |
+#if defined(__linux) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
28 |
gchar *filename; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
29 |
gchar *contents; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
30 |
size_t length; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
31 |
@@ -172,7 +175,7 @@ get_start_time_for_pid (pid_t pid) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
32 |
g_free (filename); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
33 |
g_free (contents); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
34 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
35 |
-#else /*if !defined(__FreeBSD__)*/ |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
36 |
+#elif defined(__FreeBSD__) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
37 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
38 |
struct kinfo_proc p; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
39 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
40 |
@@ -189,6 +192,33 @@ get_start_time_for_pid (pid_t pid) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
41 |
start_time = (guint64) p.ki_start.tv_sec; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
42 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
43 |
out: |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
44 |
+#elif defined(__SVR4) || defined(__sun) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
45 |
+ |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
46 |
+ psinfo_t p; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
47 |
+ gchar *filename; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
48 |
+ int fd; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
49 |
+ |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
50 |
+ start_time = 0; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
51 |
+ |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
52 |
+ filename = g_strdup_printf ("/proc/%d/psinfo", (int) pid); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
53 |
+ if ((fd = open(filename, O_RDONLY)) < 0) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
54 |
+ { |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
55 |
+ g_warning ("Error opening %s (%s)", |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
56 |
+ filename, |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
57 |
+ g_strerror (errno)); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
58 |
+ goto out; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
59 |
+ } |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
60 |
+ if (read(fd, &p, sizeof (p)) != sizeof (p)) |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
61 |
+ { |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
62 |
+ g_warning ("Error reading %s", |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
63 |
+ filename); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
64 |
+ close(fd); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
65 |
+ goto out; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
66 |
+ } |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
67 |
+ start_time = (guint64) p.pr_start.tv_sec; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
68 |
+ close(fd); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
69 |
+out: |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
70 |
+ g_free (filename); |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
71 |
#endif |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
72 |
|
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
73 |
return start_time; |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
74 |
-- |
0f8554f505cf
SFExfce4-power-manager.spec: initial spec with patch from Guido Berhoerster
jurikm
parents:
diff
changeset
|
75 |
cgit v0.8.3.4 |