Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sys-utsname.c « support - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: deccad5a07b82dfbfb569181710febd339ff0e99 (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
/*
 * <sys/sendfile.h> wrapper functions.
 *
 * Authors:
 *   Jonathan Pryor (jonpryor@vt.edu)
 *
 * Copyright (C) 2004 Jonathan Pryor
 */

#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>

#include "map.h"
#include "mph.h"

#include <sys/utsname.h>

G_BEGIN_DECLS

static const mph_string_offset_t
utsname_offsets[] = {
	MPH_STRING_OFFSET(struct utsname, sysname,  MPH_STRING_OFFSET_ARRAY),
	MPH_STRING_OFFSET(struct utsname, nodename, MPH_STRING_OFFSET_ARRAY),
	MPH_STRING_OFFSET(struct utsname, release,  MPH_STRING_OFFSET_ARRAY),
	MPH_STRING_OFFSET(struct utsname, version,  MPH_STRING_OFFSET_ARRAY),
	MPH_STRING_OFFSET(struct utsname, machine,  MPH_STRING_OFFSET_ARRAY)
};

static const mph_string_offset_t
mph_utsname_offsets[] = {
	MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, sysname,  MPH_STRING_OFFSET_PTR),
	MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, nodename, MPH_STRING_OFFSET_PTR),
	MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, release,  MPH_STRING_OFFSET_PTR),
	MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, version,  MPH_STRING_OFFSET_PTR),
	MPH_STRING_OFFSET(struct Mono_Posix_Syscall__Utsname, machine,  MPH_STRING_OFFSET_PTR)
};

int
Mono_Posix_Syscall_uname (struct Mono_Posix_Syscall__Utsname *buf)
{
	struct utsname _buf;
	int r;

	if (!buf) {
		errno = EFAULT;
		return -1;
	}

	r = uname (&_buf);
	if (r == 0) {
		buf->_buf_ = _mph_copy_structure_strings (buf, mph_utsname_offsets,
				&_buf, utsname_offsets, sizeof(utsname_offsets)/sizeof(utsname_offsets[0]));
		buf->domainname = NULL;
		if (!buf->_buf_) {
			errno = ENOMEM;
			return -1;
		}
	}
	return r;
}

G_END_DECLS

/*
 * vim: noexpandtab
 */