Merge pull request #132 from giuseppe/fixes

main.c: reload the directory on stat
This commit is contained in:
Daniel J Walsh 2019-10-15 19:13:53 -04:00 committed by GitHub
commit 3bc0aa6427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

4
NEWS
View File

@ -1,3 +1,7 @@
* fuse-overlayfs-0.6.5
- stat reports correctly the number of links for a directory.
* fuse-overlayfs-0.6.4
- do not lose the setuid bit after a write when the writeback cache is used.

View File

@ -1,5 +1,5 @@
AC_PREREQ([2.69])
AC_INIT([fuse-overlayfs], [0.6.4], [giuseppe@scrivano.org])
AC_INIT([fuse-overlayfs], [0.6.5], [giuseppe@scrivano.org])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])

20
main.c
View File

@ -1862,6 +1862,16 @@ ovl_lookup (fuse_req_t req, fuse_ino_t parent, const char *name)
return;
}
if (node_dirp (node))
{
node = reload_dir (lo, node);
if (node == NULL)
{
fuse_reply_err (req, errno);
return;
}
}
err = rpl_stat (req, node, -1, NULL, NULL, &e.attr);
if (err)
{
@ -2108,6 +2118,16 @@ ovl_do_readdir (fuse_req_t req, fuse_ino_t ino, size_t size,
}
else
{
if (node_dirp (node))
{
node = reload_dir (lo, node);
if (node == NULL)
{
fuse_reply_err (req, errno);
return;
}
}
memset (&e, 0, sizeof (e));
ret = rpl_stat (req, node, -1, NULL, NULL, st);
if (ret < 0)

View File

@ -21,6 +21,11 @@ fuse-overlayfs -o sync=0,threaded=1,lowerdir=lower,upperdir=upper,workdir=workdi
SUID_TEST=$(pwd)/suid-test
(cd merged; $SUID_TEST)
# Test the number of hard links for populated directories is > 2
test $(stat -c %h merged/etc) -gt 2
ls merged/usr
test $(stat -c %h merged/usr) -gt 2
stat -c %A upper/suid | grep s
stat -c %a upper/nosuid | grep -v s