Hello list, I know this has been discussed before (June 2007 looks to be the most recent time), so apologies for covering (sort of) old ground. The lowdown is that samba uses readdir to get its directory listing and this is returned in whatever order the filesystem sees as appropriate (using ext3, it seems to be related to mtime). I have a device which accesses a share using CIFS and presents the files in the order that they are returned by the server. This works fine using NTFS on Windows XP (as that filesystem returns the files alphabetically) but ends up in a confusing list when accessing the ext3 share. I understand that it's not a good default for Samba to do the sorting (as mostly it's not needed - the client can do it), but I'd love to have an option for an individual service to return a sorted directory list (accepting the performance hit that it would incur). Is this something that would be included in a future Samba release? I guess another alternative would be to have a Samba VFS that sorts the readdir output before passing it on. Can anyone comment on this as a possible solution and whether it has been accomplished before? Any thoughts or comments would be much appreciated. Andy
2008/12/29 Andy Kelk <andykelk@gmail.com>:> I guess another alternative would be to have a Samba VFS that sorts > the readdir output before passing it on. Can anyone comment on this as > a possible solution and whether it has been accomplished before?I've implemented something which (I think) will do this. Unfortunately, as a first time vfs author, I'm having trouble getting it to install correctly. I have it built and linked as a .so file. I have moved it into my /usr/lib/samba/vfs directory. I have added it to a section of my smb.conf file ("vfs objects = sorted"). When trying to access that share, I get a NT_STATUS_BAD_NETWORK_NAME error. The log shows: [2008/12/30 15:23:10, 3] smbd/vfs.c:vfs_init_custom(130) Initialising custom vfs hooks from [sorted] [2008/12/30 15:23:10, 10] smbd/vfs.c:vfs_find_backend_entry(48) vfs_find_backend_entry called for sorted [2008/12/30 15:23:10, 5] lib/module.c:smb_probe_module(111) Probing module 'sorted' [2008/12/30 15:23:10, 5] lib/module.c:smb_probe_module(130) Probing module 'sorted': Trying to load from /usr/lib/samba/vfs/sorted.so [2008/12/30 15:23:10, 2] lib/module.c:do_smb_load_module(64) Module '/usr/lib/samba/vfs/sorted.so' loaded [2008/12/30 15:23:10, 10] smbd/vfs.c:vfs_find_backend_entry(48) vfs_find_backend_entry called for sorted_transparent [2008/12/30 15:23:10, 5] smbd/vfs.c:smb_register_vfs(86) Successfully added vfs backend 'sorted_transparent' [2008/12/30 15:23:10, 10] smbd/vfs.c:vfs_find_backend_entry(48) vfs_find_backend_entry called for sorted [2008/12/30 15:23:10, 0] smbd/vfs.c:vfs_init_custom(176) Can't find a vfs module [sorted] [2008/12/30 15:23:10, 0] smbd/vfs.c:smbd_vfs_init(317) smbd_vfs_init: vfs_init_custom failed for sorted Anyone able to shed some light on what I might be doing wrong? This is on Ubuntu Intrepid using Samba 3.2.3. Many thanks Andy
2008/12/30 Andy Kelk <andykelk@gmail.com>:> Anyone able to shed some light on what I might be doing wrong?I hate it when this happens. I figured out my stupid mistake (sending the wrong name in smb_register_vfs. Apologies for time-wasting. Andy
On Monday 29 December 2008 08:52:25 Andy Kelk wrote:> I guess another alternative would be to have a Samba VFS that sorts > the readdir output before passing it on. Can anyone comment on this as > a possible solution and whether it has been accomplished before?I have now implemented a very simple directory sort for samba. I have not stress-tested it yet or had much opportunity to see how it works other than in my limited set-up. I can't make any great claims for its robustness or performance but I have found it very useful in fixing my own problem. It may also help others out so I've posted the results here: http://code.google.com/p/samba-dirsort-vfs/ Andy