summaryrefslogtreecommitdiff
path: root/usr/src/lib/brand/lx/lx_brand/common/module.c
blob: 78a593712ff57e10e40aa5626741e5517c371d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2014 Joyent, Inc.  All rights reserved.
 */

/*
 * We don't support Linux modules, but we have to emulate enough of the system
 * calls to show that we don't have any modules installed.
 */

#include <errno.h>
#include <sys/types.h>
#include <sys/lx_misc.h>
#include <sys/lx_syscall.h>

/*
 * For query_module(), we provide an empty list of modules, and return ENOENT
 * on any request for a specific module.
 */
#define	LX_QM_MODULES	1
#define	LX_QM_DEPS	2
#define	LX_QM_REFS	3
#define	LX_QM_SYMBOLS	4
#define	LX_QM_INFO	5

/*ARGSUSED*/
long
lx_query_module(uintptr_t p1, uintptr_t p2, uintptr_t p3, uintptr_t p4,
    uintptr_t p5)
{
	/*
	 * parameter p1 is the 'name' argument.
	 */
	int which = (int)p2;
	char *buf = (char *)p3;
	size_t bufsize = (size_t)p4;
	size_t *ret = (size_t *)p5;

	switch (which) {
	case 0:
		/*
		 * Special case: always return 0
		 */
		return (0);

	case LX_QM_MODULES:
		/*
		 * Generate an empty list of modules.
		 */
		if (bufsize && buf)
			buf[0] = '\0';
		if (ret)
			*ret = 0;
		return (0);

	case LX_QM_DEPS:
	case LX_QM_REFS:
	case LX_QM_SYMBOLS:
	case LX_QM_INFO:
		/*
		 * Any requests for specific module information return ENOENT.
		 */
		return (-ENOENT);

	default:
		return (-EINVAL);
	}
}