- if((a = file_stat(full = combine_path("/",root,full), lstat)))
This is also wrong. The stat->pullpath should not include root, it should be relative to the chroot point. The correct value is the of full before the initial / was removed. But you could also use "/"+full.
Example:
wd = "/foo/bar" root = "/gaz/onk" file = "../ho/hum.txt"
Value of full before file_stat(): "foo/ho/hum.txt"
Correct path to give to file_stat(): "/gaz/onk/foo/ho/hum.txt" Correct value to set stat->fullpath to: "/foo/ho/hum.txt"