[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
netio COPYING ChangeLog Makefile lib.c lib.h ma...
From: |
Thomas Schwinge |
Subject: |
netio COPYING ChangeLog Makefile lib.c lib.h ma... |
Date: |
Sat, 04 Sep 2010 07:13:19 +0000 |
CVSROOT: /cvsroot/hurdextras
Module name: netio
Changes by: Thomas Schwinge <tschwinge> 10/09/04 07:13:19
Removed files:
. : COPYING ChangeLog Makefile lib.c lib.h main.c
netfs.c netio.h node.c node.h protocol.c
protocol.h version.h
Log message:
netio is now maintained in a Git repository:
<http://git.savannah.gnu.org/cgit/hurd/incubator.git/log/?h=netio/master>
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/netio/COPYING?cvsroot=hurdextras&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/ChangeLog?cvsroot=hurdextras&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/Makefile?cvsroot=hurdextras&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/lib.c?cvsroot=hurdextras&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/lib.h?cvsroot=hurdextras&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/main.c?cvsroot=hurdextras&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/netfs.c?cvsroot=hurdextras&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/netio.h?cvsroot=hurdextras&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/node.c?cvsroot=hurdextras&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/node.h?cvsroot=hurdextras&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/protocol.c?cvsroot=hurdextras&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/protocol.h?cvsroot=hurdextras&r1=1.2&r2=0
http://cvs.savannah.gnu.org/viewcvs/netio/version.h?cvsroot=hurdextras&r1=1.2&r2=0
Patches:
Index: COPYING
===================================================================
RCS file: COPYING
diff -N COPYING
--- COPYING 15 Apr 2002 23:17:21 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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 of the License, 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
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
Index: ChangeLog
===================================================================
RCS file: ChangeLog
diff -N ChangeLog
--- ChangeLog 23 Oct 2002 01:06:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-2002-10-23 Moritz Schulte <address@hidden>
-
- * netfs.c (netfs_attempt_lookup): Return ENOTDIR instead of
- EOPNOTSUPP in case the user tries to look something up beneath a
- port node.
- (netfs_S_io_read): Correct the netio specific hack, make it apply
- only for PORT_NODEs.
- (netfs_attempt_create_file): Clear *np and unlocked &dir->lock.
- (netfs_attempt_write): Set err to EISDIR if trying to write to a
- node, which is not a PORT_NODE.
- (netfs_attempt_read): Set *len to 0, if trying to read from a
- node, which is not a PORT_NODE, otherwise try to read from socket
- via socket_recv; update *len to nread after successfull reading.
- * main.c: Declare ul_node static.
- * lib.h: Include comments from lib.c.
- * version.h: Updated.
- * protocol.c (PROTOCOL_INIT): New macro, used in initializing
- protocols array.
- (protocol_socket_open_tcp): Renamed to protocol_socket_open_TCP.
- (protocol_socket_open_udp): Renamed to protocol_socket_open_UDP.
- (protocol_find_node): Cleanup.
- * main.c: Assigned Copyright to FSF.
- * Makefile: Likewise.
- * lib.c: Likewise.
- * lib.h: Likewise.
- * netfs.c: Likewise.
- * netio.h: Likewise.
- (PROTOCOL_NAME_TCP): Defined to "tcp".
- (PROTOCOL_NAME_UDP): Defined to "udp".
- Typedef for socket_open_func_t.
- (OPENONLY_STATE_MODES): Remove definition.
- Added some comments.
- * node.c: Likewise.
- * node.h: Likewise.
- * protocol.c: Likewise.
- (protocol_socket_open_std): Added static keyword.
- (protocol_socket_open_tcp): Likewise.
- (protocol_socket_open_udp): Likewise.
- Declared protocol_socket_open_tcp and protocol_socket_open_udp.
- * protocol.h: Likewise.
- * protocol.c (protocol_register_protocols): Renamed to
- protocol_register_default ...
- * protocol.h: Likewise.
- * main.c (main): ... and used.
- * netfs.c (netfs_attempt_mkdir): Call protocol_register to create
- protocol directories beneath the root directory.
- (netfs_attempt_rmdir): Cleanup.
-
-2002-10-22 Moritz Schulte <address@hidden>
-
- * protocol.c (protocol_register): Don't take "id" and
- "socket_open_func" arguments.
- (protocol_register): Don't allocate new protocol structure for the
- node, instead use a pointer to the static protocols structure.
- (protocol_find_by_name): New function.
- (protocol_register_protocols): Rewritten to iterate over protocols
- list.
- * protocol.h (protocol_register): Likewise.
- * node.c (node_destroy): Don't free np->nn->protocol.
- * netio.h (struct protocol): Typedef to protocol_t.
- * protocol.c (protocols): New array, initialized with protocol
- information.
- * netfs.c (netfs_attempt_lookup): Use strcmp instead of
- STRING_EQUAL.
- * lib.h: Remove STRING_EQUAL definition.
- * Makefile (CFLAGS): Added -D_FILE_OFFSET_BITS=64.
-
-2002-10-19 Moritz Schulte <address@hidden>
-
- * netio.h (NETIO_VERSION): Set to "0.2".
-
-2002-10-19 Moritz Schulte <address@hidden>
-
- * main.c (main): Initialize stat_default.
- * node.c: New variable: struct stat stat_default.
- (node_make_new): Initialize (*node)->nn_stat with stat_default.
- * node.c (node_make_protocol_node): Remove unnecessary nn_stat
- initialization.
- (node_make_host_node): Likewise.
- (node_make_port_node): Likewise.
- * main.c: New variable: int fsid ...
- (main): ... initialized with getpid ().
-
-2002-10-16 Moritz Schulte <address@hidden>
-
- * main.c: (main): Set netfs_root_node->nn_stat.st_fsid after
- netfs_root_node->nn_stat is initialized.
-
-2002-05-27 Moritz Schulte <address@hidden>
-
- * main.c (netfs_server_name, netfs_server_version): New variables.
Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- Makefile 23 Oct 2002 01:06:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,45 +0,0 @@
-# netio - creates socket ports via the filesystem
-# Copyright (C) 2001, 02 Free Software Foundation, Inc.
-# Written by Moritz Schulte.
-#
-# 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 of the License, 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
-
-CFLAGS = -g -Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-
-netio: main.o netfs.o node.o lib.o protocol.o
- gcc $(CFLAGS) -lnetfs -lfshelp -liohelp -lthreads -lports \
- -lihash -lshouldbeinlibc \
- -o netio main.o netfs.o node.o lib.o protocol.o
-
-main.o: main.c netio.h lib.h node.h protocol.h
- gcc $(CFLAGS) -c main.c
-
-netfs.o: netfs.c netio.h lib.h node.h protocol.h
- gcc $(CFLAGS) -c netfs.c
-
-lib.o: lib.c lib.h
- gcc $(CFLAGS) -c lib.c
-
-node.o: node.c netio.h lib.h protocol.h
- gcc $(CFLAGS) -c node.c
-
-protocol.o: protocol.c netio.h lib.h node.h
- gcc $(CFLAGS) -c protocol.c
-
-clean:
- rm -rf *.o netio
-
-.PHONY: clean
Index: lib.c
===================================================================
RCS file: lib.c
diff -N lib.c
--- lib.c 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,65 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <hurd.h>
-#include <hurd/socket.h>
-#include <hurd/paths.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <errno.h>
-#include <error.h>
-
-#include "lib.h"
-
-/* Try to alloc SIZE bytes into *MEM. Return ENOMEM if malloc()
- failed. */
-error_t
-my_malloc (size_t size, void **mem)
-{
- *mem = malloc (size);
- if (! *mem)
- return ENOMEM;
- return 0;
-}
-
-/* Open a port to the socket server for the protocol family number NO
- and store it in *SOCK. Return 0 on success or an error code. */
-error_t
-open_socket_server (int no, pf_t *sock)
-{
- char *path;
- error_t err;
- pf_t port;
-
- err = asprintf (&path, "%s/%i", _SERVERS_SOCKET, no);
- if (err < 0)
- return ENOMEM;
- err = 0;
- port = file_name_lookup (path, 0, 0);
- free (path);
- if (port == MACH_PORT_NULL)
- err = errno;
- else
- *sock = port;
- return err;
-}
Index: lib.h
===================================================================
RCS file: lib.h
diff -N lib.h
--- lib.h 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <errno.h>
-#include <stdint.h>
-#include <hurd/socket.h>
-
-/* Try to alloc SIZE bytes into *MEM. Return ENOMEM if malloc()
- failed. */
-error_t my_malloc (size_t size, void **mem);
-
-/* Open a port to the socket server for the protocol family number NO
- and store it in *SOCK. Return 0 on success or an error code. */
-error_t open_socket_server (int no, pf_t *sock);
Index: main.c
===================================================================
RCS file: main.c
diff -N main.c
--- main.c 23 Oct 2002 01:06:23 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,156 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <hurd.h>
-#include <hurd/netfs.h>
-#include <hurd/paths.h>
-#include <argp.h>
-#include <errno.h>
-#include <error.h>
-#include <stdio.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include "netio.h"
-#include "lib.h"
-#include "node.h"
-#include "protocol.h"
-
-#include "version.h"
-
-char *netfs_server_name = "netio";
-char *netfs_server_version = HURD_VERSION;
-
-const char *argp_program_version = STANDARD_HURD_VERSION (netio);
-const char *argp_program_bug_address =
-"Moritz Schulte <address@hidden>";
-const char *doc = "Hurd netio translator v" NETIO_VERSION;
-
-/* The underlying node. */
-static mach_port_t ul_node;
-
-/* The socket server, PF_INET for us. */
-pf_t socket_server;
-
-/* Has to be defined for libnetfs... */
-int netfs_maxsymlinks = 0;
-
-/* Our filesystem id - will be our pid. */
-int fsid = 0;
-
-/* Used for updating node information. */
-volatile struct mapped_time_value *netio_maptime;
-
-/* argp options. */
-static const struct argp_option netio_options[] =
-{
- { 0 }
-};
-
-/* argp option parser. */
-static error_t
-parse_opts (int key, char *arg, struct argp_state *sate)
-{
- return 0;
-}
-
-/* Main. */
-int
-main (int argc, char **argv)
-{
- struct argp netio_argp = { netio_options, parse_opts,
- NULL, doc, NULL };
- mach_port_t bootstrap_port;
- error_t err;
- extern struct stat stat_default;
-
- /* Start the server. */
- argp_parse (&netio_argp, argc, argv, 0, 0, 0);
- task_get_bootstrap_port (mach_task_self (), &bootstrap_port);
- netfs_init ();
- ul_node = netfs_startup (bootstrap_port, 0);
-
- /* Initialize netio. */
- err = node_make_root_node (&netfs_root_node);
- if (err)
- error (EXIT_FAILURE, err, "cannot create root node");
- fsid = getpid ();
-
- {
- /* Here we adjust the root node permissions. */
- struct stat ul_node_stat;
- err = io_stat (ul_node, &ul_node_stat);
- if (err)
- error (EXIT_FAILURE, err, "cannot stat underlying node");
- netfs_root_node->nn_stat = ul_node_stat;
- netfs_root_node->nn_stat.st_fsid = fsid;
- netfs_root_node->nn_stat.st_mode = S_IFDIR | (ul_node_stat.st_mode
- & ~S_IFMT & ~S_ITRANS);
-
- /* If the underlying node isn't a directory, enhance the stat
- information, if needed. */
- if (! S_ISDIR (ul_node_stat.st_mode))
- {
- if (ul_node_stat.st_mode & S_IRUSR)
- netfs_root_node->nn_stat.st_mode |= S_IXUSR;
- if (ul_node_stat.st_mode & S_IRGRP)
- netfs_root_node->nn_stat.st_mode |= S_IXGRP;
- if (ul_node_stat.st_mode & S_IROTH)
- netfs_root_node->nn_stat.st_mode |= S_IXOTH;
- }
- }
-
- err = maptime_map (0, 0, &netio_maptime);
- if (err)
- error (EXIT_FAILURE, err, "cannot map time");
-
- fshelp_touch (&netfs_root_node->nn_stat,
- TOUCH_ATIME|TOUCH_MTIME|TOUCH_CTIME,
- netio_maptime);
-
- /* Here we initialize the default stat information for netio
- nodes. */
- stat_default.st_fstype = FSTYPE_MISC;
- stat_default.st_fsid = fsid;
- stat_default.st_ino = 1; /* ? */
- stat_default.st_gen = 0;
- stat_default.st_rdev = 0;
- stat_default.st_mode = 0;
- stat_default.st_nlink = 0;
- stat_default.st_uid = netfs_root_node->nn_stat.st_uid;
- stat_default.st_gid = netfs_root_node->nn_stat.st_gid;
- stat_default.st_size = 0;
- stat_default.st_blksize = 0;
- stat_default.st_blocks = 0;
- stat_default.st_author = netfs_root_node->nn_stat.st_author;
-
- err = open_socket_server (PF_INET, &socket_server);
- if (err)
- error (EXIT_FAILURE, err, "open_socket_server");
-
- err = protocol_register_default ();
- if (err)
- error (EXIT_FAILURE, err, "protocol_register_default");
-
- for (;;)
- netfs_server_loop ();
-
- /* Never reached. */
- exit (0);
-}
Index: netfs.c
===================================================================
RCS file: netfs.c
diff -N netfs.c
--- netfs.c 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,693 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <hurd/netfs.h>
-#include <hurd/socket.h>
-#include <argz.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <dirent.h>
-#include <sys/mman.h>
-
-#include "netio.h"
-#include "lib.h"
-#include "node.h"
-#include "protocol.h"
-
-/* Returned directory entries are aligned to blocks this many bytes
- long. Must be a power of two. For netfs_get_dirents. Taken from
- hostmux. */
-#define DIRENT_ALIGN 4
-#define DIRENT_NAME_OFFS offsetof (struct dirent, d_name)
-/* Length is structure before the name + the name + '\0', all
- padded to a four-byte alignment. */
-#define DIRENT_LEN(name_len) \
- ((DIRENT_NAME_OFFS + (name_len) + 1 + (DIRENT_ALIGN - 1)) \
- & ~(DIRENT_ALIGN - 1))
-
-/* The user must define this function. Lookup NAME in DIR (which is
- locked) for USER; set *NP to the found name upon return. If the
- name was not found, then return ENOENT. On any error, clear *NP.
- (*NP, if found, should be locked and a reference to it generated.
- This call should unlock DIR no matter what.) */
-error_t
-netfs_attempt_lookup (struct iouser *user, struct node *dir,
- char *name, struct node **node)
-{
- error_t err;
-
- err = fshelp_access (&dir->nn_stat, S_IEXEC, user);
- if (err)
- goto out;
- if (! strcmp (name, "."))
- {
- *node = dir;
- netfs_nref (*node);
- }
- else if (! strcmp (name, ".."))
- {
- *node = dir->nn->dir;
- netfs_nref (*node);
- }
- else
- {
- if (dir->nn->flags & PROTOCOL_NODE)
- err = node_make_host_node (user, dir, name, node);
- else if (dir->nn->flags & HOST_NODE)
- err = node_make_port_node (user, dir, name, node);
- else if (dir->nn->flags & ROOT_NODE)
- {
- err = protocol_find_node (name, node);
- if (! err)
- netfs_nref (*node);
- }
- else
- /* Trying to look something inside beneath a port node. */
- err = ENOTDIR;
- }
-
- out:
- fshelp_touch (&dir->nn_stat, TOUCH_ATIME, netio_maptime);
- mutex_unlock (&dir->lock);
- if (err)
- *node = 0;
- else
- mutex_lock (&(*node)->lock);
- return err;
-}
-
-/* Return an argz string describing the current options. Fill *ARGZ
- with a pointer to newly malloced storage holding the list and *LEN
- to the length of that storage. */
-error_t
-netfs_append_args (char **argz, size_t *argz_len)
-{
- return 0;
-}
-
-/* Make sure that NP->nn_stat is filled with current information.
- CRED identifies the user responsible for the operation. */
-error_t
-netfs_validate_stat (struct node *np, struct iouser *cred)
-{
- return 0;
-}
-
-/* This should attempt a chmod call for the user specified by CRED on
- locked node NP, to change the owner to UID and the group to GID. */
-error_t
-netfs_attempt_chown (struct iouser *cred, struct node *np,
- uid_t uid, uid_t gid)
-{
- return EOPNOTSUPP;
-}
-
-/* This should attempt a chauthor call for the user specified by CRED
- on locked node NP, thereby changing the author to AUTHOR. */
-error_t
-netfs_attempt_chauthor (struct iouser *cred, struct node *np,
- uid_t author)
-{
- return EOPNOTSUPP;
-}
-
-/* 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
-netfs_attempt_chmod (struct iouser *cred, struct node *np,
- mode_t mode)
-{
- error_t err;
-
- /* We only support permission chmod's on the root node. */
- if (np->nn->dir ||
- ((mode & S_IFMT) | (np->nn_stat.st_mode & S_IFMT))
- != (np->nn_stat.st_mode & S_IFMT))
- err = EOPNOTSUPP;
- else
- {
- if (! (err = fshelp_isowner (&np->nn_stat, cred)))
- {
- np->nn_stat.st_mode = mode | (np->nn_stat.st_mode & S_IFMT);
- fshelp_touch (&np->nn_stat, TOUCH_CTIME, netio_maptime);
- }
- }
- return err;
-}
-
-/* Attempt to turn locked node NP (user CRED) into a symlink with
- target NAME. */
-error_t
-netfs_attempt_mksymlink (struct iouser *cred, struct node *np,
- char *name)
-{
- return EOPNOTSUPP;
-}
-
-/* Attempt to turn NODE (user CRED) into a device. TYPE is either
- S_IFBLK or S_IFCHR. NP is locked. */
-error_t
-netfs_attempt_mkdev (struct iouser *cred, struct node *np,
- mode_t type, dev_t indexes)
-{
- return EOPNOTSUPP;
-}
-
-/* Attempt to set the passive translator record for FILE to ARGZ (of
- length ARGZLEN) for user CRED. NP is locked. */
-error_t
-netfs_set_translator (struct iouser *cred, struct node *np,
- char *argz, size_t argzlen)
-{
- return EOPNOTSUPP;
-}
-
-/* For locked node NODE with S_IPTRANS set in its mode, look up the
- name of its translator. Store the name into newly malloced
- storage, and return it in *ARGZ; set *ARGZ_LEN to the total length. */
-error_t
-netfs_get_translator (struct node *node, char **argz,
- size_t *argz_len)
-{
- return EOPNOTSUPP;
-}
-
-/* This should attempt a chflags call for the user specified by CRED
- on locked node NP, to change the flags to FLAGS. */
-error_t
-netfs_attempt_chflags (struct iouser *cred, struct node *np,
- int flags)
-{
- return EOPNOTSUPP;
-}
-
-/* This should attempt a utimes call for the user specified by CRED on
- locked node NP, to change the atime to ATIME and the mtime to
- MTIME. If ATIME or MTIME is null, then set to the current time. */
-error_t
-netfs_attempt_utimes (struct iouser *cred, struct node *np,
- struct timespec *atime, struct timespec *mtime)
-{
- return 0;
-}
-
-/* This should attempt to set the size of the locked file NP (for user
- CRED) to SIZE bytes long. */
-error_t
-netfs_attempt_set_size (struct iouser *cred, struct node *np,
- off_t size)
-{
- return 0;
-}
-
-/* This should attempt to fetch filesystem status information for the
- remote filesystem, for the user CRED. NP is locked. */
-error_t
-netfs_attempt_statfs (struct iouser *cred, struct node *np,
- struct statfs *st)
-{
- return EOPNOTSUPP;
-}
-
-/* This should sync the locked file NP completely to disk, for the
- user CRED. If WAIT is set, return only after the sync is
- completely finished. */
-error_t
-netfs_attempt_sync (struct iouser *cred, struct node *np,
- int wait)
-{
-
- return EOPNOTSUPP;
-}
-
-/* This should sync the entire remote filesystem. If WAIT is set,
- return only after the sync is completely finished. */
-error_t
-netfs_attempt_syncfs (struct iouser *cred, int wait)
-{
- return 0;
-}
-
-/* Delete NAME in DIR (which is locked) for USER. */
-error_t
-netfs_attempt_unlink (struct iouser *user, struct node *dir,
- char *name)
-{
- return EOPNOTSUPP;
-}
-
-/* Attempt to rename the directory FROMDIR to TODIR. Note that neither
- of the specific nodes are locked. */
-error_t
-netfs_attempt_rename (struct iouser *user, struct node *fromdir,
- char *fromname, struct node *todir,
- char *toname, int excl)
-{
- return EOPNOTSUPP;
-}
-
-/* Attempt to create a new directory named NAME in DIR (which is
- locked) for USER with mode MODE. */
-error_t
-netfs_attempt_mkdir (struct iouser *user, struct node *dir,
- char *name, mode_t mode)
-{
- error_t err = 0;
-
- /* Creating of protocol directories is allowed. */
- if (dir->nn->dir)
- err = EOPNOTSUPP;
- else
- {
- err = protocol_register (name);
- if (err == ENOENT)
- err = EOPNOTSUPP;
- }
- return err;
-}
-
-/* Attempt to remove directory named NAME in DIR (which is locked) for
- USER. */
-error_t
-netfs_attempt_rmdir (struct iouser *user,
- struct node *dir, char *name)
-{
- error_t err = 0;
-
- /* Removing of protocol directories is allowed. */
- if (dir->nn->dir)
- err = EOPNOTSUPP;
- else
- err = protocol_unregister (name);
- return err;
-}
-
-/* Create a link in DIR with name NAME to FILE for USER. Note that
- neither DIR nor FILE are locked. If EXCL is set, do not delete the
- target. Return EEXIST if NAME is already found in DIR. */
-error_t
-netfs_attempt_link (struct iouser *user, struct node *dir,
- struct node *file, char *name, int excl)
-{
- return EOPNOTSUPP;
-}
-
-/* Attempt to create an anonymous file related to DIR (which is
- locked) for USER with MODE. Set *NP to the returned file upon
- success. No matter what, unlock DIR. */
-error_t
-netfs_attempt_mkfile (struct iouser *user, struct node *dir,
- mode_t mode, struct node **np)
-{
- return EOPNOTSUPP;
-}
-
-/* (We don't use this function!) Attempt to create a file named NAME
- in DIR (which is locked) for USER with MODE. Set *NP to the new
- node upon return. On any error, clear *NP. *NP should be locked
- on success; no matter what, unlock DIR before returning. */
-error_t
-netfs_attempt_create_file (struct iouser *user, struct node *dir,
- char *name, mode_t mode, struct node **np)
-{
- *np = 0;
- mutex_unlock (&dir->lock);
- return EOPNOTSUPP;
-}
-
-/* Read the contents of locked node NP (a symlink), for USER, into
- BUF. */
-error_t
-netfs_attempt_readlink (struct iouser *user, struct node *np,
- char *buf)
-{
- return EOPNOTSUPP;
-}
-
-/* libnetfs uses this functions once. */
-error_t
-netfs_check_open_permissions (struct iouser *user, struct node *np,
- int flags, int newnode)
-{
- error_t err = 0;
-
- if (! err && (flags & O_READ))
- err = fshelp_access (&np->nn_stat, S_IREAD, user);
- if (! err && (flags & O_WRITE))
- err = fshelp_access (&np->nn_stat, S_IWRITE, user);
- if (! err && (flags & O_EXEC))
- err = fshelp_access (&np->nn_stat, S_IEXEC, user);
- return err;
-}
-
-/* Read from the locked file NP for user CRED starting at OFFSET and
- continuing for up to *LEN bytes. Put the data at DATA. Set *LEN
- to the amount successfully read upon return. */
-error_t
-netfs_attempt_read (struct iouser *cred, struct node *np,
- off_t offset, size_t *len, void *data)
-{
- error_t err = 0;
-
- if (! (np->nn->flags & PORT_NODE))
- *len = 0;
- else
- {
- addr_port_t addrport;
- char *bufp = (char *) data;
- mach_msg_type_number_t nread = *len;
- mach_port_t *ports;
- mach_msg_type_number_t nports;
- char *cdata = NULL;
- mach_msg_type_number_t clen = 0;
- int flags = 0;
-
- err = socket_recv (np->nn->sock, &addrport, flags, &bufp, &nread,
- &ports, &nports, &cdata, &clen, &flags,
- *len);
- if (! err)
- {
- mach_port_deallocate (mach_task_self (), addrport);
- vm_deallocate (mach_task_self (), (vm_address_t) cdata, clen);
- if (bufp != (char *) data)
- {
- memcpy ((char *) data, bufp, nread);
- vm_deallocate (mach_task_self (), (vm_address_t) bufp, nread);
- }
- *len = nread;
- }
- }
-
- return err;
-}
-
-/* Write to the locked file NP for user CRED starting at OFFSET and
- continuing for up to *LEN bytes from DATA. Set *LEN to the amount
- successfully written upon return. */
-error_t
-netfs_attempt_write (struct iouser *cred, struct node *np,
- off_t offset, size_t *len, void *data)
-{
- error_t err = 0;
-
- if (np->nn->flags & PORT_NODE)
- {
- if (! np->nn->connected)
- err = node_connect_socket (np);
- if (! err)
- err = socket_send (np->nn->sock, MACH_PORT_NULL, 0, (char *) data,
- *len, NULL, MACH_MSG_TYPE_COPY_SEND, 0, NULL, 0,
- (int *) len);
- }
- else
- err = EISDIR;
-
- return err;
-}
-
-/* Return the valid access types (bitwise OR of O_READ, O_WRITE, and
- O_EXEC) in *TYPES for locked file NP and user CRED. */
-error_t
-netfs_report_access (struct iouser *cred, struct node *np,
- int *types)
-{
- *types = 0;
- if (fshelp_access (&np->nn_stat, S_IREAD, cred) == 0)
- *types |= O_READ;
- if (fshelp_access (&np->nn_stat, S_IWRITE, cred) == 0)
- *types |= O_WRITE;
- if (fshelp_access (&np->nn_stat, S_IEXEC, cred) == 0)
- *types |= O_EXEC;
- return 0;
-}
-
-/* Create a new user from the specified UID and GID arrays. */
-struct iouser *
-netfs_make_user (uid_t *uids, int nuids, uid_t *gids, int ngids)
-{
- return NULL;
-}
-
-/* Node NP has no more references; free all its associated storage. */
-void
-netfs_node_norefs (struct node *np)
-{
- node_destroy (np);
-}
-
-/* Fill the array *DATA of size BUFSIZE with up to NENTRIES dirents
- from DIR (which is locked) starting with entry ENTRY for user CRED.
- The number of entries in the array is stored in *AMT and the number
- of bytes in *DATACNT. If the supplied buffer is not large enough
- to hold the data, it should be grown. Taken from hostmux. */
-error_t
-netfs_get_dirents (struct iouser *cred, struct node *dir,
- int first_entry, int num_entries, char **data,
- mach_msg_type_number_t *data_len,
- vm_size_t max_data_len, int *data_entries)
-{
- error_t err;
- int count;
- size_t size = 0; /* Total size of our return block. */
- struct node *first_name, *nm;
-
- /* Add the length of a directory entry for NAME to SIZE and return true,
- unless it would overflow MAX_DATA_LEN or NUM_ENTRIES, in which case
- return false. */
- int bump_size (const char *name)
- {
- if (num_entries == -1 || count < num_entries)
- {
- size_t new_size = size + DIRENT_LEN (strlen (name));
- if (max_data_len > 0 && new_size > max_data_len)
- return 0;
- size = new_size;
- count++;
- return 1;
- }
- else
- return 0;
- }
-
- if (dir->nn->flags & PORT_NODE)
- return ENOTDIR;
-
- /* Find the first entry. */
- for (first_name = dir->nn->entries, count = 0;
- first_name && first_entry > count;
- first_name = first_name->next)
- count++;
-
- count = 0;
-
- /* Make space for the `.' and `..' entries. */
- if (first_entry == 0)
- bump_size (".");
- if (first_entry <= 1)
- bump_size ("..");
-
- /* See how much space we need for the result. */
- for (nm = first_name; nm; nm = nm->next)
- if (!bump_size (nm->nn->protocol->name))
- break;
-
- /* Allocate it. */
- *data = mmap (0, size, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
- err = ((void *) *data == (void *) -1) ? errno : 0;
-
- if (! err)
- /* Copy out the result. */
- {
- char *p = *data;
-
- int add_dir_entry (const char *name, ino_t fileno, int type)
- {
- if (num_entries == -1 || count < num_entries)
- {
- struct dirent hdr;
- size_t name_len = strlen (name);
- size_t sz = DIRENT_LEN (name_len);
-
- if (sz > size)
- return 0;
- else
- size -= sz;
-
- hdr.d_fileno = fileno;
- hdr.d_reclen = sz;
- hdr.d_type = type;
- hdr.d_namlen = name_len;
-
- memcpy (p, &hdr, DIRENT_NAME_OFFS);
- strcpy (p + DIRENT_NAME_OFFS, name);
- p += sz;
-
- count++;
-
- return 1;
- }
- else
- return 0;
- }
-
- *data_len = size;
- *data_entries = count;
-
- count = 0;
-
- /* Add `.' and `..' entries. */
- if (first_entry == 0)
- add_dir_entry (".", 2, DT_DIR);
- if (first_entry <= 1)
- add_dir_entry ("..", 2, DT_DIR);
-
- /* Fill in the real directory entries. */
- for (nm = first_name; nm; nm = nm->next)
- if (!add_dir_entry (nm->nn->protocol->name, nm->nn->protocol->id,
- DT_DIR))
- break;
- }
-
- fshelp_touch (&dir->nn_stat, TOUCH_ATIME, netio_maptime);
- return err;
-}
-
-/* We need our special version of netfs_S_io_read. */
-
-error_t
-block_for_reading (socket_t sock)
-{
- mach_port_t reply_port;
- int type = SELECT_READ;
- error_t err;
-
- do
- {
- reply_port = mach_reply_port ();
- if (reply_port == MACH_PORT_NULL)
- return EIEIO; /* FIXME? */
- err = io_select (sock, reply_port, 1000, &type);
- }
- while (err == EMACH_RCV_TIMED_OUT);
- return err;
-}
-
-/* Implement the io_read interface. This is the original
- implementation from libnetfs with one special hack at the
- beginning. */
-error_t
-netfs_S_io_read (struct protid *user,
- char **data,
- mach_msg_type_number_t *datalen,
- off_t offset,
- mach_msg_type_number_t amount)
-{
- error_t err;
- off_t start;
- struct node *node;
- int alloced = 0;
-
- if (!user)
- return EOPNOTSUPP;
-
- node = user->po->np;
-
- /* This is our special hack; applies only to PORT_NODEs. */
- if (node->nn->flags & PORT_NODE)
- {
- err = 0;
- if (! node->nn->connected)
- err = node_connect_socket (node);
- if (! err)
- err = block_for_reading (node->nn->sock);
- if (err)
- return err;
- }
-
- mutex_lock (&user->po->np->lock);
-
- if ((user->po->openstat & O_READ) == 0)
- {
- mutex_unlock (&node->lock);
- return EBADF;
- }
-
- if (amount > *datalen)
- {
- alloced = 1;
- *data = mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
- }
- *datalen = amount;
-
- start = (offset == -1 ? user->po->filepointer : offset);
-
- if (start < 0)
- err = EINVAL;
- else if (S_ISLNK (node->nn_stat.st_mode))
- /* Read from a symlink. */
- {
- off_t size = node->nn_stat.st_size;
-
- if (start + amount > size)
- amount = size - start;
-
- if (start >= size)
- {
- *datalen = 0;
- err = 0;
- }
- else if (amount < size || start > 0)
- {
- char *whole_link = alloca (size);
- err = netfs_attempt_readlink (user->user, node, *data);
- if (! err)
- {
- memcpy (*data, whole_link + start, amount);
- *datalen = amount;
- }
- }
- else
- err = netfs_attempt_readlink (user->user, node, *data);
- }
- else
- /* Read from a normal file. */
- err = netfs_attempt_read (user->user, node, start, datalen, *data);
-
- if (offset == -1 && !err)
- user->po->filepointer += *datalen;
-
- mutex_unlock (&node->lock);
-
- if (err && alloced)
- munmap (*data, amount);
-
- if (!err && alloced && (round_page (*datalen) < round_page (amount)))
- munmap (*data + round_page (*datalen),
- round_page (amount) - round_page (*datalen));
-
- return err;
-}
Index: netio.h
===================================================================
RCS file: netio.h
diff -N netio.h
--- netio.h 23 Oct 2002 01:06:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <hurd/socket.h>
-#include <stdint.h>
-#include <maptime.h>
-
-#define NETIO_VERSION "0.3cvs"
-
-/* The supported protocols. */
-#define PROTOCOL_ID_TCP 0x00000001
-#define PROTOCOL_ID_UDP 0x00000002
-#define PROTOCOL_NAME_TCP "tcp"
-#define PROTOCOL_NAME_UDP "udp"
-
-/* Type for functions, which connect a node socket. */
-typedef error_t (*socket_open_func_t) (struct node *node);
-
-/* One of these items per supported protocol. */
-typedef struct protocol
-{
- int id;
- char *name;
- socket_open_func_t socket_open_func;
-} protocol_t;
-
-/* The different kinds of nodes managed by netio. */
-#define ROOT_NODE 0x00000001
-#define PROTOCOL_NODE 0x00000002
-#define HOST_NODE 0x00000004
-#define PORT_NODE 0x00000008
-
-struct netnode
-{
- unsigned short int flags; /* Either ROOT_NODE, PROTOCOL_NODE,
- HOST_NODE or PORT_NODE. */
- char *host; /* The host to connect to. */
- uint16_t port; /* The port to connect to. */
- struct protocol *protocol; /* The protocol information. */
- socket_t sock; /* Our socket port. */
- addr_port_t addr; /* Our socket address port. */
- unsigned short int connected; /* non-zero, if the socket is
- connected. */
- struct node *entries; /* The entries in this directory, only
- useful for the root node. */
- struct node *dir; /* The parent directory. */
-};
-
-/* Used for touching the [acm]times of our nodes. */
-extern volatile struct mapped_time_value *netio_maptime;
Index: node.c
===================================================================
RCS file: node.c
diff -N node.c
--- node.c 23 Oct 2002 01:06:23 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,210 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <hurd/netfs.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/socket.h>
-
-#include "netio.h"
-#include "lib.h"
-
-/* The default stat information for netio nodes. */
-struct stat stat_default;
-
-/* Create a new node in the directory *DIR (if DIR is nonzero) and
- store it in *NODE. If CONNECT is true (in which case *DIR has to
- be a valid directory node), attach the new node to the list of
- directory entries of *DIR. Return 0 on success or an error code. */
-error_t
-node_make_new (struct node *dir, int connect, struct node **node)
-{
- struct netnode *netnode;
- error_t err;
-
- err = my_malloc (sizeof (struct netnode), (void **) &netnode);
- if (err)
- return err;
- *node = netfs_make_node (netnode);
- if (! *node)
- {
- free (netnode);
- return ENOMEM;
- }
- (*node)->nn->flags = 0;
- (*node)->nn->host = 0;
- (*node)->nn->port = 0;
- (*node)->nn->protocol = 0;
- (*node)->nn->sock = MACH_PORT_NULL;
- (*node)->nn->addr = MACH_PORT_NULL;
- (*node)->nn->connected = 0;
- (*node)->nn->entries = 0;
- (*node)->nn->dir = dir;
- (*node)->nn_stat = stat_default;
-
- if (dir)
- netfs_nref (dir);
-
- if (connect)
- {
- (*node)->next = dir->nn->entries;
- (*node)->prevp = &dir->nn->entries;
- if ((*node)->next)
- (*node)->next->prevp = &(*node)->next;
- dir->nn->entries = (*node);
- }
- else
- {
- (*node)->next = 0;
- (*node)->prevp = 0;
- }
- return err;
-}
-
-/* Destroy the node and release a reference to the parent directory. */
-error_t
-node_destroy (struct node *np)
-{
- if (np->nn->flags & PORT_NODE)
- {
- if (np->nn->connected)
- socket_shutdown (np->nn->sock, 2);
- }
- else if (np->nn->flags & HOST_NODE)
- free (np->nn->host);
- else if (np->nn->flags & PROTOCOL_NODE)
- {
- *np->prevp = np->next;
- if (np->next)
- np->next->prevp = np->prevp;
- }
- assert (np->nn->dir);
- spin_unlock (&netfs_node_refcnt_lock); /* FIXME? Is this locking
- okay? */
- netfs_nput (np->nn->dir);
- spin_lock (&netfs_node_refcnt_lock);
- free (np->nn);
- free (np);
- return 0;
-}
-
-/* Create a new protocol node for *PROTOCOL in the directory *DIR.
- Return 0 on success or an error code. */
-error_t
-node_make_protocol_node (struct node *dir, protocol_t *protocol)
-{
- struct node *node;
- error_t err;
-
- err = node_make_new (dir, 1, &node);
- if (err)
- return err;
- node->nn->flags |= PROTOCOL_NODE;
- node->nn->protocol = protocol;
- node->nn_stat.st_mode = S_IFDIR
- | S_IRUSR | S_IXUSR
- | S_IRGRP | S_IXGRP
- | S_IROTH | S_IXOTH;
- node->nn_stat.st_ino = protocol->id;
- node->nn_stat.st_nlink = 2;
- fshelp_touch (&node->nn_stat, TOUCH_ATIME | TOUCH_CTIME | TOUCH_MTIME,
- netio_maptime);
- return err;
-}
-
-/* Create a new host node for HOST in the directory *DIR and store it
- in *NODE. Return 0 on success or an error code. */
-error_t
-node_make_host_node (struct iouser *user, struct node *dir, char *host,
- struct node **node)
-{
- struct node *np;
- error_t err;
- err = node_make_new (dir, 0, &np);
- if (err)
- return err;
- np->nn->host = strdup (host);
- if (! np->nn->host)
- {
- netfs_nrele (np);
- err = ENOMEM;
- goto out;
- }
- np->nn->flags |= HOST_NODE;
- np->nn->protocol = dir->nn->protocol;
- np->nn_stat.st_mode = S_IFDIR | S_IRUSR | S_IXUSR ;
- fshelp_touch (&np->nn_stat, TOUCH_ATIME | TOUCH_CTIME | TOUCH_MTIME,
- netio_maptime);
- *node = np;
-
- out:
- return err;
-}
-
-/* Create a new port node for PORT in the directory *DIR and store it
- in *NODE. Return 0 on success or an error code. */
-error_t
-node_make_port_node (struct iouser *user, struct node *dir,
- char *port, struct node **node)
-{
- struct node *np;
- error_t err;
- err = node_make_new (dir, 0, &np);
- if (err)
- return err;
- np->nn->flags |= PORT_NODE;
- np->nn->host = dir->nn->host;
- np->nn->protocol = dir->nn->protocol;
- np->nn->port = (uint16_t) strtol (port, 0, 10);
- np->nn->flags |= HOST_NODE;
- np->nn->protocol = dir->nn->protocol;
- np->nn_stat.st_mode = S_IFSOCK | S_IRUSR | S_IWUSR ;
- fshelp_touch (&np->nn_stat, TOUCH_ATIME | TOUCH_CTIME | TOUCH_MTIME,
- netio_maptime);
- *node = np;
- return err;
-}
-
-/* Create the root node. Return 0 on success or an error code. */
-error_t
-node_make_root_node (struct node **node)
-{
- struct node *np;
- error_t err;
- err = node_make_new (0, 0, &np);
- if (err)
- goto out;
- np->nn->flags |= ROOT_NODE;
- *node = np;
- out:
- return err;
-}
-
-/* Connect the socket of the node *NP. Return 0 on success or an
- error code. */
-error_t
-node_connect_socket (struct node *np)
-{
- error_t err;
-
- err = (*np->nn->protocol->socket_open_func) (np);
- if (! err)
- np->nn->connected = 1;
- return err;
-}
Index: node.h
===================================================================
RCS file: node.h
diff -N node.h
--- node.h 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <errno.h>
-#include <hurd/netfs.h>
-#include <hurd/iohelp.h>
-
-error_t node_make_new (struct node *dir, int connect, struct node **node);
-error_t node_make_protocol_node (struct node *dir,
- struct protocol *protocol);
-error_t node_make_host_node (struct iouser *user, struct node *dir,
- char *host, struct node **node);
-error_t node_make_port_node (struct iouser *user, struct node *dir,
- char *port, struct node **node);
-error_t node_make_root_node (struct node **the_node);
-error_t node_connect_socket (struct node *np);
-error_t node_destroy (struct node *np);
-
Index: protocol.c
===================================================================
RCS file: protocol.c
diff -N protocol.c
--- protocol.c 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,182 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 <hurd/netfs.h>
-#include <hurd/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-
-#include "netio.h"
-#include "lib.h"
-#include "node.h"
-
-static error_t protocol_socket_open_TCP (struct node *node);
-static error_t protocol_socket_open_UDP (struct node *node);
-
-#define PROTOCOL_INIT(p) { PROTOCOL_ID_##p, PROTOCOL_NAME_##p, \
- protocol_socket_open_##p }
-
-static protocol_t protocols[] = { PROTOCOL_INIT (TCP),
- PROTOCOL_INIT (UDP),
- { 0, NULL, NULL } };
-
-static error_t protocol_find_by_name (char *name, protocol_t **protocol);
-
-/* Connect the node *NODE with style STYLE (SOCK_STREAM or
- SOCK_DGRAM). Used by protocol_socket_open_{tcp,udp}. Return 0 on
- success or an error code. */
-static error_t
-protocol_socket_open_std (struct node *node, int style)
-{
- extern pf_t socket_server;
- socket_t sock;
- addr_port_t aport;
- error_t err;
- struct sockaddr_in addr;
- struct hostent *hostinfo;
-
- hostinfo = gethostbyname (node->nn->host);
- if (hostinfo == NULL)
- {
- err = h_errno;
- goto out;
- }
-
- if ((err = socket_create (socket_server, style, 0, &sock)))
- goto out;
- addr.sin_family = AF_INET;
- addr.sin_addr = *(struct in_addr *) hostinfo->h_addr;
- addr.sin_port = htons (node->nn->port);
- if ((err = socket_create_address (sock, addr.sin_family,
- (char *) &addr, sizeof (addr), &aport)))
- goto out;
- if ((err = socket_connect (sock, aport)))
- goto out;
-
- node->nn->sock = sock;
- node->nn->addr = aport;
-
- /* FIXME: cleanup missing? */
-
- out:
- return err;
-}
-
-/* Open a TCP socket for *NODE. Return 0 on success or an error code. */
-static error_t
-protocol_socket_open_TCP (struct node *node)
-{
- return protocol_socket_open_std (node, SOCK_STREAM);
-}
-
-/* Open a UDP socket for *NODE. Return 0 on success or an error code. */
-static error_t
-protocol_socket_open_UDP (struct node *node)
-{
- return protocol_socket_open_std (node, SOCK_DGRAM);
-}
-
-/* Store the protocol node for the protocol specified by NAME in
- *NODE. Return 0 on success or ENOENT if the node could not be
- found. */
-error_t
-protocol_find_node (char *name, struct node **node)
-{
- struct node *np;
- error_t err = ENOENT;
-
- for (np = netfs_root_node->nn->entries;
- np && strcmp (np->nn->protocol->name, name);
- np = np->next);
- if (np)
- {
- *node = np;
- err = 0;
- }
- return err;
-}
-
-/* Register a protocol specified by ID and NAME, creating an according
- node. Sockets for that protocol get opened by SOCKET_OPEN_FUNC.
- Return 0 on success or an error code. */
-error_t
-protocol_register (char *name)
-{
- error_t err;
- protocol_t *protocol;
-
- err = protocol_find_by_name (name, &protocol);
- if (err)
- return EOPNOTSUPP; /* No protocol definition by that name
- found. */
- err = node_make_protocol_node (netfs_root_node, protocol);
- if (err)
- return err;
-
- return err;
-}
-
-/* Unregister the protocol specified by NAME, drop the reference to
- the protocol node. Return 0 on success or ENOENT if that protocol
- could not be found. */
-error_t
-protocol_unregister (char *name)
-{
- struct node *np;
- error_t err;
-
- err = protocol_find_node (name, &np);
- if (err)
- return err;
- netfs_nrele (np);
- return 0;
-}
-
-/* Register the protocols - create according nodes. Return 0 on
- success or an error code. */
-error_t
-protocol_register_default (void)
-{
- protocol_t *p;
- error_t err = 0;
-
- for (p = protocols; ! err && p->name; p++)
- err = protocol_register (p->name);
-
- return err;
-}
-
-/* Lookup the protocol information for NAME and store them in
- *PROTOCOL. Return zero on success or ENOENT if the protocol for
- NAME could not be found. */
-static error_t
-protocol_find_by_name (char *name, protocol_t **protocol)
-{
- protocol_t *p;
- error_t err = 0;
-
- for (p = protocols; p->name && strcmp (p->name, name); p++);
-
- if (p->name)
- *protocol = p;
- else
- err = ENOENT;
-
- return err;
-}
Index: protocol.h
===================================================================
RCS file: protocol.h
diff -N protocol.h
--- protocol.h 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,23 +0,0 @@
-/* netio - creates socket ports via the filesystem
- Copyright (C) 2001, 02 Free Software Foundation, Inc.
- Written by Moritz Schulte.
-
- 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 of the
- License, 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 */
-
-error_t protocol_register_default (void);
-error_t protocol_register (char *name);
-error_t protocol_unregister (char *name);
-error_t protocol_find_node (char *name, struct node **node);
Index: version.h
===================================================================
RCS file: version.h
diff -N version.h
--- version.h 23 Oct 2002 01:06:23 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-/* Hurd version
- Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
- Written by Thomas Bushnell, n/BSG.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd 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.
-
- The GNU Hurd 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, USA. */
-
-#ifndef HURD_VERSION
-#define HURD_VERSION "0.3"
-#endif
-
-/* The standard way to print versions for --version. */
-#define STANDARD_HURD_VERSION(s) \
- #s " (GNU Hurd) " HURD_VERSION
-#define STANDARD_HURD_VERSION_EXTRA(s, extra) \
- #s " (GNU Hurd; " extra ") " HURD_VERSION
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- netio COPYING ChangeLog Makefile lib.c lib.h ma...,
Thomas Schwinge <=