Currently FSCTLs are implemented in the body of Samba itself, so if Vendors want to implement their own FSCTLs they have to modify Samba code. It would be better if the processing of FSCTLs was handled in the VFS with the current code being the default in modules/vfs_default.c.
Created attachment 6898 [details] A torture test that tests some aspects of the current implementation of FSCTLs This test was written as an aide to getting the VFS default code correct and so that developers of vendor-specific FSCTLs have a template to work with.
While I do like the idea of pushing the FSCTL through the VFS I'm not sure we should do it within a 3.6.x release. I thought that our assumption was that we try to keep the VFS stable within a major release series. Jeremy?
Yes, we need to keep the VFS stable for 3.6.x, this is more of a 4.0.x enhancement in terms of when we ship the code changes. No issues with keeping this bug up to date with private patches OEM's and vendors might need if they want to get this into their versions of 3.6.x however. Jeremy.
Created attachment 6900 [details] A git format-patch patch against master that passes my torture test This patch builds and handles the torture test correctly as far as I can see. I checked it by looking at a Wireshark capture. The patch is against Master. I will probably create one against 3.6.0 and 3.6.1 when it comes out.
Comment on attachment 6900 [details] A git format-patch patch against master that passes my torture test Superseded by latest patch
Created attachment 6906 [details] A git format-patch patch against master that passes my torture test I added a Signed-off-by: This patch is against master. It passes my torture test and an inspection of a tcpdump capture suggests that it is working OK. I might write more tests. Will probably merge it to 3.6.0 and 3.6.1 when it comes out and provide separate patches.
Created attachment 6908 [details] Reworked the patch to pass a talloc_context at Volker's suggestion This is essentially the same patch as the earlier one but now a talloc context is passed into the FSCTL VFS routine. (I note that existing routines in vfs_default use talloc_tos().)
Created attachment 6933 [details] Reworked the patch again to use talloc_array as suggested by Rusty This is a slightly reworked patch to move FSCTL handling into the VFS. It includes two changes from the original: 1. Pass a talloc context to the FSCTL VFS routine 2. Use talloc_array rather that talloc_size. This has been tested using my torture test and passes.
Hi Richard, As we're passing raw bytes here, could you change "char" into "uint8_t"? In vfswrap_fsctl() we could have const char *in_data = (const char *)_in_data; char **out_data = (char **)_out_data; on top to avoid warnings. We may also need casts in the caller, but I think we should have the correct types in the API. Otherwise the patches look good to me. If they pass the tests, we should run them in make test. You need to add "NTTRANS-FSCTL" to the array, where "SMB2-BASIC" is already listed in source3/selftest/tests.py. metze
Created attachment 6935 [details] Reworked it to make the changes suggested by Metze. Reworked the patch one more time to: 1. Pass uint8_t pointers rather than char pointers and add casts where needed. 2. Enable the NTTRANS-FSCTL test in the self tests (have not tested this :-) 3. Pass a talloc context (requested by Volker) 4. Use talloc_array (requested by Rusty) Again, it passes my NTTRANS-FSCTL test. However, my first patch with the new test will have to be applied before this patch, otherwise the self tests will fail.
This has been fixed with the following commits: 595cc42a46f5dfbac5c17a403fb1f82769f26ff2 Author: Richard Sharpe <realrichardsharpe@gmail.com> Date: Sat Oct 1 09:03:13 2011 -0700 Add the new test_nttrans_fsctl.c to waf Autobuild-User: Richard Sharpe <sharpe@samba.org> Autobuild-Date: Sat Oct 1 19:36:53 CEST 2011 on sn-devel-104 commit c875ab8747d65cc6556228616f076b0928013c87 Author: Richard Sharpe <realrichardsharpe@gmail.com> Date: Fri Sep 16 11:52:22 2011 -0700 Move FSCTL handling into the VFS. Initial code changes. Passes smbtorture NT commit e8f143a45cceb8d2c01d45167a0c90d5c7f38289 Author: Richard Sharpe <realrichardsharpe@gmail.com> Date: Thu Sep 15 16:13:54 2011 -0700 Add a torture test to test existing FSCTL responses