Hi all, when requesting xattr on FreeBSD, only 256 bytes EAs are returned. This behaviour has been found by Alex Masterov. :-) When looking at the code in smbd/trans2.c, it seems to be clear, that the code path with the second try with 65536 bytes is not reached. (due to wrong return code or different errno). static BOOL get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn, files_struct *fsp, const char *fname, char *ea_name, struct ea_struct *pea) { /* Get the value of this xattr. Max size is 64k. */ size_t attr_size = 256; char *val = NULL; ssize_t sizeret; again: val = TALLOC_REALLOC_ARRAY(mem_ctx, val, char, attr_size); if (!val) { return False; } if (fsp && fsp->fh->fd != -1) { sizeret = SMB_VFS_FGETXATTR(fsp, fsp->fh->fd, ea_name, val, attr_size); } else { sizeret = SMB_VFS_GETXATTR(conn, fname, ea_name, val, attr_size); } if (sizeret == -1 && errno == ERANGE && attr_size != 65536) { attr_size = 65536; goto again; } ---- Timur I. Bakeyev (BAT), who had coded the special FreeBSD xattr additions, had a closer look at that - and found some strange oddities. He has prepared a patch, which was tested by Alex Masterov. AFAIK - the former seen glitches are gone now. :-) I do not run a FreeBSD box here - so Alex might comment on his tests. He usually is testing with latest svn revision. BaT told me on irc, that he will send his patch. Cheers, Guenter Kukkukk
(In reply to comment #0) > Hi all, > > BaT told me on irc, that he will send his patch. > > Cheers, Guenter Kukkukk And here I do attach promissed patch which addresses this problem. With regards, Timur.
Created attachment 1543 [details] Fix to the xattr attributes emulation through EA in *BSD The problem with FreeBSD EA API is that it just uses passed buffer and truncates the result, if it doesn't fit, no erro is generated. so this patch checks first, how much space is needed and if buffer not big enough - function returns error. Similar fixes are done to support additional flags used by setxattr() function.
I can prove the truth of this report. Before BaT's patch there was problem - OS/2 could set EA with any size supported by FreeBSD filesystem. But samba could get only first 256 bytes of EA. FreeBSD system utility getextattr could get full size EA. After patching with above patch this problem gone, i.e. now samba can get full size of EA. Thanks to Timur & Guenter!
Applied, thanks ! Jeremy.