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
|
/* fsys_get_children
Copyright (C) 2017 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
The GNU Hurd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
#include "priv.h"
#include "fsys_S.h"
#include <argz.h>
/* Return any active child translators. NAMES is an argz vector
containing file names relative to the root of the translator.
CONTROLS is an array containing the corresponding control ports.
Note that translators are bound to nodes, and nodes can have zero
or more links in the file system, therefore there is no guarantee
that a translators name refers to an existing link in the file
system. */
error_t
diskfs_S_fsys_get_children (struct diskfs_control *fsys,
mach_port_t reply,
mach_msg_type_name_t replytype,
char **names,
mach_msg_type_number_t *names_len,
mach_port_t **controls,
mach_msg_type_name_t *controlsPoly,
mach_msg_type_number_t *controlsCnt)
{
error_t err;
char *n = NULL, *orig_names = *names;
size_t n_len = 0;
mach_port_t *c;
size_t c_count;
if (! fsys)
return EOPNOTSUPP;
err = fshelp_get_active_translators (&n, &n_len, &c, &c_count);
if (err)
goto errout;
err = iohelp_return_malloced_buffer (n, n_len, names, names_len);
n = NULL; /* n was freed by iohelp_return_malloced_buffer. */
if (err)
goto errout;
err = iohelp_return_malloced_buffer ((char *) c, c_count * sizeof *c,
(char **) controls, controlsCnt);
c = NULL; /* c was freed by iohelp_return_malloced_buffer. */
if (err)
{
if (*names != orig_names)
munmap (*names, n_len);
goto errout;
}
*controlsPoly = MACH_MSG_TYPE_MOVE_SEND;
*controlsCnt = c_count;
errout:
free (n);
free (c);
return err;
}
|