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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
|
/* chroot.c -- support for writing chrooting translators
Copyright (C) 2002, 2003, 2008, 2013, 2016 Free Software Foundation, Inc.
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <argz.h>
#include <argp.h>
#include <dirent.h>
#include <error.h>
#include <hurd/netfs.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <pthread.h>
#include <hurd/ihash.h>
#include <hurd/paths.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <version.h>
#include "chroot.h"
#include "libnetfs/fs_S.h"
#include "libnetfs/io_S.h"
#include "libnetfs/fsys_S.h"
#include "libports/notify_S.h"
#include "libports/interrupt_S.h"
/* Make a new virtual node. Always consumes the ports. If
successful, NP will be locked. */
error_t __attribute__ ((weak))
chroot_new_node (file_t file, size_t size, struct node **np)
{
error_t err;
struct netnode *nn;
*np = netfs_make_node_alloc (sizeof *nn + size);
if (*np == NULL)
{
mach_port_deallocate (mach_task_self (), file);
return ENOMEM;
}
nn = netfs_node_netnode (*np);
nn->file = file;
return 0;
}
/* Node NP has no more references; free all its associated storage. */
void
netfs_node_norefs (struct node *np)
{
pthread_mutex_unlock (&np->lock);
chroot_node_norefs (np);
mach_port_deallocate (mach_task_self (), netfs_node_netnode (np)->file);
free (np);
}
/* This is the cleanup function we install in netfs_protid_class. If
the associated nodes reference count would also drop to zero, and
the node has no faked attributes, we destroy it as well. */
static void
chroot_netfs_release_protid (void *cookie)
{
netfs_release_protid (cookie);
int cports = ports_count_class (netfs_control_class);
int nports = ports_count_class (netfs_protid_class);
ports_enable_class (netfs_control_class);
ports_enable_class (netfs_protid_class);
if (cports == 0 && nports == 0)
{
/* The last client is gone. Our job is done. */
error_t err = netfs_shutdown (0);
if (! err)
exit (EXIT_SUCCESS);
/* If netfs_shutdown returns EBUSY, we lost a race against
fsys_goaway. Hence we ignore this error. */
if (err != EBUSY)
error (1, err, "netfs_shutdown");
}
}
error_t __attribute__ ((weak))
chroot_init (void)
{
/* Install our own clean routine. */
netfs_protid_class->clean_routine = chroot_netfs_release_protid;
return 0;
}
/* This is called by netfs_S_fsys_getroot. */
error_t __attribute__ ((weak))
netfs_check_open_permissions (struct iouser *user, struct node *np,
int flags, int newnode)
{
return 0; /* XXX */
}
error_t __attribute__ ((weak))
netfs_S_dir_lookup (struct protid *diruser,
char *filename,
int flags,
mode_t mode,
retry_type *do_retry,
char *retry_name,
mach_port_t *retry_port,
mach_msg_type_name_t *retry_port_type)
{
struct node *dnp, *np;
error_t err;
struct protid *newpi;
struct iouser *user;
file_t file;
file_t dir;
if (!diruser)
return EOPNOTSUPP;
dnp = diruser->po->np;
//error (0, 0, "dir_lookup (#uids: %d, %s, flags %x, ...)", diruser->user->uids->num, filename, flags);
dir = netfs_node_netnode (dnp)->file;
err = dir_lookup (dir, filename, flags, mode, do_retry, retry_name, &file);
if (err)
return err;
switch (*do_retry)
{
case FS_RETRY_NORMAL:
break;
case FS_RETRY_REAUTH:
/* Fallthrough. */
case FS_RETRY_MAGICAL:
*retry_port = file;
*retry_port_type = MACH_MSG_TYPE_MOVE_SEND;
return 0;
default:
/* Invalid response to our dir_lookup request. */
if (MACH_PORT_VALID (file))
mach_port_deallocate (mach_task_self (), file);
*retry_port = MACH_PORT_NULL;
*retry_port_type = MACH_MSG_TYPE_COPY_SEND;
return EOPNOTSUPP;
}
/* We have a new port to an underlying node.
Find or make our corresponding virtual node. */
np = 0;
err = chroot_new_node (file, 0, &np);
if (!err)
err = netfs_validate_stat (np, diruser->user);
if (err)
goto lose;
assert (*do_retry == FS_RETRY_NORMAL);
flags &= ~(O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS|O_NONBLOCK);
err = iohelp_dup_iouser (&user, diruser->user);
if (!err)
{
newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po),
user);
if (! newpi)
{
iohelp_free_iouser (user);
err = errno;
}
else
{
*retry_port = ports_get_right (newpi);
*retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
ports_port_deref (newpi);
}
}
lose:
if (dir != netfs_node_netnode (dnp)->file)
mach_port_deallocate (mach_task_self (), dir);
if (np != NULL)
netfs_nput (np);
return err;
}
/* The user may define this function. Attempt to set the passive
translator record for FILE to ARGZ (of length ARGZLEN) for user
CRED. */
error_t __attribute__ ((weak))
netfs_set_translator (struct iouser *cred, struct node *np,
char *argz, size_t argzlen)
{
return file_set_translator (netfs_node_netnode (np)->file,
FS_TRANS_EXCL|FS_TRANS_SET,
0, 0,
argz, argzlen,
MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
}
/* These callbacks are used only by the standard netfs_S_dir_lookup,
which we do not use. But the shared library requires us to define them. */
error_t __attribute__ ((weak))
netfs_attempt_lookup (struct iouser *user, struct node *dir,
char *name, struct node **np)
{
assert (! "should not be here");
return EIEIO;
}
error_t __attribute__ ((weak))
netfs_attempt_create_file (struct iouser *user, struct node *dir,
char *name, mode_t mode, struct node **np)
{
assert (! "should not be here");
return EIEIO;
}
/* Make sure that NP->nn_stat is filled with the most current information.
CRED identifies the user responsible for the operation. NP is locked. */
error_t __attribute__ ((weak))
netfs_validate_stat (struct node *np, struct iouser *cred)
{
struct stat st;
error_t err = io_stat (netfs_node_netnode (np)->file, &st);
if (err)
return err;
np->nn_stat = st;
/* XXX */
np->nn_translated = S_ISLNK (st.st_mode) ? S_IFLNK : 0;
return 0;
}
error_t __attribute__ ((weak))
netfs_attempt_chown (struct iouser *cred, struct node *np,
uid_t uid, uid_t gid)
{
if (! cred)
return EOPNOTSUPP;
return file_chown (netfs_node_netnode (np)->file, uid, gid);
}
error_t __attribute__ ((weak))
netfs_attempt_chauthor (struct iouser *cred, struct node *np, uid_t author)
{
if (! cred)
return EOPNOTSUPP;
return file_chauthor (netfs_node_netnode (np)->file, author);
}
/* This should attempt a chmod call for the user specified by CRED on
locked node NODE, to change the mode to MODE. Unlike the normal Unix
and Hurd meaning of chmod, this function is also used to attempt to
change files into other types. If such a transition is attempted which
is impossible, then return EOPNOTSUPP. */
error_t __attribute__ ((weak))
netfs_attempt_chmod (struct iouser *cred, struct node *np, mode_t mode)
{
if (! cred)
return EOPNOTSUPP;
return file_chmod (netfs_node_netnode (np)->file, mode);
}
/* The user must define this function. Attempt to turn locked node NP
(user CRED) into a symlink with target NAME. */
error_t __attribute__ ((weak))
netfs_attempt_mksymlink (struct iouser *cred, struct node *np, char *name)
{
int namelen = strlen (name) + 1;
char trans[sizeof _HURD_SYMLINK + namelen];
memcpy (trans, _HURD_SYMLINK, sizeof _HURD_SYMLINK);
memcpy (&trans[sizeof _HURD_SYMLINK], name, namelen);
return file_set_translator (netfs_node_netnode (np)->file,
FS_TRANS_EXCL|FS_TRANS_SET,
FS_TRANS_EXCL|FS_TRANS_SET, 0,
trans, sizeof trans,
MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND);
}
error_t __attribute__ ((weak))
netfs_attempt_mkdev (struct iouser *cred, struct node *np,
mode_t type, dev_t indexes)
{
char *trans = 0;
int translen = asprintf (&trans, "%s%c%d%c%d",
S_ISCHR (type) ? _HURD_CHRDEV : _HURD_BLKDEV,
'\0', major (indexes), '\0', minor (indexes));
if (trans == 0)
return ENOMEM;
else
{
error_t err = file_set_translator (netfs_node_netnode (np)->file,
FS_TRANS_EXCL|FS_TRANS_SET,
FS_TRANS_EXCL|FS_TRANS_SET, 0,
trans, translen + 1,
MACH_PORT_NULL,
MACH_MSG_TYPE_COPY_SEND);
free (trans);
return err;
}
}
error_t __attribute__ ((weak))
netfs_attempt_chflags (struct iouser *cred, struct node *np, int flags)
{
return file_chflags (netfs_node_netnode (np)->file, flags);
}
error_t __attribute__ ((weak))
netfs_attempt_utimes (struct iouser *cred, struct node *np,
struct timespec *atime, struct timespec *mtime)
{
union tv
{
struct timeval tv;
time_value_t tvt;
};
union tv a, m;
if (atime)
{
TIMESPEC_TO_TIMEVAL (&a.tv, atime);
}
else
a.tv.tv_sec = a.tv.tv_usec = -1;
if (mtime)
{
TIMESPEC_TO_TIMEVAL (&m.tv, mtime);
}
else
m.tv.tv_sec = m.tv.tv_usec = -1;
return file_utimes (netfs_node_netnode (np)->file, a.tvt, m.tvt);
}
error_t __attribute__ ((weak))
netfs_attempt_set_size (struct iouser *cred, struct node *np, off_t size)
{
return file_set_size (netfs_node_netnode (np)->file, size);
}
error_t __attribute__ ((weak))
netfs_attempt_statfs (struct iouser *cred, struct node *np, struct statfs *st)
{
return file_statfs (netfs_node_netnode (np)->file, st);
}
error_t __attribute__ ((weak))
netfs_attempt_sync (struct iouser *cred, struct node *np, int wait)
{
return file_sync (netfs_node_netnode (np)->file, wait, 0);
}
error_t __attribute__ ((weak))
netfs_attempt_syncfs (struct iouser *cred, int wait)
{
return 0;
}
error_t __attribute__ ((weak))
netfs_attempt_mkdir (struct iouser *user, struct node *dir,
char *name, mode_t mode)
{
return dir_mkdir (netfs_node_netnode (dir)->file, name, mode | S_IRWXU);
}
/* XXX
Removing a node should mark the netnode so that it is GC'd when
it has no hard refs.
*/
error_t __attribute__ ((weak))
netfs_attempt_unlink (struct iouser *user, struct node *dir, char *name)
{
return dir_unlink (netfs_node_netnode (dir)->file, name);
}
error_t __attribute__ ((weak))
netfs_attempt_rename (struct iouser *user, struct node *fromdir,
char *fromname, struct node *todir,
char *toname, int excl)
{
return dir_rename (netfs_node_netnode (fromdir)->file, fromname,
netfs_node_netnode (todir)->file, toname, excl);
}
error_t __attribute__ ((weak))
netfs_attempt_rmdir (struct iouser *user,
struct node *dir, char *name)
{
return dir_rmdir (netfs_node_netnode (dir)->file, name);
}
error_t __attribute__ ((weak))
netfs_attempt_link (struct iouser *user, struct node *dir,
struct node *file, char *name, int excl)
{
return dir_link (netfs_node_netnode (dir)->file,
netfs_node_netnode (file)->file, name, excl);
}
error_t __attribute__ ((weak))
netfs_attempt_mkfile (struct iouser *user, struct node *dir,
mode_t mode, struct node **np)
{
file_t newfile;
error_t err = dir_mkfile (netfs_node_netnode (dir)->file, O_RDWR|O_EXEC,
mode, &newfile);
pthread_mutex_unlock (&dir->lock);
if (err)
return err;
err = chroot_new_node (newfile, 0, np);
if (err)
return err;
pthread_mutex_unlock (&(*np)->lock);
return err;
}
error_t __attribute__ ((weak))
netfs_attempt_readlink (struct iouser *user, struct node *np, char *buf)
{
char transbuf[sizeof _HURD_SYMLINK + np->nn_stat.st_size + 1];
char *trans = transbuf;
size_t translen = sizeof transbuf;
error_t err = file_get_translator (netfs_node_netnode (np)->file,
&trans, &translen);
if (err == 0)
{
if (translen < sizeof _HURD_SYMLINK
|| memcmp (trans, _HURD_SYMLINK, sizeof _HURD_SYMLINK) != 0)
err = EINVAL;
else
{
assert (translen <= sizeof _HURD_SYMLINK + np->nn_stat.st_size + 1);
memcpy (buf, &trans[sizeof _HURD_SYMLINK],
translen - sizeof _HURD_SYMLINK);
}
if (trans != transbuf)
munmap (trans, translen);
}
return err;
}
error_t __attribute__ ((weak))
netfs_get_dirents (struct iouser *cred, struct node *dir,
int entry, int nentries, char **data,
mach_msg_type_number_t *datacnt,
vm_size_t bufsize, int *amt)
{
error_t err;
err = dir_readdir (netfs_node_netnode (dir)->file, data, datacnt,
entry, nentries, bufsize, amt);
return err;
}
error_t __attribute__ ((weak))
netfs_attempt_read (struct iouser *cred, struct node *np,
off_t offset, size_t *len, void *data)
{
char *buf = data;
error_t err = io_read (netfs_node_netnode (np)->file,
&buf, len, offset, *len);
if (err == 0 && buf != data)
{
memcpy (data, buf, *len);
munmap (buf, *len);
}
return err;
}
error_t __attribute__ ((weak))
netfs_attempt_write (struct iouser *cred, struct node *np,
off_t offset, size_t *len, void *data)
{
return io_write (netfs_node_netnode (np)->file, data, *len, offset, len);
}
error_t __attribute__ ((weak))
netfs_report_access (struct iouser *cred, struct node *np, int *types)
{
return file_check_access (netfs_node_netnode (np)->file, types);
}
error_t __attribute__ ((weak))
netfs_file_get_storage_info (struct iouser *cred,
struct node *np,
mach_port_t **ports,
mach_msg_type_name_t *ports_type,
mach_msg_type_number_t *num_ports,
int **ints,
mach_msg_type_number_t *num_ints,
off_t **offsets,
mach_msg_type_number_t *num_offsets,
char **data,
mach_msg_type_number_t *data_len)
{
*ports_type = MACH_MSG_TYPE_MOVE_SEND;
return file_get_storage_info (netfs_node_netnode (np)->file,
ports, num_ports,
ints, num_ints,
offsets, num_offsets,
data, data_len);
}
error_t __attribute__ ((weak))
netfs_S_file_exec (struct protid *user,
task_t task,
int flags,
char *argv,
size_t argvlen,
char *envp,
size_t envplen,
mach_port_t *fds,
size_t fdslen,
mach_port_t *portarray,
size_t portarraylen,
int *intarray,
size_t intarraylen,
mach_port_t *deallocnames,
size_t deallocnameslen,
mach_port_t *destroynames,
size_t destroynameslen)
{
error_t err;
file_t file;
if (!user)
return EOPNOTSUPP;
file = netfs_node_netnode (user->po->np)->file;
err = mach_port_mod_refs (mach_task_self (),
file, MACH_PORT_RIGHT_SEND, 1);
if (!err)
{
/* We cannot use MACH_MSG_TYPE_MOVE_SEND because we might need to
retry an interrupted call that would have consumed the rights. */
err = file_exec (file, task, flags, argv, argvlen,
envp, envplen, fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
intarray, intarraylen, deallocnames, deallocnameslen,
destroynames, destroynameslen);
mach_port_deallocate (mach_task_self (), file);
}
if (err == 0)
{
size_t i;
mach_port_deallocate (mach_task_self (), task);
for (i = 0; i < fdslen; ++i)
mach_port_deallocate (mach_task_self (), fds[i]);
for (i = 0; i < portarraylen; ++i)
mach_port_deallocate (mach_task_self (), portarray[i]);
}
return err;
}
error_t __attribute__ ((weak))
netfs_S_io_map (struct protid *user,
mach_port_t *rdobj, mach_msg_type_name_t *rdobjtype,
mach_port_t *wrobj, mach_msg_type_name_t *wrobjtype)
{
if (!user)
return EOPNOTSUPP;
*rdobjtype = *wrobjtype = MACH_MSG_TYPE_MOVE_SEND;
return io_map (netfs_node_netnode (user->po->np)->file, rdobj, wrobj);
}
error_t __attribute__ ((weak))
netfs_S_io_map_cntl (struct protid *user,
mach_port_t *obj,
mach_msg_type_name_t *objtype)
{
if (!user)
return EOPNOTSUPP;
*objtype = MACH_MSG_TYPE_MOVE_SEND;
return io_map_cntl (netfs_node_netnode (user->po->np)->file, obj);
}
error_t __attribute__ ((weak))
netfs_S_io_identity (struct protid *user,
mach_port_t *id,
mach_msg_type_name_t *idtype,
mach_port_t *fsys,
mach_msg_type_name_t *fsystype,
ino_t *fileno)
{
if (!user)
return EOPNOTSUPP;
*idtype = *fsystype = MACH_MSG_TYPE_MOVE_SEND;
return io_identity (netfs_node_netnode (user->po->np)->file,
id, fsys, fileno);
}
#define NETFS_S_SIMPLE(name) \
error_t __attribute__ ((weak)) \
netfs_S_##name (struct protid *user) \
{ \
if (!user) \
return EOPNOTSUPP; \
\
return name (netfs_node_netnode (user->po->np)->file); \
}
NETFS_S_SIMPLE (io_get_conch)
NETFS_S_SIMPLE (io_release_conch)
NETFS_S_SIMPLE (io_eofnotify)
NETFS_S_SIMPLE (io_readnotify)
NETFS_S_SIMPLE (io_readsleep)
NETFS_S_SIMPLE (io_sigio)
error_t __attribute__ ((weak))
netfs_S_io_prenotify (struct protid *user,
vm_offset_t start, vm_offset_t stop)
{
if (!user)
return EOPNOTSUPP;
return io_prenotify (netfs_node_netnode (user->po->np)->file, start, stop);
}
error_t __attribute__ ((weak))
netfs_S_io_postnotify (struct protid *user,
vm_offset_t start, vm_offset_t stop)
{
if (!user)
return EOPNOTSUPP;
return io_postnotify (netfs_node_netnode (user->po->np)->file, start, stop);
}
/* This overrides the library's definition. */
int __attribute__ ((weak))
netfs_demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
{
mig_routine_t routine;
if ((routine = netfs_io_server_routine (inp)) ||
(routine = netfs_fs_server_routine (inp)) ||
(routine = ports_notify_server_routine (inp)) ||
(routine = netfs_fsys_server_routine (inp)) ||
/* XXX we should intercept interrupt_operation and do
the ports_S_interrupt_operation work as well as
sending an interrupt_operation to the underlying file.
*/
(routine = ports_interrupt_server_routine (inp)))
{
(*routine) (inp, outp);
return TRUE;
}
else
{
/* We didn't recognize the message ID, so pass the message through
unchanged to the underlying file. */
struct protid *cred;
if (MACH_MSGH_BITS_LOCAL (inp->msgh_bits) ==
MACH_MSG_TYPE_PROTECTED_PAYLOAD)
cred = ports_lookup_payload (netfs_port_bucket,
inp->msgh_protected_payload,
netfs_protid_class);
else
cred = ports_lookup_port (netfs_port_bucket,
inp->msgh_local_port,
netfs_protid_class);
if (cred == 0)
/* This must be an unknown message on our fsys control port. */
return 0;
else
{
error_t err;
assert (MACH_MSGH_BITS_LOCAL (inp->msgh_bits)
== MACH_MSG_TYPE_MOVE_SEND
|| MACH_MSGH_BITS_LOCAL (inp->msgh_bits)
== MACH_MSG_TYPE_PROTECTED_PAYLOAD);
inp->msgh_bits = (inp->msgh_bits & MACH_MSGH_BITS_COMPLEX)
| MACH_MSGH_BITS (MACH_MSG_TYPE_COPY_SEND,
MACH_MSGH_BITS_REMOTE (inp->msgh_bits));
inp->msgh_local_port = inp->msgh_remote_port; /* reply port */
inp->msgh_remote_port = netfs_node_netnode (cred->po->np)->file;
err = mach_msg (inp, MACH_SEND_MSG, inp->msgh_size, 0,
MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL);
if (err)
((mig_reply_header_t *) outp)->RetCode = err;
else
/* We already sent the message, so the server loop
shouldn't do it again. */
((mig_reply_header_t *) outp)->RetCode = MIG_NO_REPLY;
ports_port_deref (cred);
return 1;
}
}
}
|