Revision b928095b0a7cff7fb9fcf4c706348ceb8ab2c295 authored by Miklos Szeredi on 24 September 2014, 15:56:17 UTC, committed by Al Viro on 27 September 2014, 01:16:42 UTC
If overwriting an empty directory with rename, then need to drop the extra
nlink.

Test prog:

#include <stdio.h>
#include <fcntl.h>
#include <err.h>
#include <sys/stat.h>

int main(void)
{
	const char *test_dir1 = "test-dir1";
	const char *test_dir2 = "test-dir2";
	int res;
	int fd;
	struct stat statbuf;

	res = mkdir(test_dir1, 0777);
	if (res == -1)
		err(1, "mkdir(\"%s\")", test_dir1);

	res = mkdir(test_dir2, 0777);
	if (res == -1)
		err(1, "mkdir(\"%s\")", test_dir2);

	fd = open(test_dir2, O_RDONLY);
	if (fd == -1)
		err(1, "open(\"%s\")", test_dir2);

	res = rename(test_dir1, test_dir2);
	if (res == -1)
		err(1, "rename(\"%s\", \"%s\")", test_dir1, test_dir2);

	res = fstat(fd, &statbuf);
	if (res == -1)
		err(1, "fstat(%i)", fd);

	if (statbuf.st_nlink != 0) {
		fprintf(stderr, "nlink is %lu, should be 0\n", statbuf.st_nlink);
		return 1;
	}

	return 0;
}

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 0f33be0
History
File Mode Size
include
Kconfig -rw-r--r-- 7.2 KB
Makefile -rw-r--r-- 1.4 KB
Makefile.boot -rw-r--r-- 323 bytes
aemif.c -rw-r--r-- 5.8 KB
asp.h -rw-r--r-- 1.4 KB
board-da830-evm.c -rw-r--r-- 17.3 KB
board-da850-evm.c -rw-r--r-- 38.6 KB
board-dm355-evm.c -rw-r--r-- 10.4 KB
board-dm355-leopard.c -rw-r--r-- 7.1 KB
board-dm365-evm.c -rw-r--r-- 18.5 KB
board-dm644x-evm.c -rw-r--r-- 20.1 KB
board-dm646x-evm.c -rw-r--r-- 18.3 KB
board-mityomapl138.c -rw-r--r-- 13.3 KB
board-neuros-osd2.c -rw-r--r-- 6.5 KB
board-omapl138-hawk.c -rw-r--r-- 8.2 KB
board-sffsdr.c -rw-r--r-- 4.4 KB
cdce949.c -rw-r--r-- 6.1 KB
clock.c -rw-r--r-- 15.3 KB
clock.h -rw-r--r-- 3.9 KB
common.c -rw-r--r-- 2.9 KB
cp_intc.c -rw-r--r-- 5.5 KB
cpuidle.c -rw-r--r-- 2.4 KB
da830.c -rw-r--r-- 39.0 KB
da850.c -rw-r--r-- 35.5 KB
da8xx-dt.c -rw-r--r-- 2.3 KB
davinci.h -rw-r--r-- 4.2 KB
devices-da8xx.c -rw-r--r-- 22.8 KB
devices.c -rw-r--r-- 8.3 KB
dm355.c -rw-r--r-- 25.1 KB
dm365.c -rw-r--r-- 35.9 KB
dm644x.c -rw-r--r-- 21.9 KB
dm646x.c -rw-r--r-- 22.4 KB
irq.c -rw-r--r-- 3.6 KB
mux.c -rw-r--r-- 2.6 KB
mux.h -rw-r--r-- 1.4 KB
pm.c -rw-r--r-- 3.8 KB
pm_domain.c -rw-r--r-- 1.4 KB
psc.c -rw-r--r-- 3.8 KB
serial.c -rw-r--r-- 2.9 KB
sleep.S -rw-r--r-- 5.4 KB
sram.c -rw-r--r-- 1.8 KB
time.c -rw-r--r-- 11.4 KB
usb.c -rw-r--r-- 3.8 KB

back to top