Message ID | 20151201171014.GY8644@n2100.arm.linux.org.uk (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | Andy Gross |
Headers | show |
On Tue, 1 Dec 2015 17:10:14 +0000 Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > Another suggestion - maybe recordmcount, which fstat()s the file, > should check the st_nlink before modifying the file, and error out > with a helpful error message telling people not to use hardlinks, > which would stop nasty surprises (and make it a rule that this should > be implemented as a general principle for good build behaviour) - iow, Actually I like this solution the best. > something like this (untested): Can you test it to see if it gives you the error, otherwise I need to set up a CCACHE_HARDLINK environment :-) I guess another solution is to do a copy instead of modifying in place if it detects the multiple hard link? -- Steve > > scripts/recordmcount.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c > index 698768bdc581..bb7589fd7392 100644 > --- a/scripts/recordmcount.c > +++ b/scripts/recordmcount.c > @@ -203,6 +203,10 @@ static void *mmap_file(char const *fname) > fprintf(stderr, "not a regular file: %s\n", fname); > fail_file(); > } > + if (sb.st_nlink != 1) { > + fprintf(stderr, "file is hard linked: %s\n", fname); > + fail_file(); > + } > addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, > fd_map, 0); > mmap_failed = 0; > > -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Dec 01, 2015 at 12:22:12PM -0500, Steven Rostedt wrote: > On Tue, 1 Dec 2015 17:10:14 +0000 > Russell King - ARM Linux <linux@arm.linux.org.uk> wrote: > > > Another suggestion - maybe recordmcount, which fstat()s the file, > > should check the st_nlink before modifying the file, and error out > > with a helpful error message telling people not to use hardlinks, > > which would stop nasty surprises (and make it a rule that this should > > be implemented as a general principle for good build behaviour) - iow, > > Actually I like this solution the best. > > > something like this (untested): > > Can you test it to see if it gives you the error, otherwise I need to > set up a CCACHE_HARDLINK environment :-) It does indeed: CC init/do_mounts_initrd.o file is hard linked: init/do_mounts_initrd.o /home/rmk/git/linux-rmk/scripts/Makefile.build:258: recipe for target 'init/do_mounts_initrd.o' failed make[2]: *** [init/do_mounts_initrd.o] Error 1 > I guess another solution is to do a copy instead of modifying in place > if it detects the multiple hard link? That would be the "transparent" solution. If you think it's worth persuing, I'll have a go at fixing recordmcount to do that.
Dne 1.12.2015 v 19:16 Russell King - ARM Linux napsal(a): > On Tue, Dec 01, 2015 at 12:22:12PM -0500, Steven Rostedt wrote: >> I guess another solution is to do a copy instead of modifying in place >> if it detects the multiple hard link? > > That would be the "transparent" solution. If you think it's worth > persuing, I'll have a go at fixing recordmcount to do that. But in terms of number of file copies, it would on par with disabling CCACHE_HARDLINK from within the Makefile. Michal -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index 698768bdc581..bb7589fd7392 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -203,6 +203,10 @@ static void *mmap_file(char const *fname) fprintf(stderr, "not a regular file: %s\n", fname); fail_file(); } + if (sb.st_nlink != 1) { + fprintf(stderr, "file is hard linked: %s\n", fname); + fail_file(); + } addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd_map, 0); mmap_failed = 0;