[BusyBox] cp says files are the same even though they are not

Aizer Danny-BDA023 Danny.Aizer at motorola.com
Mon Apr 11 11:09:32 UTC 2005


I've had today a weird situation come up:

I was running cp to copy a file from a RAM file-system (tmpfs) to a jffs2 file-system, and got the error:

cp: `/sm/tmp/download/SDMB/1.00/test2/1/1/tensr-1.00-12/tensr.conf.xml.2005.04.11-09.30.52' and `/sm/etc/monappl/tensr/tensr.conf.xml' are the same file

Although: /sm/tmp -> /tmp which is the tmpfs
          /sm/etc is on the jffs2

After checking the busy-box-0.60.3 libbb/copy_file.c (called by cp.c), I've seen that the following code triggers this message:

	if (dest_exists && source_stat.st_rdev == dest_stat.st_rdev &&
			source_stat.st_ino == dest_stat.st_ino) {
		error_msg("`%s' and `%s' are the same file", source, dest);
		return -1;
	}

(the destination file exists, BTW).

What I don't understand is how the st_rdev and st_ino are the same for the source and target despite being on different file-systems. Maybe that's OT here, but maybe the BusyBox code is not portable enough?

BTW, the BusyBox-0.60.3 is a patched version (patches irrelevant to the situation though) on MontaVista HardHat Linux 3

Thanks,
/Danny





More information about the busybox mailing list