Ejemplo n.º 1
0
static int parse_bool_option(struct isl_arg *decl, char **arg,
	struct isl_prefixes *prefixes, void *opt)
{
	const char *name;
	unsigned *p = (unsigned *)(((char *)opt) + decl->offset);
	int next_prefix;

	if (skip_name(decl, arg[0], prefixes, 0, NULL)) {
		if ((decl->flags & ISL_ARG_BOOL_ARG) && arg[1]) {
			char *endptr;
			int val = strtol(arg[1], &endptr, 0);
			if (*endptr == '\0' && (val == 0 || val == 1)) {
				if (decl->offset != (size_t) -1)
					*p = val;
				if (decl->u.b.set)
					decl->u.b.set(opt, val);
				return 2;
			}
		}
		if (decl->offset != (size_t) -1)
			*p = 1;
		if (decl->u.b.set)
			decl->u.b.set(opt, 1);

		return 1;
	}

	if (!decl->long_name)
		return 0;

	name = skip_dash_dash(decl, arg[0]);
	if (!name)
		return 0;

	next_prefix = 0;
	name = skip_prefixes(name, prefixes, &next_prefix);

	if (strncmp(name, "no-", 3))
		return 0;
	name += 3;

	name = skip_prefixes(name, prefixes, &next_prefix);

	if (match_long_name(decl, name, name + strlen(name))) {
		if (decl->offset != (size_t) -1)
			*p = 0;
		if (decl->u.b.set)
			decl->u.b.set(opt, 0);

		return 1;
	}

	return 0;
}
Ejemplo n.º 2
0
/*
 * Returns non-zero if opcode modifies the interrupt flag.
 */
static int __kprobes is_IF_modifier(kprobe_opcode_t *insn)
{
	/* Skip prefixes */
	insn = skip_prefixes(insn);

	switch (*insn) {
	case 0xfa:		/* cli */
	case 0xfb:		/* sti */
	case 0xcf:		/* iret/iretd */
	case 0x9d:		/* popf/popfd */
		return 1;
	}

	return 0;
}
Ejemplo n.º 3
0
static const char *skip_name(struct isl_arg *decl, const char *arg,
	struct isl_prefixes *prefixes, int need_argument, int *has_argument)
{
	const char *equal;
	const char *name;
	const char *end;

	if (arg[0] == '-' && arg[1] && arg[1] == decl->short_name) {
		if (need_argument && !arg[2])
			return NULL;
		if (has_argument)
			*has_argument = arg[2] != '\0';
		return arg + 2;
	}
	if (!decl->long_name)
		return NULL;

	name = skip_dash_dash(decl, arg);
	if (!name)
		return NULL;

	equal = strchr(name, '=');
	if (need_argument && !equal)
		return NULL;

	if (has_argument)
		*has_argument = !!equal;
	end = equal ? equal : name + strlen(name);

	name = skip_prefixes(name, prefixes, NULL);

	if (!match_long_name(decl, name, end))
		return NULL;

	return equal ? equal + 1 : end;
}