mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
LINUX: Avoid check for key_type.match existence
Commit b5de4a9f removed our key_type 'match' function for kernels that do not have such a 'match' function pointer. However, this added a configure test where we are supposed to fail for the "new" behavior, which is discouraged. This causes an actual problem, because this test will fail on at least RHEL5, due to arguably unrelated reasons (the header file for the relevant struct is in key.h instead of key-type.h). And so, in that situation we avoid defining a 'match' function callback, meaning our 'match' function callback is NULL, which causes a panic when we try to actually look up keys for a PAG. To fix this, transform the 'match' config test into one where we succeed for the "new" behavior. We do this by testing for the existence of the new functionality that replaced the old 'match' function, which is the match_preparse function (specifically, the 'cmp' field in the structure accepted by match_preparse). This should cause unrelated compilation errors to cause us to revert to the "old" behavior instead of the "new" behavior. At worst, this should cause build issues if we get the config test wrong (since we will try to use the 'match' function definition that does not exist), instead of panicing at runtime. Note that while we test for key_type.match_preparse, we don't actually use that function, since our 'match' functionality is the same as the default behavior (according to b5de4a9f). So, we can avoid defining any such function for newer kernels. Thanks to Stephan Wiesand for bisecting this issue. Change-Id: If6f93d6b5340fa738a55adeb7778d26ff5dbacc1 Reviewed-on: http://gerrit.openafs.org/11589 Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com> Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
parent
255c0a564f
commit
a9a3cb2eff
@ -891,7 +891,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
|
|||||||
AC_CHECK_LINUX_STRUCT([file_system_type], [mount], [fs.h])
|
AC_CHECK_LINUX_STRUCT([file_system_type], [mount], [fs.h])
|
||||||
AC_CHECK_LINUX_STRUCT([inode_operations], [truncate], [fs.h])
|
AC_CHECK_LINUX_STRUCT([inode_operations], [truncate], [fs.h])
|
||||||
AC_CHECK_LINUX_STRUCT([key_type], [instantiate_prep], [key-type.h])
|
AC_CHECK_LINUX_STRUCT([key_type], [instantiate_prep], [key-type.h])
|
||||||
AC_CHECK_LINUX_STRUCT([key_type], [match], [key-type.h])
|
AC_CHECK_LINUX_STRUCT([key_type], [match_preparse], [key-type.h])
|
||||||
AC_CHECK_LINUX_STRUCT([key_type], [preparse], [key-type.h])
|
AC_CHECK_LINUX_STRUCT([key_type], [preparse], [key-type.h])
|
||||||
AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
|
AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
|
||||||
AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
|
AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
|
||||||
|
@ -498,7 +498,13 @@ error:
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(STRUCT_KEY_TYPE_HAS_MATCH)
|
#if !defined(STRUCT_KEY_TYPE_HAS_MATCH_PREPARSE)
|
||||||
|
/* Note that we only define a ->match function if struct
|
||||||
|
* key_type.match_preparse does _not_ exist. If key_type.match_preparse does
|
||||||
|
* exist, we would use that to specify an alternative comparison function; but
|
||||||
|
* since we just rely on default behavior, we don't need to actually specify
|
||||||
|
* one. But for kernels with no such match_preparse function, we need to
|
||||||
|
* specify a 'match' function, since there is no default. */
|
||||||
static int afs_pag_match(const struct key *key, const void *description)
|
static int afs_pag_match(const struct key *key, const void *description)
|
||||||
{
|
{
|
||||||
return strcmp(key->description, description) == 0;
|
return strcmp(key->description, description) == 0;
|
||||||
@ -529,7 +535,7 @@ struct key_type key_type_afs_pag =
|
|||||||
#else
|
#else
|
||||||
.instantiate = afs_pag_instantiate,
|
.instantiate = afs_pag_instantiate,
|
||||||
#endif
|
#endif
|
||||||
#if defined(STRUCT_KEY_TYPE_HAS_MATCH)
|
#if !defined(STRUCT_KEY_TYPE_HAS_MATCH_PREPARSE)
|
||||||
.match = afs_pag_match,
|
.match = afs_pag_match,
|
||||||
#endif
|
#endif
|
||||||
.destroy = afs_pag_destroy,
|
.destroy = afs_pag_destroy,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user