#define fsprops_lookup(values, value) \
__fsprops_lookup((values), ARRAY_SIZE(values), (value))
+/* Self-healing fs property */
+
+static const char *fsprop_self_healing_values[] = {
+ [FSPROP_SELFHEAL_UNSET] = NULL,
+ [FSPROP_SELFHEAL_NONE] = "none",
+ [FSPROP_SELFHEAL_CHECK] = "check",
+ [FSPROP_SELFHEAL_OPTIMIZE] = "optimize",
+ [FSPROP_SELFHEAL_REPAIR] = "repair",
+};
+
+/* Convert the self_healing property enum to a string. */
+const char *
+fsprop_write_self_healing(
+ enum fsprop_self_healing x)
+{
+ if (x <= FSPROP_SELFHEAL_UNSET ||
+ x >= ARRAY_SIZE(fsprop_self_healing_values))
+ return NULL;
+ return fsprop_self_healing_values[x];
+}
+
+/*
+ * Turn a self_healing value string into an enumerated value, or _UNSET if it's
+ * not recognized.
+ */
+enum fsprop_self_healing
+fsprop_read_self_healing(
+ const char *value)
+{
+ int ret = fsprops_lookup(fsprop_self_healing_values, value);
+ if (ret < 0)
+ return FSPROP_SELFHEAL_UNSET;
+ return ret;
+}
+
/* Return true if a fs property name=value tuple is allowed. */
bool
fsprop_validate(
const char *name,
const char *value)
{
+ if (!strcmp(name, FSPROP_SELF_HEALING_NAME))
+ return fsprops_lookup(fsprop_self_healing_values, value) >= 0;
+
return true;
}
/* Specific Filesystem Properties */
+#define FSPROP_SELF_HEALING_NAME "self_healing"
+
+enum fsprop_self_healing {
+ FSPROP_SELFHEAL_UNSET = 0, /* do not set property */
+ FSPROP_SELFHEAL_NONE, /* no background scrubs */
+ FSPROP_SELFHEAL_CHECK, /* allow only background checking */
+ FSPROP_SELFHEAL_OPTIMIZE, /* allow background optimization */
+ FSPROP_SELFHEAL_REPAIR, /* allow background repair & optimization */
+};
+
+const char *fsprop_write_self_healing(enum fsprop_self_healing x);
+enum fsprop_self_healing fsprop_read_self_healing(const char *value);
+
#endif /* __LIBFROG_FSPROPERTIES_H__ */