summaryrefslogtreecommitdiff
path: root/include/env_flags.h
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-12-11 22:16:34 -0600
committerTom Rini <trini@ti.com>2012-12-13 11:46:56 -0700
commit267541f776f1e2bec21681c6e39a4c93af9621cf (patch)
tree861ff411eab98193f9914d30ec420628e79912e0 /include/env_flags.h
parentfffad71bc489cf224eda6d826a1645423852ee45 (diff)
env: Add support for access control to .flags
Add support for read-only, write-once, and change-default. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'include/env_flags.h')
-rw-r--r--include/env_flags.h50
1 files changed, 47 insertions, 3 deletions
diff --git a/include/env_flags.h b/include/env_flags.h
index 7e72523f02..0bdae07838 100644
--- a/include/env_flags.h
+++ b/include/env_flags.h
@@ -36,9 +36,18 @@ enum env_flags_vartype {
env_flags_vartype_end
};
+enum env_flags_varaccess {
+ env_flags_varaccess_any,
+ env_flags_varaccess_readonly,
+ env_flags_varaccess_writeonce,
+ env_flags_varaccess_changedefault,
+ env_flags_varaccess_end
+};
+
#define ENV_FLAGS_VAR ".flags"
#define ENV_FLAGS_ATTR_MAX_LEN 2
#define ENV_FLAGS_VARTYPE_LOC 0
+#define ENV_FLAGS_VARACCESS_LOC 1
#ifndef CONFIG_ENV_FLAGS_LIST_STATIC
#define CONFIG_ENV_FLAGS_LIST_STATIC ""
@@ -53,15 +62,31 @@ enum env_flags_vartype {
*/
void env_flags_print_vartypes(void);
/*
+ * Print the whole list of available access flags.
+ */
+void env_flags_print_varaccess(void);
+/*
* Return the name of the type.
*/
const char *env_flags_get_vartype_name(enum env_flags_vartype type);
+/*
+ * Return the name of the access.
+ */
+const char *env_flags_get_varaccess_name(enum env_flags_varaccess access);
#endif
/*
* Parse the flags string from a .flags attribute list into the vartype enum.
*/
enum env_flags_vartype env_flags_parse_vartype(const char *flags);
+/*
+ * Parse the flags string from a .flags attribute list into the varaccess enum.
+ */
+enum env_flags_varaccess env_flags_parse_varaccess(const char *flags);
+/*
+ * Parse the binary flags from a hash table entry into the varaccess enum.
+ */
+enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags);
#ifdef USE_HOSTCC
/*
@@ -69,11 +94,25 @@ enum env_flags_vartype env_flags_parse_vartype(const char *flags);
*/
enum env_flags_vartype env_flags_get_type(const char *name);
/*
+ * Look up the access of a variable directly from the .flags var.
+ */
+enum env_flags_varaccess env_flags_get_access(const char *name);
+/*
* Validate the newval for its type to conform with the requirements defined by
* its flags (directly looked at the .flags var).
*/
int env_flags_validate_type(const char *name, const char *newval);
/*
+ * Validate the newval for its access to conform with the requirements defined
+ * by its flags (directly looked at the .flags var).
+ */
+int env_flags_validate_access(const char *name, int check_mask);
+/*
+ * Validate that the proposed access to variable "name" is valid according to
+ * the defined flags for that variable, if any.
+ */
+int env_flags_validate_varaccess(const char *name, int check_mask);
+/*
* Validate the parameters passed to "env set" for type compliance
*/
int env_flags_validate_env_set_params(int argc, char * const argv[]);
@@ -94,13 +133,18 @@ void env_flags_init(ENTRY *var_entry);
int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
int flag);
+#endif /* USE_HOSTCC */
+
/*
* These are the binary flags used in the environment entry->flags variable to
* decribe properties of veriables in the table
*/
-#define ENV_FLAGS_VARTYPE_BIN_MASK 0x00000007
+#define ENV_FLAGS_VARTYPE_BIN_MASK 0x00000007
/* The actual variable type values use the enum value (within the mask) */
-
-#endif /* USE_HOSTCC */
+#define ENV_FLAGS_VARACCESS_PREVENT_DELETE 0x00000008
+#define ENV_FLAGS_VARACCESS_PREVENT_CREATE 0x00000010
+#define ENV_FLAGS_VARACCESS_PREVENT_OVERWR 0x00000020
+#define ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR 0x00000040
+#define ENV_FLAGS_VARACCESS_BIN_MASK 0x00000078
#endif /* __ENV_FLAGS_H__ */