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>
40 lines
749 B
C
40 lines
749 B
C
/*
|
|
* 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__ */
|