1 |
vapier 11/03/01 05:01:30 |
2 |
|
3 |
Modified: qlist.c |
4 |
Log: |
5 |
rewrite vdb walking so we handle ROOT correctly, and we avoid using chdir everywhere |
6 |
|
7 |
Revision Changes Path |
8 |
1.60 portage-utils/qlist.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qlist.c?rev=1.60&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qlist.c?rev=1.60&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/qlist.c?r1=1.59&r2=1.60 |
13 |
|
14 |
Index: qlist.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/portage-utils/qlist.c,v |
17 |
retrieving revision 1.59 |
18 |
retrieving revision 1.60 |
19 |
diff -u -r1.59 -r1.60 |
20 |
--- qlist.c 21 Feb 2011 07:33:21 -0000 1.59 |
21 |
+++ qlist.c 1 Mar 2011 05:01:30 -0000 1.60 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2005-2010 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qlist.c,v 1.59 2011/02/21 07:33:21 vapier Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qlist.c,v 1.60 2011/03/01 05:01:30 vapier Exp $ |
28 |
* |
29 |
* Copyright 2005-2010 Ned Ludd - <solar@g.o> |
30 |
* Copyright 2005-2010 Mike Frysinger - <vapier@g.o> |
31 |
@@ -41,7 +41,7 @@ |
32 |
/* "query filename for pkgname", */ |
33 |
COMMON_OPTS_HELP |
34 |
}; |
35 |
-static const char qlist_rcsid[] = "$Id: qlist.c,v 1.59 2011/02/21 07:33:21 vapier Exp $"; |
36 |
+static const char qlist_rcsid[] = "$Id: qlist.c,v 1.60 2011/03/01 05:01:30 vapier Exp $"; |
37 |
#define qlist_usage(ret) usage(ret, QLIST_FLAGS, qlist_long_opts, qlist_opts_help, lookup_applet_idx("qlist")) |
38 |
|
39 |
extern char *grab_vdb_item(const char *, const char *, const char *); |
40 |
@@ -183,25 +183,26 @@ |
41 |
if ((argc == optind) && (!just_pkgname)) |
42 |
qlist_usage(EXIT_FAILURE); |
43 |
|
44 |
- xchdir(portroot); |
45 |
- xchdir(portvdb); |
46 |
- |
47 |
- if ((dfd = scandir(".", &cat, filter_hidden, alphasort)) < 0) |
48 |
- return EXIT_FAILURE; |
49 |
- |
50 |
buflen = _Q_PATH_MAX; |
51 |
buf = xmalloc(buflen); |
52 |
|
53 |
+ snprintf(buf, buflen, "%s/%s", portroot, portvdb); |
54 |
+ if ((dfd = scandir(buf, &cat, filter_hidden, alphasort)) < 0) { |
55 |
+ free(buf); |
56 |
+ return EXIT_FAILURE; |
57 |
+ } |
58 |
+ |
59 |
/* open /var/db/pkg */ |
60 |
for (j = 0; j < dfd; j++) { |
61 |
int a, x; |
62 |
+ |
63 |
+ /* skip the "-MERGE-" stuff */ |
64 |
if (cat[j]->d_name[0] == '-') |
65 |
continue; |
66 |
- if (chdir(cat[j]->d_name) != 0) |
67 |
- continue; |
68 |
|
69 |
/* open the cateogry */ |
70 |
- if ((a = scandir(".", &de, filter_hidden, alphasort)) < 0) |
71 |
+ snprintf(buf, buflen, "%s/%s/%s", portroot, portvdb, cat[j]->d_name); |
72 |
+ if ((a = scandir(buf, &de, filter_hidden, alphasort)) < 0) |
73 |
continue; |
74 |
|
75 |
for (x = 0; x < a; x++) { |
76 |
@@ -321,7 +322,6 @@ |
77 |
} |
78 |
while (a--) free(de[a]); |
79 |
free(de); |
80 |
- xchdir(".."); |
81 |
} |
82 |
|
83 |
if (dups_only) { |
84 |
@@ -350,8 +350,10 @@ |
85 |
free_sets(dups); |
86 |
free_sets(sets); |
87 |
} |
88 |
+ |
89 |
while (dfd--) free(cat[dfd]); |
90 |
free(cat); |
91 |
+ |
92 |
return EXIT_SUCCESS; |
93 |
} |