diff --git a/src/nfs/nfs_kv_setattr.cpp b/src/nfs/nfs_kv_setattr.cpp index b55b3c73..3eeb13c9 100644 --- a/src/nfs/nfs_kv_setattr.cpp +++ b/src/nfs/nfs_kv_setattr.cpp @@ -61,7 +61,7 @@ resume_1: } if (st->ientry["type"].string_value() != "file" && st->ientry["type"].string_value() != "" && - !st->set_attrs["size"].is_null()) + st->set_attrs.find("size") != st->set_attrs.end()) { auto cb = std::move(st->cb); cb(-EINVAL); @@ -96,8 +96,13 @@ resume_1: nfs_kv_continue_setattr(st, 2); }, [st](int res, const std::string & cas_value) { + if ((res == 0 || res == -ENOENT && st->ino == KV_ROOT_INODE) && cas_value == st->ientry_text) + { + st->cas_res = 0; + return true; + } st->cas_res = res; - return (res == 0 || res == -ENOENT && st->ino == KV_ROOT_INODE) && cas_value == st->ientry_text; + return false; }); return; resume_2: diff --git a/tests/test_nfs.sh b/tests/test_nfs.sh index 90f84e55..665f85c0 100755 --- a/tests/test_nfs.sh +++ b/tests/test_nfs.sh @@ -15,6 +15,8 @@ sudo mount localhost:/ ./testdata/nfs -o port=2050,mountport=2050,nfsvers=3,soft MNT=$(pwd)/testdata/nfs trap "sudo umount -f $MNT"' || true; kill -9 $(jobs -p)' EXIT +chown 1000:1000 ./testdata/nfs + touch ./testdata/nfs/f1 chown 1000:1000 ./testdata/nfs/f1 chmod 600 ./testdata/nfs/f1