README.hardlinks revision 1.1
11.1Sdholland# $NetBSD: README.hardlinks,v 1.1 2016/05/29 22:32:03 dholland Exp $
21.1Sdholland#
31.1Sdholland
41.1Sdhollandcatman.8 notes that this code doesn't handle hard links.
51.1Sdholland
61.1SdhollandTo fix this, one might proceed as follows:
71.1Sdholland
81.1Sdholland(1) Add an additional data structure mapping (fsid_t, ino_t) pairs
91.1Sdhollandfrom stat to filenames.
101.1Sdholland
111.1Sdholland(2) In scanmandir(), in the readdir loop, next to the code that checks
121.1Sdhollandfor a symlink, check if the page's linkcount > 1 (manstat.st_nlink > 1)
131.1Sdhollandand if so:
141.1Sdholland   a. Check the new data structure to see if this file's been seen before.
151.1Sdholland      If so, use the saved name of the page to construct a hard link in the
161.1Sdholland      cat directory, and continue to the next directory entry.
171.1Sdholland   b. If not, add to the new data structure to remember this page and
181.1Sdholland      process it as normal.
191.1Sdholland
201.1SdhollandOne might clear the data structure for each mandir or not; probably
211.1Sdhollandfor each man tree is best. The size of the structure isn't
221.1Sdhollandprohibitive; but the chances of ever seeing the same hardlinked page
231.1Sdhollandin two different man trees (e.g. in both /usr/share/man and
241.1Sdholland/usr/pkg/man) are pretty well zero.
251.1Sdholland
261.1SdhollandAll of this seems like a SMOP, but it doesn't really seem worth doing
271.1Sdhollandat the moment given that we don't build catpages at all by default and
281.1Sdhollandthey aren't particularly useful to have any more except on the slowest
291.1Sdhollandof slow hardware. I've left this note so that someone else can take it
301.1Sdhollandup if they see fit.
311.1Sdholland
321.1Sdholland - dholland 20160529
33