summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjdp <jdp@FreeBSD.org>1999-07-30 23:14:15 +0000
committerjdp <jdp@FreeBSD.org>1999-07-30 23:14:15 +0000
commit36ac898832f82e5095ab6f4d9ac182dc2cf1c492 (patch)
tree959a3485782c766833a53485d84a9ebfd487f317 /usr.sbin
parent668aec5d3d773699c06f721e3bbef0f1d6e64954 (diff)
downloadFreeBSD-src-36ac898832f82e5095ab6f4d9ac182dc2cf1c492.zip
FreeBSD-src-36ac898832f82e5095ab6f4d9ac182dc2cf1c492.tar.gz
When listing the installed packages, do it in alphabetical order.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/info/perform.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index 84a3b9a..eee1b76 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: perform.c,v 1.25 1998/09/11 07:26:58 jkh Exp $";
+ "$Id: perform.c,v 1.26 1998/12/16 13:59:31 jkh Exp $";
#endif
/*
@@ -26,8 +26,10 @@ static const char rcsid[] =
#include "lib.h"
#include "info.h"
+#include <fts.h>
#include <signal.h>
+static int fname_cmp(const FTSENT **, const FTSENT **);
static int pkg_do(char *);
int
@@ -49,17 +51,24 @@ pkg_perform(char **pkgs)
return abs(access(buf, R_OK));
}
else if (AllInstalled) {
- DIR *dirp;
- struct dirent *dp;
+ FTS *ftsp;
+ FTSENT *f;
+ char *paths[2];
if (!isdir(tmp))
return 1;
- dirp = opendir(tmp);
- if (dirp) {
- for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
- if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, ".."))
- err_cnt += pkg_do(dp->d_name);
- (void)closedir(dirp);
+ paths[0] = tmp;
+ paths[1] = NULL;
+ ftsp = fts_open(paths, FTS_LOGICAL | FTS_NOCHDIR | FTS_NOSTAT,
+ fname_cmp);
+ if (ftsp != NULL) {
+ while ((f = fts_read(ftsp)) != NULL) {
+ if (f->fts_info == FTS_D && f->fts_level == 1) {
+ err_cnt += pkg_do(f->fts_name);
+ fts_set(ftsp, f, FTS_SKIP);
+ }
+ }
+ fts_close(ftsp);
}
}
else
@@ -214,3 +223,9 @@ cleanup(int sig)
if (sig)
exit(1);
}
+
+static int
+fname_cmp(const FTSENT **a, const FTSENT **b)
+{
+ return strcmp((*a)->fts_name, (*b)->fts_name);
+}
OpenPOWER on IntegriCloud