]>
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, 2012 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
);
65 if (!conn
->impersonate_client ())
72 if (!adjust_identity_info (&_parameters
.in
.ipcblk
))
75 conn
->revert_to_self ();
80 /* Early revert_to_self since IPC code runs in kernel mode. */
81 conn
->revert_to_self ();
82 /* sysv_shm.cc takes care of itself. */
84 thread
td (client
, &_parameters
.in
.ipcblk
, false);
86 shmop_t shmop
= _parameters
.in
.shmop
; /* Get's overwritten otherwise. */
90 ipc_p_vmspace (td
.ipcblk
);
91 res
= shmat (&td
, &_parameters
.in
.atargs
);
94 res
= shmctl (&td
, &_parameters
.in
.ctlargs
);
97 ipc_p_vmspace (td
.ipcblk
);
98 res
= shmdt (&td
, &_parameters
.in
.dtargs
);
101 res
= shmget (&td
, &_parameters
.in
.getargs
);
104 res
= cygwin_shmfork_myhook (&td
, &_parameters
.in
.forkargs
);
108 td
.td_retval
[0] = -1;
111 /* Allocated by the call to adjust_identity_info(). */
112 if (_parameters
.in
.ipcblk
.gidlist
)
113 free (_parameters
.in
.ipcblk
.gidlist
);
115 if (shmop
== SHMOP_shmat
)
116 _parameters
.out
.ptr
= td
.td_retval
[0];
118 _parameters
.out
.ret
= td
.td_retval
[0];
119 if (shmop
== SHMOP_shmget
)
120 _parameters
.out
.obj
= td
.td_retval
[1];
121 msglen (sizeof (_parameters
.out
));
123 #endif /* __OUTSIDE_CYGWIN__ */
This page took 0.039209 seconds and 5 git commands to generate.