From: Christof Schmitt Date: Fri, 1 Apr 2016 16:47:31 +0000 (-0700) Subject: vfs: Add helper to check for missing VFS functions X-Git-Tag: tdb-1.3.9~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d18a0ff9cba40e2e50bedb95657563ede8f586dd;p=thirdparty%2Fsamba.git vfs: Add helper to check for missing VFS functions Some VFS modules want to ensure that they implement all VFS functions. This helper can be used to detect missing functions in the developer build. Signed-off-by: Christof Schmitt Reviewed-by: Jeremy Allison --- diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 6ab9a7e36b2..9360802a535 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -1381,4 +1381,7 @@ void vfs_remove_all_fsp_extensions(struct files_struct *fsp); void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp); void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp); +void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns, + const char *module); + #endif /* _VFS_H */ diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index efed2683a6a..605f9ade703 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -316,6 +316,36 @@ void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp) #undef EXT_DATA_AREA +/* + * Ensure this module catches all VFS functions. + */ +#ifdef DEVELOPER +void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns, + const char *module) +{ + bool missing_fn = false; + unsigned int idx; + const uintptr_t *end = (const uintptr_t *)(fns + 1); + + for (idx = 0; ((const uintptr_t *)fns + idx) < end; idx++) { + if (*((const uintptr_t *)fns + idx) == 0) { + DBG_ERR("VFS function at index %d not implemented " + "in module %s\n", idx, module); + missing_fn = true; + } + } + + if (missing_fn) { + smb_panic("Required VFS function not implemented in module.\n"); + } +} +#else +void smb_vfs_assert_all_fns(const struct vfs_fn_pointers* fns, + const char *module) +{ +} +#endif + /***************************************************************** Generic VFS init. ******************************************************************/