1 |
solar 09/12/26 22:33:48 |
2 |
|
3 |
Modified: qlop.c |
4 |
Log: |
5 |
- make qlop print the root path for linux hosts as best as it can figure out. useful when you have lots of chroots building |
6 |
|
7 |
Revision Changes Path |
8 |
1.47 portage-utils/qlop.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qlop.c?rev=1.47&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qlop.c?rev=1.47&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/qlop.c?r1=1.46&r2=1.47 |
13 |
|
14 |
Index: qlop.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qlop.c,v |
17 |
retrieving revision 1.46 |
18 |
retrieving revision 1.47 |
19 |
diff -u -r1.46 -r1.47 |
20 |
--- qlop.c 5 Dec 2009 10:01:07 -0000 1.46 |
21 |
+++ qlop.c 26 Dec 2009 22:33:47 -0000 1.47 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2005-2007 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qlop.c,v 1.46 2009/12/05 10:01:07 vapier Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qlop.c,v 1.47 2009/12/26 22:33:47 solar Exp $ |
28 |
* |
29 |
* Copyright 2005-2007 Ned Ludd - <solar@g.o> |
30 |
* Copyright 2005-2007 Mike Frysinger - <vapier@g.o> |
31 |
@@ -52,7 +52,7 @@ |
32 |
"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE, |
33 |
COMMON_OPTS_HELP |
34 |
}; |
35 |
-static const char qlop_rcsid[] = "$Id: qlop.c,v 1.46 2009/12/05 10:01:07 vapier Exp $"; |
36 |
+static const char qlop_rcsid[] = "$Id: qlop.c,v 1.47 2009/12/26 22:33:47 solar Exp $"; |
37 |
#define qlop_usage(ret) usage(ret, QLOP_FLAGS, qlop_long_opts, qlop_opts_help, lookup_applet_idx("qlop")) |
38 |
|
39 |
#define QLOP_LIST 0x01 |
40 |
@@ -323,6 +323,16 @@ |
41 |
if (!hz) |
42 |
hz = 100; |
43 |
} |
44 |
+ |
45 |
+static char *root_readlink(const int pid) { |
46 |
+ static char path[_Q_PATH_MAX]; |
47 |
+ char buf[_Q_PATH_MAX]; |
48 |
+ memset(&path, 0, sizeof(path)); |
49 |
+ snprintf(buf, sizeof(buf), "/proc/%d/root", pid); |
50 |
+ readlink(buf, path, sizeof(path)); |
51 |
+ return (char *) path; |
52 |
+} |
53 |
+ |
54 |
void show_current_emerge(void) |
55 |
{ |
56 |
DIR *proc; |
57 |
@@ -392,6 +402,9 @@ |
58 |
GREEN, chop_ctime(start_date), NORM); |
59 |
print_seconds_for_earthlings(uptime_secs - (start_time / hz)); |
60 |
puts(NORM); |
61 |
+ p = NULL; |
62 |
+ if ((p = root_readlink(pid)) != NULL) |
63 |
+ printf(" root: %s%s%s\n", GREEN, p, NORM); |
64 |
} |
65 |
} |