The Samba-Bugzilla – Bug 7755
SMBC_getdents_ctx() ignores struct alignment rules
Last modified: 2011-11-30 18:49:46 UTC
We found that code that works flawlessly on x86 gave wrong results on the ARM platform. When listing the contents of an directory using libsmbclient (actually by means of gvfs), the number of entries returned differs between multiple calls. We tracked this down to code in SMBC_getdents_ctx() that ignores the fact that some platforms (like ARM) have different struct alignment rules.
I will attach a patch that fixes the problem. It has been tested on ARM and x86. There may be better ways to solve this though...
Created attachment 6035 [details]
patch to fix struct alignment problem on the ARM platform
I pushed something similar (based on your patch) to master and v3-6-test.
Will be fixed in v3-6-test. Let me know if you need this back-ported to 3.5.7.
A backport would be appreciated. Can you attach the patch so that I can give it some testing?
We saw this too, but since getdents just calls readdir multiple times, I just used the other iterator methods (readdir, telldir, lseekdir).
Actually, if you are filtering by specific file name / path, not using getdents is actually more efficient. Just some food for thought.