From: Sascha Wildner Date: Sat, 10 Aug 2013 20:19:05 +0000 (+0200) Subject: kernel: Start removing syslink. X-Git-Tag: v3.7.0~569 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/181bd34e6345ca2b2773c36c4c59b5e54038e0c3?hp=641d490fbca75be365c89f944ed8d413acfb4af7 kernel: Start removing syslink. It's tied in with a few things that we don't want to break, so care is needed. Approved-by: dillon --- diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc index f166185791..5d29675641 100644 --- a/Makefile_upgrade.inc +++ b/Makefile_upgrade.inc @@ -2141,6 +2141,8 @@ TO_REMOVE+=/usr/include/sys/bitstring.h TO_REMOVE+=/usr/share/man/cat4/pst.4.gz TO_REMOVE+=/usr/share/man/man4/pst.4.gz TO_REMOVE+=/usr/share/man/man8/loader.8.gz.old +TO_REMOVE+=/usr/share/man/cat2/syslink.2.gz +TO_REMOVE+=/usr/share/man/man2/syslink.2.gz .if ${MACHINE_ARCH} == "x86_64" TO_REMOVE+=/usr/sbin/stlstats diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index bcbe93701c..7e2e4eb8f9 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -85,7 +85,7 @@ MAN+= _exit.2 accept.2 access.2 acct.2 adjtime.2 \ setuid.2 shmat.2 shmctl.2 shmget.2 shutdown.2 \ sigaction.2 sigaltstack.2 sigpending.2 sigprocmask.2 sigreturn.2 \ sigstack.2 sigsuspend.2 socket.2 socketpair.2 stat.2 statfs.2 \ - statvfs.2 swapon.2 symlink.2 sync.2 sysarch.2 syscall.2 syslink.2 \ + statvfs.2 swapon.2 symlink.2 sync.2 sysarch.2 syscall.2 \ truncate.2 tls.2 umask.2 umtx.2 undelete.2 \ unlink.2 unlinkat.2 utimes.2 utrace.2 usched_set.2 \ uuidgen.2 \ diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 85cc106e79..7de749a081 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -248,7 +248,6 @@ DF306.0 { sys_checkpoint; sysarch; syscall; - syslink; truncate; umask; umtx_sleep; @@ -542,7 +541,6 @@ DFprivate_1.0 { __sys_sys_checkpoint; __sys_sysarch; __sys_syscall; - __sys_syslink; __sys_umask; __sys_umtx_sleep; __sys_umtx_wakeup; @@ -839,7 +837,6 @@ DFprivate_1.0 { _sys_checkpoint; _sysarch; _syscall; - _syslink; _umask; _umtx_sleep; _umtx_wakeup; diff --git a/lib/libc/sys/syslink.2 b/lib/libc/sys/syslink.2 deleted file mode 100644 index 05be86c275..0000000000 --- a/lib/libc/sys/syslink.2 +++ /dev/null @@ -1,133 +0,0 @@ -.\" Copyright (c) 2007 The DragonFly Project. All rights reserved. -.\" -.\" This code is derived from software contributed to The DragonFly Project -.\" by Matthew Dillon -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" 3. Neither the name of The DragonFly Project nor the names of its -.\" contributors may be used to endorse or promote products derived -.\" from this software without specific, prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $DragonFly: src/lib/libc/sys/syslink.2,v 1.11 2007/12/23 15:31:28 swildner Exp $ -.\" -.Dd March 13, 2007 -.Dt SYSLINK 2 -.Os -.Sh NAME -.Nm syslink -.Nd low level connect to the cluster mesh -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/syslink.h -.In sys/syslink_msg.h -.Ft int -.Fn syslink "int cmd" "struct syslink_info *info" "size_t bytes" -.Sh DESCRIPTION -The -.Fn syslink -system call manages the system link protocol interface to the kernel. -At the moment the only command implemented is -.Dv SYSLINK_CMD_NEW -which -establishes a connected pair of file descriptors suitable for communication -between two user processes. -Other system calls may also indirectly return a -.Nm -descriptor, for example when mounting a user filesystem. -.Pp -System links are not pipes. -Reads and writes are message based and the kernel carefully checks the -.Vt syslink_msg -structure for conformance. -Every message sent requires a reply to be returned. -If the remote end dies, the kernel automatically replies to any unreplied -messages. -.Pp -.Nm Syslink -commands are very similar to high level device operations. -An out-of-band DMA buffer (<= 128KB) may be specified along with the -.Nm -message by placing it in -.Fa iov[1] -in a -.Fn readv -or -.Fn writev -system call on a -.Nm -descriptor. -The -.Nm -message must also have the appropriate flags set for the kernel to -recognize the DMA buffer. -The return value from -.Fn readv -or -.Fn writev -only accounts for -.Fa iov[0] . -The caller checks message flags to determine if any DMA occurred. -.Pp -DMA buffers must be managed carefully. -Sending a command along with a DMA buffer does not immediately copy out -the buffer. -The originator of the command may free the VM space related to the buffer -but must leave the storage backing the buffer intact until a reply to that -command is received. -For example, the originator can memory map a file and supply pointers into -the mapping as part of a -.Nm -command, then remap the space for other purposes without waiting for a -.Nm -command to be replied. -As long as the contents at the related offsets in the backing -store (the file) are not modified, the operation is legal. -Anonymous memory can also be used in this manner by -.Fn munmap Ns ing -it after having sent the command. -However, it should be noted that mapping memory can be quite expensive. -.Pp -Since there is no reply to a reply, the target has no way of knowing when -the DMA buffer it supplies in a reply will be drained. -Because of this, buffers associated with reply messages are always -immediately copied by the kernel allowing the target to throw the buffer -away and reuse its memory after replying. -There are no backing object restrictions for replies. -.Pp -The kernel has the option of mapping the originator's buffer directly into -the target's VM space. -DMA buffers must be page-aligned and it is best to use -.Fn mmap -to allocate and manage them. -This feature is not yet implemented. -.Sh RETURN VALUES -.Rv -std -.\".Sh SEE ALSO -.Sh HISTORY -The -.Fn syslink -function first appeared in -.Dx 1.9 . diff --git a/sbin/syslink/Makefile b/sbin/syslink/Makefile deleted file mode 100644 index e1313656ff..0000000000 --- a/sbin/syslink/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $DragonFly: src/sbin/syslink/Makefile,v 1.1 2007/04/16 17:36:04 dillon Exp $ -# - -PROG= syslink -MAN= syslink.8 -WARNS?= 2 - -.include diff --git a/sbin/syslink/syslink.8 b/sbin/syslink/syslink.8 deleted file mode 100644 index 8a3cec582f..0000000000 --- a/sbin/syslink/syslink.8 +++ /dev/null @@ -1,174 +0,0 @@ -.\" -.\" Copyright (c) 2007 -.\" The DragonFly Project. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in -.\" the documentation and/or other materials provided with the -.\" distribution. -.\" 3. Neither the name of The DragonFly Project nor the names of its -.\" contributors may be used to endorse or promote products derived -.\" from this software without specific, prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $DragonFly: src/sbin/syslink/syslink.8,v 1.1 2007/04/16 17:36:04 dillon Exp $ -.\" -.Dd April 14, 2007 -.Dt SYSLINK 8 -.Os -.Sh NAME -.Nm syslink -.Nd manage system resource links -.Sh SYNOPSIS -.Nm -.Op Fl lnv -.Op Ar sysid[:linkid] -.Nm -.Op Fl fnv -.Op Fl p Ar pidfile -.Ar sysid -.Cm add -.Ar [protocol:]target[/bits] -.Op Cm label Ar name -.Op Cm port Ar port -.Nm -.Op Fl fnv -.Ar sysid[:linkid] -.Cm delete -.Nm -.Op Fl fnv -.Ar sysid[:linkid] -.Cm modify -.Op Cm label Ar name -.Sh DESCRIPTION -The -.Nm -utility manages the system syslink infrastructure. -It may be used to list, add, modify, or delete elements of the syslink -mesh managed by the current host. -.Pp -The following options are available: -.Bl -tag -width indent -.It Fl f -Disable prompting, force the operation. -.It Fl n -List network addresses numerically, else a reverse DNS lookup will be made -.It Fl v -Generate more verbose output. The more -.Fl v -options specified, the more verbose the output. -.It Fl l -Dump the entire list of route nodes and links, dump a specific route -node, or dump a specific link. -.It Fl p Ar pidfile -This option must be specified when adding targets that require -.Nm -to fork and run in the background. -.It Cm add Ar [protocol:]target[/bits] Ar options... -Associate a new link with the specified router. Stream or packet switched -links may be specified. If the link represents a subnet the number of bits -for the subnet must be specified and must support broadcast addressing. -In addition to being able to operate over a standard UDP broadcast network -it is possible to implement a subnet over a point to point link such as -a TCP connection, pipe, or point-to-point UDP connection. In these cases -the target is responsible for handling the broadcast address in the syslink -messages. If no protocol is specified, a stream TCP connection is assumed -if no subnet is specified and a broadcastable UDP subnet is assumed if a -subnet is specified. -.It Cm del[ete] Ar options... -Delete an existing link or router. A router may only be deleted if no -links are associated with it. -.It Cm mod[ify] Ar options... -Modify an existing link or router. Currently only the label may be modified. -.El -.Pp -A sysid or linkid may be specified in hex using a -.Cm 0x -prefix, or symbolically using its label name. -.Pp -.Nm -uses port 32 by default for tcp and udp protocols. The port may be -overridden using the -.Cm port -specification. -.Sh PROTOCOLS -The following protocol specifications are supported -.Bl -tag -width indent -.It Cm tcp: Ns Ar host Ns Op /bits -.Nm -will connect to the target host, which may be specified as an IP address or -domain name, and associate the resulting descriptor with the syslink -route node. -Note that you may specify a subnet, in which case the target of the -point-to-point link will be responsible for handling subnet addresses -in the syslink messages. -.It Cm udp: Ns Ar host Ns Op /bits -.Nm -will connect to the target host or broadcast address, which may be specified -as an IP address or domain name, and associate the resulting descriptor -with the syslink route node. -The kernel will use the -.Xr sendto 2 -facility to distribute syslink messages to individual or broadcast targets -.It Cm udp_ptp: Ns Ar host Ns Op /bits -.Nm -will construct a non-broadcast point-to-point UDP connection and -associate it with the syslink route node. -Note that you may specify a subnet, in which case the target of the -point-to-point link will be responsible for handling subnet addresses -in the syslink messages. -.It Cm pipe: Ns Ar descriptor Ns Op /bits -.Nm -will associate the specified descriptor number with the syslink -route node. The descriptor should represent a full duplex stream connection. -.It Cm fifo: Ns Ar path Ns Op /bits -.Nm -will open the specified file, which should be a fifo or otherwise -represent a full duplex stream connection, and associate it with the -syslink route node. -.It Cm listen: Ns Ar bindaddr Ns Cm /bits -.Nm -will bind to the specified address (use 'any' for a wildcard binding), -fork, and run in the background accepting connections. -A pipe will be associated with the syslink route node and the -background process will route data from the accepted connections to -the route node and vise-versa. -A subnet specification is mandatory and determines the maximum number -of connections the background process will maintain (minus 2). For -example, if 8 bits is specified, 254 connections can be maintained. -The pid of the background service will be written to the pidfile. -.El -.Sh FILES -.Sh EXAMPLES -.Pp -.Dl "syslink root add" -.Dl "syslink root add udp:10.0.0.255/8 label mylan" -.Dl "syslink -l root:mylan" -.Dl "syslink -l" -.Sh COMPATIBILITY -This is a -.Dx -specific command. -.Sh HISTORY -A -.Nm -utility first appeared in -.Dx 1.9 . diff --git a/sbin/syslink/syslink.c b/sbin/syslink/syslink.c deleted file mode 100644 index a8de2bdc6a..0000000000 --- a/sbin/syslink/syslink.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Matthew Dillon - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $DragonFly: src/sbin/syslink/syslink.c,v 1.1 2007/04/16 17:36:04 dillon Exp $ - */ - -#include "syslink.h" - -enum cmd { CMD_NONE, CMD_LIST, CMD_ADD, CMD_DEL, CMD_MOD }; - -static int parse_add(const char *base); -static int run_cmd(enum cmd commandopt); -static void usage(const char *av0); - -int ForceOpt; -int NumericOpt; -int VerboseOpt; -const char *SysId; -const char *LinkId; -const char *LabelStr; -enum proto Protocol; /* filled in by parse_add() */ -int NumBits; -int TargetFd = -1; -const char *TargetPath; -struct sockaddr_in TargetSin; - -int -main(int ac, char **av) -{ - const char *pidfile = NULL; - const char *av0 = av[0]; - char *ptr; - enum cmd commandopt; - int ch; - int i; - - commandopt = CMD_NONE; - - while ((ch = getopt(ac, av, "fnlvp:")) != -1) { - switch(ch) { - case 'f': - ++ForceOpt; - break; - case 'n': - ++NumericOpt; - break; - case 'l': - commandopt = CMD_LIST; - break; - case 'v': - ++VerboseOpt; - break; - case 'p': - pidfile = optarg; - break; - default: - fprintf(stderr, "unknown option: -%c\n", optopt); - usage(av0); - } - } - ac -= optind; - av += optind; - - /* - * -l with no arguments dumps all syslink routers. This is the - * only command that does not require further arguments. - */ - if (commandopt == CMD_LIST && ac == 0) - exit(run_cmd(commandopt)); - if (ac == 0) - usage(av0); - - /* - * Parse sysid[:linkid] - */ - ptr = strdup(av[0]); - SysId = ptr; - if ((ptr = strchr(ptr, ':')) != NULL) { - *ptr++ = 0; - LinkId = ptr; - } - --ac; - ++av; - - /* - * Handle options that are actually commands (-l only at the moment). - * There should be no more arguments if we have a command-as-option. - */ - if (commandopt != CMD_NONE) { - if (ac) - usage(av0); - exit(run_cmd(commandopt)); - } - - /* - * Parse keyword commands, set commandopt as an earmark. - */ - if (ac == 0) { - fprintf(stderr, "Missing command directive\n"); - usage(av0); - } - --ac; - ++av; - - if (strcmp(av[-1], "add") == 0) { - /* - * add [protocol:]target[/bits] - */ - commandopt = CMD_ADD; - if (ac == 0) - usage(av0); - if (parse_add(av[0])) - usage(av0); - --ac; - ++av; - } else if (strcmp(av[-1], "del") == 0) { - commandopt = CMD_DEL; - } else if (strcmp(av[-1], "delete") == 0) { - commandopt = CMD_DEL; - } else if (strcmp(av[-1], "mod") == 0) { - commandopt = CMD_MOD; - } else if (strcmp(av[-1], "modify") == 0) { - commandopt = CMD_MOD; - } else { - fprintf(stderr, "Unknown command directive: %s\n", av[-1]); - usage(av0); - } - - /* - * Parse supplementary info - */ - for (i = 0; i < ac; ++i) { - if (strcmp(av[i], "label") == 0) { - LabelStr = av[i+1]; - ++i; - } else if (strcmp(av[i], "port") == 0) { - ptr = av[i+1]; - TargetSin.sin_port = htons(strtol(ptr, &ptr, 0)); - if (*ptr) { - fprintf(stderr, "Non-numeric port specified\n"); - usage(av0); - } - ++i; - } else { - fprintf(stderr, "Unknown directive: %s\n", av[i]); - usage(av0); - } - } - if (i > ac) { - fprintf(stderr, "Expected argument for last directive\n"); - usage(av0); - } - - exit(run_cmd(commandopt)); -} - -/* - * Parse [protocol:]target[/bits] - */ -static -int -parse_add(const char *base) -{ - char *prot_str; - char *targ_str; - char *bits_str; - char *ptr; - struct hostent *he; - - /* - * Split out the protocol from the protocol:target/subnet string, - * leave target/subnet in targ_str. - */ - if (strchr(base, ':')) { - prot_str = strdup(base); - targ_str = strchr(prot_str, ':'); - *targ_str++ = 0; - } else { - prot_str = NULL; - targ_str = strdup(base); - } - - /* - * Parse the /subnet out of the target string, if present. - */ - if ((bits_str = strchr(targ_str, '/')) != NULL) { - *bits_str++ = 0; - NumBits = strtol(bits_str, &ptr, NULL); - if (*ptr) { - fprintf(stderr, "Malformed /subnet\n"); - return(-1); - } - if (NumBits < 2 || NumBits > 24) { - fprintf(stderr, "Subnet must be 2-24 bits\n"); - return(-1); - } - } - - /* - * Figure out the protocol - */ - if (prot_str == NULL) { - if (bits_str) - Protocol = PROTO_TCP; - else - Protocol = PROTO_UDP; - } else if (strcmp(prot_str, "tcp") == 0) { - Protocol = PROTO_TCP; - } else if (strcmp(prot_str, "udp") == 0) { - Protocol = PROTO_UDP; - } else if (strcmp(prot_str, "udp_ptp") == 0) { - Protocol = PROTO_UDP_PTP; - } else if (strcmp(prot_str, "pipe") == 0) { - Protocol = PROTO_PIPE; - } else if (strcmp(prot_str, "fifo") == 0) { - Protocol = PROTO_FIFO; - } else if (strcmp(prot_str, "listen") == 0) { - Protocol = PROTO_LISTEN; - } else { - fprintf(stderr, "Unknown protocol: %s\n", prot_str); - return(-1); - } - - /* - * Process the host, file, or descriptor specification - */ - switch(Protocol) { - case PROTO_TCP: - case PROTO_UDP: - case PROTO_UDP_PTP: - case PROTO_LISTEN: - TargetSin.sin_len = sizeof(TargetSin); - TargetSin.sin_family = AF_INET; - if (inet_aton(targ_str, &TargetSin.sin_addr) != 0) { - } else if ((he = gethostbyname2(targ_str, AF_INET)) != NULL) { - bcopy(he->h_addr, &TargetSin.sin_addr, he->h_length); - } else { - fprintf(stderr, "Cannot resolve target %s\n", targ_str); - return(-1); - } - break; - case PROTO_PIPE: - TargetFd = strtol(targ_str, &ptr, 0); - if (*ptr) { - fprintf(stderr, "non-numeric file descriptor " - "number in target\n"); - return(-1); - } - break; - case PROTO_FIFO: - TargetPath = targ_str; - break; - } - return(0); -} - -static -int -run_cmd(enum cmd commandopt) -{ - int exitcode = 0; - - /* - * Run the command - */ - switch(commandopt) { - case CMD_NONE: - break; - case CMD_LIST: - printf("list\n"); - break; - case CMD_ADD: - printf("add\n"); - break; - case CMD_DEL: - printf("del\n"); - break; - case CMD_MOD: - printf("mod\n"); - break; - } - return(exitcode); -} - -static -void -usage(const char *av0) -{ - fprintf(stderr, - "syslink -l [-nv] [sysid[:linkid]]\n" - "syslink [-fnv] [-p pidfile] sysid add [protocol:]target[/bits]\n" - " [label name] [port num]\n" - "syslink [-fnv] sysid[:linkid] delete\n" - "syslink [-fnv] sysid[:linkid] modify\n" - " [label name] [port num]\n" - ); - exit(1); -} - diff --git a/sbin/syslink/syslink.h b/sbin/syslink/syslink.h deleted file mode 100644 index d3c9bf3ca3..0000000000 --- a/sbin/syslink/syslink.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Matthew Dillon - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $DragonFly: src/sbin/syslink/syslink.h,v 1.1 2007/04/16 17:36:04 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum proto { PROTO_TCP, PROTO_UDP, PROTO_UDP_PTP, - PROTO_PIPE, PROTO_FIFO, PROTO_LISTEN }; - -extern int ForceOpt; -extern int NumericOpt; -extern int VerboseOpt; -extern const char *SysId; -extern const char *LinkId; -extern const char *LabelStr; -extern enum proto Protocol; /* filled in by parse_add() */ -extern int NumBits; -extern int TargetFd; -extern const char *TargetPath; -extern struct sockaddr_in TargetSin; - diff --git a/sys/conf/files b/sys/conf/files index fd561b2fdd..9db4409434 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -914,7 +914,6 @@ kern/subr_firmware.c standard kern/subr_kcore.c standard kern/subr_kobj.c standard kern/subr_log.c standard -kern/subr_shims.c standard kern/libmchain/subr_mchain.c optional libmchain kern/subr_module.c standard kern/subr_param.c standard diff --git a/sys/conf/options b/sys/conf/options index 39c5281c6f..65acc43e40 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -656,10 +656,6 @@ SCTP_STR_LOGGING opt_sctp.h SCTP_FR_LOGGING opt_sctp.h SCTP_MAP_LOGGING opt_sctp.h -# syslink kernel support -# -SYSLINK opt_syslink.h - # DSCHED stuff DSCHED_AS opt_dsched.h DSCHED_BFQ opt_dsched.h diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index f52eaef9b3..1b75d1226b 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -520,7 +520,7 @@ struct sysent sysent[] = { { AS(usched_set_args), (sy_call_t *)sys_usched_set }, /* 481 = usched_set */ { AS(extaccept_args), (sy_call_t *)sys_extaccept }, /* 482 = extaccept */ { AS(extconnect_args), (sy_call_t *)sys_extconnect }, /* 483 = extconnect */ - { AS(syslink_args), (sy_call_t *)sys_syslink }, /* 484 = syslink */ + { 0, (sy_call_t *)sys_nosys }, /* 484 = obsolete syslink */ { AS(mcontrol_args), (sy_call_t *)sys_mcontrol }, /* 485 = mcontrol */ { AS(vmspace_create_args), (sy_call_t *)sys_vmspace_create }, /* 486 = vmspace_create */ { AS(vmspace_destroy_args), (sy_call_t *)sys_vmspace_destroy }, /* 487 = vmspace_destroy */ diff --git a/sys/kern/kern_syslink.c b/sys/kern/kern_syslink.c index 1e70a2ee62..c887f7cc42 100644 --- a/sys/kern/kern_syslink.c +++ b/sys/kern/kern_syslink.c @@ -68,8 +68,6 @@ #include #include -#include "opt_syslink.h" - /* * Syslink Connection abstraction */ diff --git a/sys/kern/subr_shims.c b/sys/kern/subr_shims.c deleted file mode 100644 index 75f9f525bf..0000000000 --- a/sys/kern/subr_shims.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Matthew Dillon - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $DragonFly: src/sys/kern/subr_shims.c,v 1.1 2007/04/26 02:10:59 dillon Exp $ - */ -/* - * Shims for kernel-compiled features that are not present, allowing us - * to implement the support without excessived conditionals outside of - * this file. - */ - -#include -#include -#include -#include -#include - -#include "opt_syslink.h" - -#ifndef SYSLINK - -int -sys_syslink(struct syslink_args *uap) -{ - return(EOPNOTSUPP); -} - -#endif diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index e8a9d9ac95..21d827711e 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -492,7 +492,7 @@ const char *syscallnames[] = { "usched_set", /* 481 = usched_set */ "extaccept", /* 482 = extaccept */ "extconnect", /* 483 = extconnect */ - "syslink", /* 484 = syslink */ + "obs_syslink", /* 484 = obsolete syslink */ "mcontrol", /* 485 = mcontrol */ "vmspace_create", /* 486 = vmspace_create */ "vmspace_destroy", /* 487 = vmspace_destroy */ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 1d890800bf..3f1f740445 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -662,7 +662,7 @@ int bytes); } 482 STD BSD { int extaccept(int s, int flags, caddr_t name, int *anamelen); } 483 STD BSD { int extconnect(int s, int flags, caddr_t name, int namelen); } -484 STD BSD { int syslink(int cmd, struct syslink_info *info, size_t bytes); } +484 OBSOL BSD syslink 485 STD BSD { int mcontrol(void *addr, size_t len, int behav, off_t value); } 486 STD BSD { int vmspace_create(void *id, int type, void *data); } 487 STD BSD { int vmspace_destroy(void *id); } diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 9ff73fca0f..81bd4ce459 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -324,7 +324,7 @@ #define SYS_usched_set 481 #define SYS_extaccept 482 #define SYS_extconnect 483 -#define SYS_syslink 484 + /* 484 is obsolete syslink */ #define SYS_mcontrol 485 #define SYS_vmspace_create 486 #define SYS_vmspace_destroy 487 diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index a41d5a3770..7c3850d6e3 100644 --- a/sys/sys/syscall.mk +++ b/sys/sys/syscall.mk @@ -252,7 +252,6 @@ MIASM = \ usched_set.o \ extaccept.o \ extconnect.o \ - syslink.o \ mcontrol.o \ vmspace_create.o \ vmspace_destroy.o \ diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index 0e9b770446..87ac4c13f2 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -1877,14 +1877,6 @@ struct extconnect_args { caddr_t name; char name_[PAD_(caddr_t)]; int namelen; char namelen_[PAD_(int)]; }; -struct syslink_args { -#ifdef _KERNEL - struct sysmsg sysmsg; -#endif - int cmd; char cmd_[PAD_(int)]; - struct syslink_info * info; char info_[PAD_(struct syslink_info *)]; - size_t bytes; char bytes_[PAD_(size_t)]; -}; struct mcontrol_args { #ifdef _KERNEL struct sysmsg sysmsg; @@ -2847,7 +2839,6 @@ int sys_getdents (struct getdents_args *); int sys_usched_set (struct usched_set_args *); int sys_extaccept (struct extaccept_args *); int sys_extconnect (struct extconnect_args *); -int sys_syslink (struct syslink_args *); int sys_mcontrol (struct mcontrol_args *); int sys_vmspace_create (struct vmspace_create_args *); int sys_vmspace_destroy (struct vmspace_destroy_args *); diff --git a/sys/sys/sysunion.h b/sys/sys/sysunion.h index 4a1b00a33b..c0f5dcf892 100644 --- a/sys/sys/sysunion.h +++ b/sys/sys/sysunion.h @@ -359,7 +359,6 @@ union sysunion { struct usched_set_args usched_set; struct extaccept_args extaccept; struct extconnect_args extconnect; - struct syslink_args syslink; struct mcontrol_args mcontrol; struct vmspace_create_args vmspace_create; struct vmspace_destroy_args vmspace_destroy; diff --git a/test/syslink/dummyfs.c b/test/syslink/dummyfs.c deleted file mode 100644 index 0e6ff11fd0..0000000000 --- a/test/syslink/dummyfs.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Matthew Dillon - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $DragonFly: src/test/syslink/dummyfs.c,v 1.1 2007/05/28 05:28:12 dillon Exp $ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void usage(void); - -int VerboseOpt; - -int -main(int ac, char **av) -{ - struct userfs_mount_info info; - const char *mountpt; - int ch; - - while ((ch = getopt(ac, av, "v")) != -1) { - switch(ch) { - case 'v': - ++VerboseOpt; - break; - default: - usage(); - } - } - ac -= optind; - av += optind; - if (ac == 0) - usage(); - mountpt = av[0]; - - bzero(&info, sizeof(info)); - info.cfd = -1; - if (mount("userfs", mountpt, 0, &info) < 0) { - fprintf(stderr, "Unable to mount: %s\n", strerror(errno)); - } - printf("mount successful %d\n", info.cfd); - return(0); -} - -static -void -usage(void) -{ - fprintf(stderr, "dummyfs [-v] mountpt\n"); - exit(1); -} - diff --git a/test/syslink/test1.c b/test/syslink/test1.c deleted file mode 100644 index 014ffaf08b..0000000000 --- a/test/syslink/test1.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Matthew Dillon - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $DragonFly: src/test/syslink/test1.c,v 1.1 2007/05/28 05:28:12 dillon Exp $ - */ -#include -#include -#include -#include -#include - -static void reader(int fd); -static void writer(int fd); - -int -main(int ac, char **av) -{ - union syslink_info_all info; - int fd1; - int fd2; - - bzero(&info, sizeof(info)); - if (syslink(SYSLINK_CMD_NEW, &info.head, sizeof(info)) < 0) { - perror("syslink"); - exit(1); - } - printf("fds %d %d\n", info.cmd_new.fds[0], info.cmd_new.fds[1]); - if (fork() == 0) { - reader(info.cmd_new.fds[0]); - } else { - writer(info.cmd_new.fds[1]); - } - while (wait(NULL) > 0) - ; - return(0); -} - -static -void -writer(int fd) -{ - union syslink_small_msg cmd; - union syslink_small_msg rep; - int n; - int wcount = 10; - - bzero(&cmd, sizeof(cmd)); - cmd.msg.sm_bytes = sizeof(struct syslink_msg); - cmd.msg.sm_proto = SMPROTO_BSDVFS; - cmd.msg.sm_head.se_cmd = 0; - cmd.msg.sm_head.se_bytes = sizeof(cmd.msg.sm_head); - for (;;) { - ++cmd.msg.sm_msgid; - n = write(fd, &cmd, cmd.msg.sm_bytes); - if (n < 0) { - printf("write error %s\n", strerror(errno)); - } else if (wcount) { - printf("write n = %d %lld\n", n, cmd.msg.sm_msgid); - --wcount; - } else { - printf("write n = %d %lld\n", n, cmd.msg.sm_msgid); - n = read(fd, &rep, sizeof(rep)); - printf("read-reply %d %lld\n", n, rep.msg.sm_msgid); - } - } -} - -static -void -reader(int fd) -{ - union syslink_small_msg cmd; - union syslink_small_msg rep; - int n; - - bzero(&rep, sizeof(rep)); - rep.msg.sm_bytes = sizeof(struct syslink_msg); - rep.msg.sm_proto = SMPROTO_BSDVFS | SM_PROTO_REPLY; - rep.msg.sm_msgid = 1; - rep.msg.sm_head.se_cmd = 0; - rep.msg.sm_head.se_bytes = sizeof(rep.msg.sm_head); - - for (;;) { - n = read(fd, &cmd, sizeof(cmd)); - if (n < 0 && errno == ENOSPC) { - printf("no space\n"); - exit(1); - } - if (n < 0) { - printf("read error %s\n", strerror(errno)); - } else { - printf("read n = %d\n", n); - rep.msg.sm_msgid = cmd.msg.sm_msgid; - n = write(fd, &rep, rep.msg.sm_bytes); - if (n < 0) { - printf("reply error %s\n", strerror(errno)); - } else { - printf("reply ok\n"); - } - } - if (n < 0) - break; - /*sleep(1);*/ - } -} - diff --git a/test/syslink/test2.c b/test/syslink/test2.c deleted file mode 100644 index 5917a2f97b..0000000000 --- a/test/syslink/test2.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2007 The DragonFly Project. All rights reserved. - * - * This code is derived from software contributed to The DragonFly Project - * by Matthew Dillon - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of The DragonFly Project nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific, prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $DragonFly: src/test/syslink/test2.c,v 1.1 2007/06/29 17:18:42 dillon Exp $ - */ -#include -#include -#include -#include -#include -#include -#include -#include - -static void reader(int fd); -static void writer(int fd); - -#define BUFSIZE 65536 - -int -main(int ac, char **av) -{ - union syslink_info_all info; - int fd1; - int fd2; - - bzero(&info, sizeof(info)); - if (syslink(SYSLINK_CMD_NEW, &info.head, sizeof(info)) < 0) { - perror("syslink"); - exit(1); - } - printf("fds %d %d\n", info.cmd_new.fds[0], info.cmd_new.fds[1]); - if (fork() == 0) { - reader(info.cmd_new.fds[0]); - } else { - writer(info.cmd_new.fds[1]); - } - while (wait(NULL) > 0) - ; - return(0); -} - -static -void -writer(int fd) -{ - union syslink_small_msg cmd; - union syslink_small_msg rep; - int *dmabuf; - int n; - int waitforit = 10; - off_t bytes = 0; - - dmabuf = mmap(NULL, BUFSIZE, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - - bzero(&cmd, sizeof(cmd)); - cmd.msg.sm_bytes = sizeof(struct syslink_msg); - cmd.msg.sm_proto = SMPROTO_BSDVFS; - cmd.msg.sm_msgid = 1; - cmd.msg.sm_head.se_cmd = 0 | SE_CMDF_DMAR | SE_CMDF_DMAW; - cmd.msg.sm_head.se_bytes = sizeof(cmd.msg.sm_head); - dmabuf[0] = 0; - dmabuf[4095] = 0; - for (;;) { - struct iovec iov[2]; - - iov[0].iov_base = (char *)&cmd; - iov[0].iov_len = cmd.msg.sm_bytes; - iov[1].iov_base = (char *)dmabuf; - iov[1].iov_len = BUFSIZE; - if (dmabuf[0] < 0) - --dmabuf[0]; - else - ++dmabuf[0]; - --dmabuf[4095]; - /*printf("write n = %d dmabuf[0] = %d\n", n, dmabuf[0]);*/ - n = writev(fd, iov, 2); - bytes += BUFSIZE; - if (bytes % (1024 * 1024 * 1024) == 0) { - printf("%lld\r", bytes); - fflush(stdout); - } - if (n < 0) { - printf("write error %s\n", strerror(errno)); - } else if (waitforit) { - /* fake up a pipeline */ - --waitforit; - } else { - n = read(fd, &rep, sizeof(rep)); - /*printf("read-reply %d %lld dmabuf[0] = %d\n", - n, rep.msg.sm_msgid, dmabuf[0]);*/ - } - ++cmd.msg.sm_msgid; - } -} - -static -void -reader(int fd) -{ - union syslink_small_msg cmd; - union syslink_small_msg rep; - int *dmabuf; - int n; - - dmabuf = mmap(NULL, BUFSIZE, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - - bzero(&rep, sizeof(rep)); - rep.msg.sm_bytes = sizeof(struct syslink_msg); - rep.msg.sm_proto = SMPROTO_BSDVFS | SM_PROTO_REPLY; - rep.msg.sm_head.se_cmd = SE_CMDF_REPLY; - rep.msg.sm_head.se_bytes = sizeof(rep.msg.sm_head); - - for (;;) { - struct iovec iov[2]; - - iov[0].iov_base = (char *)&cmd; - iov[0].iov_len = sizeof(cmd); - iov[1].iov_base = (char *)dmabuf; - iov[1].iov_len = BUFSIZE; - - n = readv(fd, iov, 2); - if (n < 0 && errno == ENOSPC) { - printf("no space\n"); - exit(1); - } - if (n < 0) { - printf("read error %s\n", strerror(errno)); - } else { - /*printf("read n = %d dmabuf[0] = %d [4095] = %d\n", - n, dmabuf[0], dmabuf[4095]);*/ - rep.msg.sm_msgid = cmd.msg.sm_msgid; - dmabuf[0] = -dmabuf[0]; - iov[0].iov_base = (char *)&rep; - iov[0].iov_len = rep.msg.sm_bytes; - /*n = write(fd, &rep, rep.msg.sm_bytes);*/ - n = writev(fd, iov, 2); - if (n < 0) { - printf("reply error %s\n", strerror(errno)); - } - } - if (n < 0) - break; - /*sleep(1);*/ - } -} -