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
Kconfig -rw-r--r-- 5.0 KB
Makefile -rw-r--r-- 2.8 KB
book3s.c -rw-r--r-- 23.3 KB
book3s.h -rw-r--r-- 1.3 KB
book3s_32_mmu.c -rw-r--r-- 10.1 KB
book3s_32_mmu_host.c -rw-r--r-- 10.0 KB
book3s_32_sr.S -rw-r--r-- 3.7 KB
book3s_64_mmu.c -rw-r--r-- 15.8 KB
book3s_64_mmu_host.c -rw-r--r-- 10.0 KB
book3s_64_mmu_hv.c -rw-r--r-- 43.0 KB
book3s_64_slb.S -rw-r--r-- 3.6 KB
book3s_64_vio.c -rw-r--r-- 3.7 KB
book3s_64_vio_hv.c -rw-r--r-- 3.0 KB
book3s_emulate.c -rw-r--r-- 15.5 KB
book3s_exports.c -rw-r--r-- 1010 bytes
book3s_hv.c -rw-r--r-- 67.2 KB
book3s_hv_builtin.c -rw-r--r-- 6.2 KB
book3s_hv_interrupts.S -rw-r--r-- 5.1 KB
book3s_hv_ras.c -rw-r--r-- 4.3 KB
book3s_hv_rm_mmu.c -rw-r--r-- 25.5 KB
book3s_hv_rm_xics.c -rw-r--r-- 10.7 KB
book3s_hv_rmhandlers.S -rw-r--r-- 59.4 KB
book3s_interrupts.S -rw-r--r-- 6.3 KB
book3s_mmu_hpte.c -rw-r--r-- 9.8 KB
book3s_paired_singles.c -rw-r--r-- 30.9 KB
book3s_pr.c -rw-r--r-- 44.8 KB
book3s_pr_papr.c -rw-r--r-- 9.6 KB
book3s_rmhandlers.S -rw-r--r-- 4.6 KB
book3s_rtas.c -rw-r--r-- 5.7 KB
book3s_segment.S -rw-r--r-- 9.5 KB
book3s_xics.c -rw-r--r-- 32.4 KB
book3s_xics.h -rw-r--r-- 3.0 KB
booke.c -rw-r--r-- 51.7 KB
booke.h -rw-r--r-- 5.3 KB
booke_emulate.c -rw-r--r-- 8.3 KB
booke_interrupts.S -rw-r--r-- 14.9 KB
bookehv_interrupts.S -rw-r--r-- 20.0 KB
e500.c -rw-r--r-- 14.8 KB
e500.h -rw-r--r-- 8.3 KB
e500_emulate.c -rw-r--r-- 8.8 KB
e500_mmu.c -rw-r--r-- 24.5 KB
e500_mmu_host.c -rw-r--r-- 20.8 KB
e500_mmu_host.h -rw-r--r-- 581 bytes
e500mc.c -rw-r--r-- 9.9 KB
emulate.c -rw-r--r-- 7.0 KB
emulate_loadstore.c -rw-r--r-- 6.7 KB
fpu.S -rw-r--r-- 5.7 KB
irq.h -rw-r--r-- 307 bytes
mpic.c -rw-r--r-- 41.8 KB
powerpc.c -rw-r--r-- 29.5 KB
timing.c -rw-r--r-- 7.1 KB
timing.h -rw-r--r-- 3.2 KB
trace.h -rw-r--r-- 2.7 KB
trace_booke.h -rw-r--r-- 3.8 KB
trace_pr.h -rw-r--r-- 7.0 KB

back to top