summaryrefslogtreecommitdiff
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2014-09-24 17:56:17 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-10-05 14:54:11 -0700
commit474740b9e629cad9479324efd3926a8e88b04761 (patch)
treef58c3550fa95d83b74edcb7f0e4c8656115b0d80 /mm/mmap.c
parent09338bb96a7ce2a8da60a0230e7b01b707eec778 (diff)
downloadlinux-3.10-474740b9e629cad9479324efd3926a8e88b04761.tar.gz
linux-3.10-474740b9e629cad9479324efd3926a8e88b04761.tar.bz2
linux-3.10-474740b9e629cad9479324efd3926a8e88b04761.zip
shmem: fix nlink for rename overwrite directory
commit b928095b0a7cff7fb9fcf4c706348ceb8ab2c295 upstream. 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> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/mmap.c')
0 files changed, 0 insertions, 0 deletions