diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-04-13 14:02:47 +0800 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-04-18 20:14:12 +0800 |
commit | 071ceba1e38f93ba2d937ae7fad037c5a9493655 (patch) | |
tree | 82b4377286c1c701e5a27e4d41b2ad06e1356e5c /include/binfmt.h | |
parent | 733d85510c74d9638dc88e001f45412f30a2f3d0 (diff) | |
download | barebox-071ceba1e38f93ba2d937ae7fad037c5a9493655.tar.gz barebox-071ceba1e38f93ba2d937ae7fad037c5a9493655.tar.xz |
Introduce binfmt support
This will allow to execute any file and detect it's type to handle it.
This will allow to use shell for bootp bootfile or dfu.
You can register multiple hook for the same filetype. They will be execute
in the invert order of register. If a hook does not handle the file you just
return -ERESTARTNOHAND;
This is only available with hush parser.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'include/binfmt.h')
-rw-r--r-- | include/binfmt.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/binfmt.h b/include/binfmt.h new file mode 100644 index 0000000000..46b627e36d --- /dev/null +++ b/include/binfmt.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> + * + * GPL v2 + */ + +#ifndef __BFMT_H__ +#define __BFMT_H__ + +#include <filetype.h> +#include <linux/list.h> + +struct binfmt_hook { + enum filetype type; + int (*hook)(struct binfmt_hook *b, char *file, int argc, char **argv); + char *exec; + + struct list_head list; +}; + +#ifdef CONFIG_BINFMT +int binfmt_register(struct binfmt_hook *b); +void binfmt_unregister(struct binfmt_hook *b); + +int execute_binfmt(int argc, char **argv); +#else +static inline int binfmt_register(struct binfmt_hook *b) +{ + return -EINVAL; +} +static inline void binfmt_unregister(struct binfmt_hook *b) {} + +static inline int execute_binfmt(int argc, char **argv) +{ + return 1; +} +#endif + +#endif /* __BFMT_H__ */ |