@@ -29,11 +29,49 @@ __fsprops_lookup(
#define fsprops_lookup(values, value) \
__fsprops_lookup((values), ARRAY_SIZE(values), (value))
+/* Automatic background fsck fs property */
+
+static const char *fsprop_autofsck_values[] = {
+ [FSPROP_AUTOFSCK_UNSET] = NULL,
+ [FSPROP_AUTOFSCK_NONE] = "none",
+ [FSPROP_AUTOFSCK_CHECK] = "check",
+ [FSPROP_AUTOFSCK_OPTIMIZE] = "optimize",
+ [FSPROP_AUTOFSCK_REPAIR] = "repair",
+};
+
+/* Convert the autofsck property enum to a string. */
+const char *
+fsprop_autofsck_write(
+ enum fsprop_autofsck x)
+{
+ if (x <= FSPROP_AUTOFSCK_UNSET ||
+ x >= ARRAY_SIZE(fsprop_autofsck_values))
+ return NULL;
+ return fsprop_autofsck_values[x];
+}
+
+/*
+ * Turn a autofsck value string into an enumerated value, or _UNSET if it's
+ * not recognized.
+ */
+enum fsprop_autofsck
+fsprop_autofsck_read(
+ const char *value)
+{
+ int ret = fsprops_lookup(fsprop_autofsck_values, value);
+ if (ret < 0)
+ return FSPROP_AUTOFSCK_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_AUTOFSCK_NAME))
+ return fsprops_lookup(fsprop_autofsck_values, value) >= 0;
+
return true;
}
@@ -50,4 +50,17 @@ bool fsprop_validate(const char *name, const char *value);
/* Specific Filesystem Properties */
+#define FSPROP_AUTOFSCK_NAME "autofsck"
+
+enum fsprop_autofsck {
+ FSPROP_AUTOFSCK_UNSET = 0, /* do not set property */
+ FSPROP_AUTOFSCK_NONE, /* no background scrubs */
+ FSPROP_AUTOFSCK_CHECK, /* allow only background checking */
+ FSPROP_AUTOFSCK_OPTIMIZE, /* allow background optimization */
+ FSPROP_AUTOFSCK_REPAIR, /* allow background repair & optimization */
+};
+
+const char *fsprop_autofsck_write(enum fsprop_autofsck x);
+enum fsprop_autofsck fsprop_autofsck_read(const char *value);
+
#endif /* __LIBFROG_FSPROPERTIES_H__ */