+static uint64_t fs_getfullkeyid(uint64_t keyid)
+{
+ static char buffer[PATH_MAX];
+ DIR *d = NULL;
+ struct dirent *de = NULL;
+ uint64_t ret = 0;
+
+ keydir(buffer, keyid);
+
+ d = opendir(buffer);
+ if (d) {
+ do {
+ de = readdir(d);
+ if (de && de->d_name[0] != '.') {
+ ret = strtoull(de->d_name, NULL, 16);
+ }
+ } while (de && de->d_name[0] == '.');
+ closedir(d);
+ }
+
+ if (ret == 0) {
+ subkeydir(buffer, keyid);
+
+ d = opendir(buffer);
+ if (d) {
+ do {
+ de = readdir(d);
+ if (de && de->d_name[0] != '.') {
+ ret = strtoull(de->d_name, NULL, 16);
+ }
+ } while (de && de->d_name[0] == '.');
+ closedir(d);
+ }
+ }
+
+ return ret;
+}
+