munmap & cp

From: Wiktor Niesiobedzki <bsd_at_w.evip.pl>
Date: Tue, 11 Nov 2003 15:31:15 +0100
Hi,

The simple scenario:
$ mkdir foo
$ cd foo
$ touch foo
$ cp foo foo2
cp: foo: Invalid argument

The problem lies in:
src/bin/cp/utils.c:163
                        if (munmap(p, fs->st_size) < 0) {
                                warn("%s", entp->fts_path);
                                rval = 1;
                        }

For the size 0, the munmap will return EINVAL. Returning now error leads us,
to think, that no file was copied.

My quick hack is to change the line 136:
        if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576) {
into:
	if (S_ISREG(fs->st_mode) && fs->st_size <= 8 * 1048576 && fs->st_size > 0) {


Anyone feels like to look into it?

Cheers,

Wiktor Niesiobędzki
Received on Tue Nov 11 2003 - 05:31:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:28 UTC