1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

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 <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Christof Schmitt 2016-04-01 09:47:31 -07:00 committed by Jeremy Allison
parent 94f31295b1
commit d18a0ff9cb
2 changed files with 33 additions and 0 deletions

View File

@ -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 */

View File

@ -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.
******************************************************************/