Add a data member _ndesc to the af_unix_shmem_t class, along with
methods to increment and decrement it.
Increment it during socket/fork/exec/dup, and decrement it during
close. When the last descriptor is closed, call shutdown (SHUT_RDWR)
and unlink the socket's message queue.
The shutdown call will make the socket's peer see EPIPE if it tries to
write.
- Flesh out connect_mqueue, which replaces connect_pipe.
- A new method wait_mqueue replaces wait_pipe.
- A new method wait_mqueue_thread replaces wait_pipe_thread.
- New methods send_mqueue_name and recv_peer_mqueue_name are used for
making connection requests and responding to them.
- A new method xchg_sock_info is called after a connecting socket
successfully receives its peer's mqueue name. This functionality
was previously in open_pipe.
- Remove open_pipe, listen_pipe, and create_pipe_instance, which are
no longer needed.
Also add new data members mqd_in and mqd_out, along with getter and
setter methods. mqd_in and mqd_out are mqueue descriptors for
input/output. create_mqueue creates an mqueue for reading and sets
mqd_in to its descriptor.
Make other provisional changes so that compilation will succeed.
- open_abstract_link, open_reparse_point, and open_socket now return
HANDLEs
- connect no longer checks the validity of the sockaddr structure.
It's done in open_socket.
create_symlink, create_reparse_point, and create_file now take a char
*mqueue_name argument instead of a PUNICODE_STRING. For
create_symlink, convert the string to a UNICODE_STRING and make that
the target of the symlink. For create_reparse_point, store the string
in the reparse point as is.
Make other provisional changes so that compilation will succeed. This
includes adding a methode connect_mqueue that does nothing for now.
The generated name is now an ordinary string instead of a UNICODE_STRING.
Store it in pc.path. For clarity, add methods set_mqueue_name and
get_mqueue name to do the storing and retrieving. Add a method
path_conv::get_path to help with this.
We will switch to using POSIX message queues instead of Windows pipes
for data transport. In preparation for that, update the commentary in
fhandler_socket_unix.cc.
Also move the definition of class af_unix_pkt_hdr_t to fhandler.h and
make a few minor changes.
For consistency between the fhandler_socket_unix and
fhandler_socket_wsock classes, add virtual methods saw_shutdown_read
and saw_shutdown_write to fhandler_socket. Implement them for
fhandler_socket_unix. (They were already implemented for
fhandler_socket_wsock.)
Use sizeof (af_unix_shmem_t) as the view size, as when the shared
memory was created. Previously PAGESIZE was used, causing
NtMapViewOfSection to fail with STATUS_INVALID_VIEW_SIZE.
Newlib for aarch64 uses libgloss for the backend. One common libgloss
implementation is the 'rdimon' implementation, which uses the Arm
Semihosting protocol. In order to support a remote host that runs on
Windows we need to know whether a file is to be opened in binary or
text mode. That means that we need to preserve this information via
O_BINARY until we know what the libgloss binding will be.
This patch simply copies the arm implementation from sys/arm/sys and
puts it in machine/aarch64/sys, because we don't have a 'sys' subtree
on aarch64.
The check for a file or dir within /dev/mqueue is accidentally using
the incoming path, which could be a relative path. Make sure to
restore the absolute POSIX path in path_copy and only then test the
path.
Also, move the actual check for a valid path below /dev/mqueue into
the fhandler_mqueue class.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
/dev has been handled as virtual dir in cwdstuff, thus not allowing
to start native apps from /dev as CWD, even if /dev actually exists
on disk. Unfortunately this also affects Cygwin executables started
from a debugger.
When chdir'ing to /dev, check if /dev exists on disk. If so, treat
it as any other existing path.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
reuse fhandler_virtual implementation to implement read and lseek.
The output from read(2) is modelled after the output when reading
from an mq file on Linux.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The POSIX entry points are just wrappers now, calling into
fhandler_mqueue. While at it, eliminate mqi_flags, replace with
standard fhandler nonblocking flag.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The mq_open call is just a framework now. This patch moves the
entire functionality into fhandler_mqueue. To support standard
OS calls (as on Linux), make fhandler_mqueue a derived class from
fhandler_disk_file and keep the base handle the handle to the
default stream, to allow implementing O_PATH functionlaity as well
as reading from the file and NOT reading binary message queue data.
Implement a standard fhandler_mqueue::open method, allowing, for
instance, to touch a file under /dev/mqueue and if it doesn't exist,
to create a message queue file.
FIXME: This introduces a BAD HACK into path_conv::check, which needs
reviewing.
Keep the posix path intact in the fhandler, and change get_proc_fd_name
accordingly to return only the basename plus leading slash for
/proc/<PID>/fd.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
POSIX message queues will be moved into NTFS streams.
Extend get_nt_native_path to provide a filename suffix which is not
subject to special character transposition, to allow specifying
a colon.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The default PSAPI_VERSION is controlled by WIN32_WINNT, which we set to
0x0a00 when building ldd, which gets PSAPI_VERSION=2.
This causes K32GetModuleFileNameEx to be used for GetModuleFileNameEx,
which isn't available on Windows Vista.
Define PSAPI_VERSION as 1 for the built executable to work on Windows
Vista.