Bug 7755 - SMBC_getdents_ctx() ignores struct alignment rules
Summary: SMBC_getdents_ctx() ignores struct alignment rules
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: unspecified
Hardware: Other Linux
: P3 normal
Target Milestone: ---
Assignee: Derrell Lipman
QA Contact: Samba QA Contact
Depends on:
Reported: 2010-10-26 14:22 UTC by Sven Neumann
Modified: 2011-11-30 18:49 UTC (History)
0 users

See Also:

patch to fix struct alignment problem on the ARM platform (831 bytes, patch)
2010-10-26 14:23 UTC, Sven Neumann
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Neumann 2010-10-26 14:22:02 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...
Comment 1 Sven Neumann 2010-10-26 14:23:17 UTC
Created attachment 6035 [details]
patch to fix struct alignment problem on the ARM platform
Comment 2 Jeremy Allison 2010-10-27 16:39:11 UTC
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.

Comment 3 Sven Neumann 2010-10-28 16:36:43 UTC
A backport would be appreciated. Can you attach the patch so that I can give it some testing?
Comment 4 David Kondrad 2011-11-30 18:49:46 UTC

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.