Don't ignore symlinks.

There can be symlinks which are pointing to man pages not installed in
one of the _default locations mentioned in man.conf or MANPATH. For example
there are man pages in /usr/pkg/man which are symlinked to pages in
/usr/pkg/lib/perl5/man. If we ignore symlinks, we would not be able to
index such pages installed outside the default set of directories.

(Also, the symlink test was incorecct, so we never noticed this issue)

Ok christos@, wiz@
This commit is contained in:
abhinav 2016-12-17 17:04:38 +00:00
parent 1f22587e5d
commit e4137a4e3a

View File

@ -1,4 +1,4 @@
/* $NetBSD: makemandb.c,v 1.44 2016/10/03 16:11:11 abhinav Exp $ */
/* $NetBSD: makemandb.c,v 1.45 2016/12/17 17:04:38 abhinav Exp $ */
/*
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: makemandb.c,v 1.44 2016/10/03 16:11:11 abhinav Exp $");
__RCSID("$NetBSD: makemandb.c,v 1.45 2016/12/17 17:04:38 abhinav Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@ -526,9 +526,10 @@ traversedir(const char *parent, const char *file, sqlite3 *db,
}
}
closedir(dp);
return;
}
if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))
if (!S_ISREG(sb.st_mode))
return;
if (sb.st_size == 0) {
@ -820,15 +821,8 @@ update_db(sqlite3 *db, struct mparse *mp, mandb_rec *rec)
if (md5_status == 0) {
/*
* The MD5 hash is already present in the database,
* so simply update the metadata, ignoring symlinks.
* so simply update the metadata.
*/
struct stat sb;
stat(file, &sb);
if (S_ISLNK(sb.st_mode)) {
free(md5sum);
link_count++;
continue;
}
update_existing_entry(db, file, md5sum, rec,
&new_count, &link_count, &err_count);
free(md5sum);
@ -867,12 +861,12 @@ update_db(sqlite3 *db, struct mparse *mp, mandb_rec *rec)
}
if (mflags.verbosity == 2) {
printf("Total Number of new or updated pages encountered = %d\n"
"Total number of (hard or symbolic) links found = %d\n"
"Total number of pages that were successfully"
" indexed/updated = %d\n"
"Total number of pages that could not be indexed"
" due to errors = %d\n",
printf("Number of new or updated pages encountered: %d\n"
"Number of hard links found: %d\n"
"Number of pages that were successfully"
" indexed or updated: %d\n"
"Number of pages that could not be indexed"
" due to errors: %d\n",
total_count - link_count, link_count, new_count, err_count);
}