munmap & cp

Wiktor Niesiobedzki bsd at w.evip.pl
Tue Nov 11 06:31:20 PST 2003


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



More information about the freebsd-current mailing list