]>
sourceware.org Git - newlib-cygwin.git/blob - winsup/cygserver/shm.cc
1 /* shm.cc: Single unix specification IPC interface for Cygwin.
3 Copyright 2003, 2004 Red Hat, Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 #ifdef __OUTSIDE_CYGWIN__
21 #include "cygserver.h"
23 #include "transport.h"
25 #include "cygserver_ipc.h"
26 #include "cygserver_shm.h"
28 client_request_shm::client_request_shm ()
29 : client_request (CYGSERVER_REQUEST_SHM
,
30 &_parameters
, sizeof (_parameters
))
35 client_request_shm::serve (transport_layer_base
*const conn
,
36 process_cache
*const cache
)
38 if (msglen () != sizeof (_parameters
.in
))
40 syscall_printf ("bad request body length: expecting %lu bytes, got %lu",
41 sizeof (_parameters
), msglen ());
46 if (support_sharedmem
== TUN_FALSE
)
48 syscall_printf ("Shared memory support not started");
50 if (_parameters
.in
.shmop
== SHMOP_shmat
)
51 _parameters
.out
.ptr
= (vm_offset_t
)0;
53 _parameters
.out
.ret
= -1;
54 msglen (sizeof (_parameters
.out
));
57 process
*const client
= cache
->process (_parameters
.in
.ipcblk
.cygpid
,
58 _parameters
.in
.ipcblk
.winpid
,
59 _parameters
.in
.ipcblk
.signal_arrived
);
66 if (!conn
->impersonate_client ())
73 if (!adjust_identity_info (&_parameters
.in
.ipcblk
))
76 conn
->revert_to_self ();
81 /* Early revert_to_self since IPC code runs in kernel mode. */
82 conn
->revert_to_self ();
83 /* sysv_shm.cc takes care of itself. */
85 thread td
= { client
, &_parameters
.in
.ipcblk
, {0, 0} };
87 shmop_t shmop
= _parameters
.in
.shmop
; /* Get's overwritten otherwise. */
91 ipc_p_vmspace (td
.ipcblk
);
92 res
= shmat (&td
, &_parameters
.in
.atargs
);
95 res
= shmctl (&td
, &_parameters
.in
.ctlargs
);
98 ipc_p_vmspace (td
.ipcblk
);
99 res
= shmdt (&td
, &_parameters
.in
.dtargs
);
102 res
= shmget (&td
, &_parameters
.in
.getargs
);
105 res
= cygwin_shmfork_myhook (&td
, &_parameters
.in
.forkargs
);
109 td
.td_retval
[0] = -1;
112 /* Allocated by the call to adjust_identity_info(). */
113 if (_parameters
.in
.ipcblk
.gidlist
)
114 free (_parameters
.in
.ipcblk
.gidlist
);
116 if (shmop
== SHMOP_shmat
)
117 _parameters
.out
.ptr
= td
.td_retval
[0];
119 _parameters
.out
.ret
= td
.td_retval
[0];
120 if (shmop
== SHMOP_shmget
)
121 _parameters
.out
.obj
= td
.td_retval
[1];
122 msglen (sizeof (_parameters
.out
));
124 #endif /* __OUTSIDE_CYGWIN__ */
This page took 0.041023 seconds and 5 git commands to generate.