- keypath(buffer, sizeof(buffer), keyid);
- if ((fd = open(buffer, O_RDONLY)) != -1) {
+ keypath(buffer, sizeof(buffer), keyid, dbctx->config->location);
+ fd = open(buffer, O_RDONLY);
+ if (fd == -1 && errno == ENOENT) {
+ subkeypath(buffer, sizeof(buffer), keyid,
+ dbctx->config->location);
+ fd = open(buffer, O_RDONLY);
+ }
+
+ if (fd != -1) {