/** * @brief Filter out keys not in the correct keyset * * @param split the split where to do it * @param i for which split * @param warningKey the key * @param handle where to do backend lookups * * @retval -1 on error (no backend, wrong namespace) * @retval 0 otherwise */ static int elektraSplitPostprocess (Split * split, int i, Key * warningKey, KDB * handle) { Key * cur = 0; Backend * curHandle = 0; ksRewind (split->keysets[i]); while ((cur = ksNext (split->keysets[i])) != 0) { curHandle = elektraMountGetBackend (handle, cur); if (!curHandle) return -1; keyClearSync (cur); if (curHandle != split->handles[i]) { elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it is hidden by other mountpoint"); } else switch (keyGetNamespace (cur)) { case KEY_NS_SPEC: if (!keyIsSpec (split->parents[i])) elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it is not spec"); break; case KEY_NS_DIR: if (!keyIsDir (split->parents[i])) elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it is not dir"); break; case KEY_NS_USER: if (!keyIsUser (split->parents[i])) elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it is not user"); break; case KEY_NS_SYSTEM: if (!keyIsSystem (split->parents[i])) elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it is not system"); break; case KEY_NS_PROC: elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it has a proc key name"); break; case KEY_NS_EMPTY: elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it has an empty name"); break; case KEY_NS_META: elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it has a meta name"); break; case KEY_NS_CASCADING: elektraDropCurrentKey (split->keysets[i], warningKey, curHandle, "it has a cascading name"); break; case KEY_NS_NONE: ELEKTRA_ASSERT (0 && "wrong key namespace, should not be none"); return -1; } } return 0; }
void clear_sync (KeySet *ks) { Key *k; ksRewind(ks); while ((k = ksNext(ks)) != 0) keyClearSync(k); }