summaryrefslogtreecommitdiff
path: root/libnetfs
diff options
context:
space:
mode:
Diffstat (limited to 'libnetfs')
-rw-r--r--libnetfs/ChangeLog532
-rw-r--r--libnetfs/Makefile70
-rw-r--r--libnetfs/append-args.c31
-rw-r--r--libnetfs/append-std-options.c31
-rw-r--r--libnetfs/callbacks.h25
-rw-r--r--libnetfs/demuxer.c39
-rw-r--r--libnetfs/dir-link.c44
-rw-r--r--libnetfs/dir-lookup.c376
-rw-r--r--libnetfs/dir-mkdir.c39
-rw-r--r--libnetfs/dir-mkfile.c51
-rw-r--r--libnetfs/dir-notice-changes.c30
-rw-r--r--libnetfs/dir-readdir.c58
-rw-r--r--libnetfs/dir-rename.c43
-rw-r--r--libnetfs/dir-rmdir.c36
-rw-r--r--libnetfs/dir-unlink.c33
-rw-r--r--libnetfs/drop-node.c31
-rw-r--r--libnetfs/execserver.h23
-rw-r--r--libnetfs/file-chauthor.c38
-rw-r--r--libnetfs/file-check-access.c37
-rw-r--r--libnetfs/file-chflags.c37
-rw-r--r--libnetfs/file-chmod.c39
-rw-r--r--libnetfs/file-chown.c39
-rw-r--r--libnetfs/file-exec.c150
-rw-r--r--libnetfs/file-get-fs-options.c62
-rw-r--r--libnetfs/file-get-storage-info.c54
-rw-r--r--libnetfs/file-get-translator.c113
-rw-r--r--libnetfs/file-getcontrol.c49
-rw-r--r--libnetfs/file-getlinknode.c40
-rw-r--r--libnetfs/file-lock-stat.c37
-rw-r--r--libnetfs/file-lock.c36
-rw-r--r--libnetfs/file-reparent.c67
-rw-r--r--libnetfs/file-set-size.c38
-rw-r--r--libnetfs/file-set-translator.c180
-rw-r--r--libnetfs/file-statfs.c37
-rw-r--r--libnetfs/file-sync.c38
-rw-r--r--libnetfs/file-syncfs.c40
-rw-r--r--libnetfs/file-utimes.c53
-rw-r--r--libnetfs/fsstubs.c62
-rw-r--r--libnetfs/fsys-get-options.c67
-rw-r--r--libnetfs/fsys-getroot.c151
-rw-r--r--libnetfs/fsys-set-options.c91
-rw-r--r--libnetfs/fsys-syncfs.c39
-rw-r--r--libnetfs/fsysstubs.c75
-rw-r--r--libnetfs/init-init.c43
-rw-r--r--libnetfs/init-loop.c44
-rw-r--r--libnetfs/init-startup.c49
-rw-r--r--libnetfs/io-async.c30
-rw-r--r--libnetfs/io-clear-some-openmodes.c35
-rw-r--r--libnetfs/io-duplicate.c39
-rw-r--r--libnetfs/io-get-icky-async-id.c30
-rw-r--r--libnetfs/io-get-openmodes.c34
-rw-r--r--libnetfs/io-get-owner.c34
-rw-r--r--libnetfs/io-identity.c61
-rw-r--r--libnetfs/io-mod-owner.c34
-rw-r--r--libnetfs/io-pathconf.c69
-rw-r--r--libnetfs/io-read.c104
-rw-r--r--libnetfs/io-readable.c49
-rw-r--r--libnetfs/io-reauthenticate.c54
-rw-r--r--libnetfs/io-restrict-auth.c78
-rw-r--r--libnetfs/io-revoke.c61
-rw-r--r--libnetfs/io-seek.c63
-rw-r--r--libnetfs/io-select.c33
-rw-r--r--libnetfs/io-set-all-openmodes.c36
-rw-r--r--libnetfs/io-set-some-openmodes.c35
-rw-r--r--libnetfs/io-stat.c54
-rw-r--r--libnetfs/io-write.c73
-rw-r--r--libnetfs/iostubs.c89
-rw-r--r--libnetfs/make-node.c40
-rw-r--r--libnetfs/make-peropen.c56
-rw-r--r--libnetfs/make-protid.c45
-rw-r--r--libnetfs/misc.h24
-rw-r--r--libnetfs/modes.h23
-rw-r--r--libnetfs/mutations.h33
-rw-r--r--libnetfs/netfs.h345
-rw-r--r--libnetfs/nput.c37
-rw-r--r--libnetfs/nref.c29
-rw-r--r--libnetfs/nrele.c36
-rw-r--r--libnetfs/parse-runtime-options.c30
-rw-r--r--libnetfs/priv.h36
-rw-r--r--libnetfs/release-peropen.c46
-rw-r--r--libnetfs/release-protid.c35
-rw-r--r--libnetfs/runtime-argp.c23
-rw-r--r--libnetfs/set-get-trans.c44
-rw-r--r--libnetfs/set-options.c30
-rw-r--r--libnetfs/shutdown.c28
-rw-r--r--libnetfs/startup-argp.c49
-rw-r--r--libnetfs/std-runtime-argp.c24
-rw-r--r--libnetfs/std-startup-argp.c27
-rw-r--r--libnetfs/trans-callback.c79
-rw-r--r--libnetfs/unparse-runtime-options.c33
90 files changed, 5544 insertions, 0 deletions
diff --git a/libnetfs/ChangeLog b/libnetfs/ChangeLog
new file mode 100644
index 00000000..60429722
--- /dev/null
+++ b/libnetfs/ChangeLog
@@ -0,0 +1,532 @@
+2000-01-25 Roland McGrath <roland@baalperazim.frob.com>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Follow symlink despite flags if
+ MUSTBEDIR is set (i.e. there was a trailing slash).
+
+1999-10-11 Roland McGrath <roland@baalperazim.frob.com>
+
+ * dir-readdir.c (netfs_S_dir_readdir): Take new DATA_DEALLOC parameter.
+
+1999-09-13 Roland McGrath <roland@baalperazim.frob.com>
+
+ * iostubs.c: Reverted changes related to io_map_segment.
+
+1999-09-09 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * fsstubs.c (netfs_S_io_pathconf): Delete function.
+ * io-pathconf.c: New file.
+ * Makefile (IOSRCS): Add io-pathconf.c.
+
+1999-09-07 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * iostubs.c (netfs_S_io_map_segment): New function.
+
+1999-07-11 Roland McGrath <roland@baalperazim.frob.com>
+
+ * file-get-storage-info.c: Add #include <sys/mman.h>.
+ * file-get-translator.c: Likewise.
+
+1999-07-10 Roland McGrath <roland@baalperazim.frob.com>
+
+ * io-read.c: Add #include <sys/mman.h> for munmap decl.
+ * release-protid.c: Likewise.
+
+1999-07-09 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * file-get-storage-info.c (netfs_S_file_get_storage_info): Use
+ mmap instead of vm_allocate.
+ * file-get-translator.c (netfs_S_file_get_translator): Likewise.
+ * io-read.c (netfs_S_io_read): Likewise.
+
+1999-07-03 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * io-read.c (netfs_S_io_read): Use munmap instead of
+ vm_deallocate.
+ * release-protid.c (netfs_release_protid): Likewise.
+
+1999-07-01 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * nref.c: New file; guts from netfs.h.
+ * nrele.c: Likewise.
+ * nput.c: Likewise.
+ * netfs.h (netfs_nref, netfs_nrele, netfs_nput): Replace inline
+ definitions with normal declarations.
+ (NETFS_EI): Remove macro.
+ * netfs.c: Deleted file.
+ * Makefile (OTHERSRCS): Add nref.c, nrele.c, nput.c. Remove
+ netfs.c.
+
+Thu Mar 4 07:18:21 1999 Joel N. Weber II <devnull@theobromine.ai.mit.edu>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Only set newnode to 1 if the
+ lookup does not need to be retried as a result of getting EEXIST.
+
+1999-02-28 Roland McGrath <roland@baalperazim.frob.com>
+
+ * io-revoke.c (netfs_S_io_revoke): Use ports_class_iterate.
+
+Mon Feb 22 04:30:18 1999 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * io-revoke.c (netfs_S_io_revoke): Protect the revocation by
+ blocking other rpcs.
+
+Sat Feb 20 20:54:26 1999 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * io-revoke.c (netfs_S_io_revoke): Release lock before iteration.
+
+1999-02-16 Roland McGrath <roland@baalperazim.frob.com>
+
+ * io-revoke.c (netfs_S_io_revoke): Fix typos.
+
+Tue Feb 16 05:37:03 1999 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * io-revoke.c: New file.
+ * Makefile (IOSRCS): Add iorevoke.c.
+
+Sun Jan 31 18:27:42 1999 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * file-utimes.c (netfs_S_file_utimes): Understand new semantics
+ for setting to current time.
+ * netfs.h (netfs_attempt_utimes): Update documentation.
+
+1999-01-22 Roland McGrath <roland@baalperazim.frob.com>
+
+ * file-set-translator.c: Remove makedev, major, minor macro definition.
+ * dir-lookup.c: Likewise.
+
+1998-08-20 Roland McGrath <roland@baalperazim.frob.com>
+
+ * file-get-fs-options.c (netfs_S_file_get_fs_options):
+ fshelp_return_malloced_buffer renamed to iohelp_*.
+ * fsys-get-options.c (netfs_S_fsys_get_options): Likewise.
+
+Tue Jul 14 16:30:48 1998 Thomas Bushnell, n/BSG <tb@mit.edu>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Don't require the node to be
+ a directory in the null pathname case.
+
+1997-09-09 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Fix type signature of
+ short_circuited_callback1.
+
+1997-09-05 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Re-aquire the lock on DNP when
+ looping to follow a symlink.
+
+1997-08-29 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * file-reparent.c (netfs_S_file_reparent): Use a copy of
+ CRED->user when creating NEW_CRED.
+
+1997-08-28 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Don't lock DNP or assume it's
+ locked when it shouldn't be.
+
+Wed Aug 20 14:05:38 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * init-loop.c (netfs_server_loop): New args for
+ ports_manage_port_operations_multithread.
+
+Mon Jul 7 16:25:49 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * file-exec.c: Include <fcntl.h> instead of <fcntlbits.h>.
+ Suggested by Marcus G. Daniels (marcus@cathcart.sysc.pdx.edu).
+
+1997-06-11 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * trans-callback.c, set-get-trans.c: New files.
+ * Makefile (OTHERSRCS): Add trans-callback.c & set-get-trans.c.
+
+1997-06-09 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * netfs.h (struct node): Remove istranslated field.
+ (netfs_get_translator): New declaration.
+
+ * dir-lookup.c (netfs_S_dir_lookup): Use S_IPTRANS bit in nn_stat
+ st_mode field rather than istranslated field.
+ * fsys-getroot.c (netfs_S_fsys_getroot): Likewise.
+ * file-set-translator.c (netfs_S_file_set_translator): Likewise.
+ * io-stat.c (netfs_S_io_stat): Set S_IATRANS & S_IROOT bits in
+ st_mode field of returned buffer if appropriate.
+
+ * init-startup.c (netfs_startup): Supply program name with error
+ messages.
+
+Tue May 27 11:55:17 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * file-chmod.c (netfs_S_file_chmod): Turn off any read-only bits.
+
+Fri Feb 28 21:14:20 1997 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * file-reparent.c (netfs_S_file_reparent): Implement.
+
+Sun Feb 23 16:27:34 1997 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * dir-mkfile.c (netfs_S_dir_mkfile): Pass context arg to
+ netfs_make_peropen instead of parent node.
+ * file-exec.c (netfs_S_file_exec): Likewise.
+ * dir-lookup.c (netfs_S_dir_lookup): Implement shadow root
+ .. traversal.
+ Use context po argument to netfs_make_peropen & as cookie to
+ fshelp_fetch_root, instead of parent node.
+ * fsys-getroot.c (netfs_S_fsys_getroot): Add PEROPEN_CONTEXT
+ variable, and pass it to netfs_make_peropen & fshelp_fetch_root.
+ * netfs.h (struct peropen): Add shadow_root_parent & shadow_root
+ fields.
+ Removed depth field. Rename dotdotnode field to root_parent.
+ (netfs_make_peropen): Add and use CONTEXT parameter.
+ * make-peropen.c (netfs_make_peropen): Add and use CONTEXT parameter.
+ * release-peropen.c (netfs_release_peropen): Finalize new state.
+
+Wed Feb 19 23:58:40 1997 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * io-read.c (netfs_S_io_read): Support reading from symlinks.
+
+Fri Feb 14 12:34:11 1997 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * file-reparent.c (diskfs_S_file_reparent): New function, from
+ dir-reparent.c.
+ * dir-reparent.c: File removed.
+ * Makefile (FSSRCS): dir-reparent.c replaced by file-reparent.c.
+
+Mon Jan 20 16:40:02 1997 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * dir-reparent.c (netfs_S_dir_reparent): New file.
+ * Makefile (FSSRCS): Add dir-reparent.c.
+
+Sat Nov 23 16:24:04 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * file-set-translator.c (netfs_S_file_set_translator): Delete var I.
+
+Wed Nov 20 17:13:13 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * fsys-syncfs.c (netfs_S_fsys_syncfs): Use iohelp_create_iouser, not
+ iohelp_make_iouser.
+
+Mon Nov 18 17:06:39 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * netfs.h (netfs_report_access): Return error_t.
+ * file-check-access.c (netfs_S_file_check_access): Deal with
+ errors from netfs_report_access.
+
+Sat Nov 16 17:17:50 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * io-restrict-auth.c (netfs_S_io_restrict_auth): Fix several typos.
+
+ * fsys-getroot.c (netfs_S_fsys_getroot): iohelp_make_iouser ->
+ iohelp_create_iouser. New arg syntax for fshelp_fetch_root.
+
+Fri Nov 15 13:39:03 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * netfs.h (struct protid): Replace member `credential' with `user'
+ of new type. All uses of old `credential' member changed to
+ use `user' member.
+ Change all functions that used to take `struct netcred' args to
+ take `struct iouser' args. All callers changed.
+ (netfs_copy_credential, netfs_dropy_credential,
+ netfs_make_credential): Delete functions.
+ * dir-lookup.c (netfs_S_dir_lookup): netfs_copy_credential ->
+ iohelp_dup_iouser.
+ * dir-mkfile.c (netfs_S_dir_mkfile): Likewise.
+ * file-exec.c (netfs_S_file_exec): Likewise.
+ * io-duplicate.c (netfs_S_io_duplicate): Likewise.
+ * release-protid.c (netfs_release_protid): netfs_drop_credential
+ -> iohelp_free_iouser.
+ * dir-lookup.c (netfs_S_dir_lookup): Omit uses of
+ netfs_interpret_credential; do it with new structures.
+ * file-exec.c (netfs_S_file_exec): Likewise.
+ * file-getcontrol.c (netfs_S_file_getcontrol): Likewise.
+ * file-set-translator.c (netfs_S_file_set_translator): Likewise;
+ using fshelp_isowner for permission check.
+ * io-restrict-auth.c (netfs_S_io_restrict_auth): Likewise; guts
+ rewritten.
+ * dir-lookup.c (netfs_S_dir_lookup): netfs_make_credential ->
+ iohelp_make_iouser.
+ * fsys-getroot.c (netfs_S_fsys_getroot): Likewise.
+ * fsys-syncfs.c (netfs_S_fsys_syncfs): Likewise.
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): Use
+ iohelp_reauth instead of doing it by hand.
+
+Mon Oct 21 21:56:33 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * netfs.h: Add extern inline protection.
+ * netfs.c: New file.
+ * Makefile (OTHERSRCS): Add netfs.c.
+
+Wed Sep 18 12:56:05 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * std-runtime-argp.c <argp.h>: New include.
+ * std-startup-argp.c <argp.h>: New include.
+ * fsys-get-options.c (netfs_S_fsys_get_options): Initialize ARGZ
+ with the program name, and call netfs_append_args instead of
+ netfs_get_options.
+ * file-get-fs-options.c (netfs_S_file_get_fs_options): Likewise.
+ * append-std-options.c (netfs_append_std_options): Doc fix.
+ * netfs.h (netfs_append_args): New declaration.
+ (netfs_get_options): Declaration removed.
+ <argp.h>: Include removed.
+ * append-args.c (netfs_append_args): New file.
+ * Makefile (OTHERSRCS): Replace get-options.c with append-args.c
+
+ * file-get-translator.c <stdio.h>: New include.
+
+Fri Aug 16 19:20:22 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * priv.h (end_using_protid_port): Only call ports_port_deref if
+ CRED is set.
+
+Fri Jul 26 14:34:11 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * file-exec.c (netfs_S_file_exec): Unlock NP before we attempt to
+ do setuid/setgid (which otherwise can deadlock during port reauth).
+ Pay attention to the error code returned by fshelp_exec_reauth,
+ and don't make NEWPI if it's an error.
+
+Tue Jul 23 14:28:33 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * file-utimes.c (netfs_S_file_utimes): `struct timespec' now uses
+ a field prefix of `tv_'.
+
+Thu Jul 18 23:09:54 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): After attaching
+ credential to NEWPI, install it in NETFS_PORT_BUCKET->portset.
+ * make-protid.c (netfs_make_protid): If CRED is null, use
+ noinstall version of ports_create_port.
+
+Sat Jul 13 20:10:02 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): Repeat
+ auth_server_authenticate for as long as we get EINTR. Tolerate
+ other errors without crashing as well.
+
+Sun Jul 7 21:28:54 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): Don't use
+ unsafe MOVE_SEND in call to auth_server_authenticate.
+
+Thu Jul 4 16:56:53 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-write.c (netfs_S_io_write): Bother implementing O_APPEND.
+
+ * io-identity.c (netfs_S_io_identity): Don't take address of ID in
+ call to fshelp_get_identity.
+
+Wed Jul 3 11:54:46 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * dir-mkfile.c (netfs_S_dir_mkfile): Return right with MAKE_SEND,
+ not COPY_SEND.
+
+ * io-identity.c (netfs_S_io_identity): Use fshelp_get_identity
+ instead of creating port ourselves.
+ * netfs.h (struct node): Delete member identity.
+ * make-node.c (netfs_make_node): Don't initialize NP->identity.
+ * drop-node.c (netfs_drop_node): Don't deallocate NP->identity.
+
+Thu Jun 27 17:57:30 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * Makefile (LCLHDRS): Add execserver.h.
+
+Thu Jun 27 00:24:57 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * append-std-options.c: New file.
+ * Makefile (OTHERSRCS): Add append-std-options.c.
+
+Wed Jun 26 15:57:13 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * netfs.h: Change options parsing interface to match libdiskfs's:
+ (netfs_set_options, netfs_get_options): Updated to inew interface.
+ (netfs_runtime_argp, netfs_std_runtime_argp, netfs_std_startup_arg):
+ New variables.
+ (netfs_append_std_options): New declaration.
+ (netfs_parse_runtime_options, netfs_unparse_runtime_options):
+ Functions removed.
+ * set-options.c (std_runtime_options): Variable removed.
+ (parse_runtime_opt): Function removed.
+ (netfs_set_options): Change to use fshelp_set_options.
+ * fsys-set-options.c (netfs_S_fsys_set_options): Don't convert
+ options string into argv vector.
+ * fsys-get-options.c (netfs_S_fsys_get_options): Use
+ fshelp_return_malloced_buffer to prepare return value.
+ * file-get-fs-options.c (netfs_S_file_get_fs_options): Likewise.
+ * get-options.c (netfs_get_options): Call netfs_append_std_options.
+ * std-startup-argp.c, std-runtime-argp.c, runtime-argp.c: New files.
+ * parse-runtime-options.c, unparse-runtime-options.c: Files removed.
+ * Makefile (OTHERSRCS): Add runtime-argp.c, std-runtime-argp.c,
+ & std-startup-argp.c. Remove parse-runtime-options.c &
+ unparse-runtime-options.c.
+
+Tue May 14 14:05:33 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * init-init.c (netfs_fsys_identity): New variable.
+ (netfs_init): Initialize netfs_fsys_identity.
+ * drop-node.c (netfs_drop_node): Destroy NP->identity if it's set.
+ * make-node.c (netfs_make_node): Initialize NP->identity.
+ * netfs.h (struct node): New member `identity'.
+ (netfs_fsys_identity): New variable.
+ * Makefile (IOSRCS): Add io-identity.c.
+ * io-identity.c: New file.
+
+Sat May 11 01:24:31 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * startup-argp.c (parse_startup_opt): Use ARGP_ERR_UNKNOWN instead
+ of EINVAL.
+
+Thu May 9 18:54:11 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * file-get-storage-info.c (netfs_S_file_get_storage_info): fixup
+
+Thu May 9 18:15:40 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * file-get-storage-info.c (netfs_S_file_get_storage_info): Change
+ to new interface.
+
+Thu May 9 11:53:49 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * make-protid.c (netfs_make_protid): Use new ports interface; if
+ it fails return zero.
+
+ * io-select.c (netfs_S_io_select): No longer has TAG arg.
+
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): Don't pass
+ right for USER to auth_server_authenticate.
+
+ * file-sync.c (netfs_S_file_sync): Accept and ignore new omitmeta
+ arg.
+
+ * dir-rename.c (netfs_S_dir_rename): Accept and pass through excl
+ flag.
+ * dir-link.c (netfs_S_dir_link): Likewise.
+ * netfs.h (netfs_attempt_link): Add excl parm.
+ (netfs_attempt_rename): Likewise.
+
+ * netfs.h (netfs_attempt_statfs): Use struct statfs, not old
+ deprecated structure.
+ * file-statfs.c (netfs_S_file_statfs): Use new struct statfs.
+
+ * netfs.h: ioserver.h -> iohelp.h.
+
+Mon Apr 29 16:27:37 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * file-getcontrol.c (netfs_S_file_getcontrol): Use correct args to
+ ports_create_port.
+
+Sat Apr 27 06:02:03 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
+
+ * file-getcontrol.c: Use ports_create_port instead of
+ ports_allocate_port, and notice the error.
+
+Wed Apr 24 16:02:51 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-seek.c (netfs_S_io_seek): Bother to set *NEWOFFSET.
+
+Fri Apr 12 16:21:53 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * file-exec.c (netfs_S_file_exec): Copy credential using
+ netfs_copy_credential before handing it off to netfs_make_protid.
+
+ * dir-lookup.c (netfs_S_dir_lookup): netfs_make_protid's second
+ arg must be a real credential; the unauthenticated port creation
+ frob now makes a genuine (but empty) credential.
+
+Thu Apr 11 18:10:29 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * Makefile (fsys-MIGSFLAGS, fs-MIGSFLAGS, io-MIGSFLAGS,
+ ifsock-MIGSFLAGS): Find mutations.h in $(srcdir).
+
+Wed Apr 3 14:47:37 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): In check for
+ deallocation of aux_gids; check against AGBUF, not AUBUF.
+
+Tue Apr 2 09:14:30 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * io-write.c: Include <fcntl.h>.
+ (netfs_S_io_write): Verify that the user has the file open for
+ writing.
+ * io-read.c: Include <fcntl.h>.
+ (netfs_S_io_read): Verify that the user has the file open for
+ reading.
+
+Mon Apr 1 16:02:29 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * fsstubs.c (netfs_S_file_exec): Remove stub.
+ * Makefile (FSSRCS): Add file-exec.c.
+ * execserver.h: New file.
+ * file-exec.c: New file.
+
+Mon Apr 1 14:21:12 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * parse-runtime-options.c (netfs_parse_runtime_options): Pass new
+ arg to arg_parse.
+
+Tue Mar 19 14:12:32 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * Makefile (LCLHDRS): Add callbacks.h misc.h modes.h mutations.h
+ priv.h.
+
+Mon Mar 18 11:09:05 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * netfs.h (netfs_startup): Add declaration.
+
+ * netfs.h (netfs_protid_class, netfs_control_class,
+ netfs_port_bucket, netfs_root_node, netfs_auth_server_port): Make
+ this extern.
+
+ * fsys-getroot.c: Include "callbacks.h".
+
+ * file-set-translator.c (makedev): New macro.
+
+Thu Mar 14 16:47:14 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * netfs.h (netfs_attempt_mkdev): Don't pass dev_t in pieces.
+ * file-set-translator.c (netfs_S_file_set_translator): In call to
+ netfs_attempt_mkdev don't pass MAJOR and MINOR in pieces.
+
+Tue Mar 12 14:57:26 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * fsys-getroot.c (netfs_S_fsys_getroot): Add translator linkage
+ code.
+ * dir-lookup.c (netfs_S_dir_lookup): Fix up and enable translator
+ linkage code.
+
+ * netfs.h (netfs_attempt_chmod): Doc fix.
+ (netfs_attempt_mksymlink, netfs_attempt_mkdev,
+ netfs_set_translator): New declarations.
+ * file-set-translator.c: New file.
+ * fsstubs.c (netfs_S_file_set_translator): Delete function.
+ * Makefile (FSSRCS): Add file-set-translator.c.
+
+Mon Mar 11 16:44:08 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu>
+
+ * fsstubs.c (netfs_S_file_get_translator): Remove function.
+ * file-get-translator.c: New file.
+ * Makefile (FSSRCS): Add file-get-translator.c.
+
+Mon Mar 4 13:36:36 1996 Miles Bader <miles@gnu.ai.mit.edu>
+
+ * fsys-set-options.c, fsys-get-options.c, file-get-fs-options.c:
+ New files.
+ * netfs.h (netfs_startup_argp, netfs_get_options,
+ netfs_set_options, netfs_parse_runtime_options,
+ netfs_unparse_runtime_options): New declarations.
+ * Makefile (OTHERSRCS): Add startup-argp.c, set-options.c,
+ get-options.c, parse-runtime-options.c, & unparse-runtime-options.c.
+ (FSYSSRCS): Add fsys-set-options.c & fsys-get-options.c.
+ (FSSRCS): Add file-get-fs-options.c.
+ * unparse-runtime-options.c (netfs_unparse_runtime_options): Add
+ comment, and remove bogus semi.
+ * fsysstubs.c (netfs_S_fsys_set_options, netfs_S_fsys_get_options):
+ Functions removed.
+ * fsstubs.c (netfs_S_file_get_fs_options): Function removed.
+ * parse-runtime-options.c: Include "netfs.h", not "priv.h".
+ * set-options.c: Likewise.
+ (parse_runtime_opt): New function.
+ * priv.h: Include <hurd/hurd_types.h>
+
+Tue Apr 11 11:15:30 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu>
+
+ * Makefile: New file.
diff --git a/libnetfs/Makefile b/libnetfs/Makefile
new file mode 100644
index 00000000..b11f1ecd
--- /dev/null
+++ b/libnetfs/Makefile
@@ -0,0 +1,70 @@
+#
+# Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation
+# Written by Michael I. Bushnell.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+dir := libnetfs
+makemode := library
+libname = libnetfs
+
+FSSRCS= dir-link.c dir-lookup.c dir-mkdir.c dir-mkfile.c \
+ dir-notice-changes.c dir-readdir.c dir-rename.c \
+ dir-rmdir.c dir-unlink.c file-chauthor.c \
+ file-check-access.c file-chflags.c file-chmod.c file-chown.c \
+ file-exec.c file-get-fs-options.c file-get-storage-info.c \
+ file-get-translator.c file-getcontrol.c file-getlinknode.c \
+ file-lock-stat.c file-lock.c file-set-size.c \
+ file-set-translator.c file-statfs.c file-sync.c file-syncfs.c \
+ file-utimes.c file-reparent.c fsstubs.c
+
+IOSRCS= io-read.c io-readable.c io-seek.c io-write.c io-stat.c io-async.c \
+ io-set-all-openmodes.c io-get-openmodes.c io-set-some-openmodes.c \
+ io-clear-some-openmodes.c io-mod-owner.c io-get-owner.c io-select.c \
+ io-get-icky-async-id.c io-reauthenticate.c io-restrict-auth.c \
+ io-duplicate.c iostubs.c io-identity.c io-revoke.c io-pathconf.c
+
+FSYSSRCS= fsys-syncfs.c fsys-getroot.c fsys-get-options.c fsys-set-options.c \
+ fsysstubs.c
+
+IFSOCKSRCS=
+OTHERSRCS= drop-node.c init-init.c make-node.c make-peropen.c make-protid.c \
+ init-loop.c demuxer.c shutdown.c release-protid.c release-peropen.c \
+ init-startup.c startup-argp.c set-options.c append-args.c \
+ runtime-argp.c std-runtime-argp.c std-startup-argp.c \
+ append-std-options.c trans-callback.c set-get-trans.c \
+ nref.c nrele.c nput.c
+
+SRCS= $(OTHERSRCS) $(FSSRCS) $(IOSRCS) $(FSYSSRCS) $(IFSOCKSRCS)
+
+LCLHDRS = netfs.h callbacks.h misc.h modes.h mutations.h priv.h execserver.h
+installhdrs=netfs.h
+
+MIGSTUBS= ioServer.o fsServer.o fsysServer.o ifsockServer.o
+
+OBJS=$(sort $(SRCS:.c=.o) $(MIGSTUBS))
+
+fsys-MIGSFLAGS = -imacros $(srcdir)/mutations.h
+fs-MIGSFLAGS = -imacros $(srcdir)/mutations.h
+io-MIGSFLAGS = -imacros $(srcdir)/mutations.h
+ifsock-MIGSFLAGS = -imacros $(srcdir)/mutations.h
+MIGCOMSFLAGS = -prefix netfs_
+
+
+include ../Makeconf
+
+fsysServer.c fsys_S.h fsServer.c fs_S.h ioServer.c io_S.h ifsockServer.c ifsock_S.h: mutations.h
diff --git a/libnetfs/append-args.c b/libnetfs/append-args.c
new file mode 100644
index 00000000..867c7bbd
--- /dev/null
+++ b/libnetfs/append-args.c
@@ -0,0 +1,31 @@
+/* Append current command-line arguments
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+
+/* Append to the malloced string *ARGZ of length *ARGZ_LEN a NUL-separated
+ list of the arguments to this translator. */
+error_t
+netfs_append_args (char **argz, size_t *argz_len)
+{
+ return netfs_append_std_options (argz, argz_len);
+}
diff --git a/libnetfs/append-std-options.c b/libnetfs/append-std-options.c
new file mode 100644
index 00000000..1590d930
--- /dev/null
+++ b/libnetfs/append-std-options.c
@@ -0,0 +1,31 @@
+/* Get standard netfs run-time options
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+
+/* Appends to ARGZ & ARGZ_LEN '\0'-separated options describing the standard
+ netfs option state. */
+error_t
+netfs_append_std_options (char **argz, unsigned *argz_len)
+{
+ return 0;
+}
diff --git a/libnetfs/callbacks.h b/libnetfs/callbacks.h
new file mode 100644
index 00000000..1dc3ab06
--- /dev/null
+++ b/libnetfs/callbacks.h
@@ -0,0 +1,25 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+
+/* Translator callback function declarations. */
+
+fshelp_fetch_root_callback1_t _netfs_translator_callback1;
+fshelp_fetch_root_callback2_t _netfs_translator_callback2;
diff --git a/libnetfs/demuxer.c b/libnetfs/demuxer.c
new file mode 100644
index 00000000..6b4f727f
--- /dev/null
+++ b/libnetfs/demuxer.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+
+int
+netfs_demuxer (mach_msg_header_t *inp,
+ mach_msg_header_t *outp)
+{
+ int netfs_fs_server (mach_msg_header_t *, mach_msg_header_t *);
+ int netfs_io_server (mach_msg_header_t *, mach_msg_header_t *);
+ int netfs_fsys_server (mach_msg_header_t *, mach_msg_header_t *);
+ int netfs_ifsock_server (mach_msg_header_t *, mach_msg_header_t *);
+
+ return (netfs_io_server (inp, outp)
+ || netfs_fs_server (inp, outp)
+ || ports_notify_server (inp, outp)
+ || netfs_fsys_server (inp, outp)
+ || ports_interrupt_server (inp, outp)
+ || netfs_ifsock_server (inp, outp));
+}
+
diff --git a/libnetfs/dir-link.c b/libnetfs/dir-link.c
new file mode 100644
index 00000000..1c31b8f9
--- /dev/null
+++ b/libnetfs/dir-link.c
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_link (struct protid *diruser, struct protid *fileuser, char *name,
+ int excl)
+{
+ error_t err;
+
+ if (!diruser)
+ return EOPNOTSUPP;
+
+ if (!fileuser)
+ return EXDEV;
+
+ /* Note that nothing is locked here */
+ err = netfs_attempt_link (diruser->user, diruser->po->np,
+ fileuser->po->np, name, excl);
+ if (!err)
+ mach_port_deallocate (mach_task_self (), fileuser->pi.port_right);
+ return err;
+}
+
+
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
new file mode 100644
index 00000000..5019017b
--- /dev/null
+++ b/libnetfs/dir-lookup.c
@@ -0,0 +1,376 @@
+/*
+ Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <fcntl.h>
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <hurd/paths.h>
+#include "netfs.h"
+#include "fs_S.h"
+#include "callbacks.h"
+#include "misc.h"
+
+error_t
+netfs_S_dir_lookup (struct protid *diruser,
+ char *filename,
+ int flags,
+ mode_t mode,
+ retry_type *do_retry,
+ char *retry_name,
+ mach_port_t *retry_port,
+ mach_msg_type_name_t *retry_port_type)
+{
+ int create; /* true if O_CREAT flag set */
+ int excl; /* true if O_EXCL flag set */
+ int mustbedir = 0; /* true if the result must be S_IFDIR */
+ int lastcomp = 0; /* true if we are at the last component */
+ int newnode = 0; /* true if this node is newly created */
+ int nsymlinks = 0;
+ struct node *dnp, *np;
+ char *nextname;
+ error_t error;
+ struct protid *newpi;
+
+ if (!diruser)
+ return EOPNOTSUPP;
+
+ create = (flags & O_CREAT);
+ excl = (flags & O_EXCL);
+
+ /* Skip leading slashes */
+ while (*filename == '/')
+ filename++;
+
+ *retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
+ *do_retry = FS_RETRY_NORMAL;
+ *retry_name = '\0';
+
+ if (*filename == '\0')
+ {
+ /* Set things up in the state expected by the code from gotit: on. */
+ dnp = 0;
+ np = diruser->po->np;
+ mutex_lock (&np->lock);
+ netfs_nref (np);
+ goto gotit;
+ }
+
+ dnp = diruser->po->np;
+ mutex_lock (&dnp->lock);
+ np = 0;
+
+ netfs_nref (dnp); /* acquire a reference for later netfs_nput */
+
+ do
+ {
+ assert (!lastcomp);
+
+ /* Find the name of the next pathname component */
+ nextname = index (filename, '/');
+
+ if (nextname)
+ {
+ *nextname++ = '\0';
+ while (*nextname == '/')
+ nextname++;
+ if (*nextname == '\0')
+ {
+ /* These are the rules for filenames ending in /. */
+ nextname = 0;
+ lastcomp = 1;
+ mustbedir = 1;
+ create = 0;
+ }
+ else
+ lastcomp = 0;
+ }
+ else
+ lastcomp = 1;
+
+ np = 0;
+
+ retry_lookup:
+
+ if ((dnp == netfs_root_node || dnp == diruser->po->shadow_root)
+ && filename[0] == '.' && filename[1] == '.' && filename[2] == '\0')
+ if (dnp == diruser->po->shadow_root)
+ /* We're at the root of a shadow tree. */
+ {
+ *do_retry = FS_RETRY_REAUTH;
+ *retry_port = diruser->po->shadow_root_parent;
+ *retry_port_type = MACH_MSG_TYPE_COPY_SEND;
+ if (! lastcomp)
+ strcpy (retry_name, nextname);
+ error = 0;
+ mutex_unlock (&dnp->lock);
+ goto out;
+ }
+ else if (diruser->po->root_parent != MACH_PORT_NULL)
+ /* We're at a real translator root; even if DIRUSER->po has a
+ shadow root, we can get here if its in a directory that was
+ renamed out from under it... */
+ {
+ *do_retry = FS_RETRY_REAUTH;
+ *retry_port = diruser->po->root_parent;
+ *retry_port_type = MACH_MSG_TYPE_COPY_SEND;
+ if (!lastcomp)
+ strcpy (retry_name, nextname);
+ error = 0;
+ mutex_unlock (&dnp->lock);
+ goto out;
+ }
+ else
+ /* We are global root */
+ {
+ error = 0;
+ np = dnp;
+ netfs_nref (np);
+ }
+ else
+ /* Attempt a lookup on the next pathname component. */
+ error = netfs_attempt_lookup (diruser->user, dnp, filename, &np);
+
+ /* At this point, DNP is unlocked */
+
+ /* Implement O_EXCL flag here */
+ if (lastcomp && create && excl && !error)
+ error = EEXIST;
+
+ /* Create the new node if necessary */
+ if (lastcomp && create && error == ENOENT)
+ {
+ mode &= ~(S_IFMT | S_ISPARE | S_ISVTX);
+ mode |= S_IFREG;
+ mutex_lock (&dnp->lock);
+ error = netfs_attempt_create_file (diruser->user, dnp,
+ filename, mode, &np);
+
+ /* If someone has already created the file (between our lookup
+ and this create) then we just got EEXIST. If we are
+ EXCL, that's fine; otherwise, we have to retry the lookup. */
+ if (error == EEXIST && !excl)
+ {
+ mutex_lock (&dnp->lock);
+ goto retry_lookup;
+ }
+
+ newnode = 1;
+ }
+
+ /* All remaining errors get returned to the user */
+ if (error)
+ goto out;
+
+ error = netfs_validate_stat (np, diruser->user);
+ if (error)
+ goto out;
+
+ if ((((flags & O_NOTRANS) == 0) || !lastcomp)
+ && ((np->nn_stat.st_mode & S_IPTRANS)
+ || S_ISFIFO (np->nn_stat.st_mode)
+ || S_ISCHR (np->nn_stat.st_mode)
+ || S_ISBLK (np->nn_stat.st_mode)
+ || fshelp_translated (&np->transbox)))
+ {
+ mach_port_t dirport;
+
+ /* A callback function for short-circuited translators.
+ S_ISLNK and S_IFSOCK are handled elsewhere. */
+ error_t short_circuited_callback1 (void *cookie1, void *cookie2,
+ uid_t *uid, gid_t *gid,
+ char **argz, size_t *argz_len)
+ {
+ struct node *np = cookie1;
+ error_t err;
+
+ err = netfs_validate_stat (np, diruser->user);
+ if (err)
+ return err;
+
+ switch (np->nn_stat.st_mode & S_IFMT)
+ {
+ case S_IFCHR:
+ case S_IFBLK:
+ asprintf (argz, "%s%c%d%c%d",
+ (S_ISCHR (np->nn_stat.st_mode)
+ ? _HURD_CHRDEV : _HURD_BLKDEV),
+ 0, major (np->nn_stat.st_rdev),
+ 0, minor (np->nn_stat.st_rdev));
+ *argz_len = strlen (*argz) + 1;
+ *argz_len += strlen (*argz + *argz_len) + 1;
+ *argz_len += strlen (*argz + *argz_len) + 1;
+ break;
+ case S_IFIFO:
+ asprintf (argz, "%s", _HURD_FIFO);
+ *argz_len = strlen (*argz) + 1;
+ break;
+ default:
+ return ENOENT;
+ }
+
+ *uid = np->nn_stat.st_uid;
+ *gid = np->nn_stat.st_gid;
+
+ return 0;
+ }
+
+ /* Create an unauthenticated port for DNP, and then
+ unlock it. */
+ newpi =
+ netfs_make_protid (netfs_make_peropen (dnp, 0, diruser->po),
+ iohelp_create_iouser (make_idvec (),
+ make_idvec ()));
+ dirport = ports_get_right (newpi);
+ mach_port_insert_right (mach_task_self (), dirport, dirport,
+ MACH_MSG_TYPE_MAKE_SEND);
+ ports_port_deref (newpi);
+
+ error = fshelp_fetch_root (&np->transbox, diruser->po,
+ dirport,
+ diruser->user,
+ lastcomp ? flags : 0,
+ ((np->nn_stat.st_mode & S_IPTRANS)
+ ? _netfs_translator_callback1
+ : short_circuited_callback1),
+ _netfs_translator_callback2,
+ do_retry, retry_name, retry_port);
+
+ if (error != ENOENT)
+ {
+ netfs_nrele (dnp);
+ netfs_nput (np);
+ *retry_port_type = MACH_MSG_TYPE_MOVE_SEND;
+ if (!lastcomp && !error)
+ {
+ strcat (retry_name, "/");
+ strcat (retry_name, nextname);
+ }
+ return error;
+ }
+
+ /* ENOENT means there was a hiccup, and the translator vanished
+ while NP was unlocked inside fshelp_fetch_root; continue as normal. */
+ error = 0;
+ }
+
+ if (S_ISLNK (np->nn_stat.st_mode)
+ && (!lastcomp
+ || mustbedir /* "foo/" must see that foo points to a dir */
+ || !(flags & (O_NOLINK|O_NOTRANS))))
+ {
+ size_t nextnamelen, newnamelen, linklen;
+ char *linkbuf;
+
+ /* Handle symlink interpretation */
+ if (nsymlinks++ > netfs_maxsymlinks)
+ {
+ error = ELOOP;
+ goto out;
+ }
+
+ linklen = np->nn_stat.st_size;
+
+ nextnamelen = nextname ? strlen (nextname) + 1 : 0;
+ newnamelen = nextnamelen + linklen + 1;
+ linkbuf = alloca (newnamelen);
+
+ error = netfs_attempt_readlink (diruser->user, np, linkbuf);
+ if (error)
+ goto out;
+
+ if (nextname)
+ {
+ linkbuf[linklen] = '/';
+ bcopy (nextname, linkbuf + linklen + 1,
+ nextnamelen - 1);
+ }
+ linkbuf[nextnamelen + linklen] = '\0';
+
+ if (linkbuf[0] == '/')
+ {
+ /* Punt to the caller */
+ *do_retry = FS_RETRY_MAGICAL;
+ *retry_port = MACH_PORT_NULL;
+ strcpy (retry_name, linkbuf);
+ goto out;
+ }
+
+ filename = linkbuf;
+ if (lastcomp)
+ {
+ lastcomp = 0;
+
+ /* Symlinks to nonexistent files aren't allowed to cause
+ creation, so clear the flag here. */
+ create = 0;
+ }
+ netfs_nput (np);
+ mutex_lock (&dnp->lock);
+ np = 0;
+ }
+ else
+ {
+ /* Normal nodes here for next filename component */
+ filename = nextname;
+ netfs_nrele (dnp);
+
+ if (lastcomp)
+ dnp = 0;
+ else
+ {
+ dnp = np;
+ np = 0;
+ }
+ }
+ }
+ while (filename && *filename);
+
+ /* At this point, NP is the node to return. */
+ gotit:
+
+ if (mustbedir)
+ {
+ netfs_validate_stat (np, diruser->user);
+ if (!S_ISDIR (np->nn_stat.st_mode))
+ {
+ error = ENOTDIR;
+ goto out;
+ }
+ }
+ error = netfs_check_open_permissions (diruser->user, np,
+ flags, newnode);
+ if (error)
+ goto out;
+
+ flags &= ~OPENONLY_STATE_MODES;
+
+ newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po),
+ iohelp_dup_iouser (diruser->user));
+ *retry_port = ports_get_right (newpi);
+ ports_port_deref (newpi);
+
+ out:
+ if (np)
+ netfs_nput (np);
+ if (dnp)
+ netfs_nrele (dnp);
+ return error;
+}
diff --git a/libnetfs/dir-mkdir.c b/libnetfs/dir-mkdir.c
new file mode 100644
index 00000000..33feb25f
--- /dev/null
+++ b/libnetfs/dir-mkdir.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_mkdir (struct protid *user, char *name, mode_t mode)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mode &= ~(S_IFMT|S_ISPARE|S_ISVTX);
+ mode |= S_IFDIR;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_mkdir (user->user, user->po->np, name, mode);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/dir-mkfile.c b/libnetfs/dir-mkfile.c
new file mode 100644
index 00000000..abd8d0ad
--- /dev/null
+++ b/libnetfs/dir-mkfile.c
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "misc.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_mkfile (struct protid *diruser, int flags, mode_t mode,
+ mach_port_t *newfile, mach_msg_type_name_t *newfiletype)
+{
+ error_t err;
+ struct node *np;
+ struct protid *newpi;
+
+ mutex_lock (&diruser->po->np->lock);
+ err = netfs_attempt_mkfile (diruser->user, diruser->po->np, mode, &np);
+
+ if (!err)
+ {
+ /* the dir is now unlocked and NP is locked */
+ flags &= OPENONLY_STATE_MODES;
+ newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po),
+ iohelp_dup_iouser (diruser->user));
+ *newfile = ports_get_right (newpi);
+ *newfiletype = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ netfs_nput (np);
+ return 0;
+ }
+ else
+ return err;
+}
+
diff --git a/libnetfs/dir-notice-changes.c b/libnetfs/dir-notice-changes.c
new file mode 100644
index 00000000..e124e0bd
--- /dev/null
+++ b/libnetfs/dir-notice-changes.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_notice_changes (struct protid *dir,
+ mach_port_t port)
+{
+ /* Don't even try */
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/dir-readdir.c b/libnetfs/dir-readdir.c
new file mode 100644
index 00000000..36f934e8
--- /dev/null
+++ b/libnetfs/dir-readdir.c
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <fcntl.h>
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_readdir (struct protid *user,
+ char **data,
+ mach_msg_type_number_t *datacnt,
+ boolean_t *data_dealloc,
+ int entry,
+ int nentries,
+ vm_size_t bufsiz,
+ int *amt)
+{
+ error_t err;
+ struct node *np;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ np = user->po->np;
+ mutex_lock (&np->lock);
+
+ err = 0;
+ if ((user->po->openstat & O_READ) == 0)
+ err = EBADF;
+ if (!err)
+ err = netfs_validate_stat (np, user->user);
+ if (!err && (np->nn_stat.st_mode & S_IFMT) != S_IFDIR)
+ err = ENOTDIR;
+ if (!err)
+ err = netfs_get_dirents (user->user, np, entry, nentries, data,
+ datacnt, bufsiz, amt);
+ *data_dealloc = 1; /* XXX */
+ mutex_unlock (&np->lock);
+ return err;
+}
diff --git a/libnetfs/dir-rename.c b/libnetfs/dir-rename.c
new file mode 100644
index 00000000..0215376b
--- /dev/null
+++ b/libnetfs/dir-rename.c
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_rename (struct protid *fromdiruser, char *fromname,
+ struct protid *todiruser, char *toname, int excl)
+{
+ error_t err;
+
+ if (!fromdiruser)
+ return EOPNOTSUPP;
+
+ if (!todiruser)
+ return EXDEV;
+
+ /* Note that nothing is locked here */
+ err = netfs_attempt_rename (fromdiruser->user, fromdiruser->po->np,
+ fromname, todiruser->po->np, toname, excl);
+ if (!err)
+ mach_port_deallocate (mach_task_self (), todiruser->pi.port_right);
+ return err;
+}
+
diff --git a/libnetfs/dir-rmdir.c b/libnetfs/dir-rmdir.c
new file mode 100644
index 00000000..9a5941d3
--- /dev/null
+++ b/libnetfs/dir-rmdir.c
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_rmdir (struct protid *diruser, char *name)
+{
+ error_t err;
+
+ if (!diruser)
+ return EOPNOTSUPP;
+
+ mutex_lock (&diruser->po->np->lock);
+ err = netfs_attempt_rmdir (diruser->user, diruser->po->np, name);
+ mutex_unlock (&diruser->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/dir-unlink.c b/libnetfs/dir-unlink.c
new file mode 100644
index 00000000..8077514a
--- /dev/null
+++ b/libnetfs/dir-unlink.c
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_dir_unlink (struct protid *user, char *name)
+{
+ error_t err;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_unlink (user->user, user->po->np, name);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/drop-node.c b/libnetfs/drop-node.c
new file mode 100644
index 00000000..b2ec95e3
--- /dev/null
+++ b/libnetfs/drop-node.c
@@ -0,0 +1,31 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+
+void
+netfs_drop_node (struct node *np)
+{
+ fshelp_drop_transbox (&np->transbox);
+ netfs_node_norefs (np);
+ spin_unlock (&netfs_node_refcnt_lock);
+}
+
+
diff --git a/libnetfs/execserver.h b/libnetfs/execserver.h
new file mode 100644
index 00000000..6c432386
--- /dev/null
+++ b/libnetfs/execserver.h
@@ -0,0 +1,23 @@
+/*
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+
+/* To contact the execserver */
+file_t _netfs_exec;
diff --git a/libnetfs/file-chauthor.c b/libnetfs/file-chauthor.c
new file mode 100644
index 00000000..ec7f6177
--- /dev/null
+++ b/libnetfs/file-chauthor.c
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_chauthor (struct protid *user,
+ uid_t author)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_chauthor (user->user, user->po->np, author);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
+
diff --git a/libnetfs/file-check-access.c b/libnetfs/file-check-access.c
new file mode 100644
index 00000000..8e36ede1
--- /dev/null
+++ b/libnetfs/file-check-access.c
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_check_access (struct protid *user,
+ int *types)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_report_access (user->user, user->po->np, types);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-chflags.c b/libnetfs/file-chflags.c
new file mode 100644
index 00000000..068a1cea
--- /dev/null
+++ b/libnetfs/file-chflags.c
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_chflags (struct protid *user,
+ int flags)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_chflags (user->user, user->po->np, flags);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-chmod.c b/libnetfs/file-chmod.c
new file mode 100644
index 00000000..0f082f18
--- /dev/null
+++ b/libnetfs/file-chmod.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_chmod (struct protid *user,
+ mode_t mode)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mode &= ~(S_IFMT | S_ISPARE | S_ITRANS);
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_chmod (user->user, user->po->np, mode);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-chown.c b/libnetfs/file-chown.c
new file mode 100644
index 00000000..4b724048
--- /dev/null
+++ b/libnetfs/file-chown.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_chown (struct protid *user,
+ uid_t owner,
+ uid_t group)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_chown (user->user, user->po->np,
+ owner, group);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-exec.c b/libnetfs/file-exec.c
new file mode 100644
index 00000000..f928292f
--- /dev/null
+++ b/libnetfs/file-exec.c
@@ -0,0 +1,150 @@
+/*
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+/* Written by Michael I. Bushnell, p/BSG. */
+
+#include "netfs.h"
+#include "execserver.h"
+#include "fs_S.h"
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <hurd/exec.h>
+#include <hurd/paths.h>
+#include <string.h>
+#include <idvec.h>
+
+kern_return_t
+netfs_S_file_exec (struct protid *cred,
+ task_t task,
+ int flags,
+ char *argv,
+ u_int argvlen,
+ char *envp,
+ u_int envplen,
+ mach_port_t *fds,
+ u_int fdslen,
+ mach_port_t *portarray,
+ u_int portarraylen,
+ int *intarray,
+ u_int intarraylen,
+ mach_port_t *deallocnames,
+ u_int deallocnameslen,
+ mach_port_t *destroynames,
+ u_int destroynameslen)
+{
+ struct node *np;
+ error_t err;
+ uid_t uid;
+ gid_t gid;
+ mode_t mode;
+ int suid, sgid;
+
+ if (!cred)
+ return EOPNOTSUPP;
+
+ if (_netfs_exec == MACH_PORT_NULL)
+ _netfs_exec = file_name_lookup (_SERVERS_EXEC, 0, 0);
+ if (_netfs_exec == MACH_PORT_NULL)
+ return EOPNOTSUPP;
+
+ if ((cred->po->openstat & O_EXEC) == 0)
+ return EBADF;
+
+ np = cred->po->np;
+
+ mutex_lock (&np->lock);
+ mode = np->nn_stat.st_mode;
+ uid = np->nn_stat.st_uid;
+ gid = np->nn_stat.st_gid;
+ err = netfs_validate_stat (np, cred->user);
+ mutex_unlock (&np->lock);
+
+ if (err)
+ return err;
+
+ if (!((mode & (S_IXUSR|S_IXGRP|S_IXOTH))
+ || ((mode & S_IUSEUNK) && (mode & (S_IEXEC << S_IUNKSHIFT)))))
+ return EACCES;
+
+ if ((mode & S_IFMT) == S_IFDIR)
+ return EACCES;
+
+ suid = mode & S_ISUID;
+ sgid = mode & S_ISGID;
+ if (suid || sgid)
+ {
+ int secure = 0;
+ error_t get_file_ids (struct idvec *uidsvec, struct idvec *gidsvec)
+ {
+ error_t err;
+
+ err = idvec_merge (uidsvec, cred->user->uids);
+ if (! err)
+ err = idvec_merge (gidsvec, cred->user->gids);
+
+ return err;
+ }
+ err =
+ fshelp_exec_reauth (suid, uid, sgid, gid,
+ netfs_auth_server_port, get_file_ids,
+ portarray, portarraylen, fds, fdslen, &secure);
+ if (secure)
+ flags |= EXEC_SECURE | EXEC_NEWTASK;
+ }
+
+ /* If the user can't read the file, then we should use a new task,
+ which would be inaccessible to the user. Actually, this doesn't
+ work, because the proc server will still give out the task port
+ to the user. Too many things depend on that that it can't be
+ changed. So this vague attempt isn't even worth trying. */
+#if 0
+ if (diskfs_access (np, S_IREAD, cred))
+ flags |= EXEC_NEWTASK;
+#endif
+
+ if (! err)
+ {
+ struct protid *newpi =
+ netfs_make_protid (netfs_make_peropen (np, O_READ, cred->po),
+ iohelp_dup_iouser (cred->user));
+ err = exec_exec (_netfs_exec,
+ ports_get_right (newpi),
+ MACH_MSG_TYPE_MAKE_SEND,
+ task, flags, argv, argvlen, envp, envplen,
+ fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
+ portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
+ intarray, intarraylen, deallocnames, deallocnameslen,
+ destroynames, destroynameslen);
+ ports_port_deref (newpi);
+ }
+
+ if (! err)
+ {
+ unsigned int i;
+
+ mach_port_deallocate (mach_task_self (), task);
+ for (i = 0; i < fdslen; i++)
+ mach_port_deallocate (mach_task_self (), fds[i]);
+ for (i = 0; i < portarraylen; i++)
+ mach_port_deallocate (mach_task_self (), portarray[i]);
+ }
+
+ return err;
+}
diff --git a/libnetfs/file-get-fs-options.c b/libnetfs/file-get-fs-options.c
new file mode 100644
index 00000000..1a18c72d
--- /dev/null
+++ b/libnetfs/file-get-fs-options.c
@@ -0,0 +1,62 @@
+/* Unparse run-time options
+
+ Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <errno.h>
+#include <argz.h>
+#include <string.h>
+
+#include "netfs.h"
+#include "fs_S.h"
+
+/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET'
+ are pending libnetfs being fleshed out some more. */
+
+/* Implement file_get_fs_options as described in <hurd/fs.defs>. */
+error_t
+netfs_S_file_get_fs_options (struct protid *user,
+ char **data, mach_msg_type_number_t *data_len)
+{
+ error_t err;
+ char *argz = 0;
+ size_t argz_len = 0;
+
+ if (! user)
+ return EOPNOTSUPP;
+
+ err = argz_add (&argz, &argz_len, program_invocation_name);
+ if (! err)
+ {
+#if NOT_YET
+ rwlock_reader_lock (&netfs_fsys_lock);
+#endif
+ err = netfs_append_args (&argz, &argz_len);
+#if NOT_YET
+ rwlock_reader_unlock (&netfs_fsys_lock);
+#endif
+ }
+
+ if (! err)
+ /* Move ARGZ from a malloced buffer into a vm_alloced one. */
+ err = iohelp_return_malloced_buffer (argz, argz_len, data, data_len);
+ else
+ free (argz);
+
+ return err;
+}
diff --git a/libnetfs/file-get-storage-info.c b/libnetfs/file-get-storage-info.c
new file mode 100644
index 00000000..e9eb32bb
--- /dev/null
+++ b/libnetfs/file-get-storage-info.c
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+#include <sys/mman.h>
+
+error_t
+netfs_S_file_get_storage_info (struct protid *user,
+ mach_port_t **ports,
+ mach_msg_type_name_t *ports_type,
+ mach_msg_type_number_t *num_ports,
+ int **ints, mach_msg_type_number_t *num_ints,
+ off_t **offsets,
+ mach_msg_type_number_t *num_offsets,
+ char **data, mach_msg_type_number_t *data_len)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ *data_len = 0;
+ *num_offsets = 0;
+ *num_ports = 0;
+
+ if (*num_ints == 0)
+ /* Argh */
+ {
+ *ints = mmap (0, sizeof (int), PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ if (*ints == (int *) -1)
+ return errno;
+ }
+
+ *num_ints = 1;
+ (*ints)[0] = STORAGE_NETWORK;
+
+ return 0;
+}
diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c
new file mode 100644
index 00000000..1489162a
--- /dev/null
+++ b/libnetfs/file-get-translator.c
@@ -0,0 +1,113 @@
+/*
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <string.h>
+#include <stdio.h>
+#include <hurd/paths.h>
+#include "netfs.h"
+#include "fs_S.h"
+#include <sys/mman.h>
+
+error_t
+netfs_S_file_get_translator (struct protid *user,
+ char **trans,
+ mach_msg_type_number_t *translen)
+{
+ struct node *np;
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ np = user->po->np;
+ mutex_lock (&np->lock);
+ err = netfs_validate_stat (np, user->user);
+
+ if (err)
+ {
+ mutex_unlock (&np->lock);
+ return err;
+ }
+
+ if (S_ISLNK (np->nn_stat.st_mode))
+ {
+ unsigned int len = sizeof _HURD_SYMLINK + np->nn_stat.st_size + 1;
+
+ if (len > *translen)
+ *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ bcopy (_HURD_SYMLINK, *trans, sizeof _HURD_SYMLINK);
+
+ err = netfs_attempt_readlink (user->user, np,
+ *trans + sizeof _HURD_SYMLINK);
+ if (!err)
+ {
+ (*trans)[sizeof _HURD_SYMLINK + np->nn_stat.st_size] = '\0';
+ *translen = len;
+ }
+ }
+ else if (S_ISCHR (np->nn_stat.st_mode) || S_ISBLK (np->nn_stat.st_mode))
+ {
+ char *buf;
+ unsigned int buflen;
+
+ buflen = asprintf (&buf, "%s%c%d%c%d",
+ (S_ISCHR (np->nn_stat.st_mode)
+ ? _HURD_CHRDEV
+ : _HURD_BLKDEV),
+ '\0', (np->nn_stat.st_rdev >> 8) & 0377,
+ '\0', (np->nn_stat.st_rdev) & 0377);
+ buflen++; /* terminating nul */
+
+ if (buflen > *translen)
+ *trans = mmap (0, buflen, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ bcopy (buf, *trans, buflen);
+ free (buf);
+ *translen = buflen;
+ err = 0;
+ }
+ else if (S_ISFIFO (np->nn_stat.st_mode))
+ {
+ unsigned int len;
+
+ len = sizeof _HURD_FIFO;
+ if (len > *translen)
+ *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ bcopy (_HURD_FIFO, *trans, sizeof _HURD_FIFO);
+ *translen = len;
+ err = 0;
+ }
+ else if (S_ISSOCK (np->nn_stat.st_mode))
+ {
+ unsigned int len;
+
+ len = sizeof _HURD_IFSOCK;
+ if (len > *translen)
+ *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+ bcopy (_HURD_IFSOCK, *trans, sizeof _HURD_IFSOCK);
+ *translen = len;
+ err = 0;
+ }
+ else
+ err = EINVAL;
+
+ mutex_unlock (&np->lock);
+
+ return err;
+}
diff --git a/libnetfs/file-getcontrol.c b/libnetfs/file-getcontrol.c
new file mode 100644
index 00000000..c33d524f
--- /dev/null
+++ b/libnetfs/file-getcontrol.c
@@ -0,0 +1,49 @@
+/* Return the filesystem corresponding to a file
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fsys_S.h"
+
+error_t
+netfs_S_file_getcontrol (struct protid *user,
+ mach_port_t *control,
+ mach_msg_type_name_t *controltype)
+{
+ error_t err;
+ struct port_info *pi;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ if (!idvec_contains (user->user->uids, 0))
+ return EPERM;
+
+ /* They've got root; give it to them. */
+ err = ports_create_port (netfs_control_class, netfs_port_bucket,
+ sizeof (struct port_info), &pi);
+ if (err)
+ return err;
+
+ *control = ports_get_right (pi);
+ *controltype = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (pi);
+ return 0;
+}
diff --git a/libnetfs/file-getlinknode.c b/libnetfs/file-getlinknode.c
new file mode 100644
index 00000000..9503d1d1
--- /dev/null
+++ b/libnetfs/file-getlinknode.c
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_getlinknode (struct protid *user,
+ file_t *port,
+ mach_msg_type_name_t *porttype)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ if (user->po->np == netfs_root_node)
+ return EBUSY;
+
+ *port = ports_get_right (user);
+ *porttype = MACH_MSG_TYPE_MAKE_SEND;
+ return 0;
+}
+
+
diff --git a/libnetfs/file-lock-stat.c b/libnetfs/file-lock-stat.c
new file mode 100644
index 00000000..12f5eccf
--- /dev/null
+++ b/libnetfs/file-lock-stat.c
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_lock_stat (struct protid *user,
+ int *mystatus,
+ int *otherstatus)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ *mystatus = user->po->lock_status;
+ *otherstatus = user->po->np->userlock.type;
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/file-lock.c b/libnetfs/file-lock.c
new file mode 100644
index 00000000..cedc9c1d
--- /dev/null
+++ b/libnetfs/file-lock.c
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_lock (struct protid *user,
+ int flags)
+{
+ error_t err;
+ if (!user)
+ return EOPNOTSUPP;
+ mutex_lock (&user->po->np->lock);
+ err = fshelp_acquire_lock (&user->po->np->userlock, &user->po->lock_status,
+ &user->po->np->lock, flags);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-reparent.c b/libnetfs/file-reparent.c
new file mode 100644
index 00000000..6397951e
--- /dev/null
+++ b/libnetfs/file-reparent.c
@@ -0,0 +1,67 @@
+/* Reparent a file
+
+ Copyright (C) 1997 Free Software Foundation
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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 the GNU Hurd; see the file COPYING. If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "fs_S.h"
+
+error_t
+netfs_S_file_reparent (struct protid *cred, mach_port_t parent,
+ mach_port_t *new_file, mach_msg_type_name_t *new_file_type)
+{
+ struct node *node;
+ struct protid *new_cred;
+
+ if (! cred)
+ return EOPNOTSUPP;
+
+ node = cred->po->np;
+
+ mutex_lock (&node->lock);
+ new_cred =
+ netfs_make_protid (netfs_make_peropen (node, cred->po->openstat, cred->po),
+ iohelp_dup_iouser (cred->user));
+ mutex_unlock (&node->lock);
+
+ if (new_cred)
+ {
+ /* Remove old shadow root state. */
+ if (new_cred->po->shadow_root && new_cred->po->shadow_root != node)
+ {
+ mutex_lock (&new_cred->po->shadow_root->lock);
+ netfs_nput (new_cred->po->shadow_root);
+ }
+ if (new_cred->po->shadow_root_parent)
+ mach_port_deallocate (mach_task_self (), new_cred->po->shadow_root_parent);
+
+ /* And install PARENT instead. */
+ new_cred->po->shadow_root = node;
+ new_cred->po->shadow_root_parent = parent;
+
+ *new_file = ports_get_right (new_cred);
+ *new_file_type = MACH_MSG_TYPE_MAKE_SEND;
+
+ ports_port_deref (new_cred);
+
+ return 0;
+ }
+ else
+ return errno;
+}
diff --git a/libnetfs/file-set-size.c b/libnetfs/file-set-size.c
new file mode 100644
index 00000000..7b253e04
--- /dev/null
+++ b/libnetfs/file-set-size.c
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_set_size (struct protid *user,
+ off_t size)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_set_size (user->user, user->po->np, size);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
+
diff --git a/libnetfs/file-set-translator.c b/libnetfs/file-set-translator.c
new file mode 100644
index 00000000..50959286
--- /dev/null
+++ b/libnetfs/file-set-translator.c
@@ -0,0 +1,180 @@
+/*
+ Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include <hurd/paths.h>
+#include <hurd/fsys.h>
+
+error_t
+netfs_S_file_set_translator (struct protid *user,
+ int passive_flags, int active_flags,
+ int killtrans_flags, char *passive,
+ mach_msg_type_number_t passivelen,
+ mach_port_t active)
+{
+ struct node *np;
+ error_t err = 0;
+ mach_port_t control;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ if (!(passive_flags & FS_TRANS_SET) && !(active_flags & FS_TRANS_SET))
+ return 0;
+
+ if (passive && passive[passivelen - 1])
+ return EINVAL;
+
+ np = user->po->np;
+ mutex_lock (&np->lock);
+
+ if (active_flags & FS_TRANS_SET)
+ {
+ /* Validate--user must be owner */
+ err = netfs_validate_stat (np, user->user);
+ if (err)
+ goto out;
+
+ err = fshelp_isowner (&np->nn_stat, user->user);
+ if (err)
+ goto out;
+
+ err = fshelp_fetch_control (&np->transbox, &control);
+ if (err)
+ goto out;
+
+ if (control != MACH_PORT_NULL
+ && (active_flags & FS_TRANS_EXCL) == 0)
+ {
+ mutex_unlock (&np->lock);
+ err = fsys_goaway (control, killtrans_flags);
+ if (err && err != MIG_SERVER_DIED && err != MACH_SEND_INVALID_DEST)
+ return err;
+ err = 0;
+ mutex_lock (&np->lock);
+ }
+ }
+
+ if ((passive_flags & FS_TRANS_SET)
+ && (passive_flags & FS_TRANS_EXCL))
+ {
+ err = netfs_validate_stat (np, user->user);
+ if (!err && (np->nn_stat.st_mode & S_IPTRANS))
+ err = EBUSY;
+ if (err)
+ goto out;
+ }
+
+ if (active_flags & FS_TRANS_SET)
+ {
+ err = fshelp_set_active (&np->transbox, active,
+ active_flags & FS_TRANS_EXCL);
+ if (err)
+ goto out;
+ }
+
+ if (passive_flags & FS_TRANS_SET)
+ {
+ mode_t newmode = 0;
+ if (!(passive_flags & FS_TRANS_FORCE))
+ {
+ /* Short circuited translators */
+
+ if (!strcmp (passive, _HURD_SYMLINK))
+ newmode = S_IFLNK;
+ else if (!(strcmp (passive, _HURD_CHRDEV)))
+ newmode = S_IFCHR;
+ else if (!strcmp (passive, _HURD_BLKDEV))
+ newmode = S_IFBLK;
+ else if (!strcmp (passive, _HURD_FIFO))
+ newmode = S_IFIFO;
+ else if (!strcmp (passive, _HURD_IFSOCK))
+ newmode = S_IFSOCK;
+ }
+
+ switch (newmode)
+ {
+ int major, minor;
+ char *arg;
+
+ case S_IFBLK:
+ case S_IFCHR:
+ /* Find the device number from the arguments
+ of the translator. */
+ arg = passive + strlen (passive) + 1;
+ assert (arg <= passive + passivelen);
+ if (arg == passive + passivelen)
+ {
+ mutex_unlock (&np->lock);
+ return EINVAL;
+ }
+ major = strtol (arg, 0, 0);
+
+ arg = arg + strlen (arg) + 1;
+ assert (arg < passive + passivelen);
+ if (arg == passive + passivelen)
+ {
+ mutex_unlock (&np->lock);
+ return EINVAL;
+ }
+ minor = strtol (arg, 0, 0);
+
+ err = netfs_attempt_mkdev (user->user, np,
+ newmode, makedev (major, minor));
+ if (err == EOPNOTSUPP)
+ goto fallback;
+ break;
+
+ case S_IFLNK:
+ arg = passive + strlen (passive) + 1;
+ assert (arg <= passive + passivelen);
+ if (arg == passive + passivelen)
+ {
+ mutex_unlock (&np->lock);
+ return EINVAL;
+ }
+
+ err = netfs_attempt_mksymlink (user->user, np, arg);
+ if (err == EOPNOTSUPP)
+ goto fallback;
+ break;
+
+ default:
+ err = netfs_validate_stat (np, user->user);
+ if (!err)
+ err = netfs_attempt_chmod (user->user, np,
+ ((np->nn_stat.st_mode & ~S_IFMT)
+ | newmode));
+ if (err == EOPNOTSUPP)
+ goto fallback;
+ break;
+
+ case 0:
+ fallback:
+ err = netfs_set_translator (user->user, np,
+ passive, passivelen);
+ break;
+ }
+ }
+
+ out:
+ mutex_unlock (&np->lock);
+ return err;
+}
diff --git a/libnetfs/file-statfs.c b/libnetfs/file-statfs.c
new file mode 100644
index 00000000..180d29fc
--- /dev/null
+++ b/libnetfs/file-statfs.c
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_statfs (struct protid *user,
+ struct statfs *st)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_statfs (user->user, user->po->np, st);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-sync.c b/libnetfs/file-sync.c
new file mode 100644
index 00000000..99492ed8
--- /dev/null
+++ b/libnetfs/file-sync.c
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_sync (struct protid *user,
+ int wait,
+ int omitmeta)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_sync (user->user, user->po->np, wait);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-syncfs.c b/libnetfs/file-syncfs.c
new file mode 100644
index 00000000..28e34a3a
--- /dev/null
+++ b/libnetfs/file-syncfs.c
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_syncfs (struct protid *user,
+ int wait,
+ int dochildren)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ /* Translators not yet supported by netfs. XXX */
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_syncfs (user->user, wait);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/file-utimes.c b/libnetfs/file-utimes.c
new file mode 100644
index 00000000..45adf825
--- /dev/null
+++ b/libnetfs/file-utimes.c
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_utimes (struct protid *user,
+ time_value_t atimein,
+ time_value_t mtimein)
+{
+ struct timespec atime, mtime;
+ error_t err;
+
+ if (atimein.microseconds != -1)
+ {
+ atime.tv_sec = atimein.seconds;
+ atime.tv_nsec = atimein.microseconds * 1000;
+ }
+
+ if (mtimein.microseconds != -1)
+ {
+ mtime.tv_sec = mtimein.seconds;
+ mtime.tv_nsec = mtimein.microseconds * 1000;
+ }
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_attempt_utimes (user->user, user->po->np,
+ atimein.microseconds != -1 ? &atime : 0,
+ mtimein.microseconds != -1 ? &mtime : 0);
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/fsstubs.c b/libnetfs/fsstubs.c
new file mode 100644
index 00000000..415c62a5
--- /dev/null
+++ b/libnetfs/fsstubs.c
@@ -0,0 +1,62 @@
+/* Unimplemented rpcs from <hurd/fs.defs>
+
+ Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fs_S.h"
+
+error_t
+netfs_S_file_notice_changes (struct protid *user,
+ mach_port_t port)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_file_get_translator_cntl (struct protid *user,
+ mach_port_t *trans,
+ mach_msg_type_name_t *transtype)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_file_getfh (struct protid *user,
+ char **data, mach_msg_type_number_t *ndata)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_ifsock_getsockaddr (struct protid *user,
+ mach_port_t *address)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_server_version (struct protid *user,
+ char *name,
+ int *major,
+ int *minor,
+ int *edit)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/fsys-get-options.c b/libnetfs/fsys-get-options.c
new file mode 100644
index 00000000..e2a73782
--- /dev/null
+++ b/libnetfs/fsys-get-options.c
@@ -0,0 +1,67 @@
+/* Unparse run-time options
+
+ Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <errno.h>
+#include <argz.h>
+#include <hurd/fsys.h>
+#include <string.h>
+
+#include "netfs.h"
+#include "fsys_S.h"
+
+/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET'
+ are pending libnetfs being fleshed out some more. */
+
+/* Implement fsys_get_options as described in <hurd/fsys.defs>. */
+error_t
+netfs_S_fsys_get_options (fsys_t fsys,
+ char **data, mach_msg_type_number_t *data_len)
+{
+ error_t err;
+ char *argz = 0;
+ size_t argz_len = 0;
+ struct port_info *port =
+ ports_lookup_port (netfs_port_bucket, fsys, netfs_control_class);
+
+ if (!port)
+ return EOPNOTSUPP;
+
+ err = argz_add (&argz, &argz_len, program_invocation_name);
+ if (! err)
+ {
+#if NOT_YET
+ rwlock_reader_lock (&netfs_fsys_lock);
+#endif
+ err = netfs_append_args (&argz, &argz_len);
+#if NOT_YET
+ rwlock_reader_unlock (&netfs_fsys_lock);
+#endif
+ }
+
+ if (! err)
+ /* Move ARGZ from a malloced buffer into a vm_alloced one. */
+ err = iohelp_return_malloced_buffer (argz, argz_len, data, data_len);
+ else
+ free (argz);
+
+ ports_port_deref (port);
+
+ return err;
+}
diff --git a/libnetfs/fsys-getroot.c b/libnetfs/fsys-getroot.c
new file mode 100644
index 00000000..1ee12f41
--- /dev/null
+++ b/libnetfs/fsys-getroot.c
@@ -0,0 +1,151 @@
+/*
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fsys_S.h"
+#include "misc.h"
+#include "callbacks.h"
+#include <fcntl.h>
+
+error_t
+netfs_S_fsys_getroot (mach_port_t cntl,
+ mach_port_t dotdot,
+ uid_t *uids, mach_msg_type_number_t nuids,
+ uid_t *gids, mach_msg_type_number_t ngids,
+ int flags,
+ retry_type *do_retry,
+ char *retry_name,
+ mach_port_t *retry_port,
+ mach_port_t *retry_port_type)
+{
+ struct port_info *pt = ports_lookup_port (netfs_port_bucket, cntl,
+ netfs_control_class);
+ struct iouser *cred;
+ error_t err;
+ struct protid *newpi;
+ mode_t type;
+ struct idvec *uvec, *gvec;
+ struct peropen peropen_context = { root_parent: dotdot };
+
+ if (!pt)
+ return EOPNOTSUPP;
+ ports_port_deref (pt);
+
+ uvec = make_idvec ();
+ gvec = make_idvec ();
+ idvec_set_ids (uvec, uids, nuids);
+ idvec_set_ids (gvec, gids, ngids);
+
+ cred = iohelp_create_iouser (uvec, gvec);
+
+ flags &= O_HURD;
+
+ mutex_lock (&netfs_root_node->lock);
+ err = netfs_validate_stat (netfs_root_node, cred);
+ if (err)
+ goto out;
+
+ type = netfs_root_node->nn_stat.st_mode & S_IFMT;
+
+ if (((netfs_root_node->nn_stat.st_mode & S_IPTRANS)
+ || fshelp_translated (&netfs_root_node->transbox))
+ && !(flags & O_NOTRANS))
+ {
+ err = fshelp_fetch_root (&netfs_root_node->transbox,
+ &peropen_context, dotdot, cred, flags,
+ _netfs_translator_callback1,
+ _netfs_translator_callback2,
+ do_retry, retry_name, retry_port);
+ if (err != ENOENT)
+ {
+ mutex_unlock (&netfs_root_node->lock);
+ iohelp_free_iouser (cred);
+ if (!err)
+ *retry_port_type = MACH_MSG_TYPE_MOVE_SEND;
+ return err;
+ }
+ /* ENOENT means translator has vanished inside fshelp_fetch_root. */
+ err = 0;
+ }
+
+ if (type == S_IFLNK && !(flags & (O_NOLINK | O_NOTRANS)))
+ {
+ char pathbuf[netfs_root_node->nn_stat.st_size + 1];
+
+ err = netfs_attempt_readlink (cred, netfs_root_node, pathbuf);
+
+ if (err)
+ goto out;
+
+ mutex_unlock (&netfs_root_node->lock);
+ iohelp_free_iouser (cred);
+
+ if (pathbuf[0] == '/')
+ {
+ *do_retry = FS_RETRY_MAGICAL;
+ *retry_port = MACH_PORT_NULL;
+ *retry_port_type = MACH_MSG_TYPE_COPY_SEND;
+ strcpy (retry_name, pathbuf);
+ mach_port_deallocate (mach_task_self (), dotdot);
+ return 0;
+ }
+ else
+ {
+ *do_retry = FS_RETRY_REAUTH;
+ *retry_port = dotdot;
+ *retry_port_type = MACH_MSG_TYPE_MOVE_SEND;
+ strcpy (retry_name, pathbuf);
+ return 0;
+ }
+ }
+
+ if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR
+ || type == S_IFIFO) && (flags & (O_READ|O_WRITE|O_EXEC)))
+ {
+ err = EOPNOTSUPP;
+ goto out;
+ }
+
+ err = netfs_check_open_permissions (cred, netfs_root_node, flags, 0);
+ if (err)
+ goto out;
+
+ flags &= ~OPENONLY_STATE_MODES;
+
+ newpi = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
+ &peropen_context),
+ cred);
+ mach_port_deallocate (mach_task_self (), dotdot);
+
+ *do_retry = FS_RETRY_NORMAL;
+ *retry_port = ports_get_right (newpi);
+ *retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
+ retry_name[0] = '\0';
+ ports_port_deref (newpi);
+
+ out:
+ if (err)
+ iohelp_free_iouser (cred);
+ mutex_unlock (&netfs_root_node->lock);
+ return err;
+}
+
+
+
diff --git a/libnetfs/fsys-set-options.c b/libnetfs/fsys-set-options.c
new file mode 100644
index 00000000..8abd5a16
--- /dev/null
+++ b/libnetfs/fsys-set-options.c
@@ -0,0 +1,91 @@
+/* Parse run-time options
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <errno.h>
+#include <argz.h>
+#include <hurd/fsys.h>
+#include <string.h>
+
+#include "netfs.h"
+#include "fsys_S.h"
+
+/* This code is originally from libdiskfs; things surrounded by `#if NOT_YET'
+ are pending libnetfs being fleshed out some more. */
+
+/* Implement fsys_set_options as described in <hurd/fsys.defs>. */
+error_t
+netfs_S_fsys_set_options (fsys_t fsys,
+ char *data, mach_msg_type_number_t data_len,
+ int do_children)
+{
+ error_t err = 0;
+ struct port_info *pt =
+ ports_lookup_port (netfs_port_bucket, fsys, netfs_control_class);
+
+ error_t
+ helper (struct node *np)
+ {
+ error_t error;
+ mach_port_t control;
+
+ error = fshelp_fetch_control (&np->transbox, &control);
+ mutex_unlock (&np->lock);
+ if (!error && (control != MACH_PORT_NULL))
+ {
+ error = fsys_set_options (control, data, data_len, do_children);
+ mach_port_deallocate (mach_task_self (), control);
+ }
+ else
+ error = 0;
+ mutex_lock (&np->lock);
+
+ if ((error == MIG_SERVER_DIED) || (error == MACH_SEND_INVALID_DEST))
+ error = 0;
+
+ return error;
+ }
+
+ if (!pt)
+ return EOPNOTSUPP;
+
+#if NOT_YET
+ if (do_children)
+ {
+ rwlock_writer_lock (&netfs_fsys_lock);
+ err = netfs_node_iterate (helper);
+ rwlock_writer_unlock (&netfs_fsys_lock);
+ }
+#endif
+
+ if (!err)
+ {
+#if NOT_YET
+ rwlock_writer_lock (&netfs_fsys_lock);
+#endif
+ err = netfs_set_options (data, data_len);
+#if NOT_YET
+ rwlock_writer_unlock (&netfs_fsys_lock);
+#endif
+ }
+
+ ports_port_deref (pt);
+
+ return err;
+}
diff --git a/libnetfs/fsys-syncfs.c b/libnetfs/fsys-syncfs.c
new file mode 100644
index 00000000..da482961
--- /dev/null
+++ b/libnetfs/fsys-syncfs.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fsys_S.h"
+
+error_t
+netfs_S_fsys_syncfs (mach_port_t cntl,
+ int wait,
+ int children)
+{
+ struct iouser *cred;
+ uid_t root = 0;
+ error_t err;
+
+ cred = iohelp_create_iouser (make_idvec (), make_idvec ());
+ idvec_set_ids (cred->uids, &root, 1);
+ idvec_set_ids (cred->gids, &root, 1);
+ err = netfs_attempt_syncfs (cred, wait);
+ iohelp_free_iouser (cred);
+ return err;
+}
diff --git a/libnetfs/fsysstubs.c b/libnetfs/fsysstubs.c
new file mode 100644
index 00000000..bed52b18
--- /dev/null
+++ b/libnetfs/fsysstubs.c
@@ -0,0 +1,75 @@
+/* Unimplemented rpcs from <hurd/fsys.defs>
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "fsys_S.h"
+
+error_t
+netfs_S_fsys_getfile (fsys_t cntl,
+ uid_t *uids, mach_msg_type_number_t nuids,
+ gid_t *gids, mach_msg_type_number_t ngids,
+ char *handle, mach_msg_type_number_t handlelen,
+ mach_port_t *file, mach_msg_type_name_t *filetype)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_fsys_getpriv (fsys_t cntl,
+ mach_port_t *host, mach_msg_type_name_t *hosttp,
+ mach_port_t *dev, mach_msg_type_name_t *devtp,
+ mach_port_t *fs, mach_msg_type_name_t *fstp)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_fsys_init (fsys_t cntl,
+ mach_port_t reply, mach_msg_type_name_t replytp,
+ mach_port_t proc, auth_t auth)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_fsys_forward (fsys_t cntl,
+ mach_port_t request,
+ char *argv, mach_msg_type_number_t argvlen)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_fsys_startup (mach_port_t bootstrap,
+ int flags,
+ mach_port_t contrl,
+ mach_port_t *realnod,
+ mach_msg_type_name_t *realnodetype)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_fsys_goaway (mach_port_t cntl,
+ int flags)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/init-init.c b/libnetfs/init-init.c
new file mode 100644
index 00000000..411430f0
--- /dev/null
+++ b/libnetfs/init-init.c
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+
+#include "netfs.h"
+
+spin_lock_t netfs_node_refcnt_lock = SPIN_LOCK_INITIALIZER;
+
+struct node *netfs_root_node = 0;
+struct port_bucket *netfs_port_bucket = 0;
+struct port_class *netfs_protid_class = 0;
+struct port_class *netfs_control_class = 0;
+auth_t netfs_auth_server_port = 0;
+mach_port_t netfs_fsys_identity;
+
+
+void
+netfs_init ()
+{
+ netfs_protid_class = ports_create_class (netfs_release_protid, 0);
+ netfs_control_class = ports_create_class (0, 0);
+ netfs_port_bucket = ports_create_bucket ();
+ netfs_auth_server_port = getauth ();
+ mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
+ &netfs_fsys_identity);
+}
diff --git a/libnetfs/init-loop.c b/libnetfs/init-loop.c
new file mode 100644
index 00000000..08bdcd18
--- /dev/null
+++ b/libnetfs/init-loop.c
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+
+static int thread_timeout = 1000 * 60 * 2; /* two minutes */
+static int server_timeout = 1000 * 60 * 10; /* ten minutes */
+
+void
+netfs_server_loop ()
+{
+ error_t err;
+
+ do
+ {
+ ports_manage_port_operations_multithread (netfs_port_bucket,
+ netfs_demuxer,
+ thread_timeout,
+ server_timeout,
+ 0);
+ err = netfs_shutdown (0);
+ }
+ while (err);
+
+ exit (0);
+}
+
diff --git a/libnetfs/init-startup.c b/libnetfs/init-startup.c
new file mode 100644
index 00000000..c457441b
--- /dev/null
+++ b/libnetfs/init-startup.c
@@ -0,0 +1,49 @@
+/*
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <stdio.h>
+#include <error.h>
+#include <hurd/fsys.h>
+#include "netfs.h"
+
+mach_port_t
+netfs_startup (mach_port_t bootstrap, int flags)
+{
+ mach_port_t realnode;
+ struct port_info *newpi;
+
+ if (bootstrap == MACH_PORT_NULL)
+ error (10, 0, "Must be started as a translator");
+
+ errno = ports_create_port (netfs_control_class, netfs_port_bucket,
+ sizeof (struct port_info), &newpi);
+ if (!errno)
+ {
+ errno = fsys_startup (bootstrap, flags, ports_get_right (newpi),
+ MACH_MSG_TYPE_MAKE_SEND, &realnode);
+ ports_port_deref (newpi);
+ }
+ if (errno)
+ error (11, errno, "Translator startup failure: fsys_startup");
+
+ mach_port_deallocate (mach_task_self (), bootstrap);
+
+ return realnode;
+}
diff --git a/libnetfs/io-async.c b/libnetfs/io-async.c
new file mode 100644
index 00000000..10504adb
--- /dev/null
+++ b/libnetfs/io-async.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_async (struct protid *user, mach_port_t notify, mach_port_t *id,
+ mach_msg_type_name_t *idt)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/io-clear-some-openmodes.c b/libnetfs/io-clear-some-openmodes.c
new file mode 100644
index 00000000..27bbfac8
--- /dev/null
+++ b/libnetfs/io-clear-some-openmodes.c
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+#include "modes.h"
+
+error_t
+netfs_S_io_clear_some_openmodes (struct protid *user, int bits)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ user->po->openstat &= ~(bits & HONORED_STATE_MODES);
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-duplicate.c b/libnetfs/io-duplicate.c
new file mode 100644
index 00000000..a41af9bf
--- /dev/null
+++ b/libnetfs/io-duplicate.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_duplicate (struct protid *user,
+ mach_port_t *newport,
+ mach_msg_type_name_t *newporttp)
+{
+ struct protid *newpi;
+
+ mutex_lock (&user->po->np->lock);
+ newpi = netfs_make_protid (user->po,
+ iohelp_dup_iouser (user->user));
+ *newport = ports_get_right (newpi);
+ mutex_unlock (&user->po->np->lock);
+ *newporttp = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ return 0;
+}
diff --git a/libnetfs/io-get-icky-async-id.c b/libnetfs/io-get-icky-async-id.c
new file mode 100644
index 00000000..49cae5eb
--- /dev/null
+++ b/libnetfs/io-get-icky-async-id.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_get_icky_async_id (struct protid *user, mach_port_t *pt,
+ mach_msg_type_name_t *ptt)
+{
+ return EOPNOTSUPP;
+}
+
diff --git a/libnetfs/io-get-openmodes.c b/libnetfs/io-get-openmodes.c
new file mode 100644
index 00000000..e197fdc9
--- /dev/null
+++ b/libnetfs/io-get-openmodes.c
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_get_openmodes (struct protid *user, int *bits)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ *bits = user->po->openstat;
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-get-owner.c b/libnetfs/io-get-owner.c
new file mode 100644
index 00000000..c86207f7
--- /dev/null
+++ b/libnetfs/io-get-owner.c
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_get_owner (struct protid *user, pid_t *owner)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ *owner = user->po->np->owner;
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-identity.c b/libnetfs/io-identity.c
new file mode 100644
index 00000000..e259a0f7
--- /dev/null
+++ b/libnetfs/io-identity.c
@@ -0,0 +1,61 @@
+/* libnetfs implementation of io_identity RPC
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_identity (struct protid *cred,
+ mach_port_t *id,
+ mach_msg_type_name_t *idtype,
+ mach_port_t *fsys,
+ mach_msg_type_name_t *fsystype,
+ int *fileno)
+{
+ struct node *np;
+ error_t err;
+
+ if (!cred)
+ return EOPNOTSUPP;
+
+ np = cred->po->np;
+ mutex_lock (&np->lock);
+
+ err = netfs_validate_stat (np, cred->user);
+ if (err)
+ {
+ mutex_unlock (&np->lock);
+ return err;
+ }
+
+ err = fshelp_get_identity (netfs_port_bucket, np->nn_stat.st_ino, id);
+ if (err)
+ {
+ mutex_unlock (&np->lock);
+ return err;
+ }
+ *idtype = MACH_MSG_TYPE_MAKE_SEND;
+ *fsys = netfs_fsys_identity;
+ *fsystype = MACH_MSG_TYPE_MAKE_SEND;
+ *fileno = np->nn_stat.st_ino;
+
+ mutex_unlock (&np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-mod-owner.c b/libnetfs/io-mod-owner.c
new file mode 100644
index 00000000..16c61060
--- /dev/null
+++ b/libnetfs/io-mod-owner.c
@@ -0,0 +1,34 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_mod_owner (struct protid *user, pid_t owner)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ user->po->np->owner = owner;
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-pathconf.c b/libnetfs/io-pathconf.c
new file mode 100644
index 00000000..78244bcd
--- /dev/null
+++ b/libnetfs/io-pathconf.c
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, 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. */
+
+#include <unistd.h>
+#include "netfs.h"
+#include "io_S.h"
+
+
+error_t
+netfs_S_io_pathconf (struct protid *user,
+ int name,
+ int *value)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ switch (name)
+ {
+ case _PC_LINK_MAX:
+ case _PC_MAX_CANON:
+ case _PC_MAX_INPUT:
+ case _PC_PIPE_BUF:
+ case _PC_VDISABLE:
+ case _PC_SOCK_MAXBUF:
+ *value = -1;
+ break;
+
+ case _PC_NAME_MAX:
+ *value = 1024; /* see <hurd/hurd_types.defs> string_t */
+ break;
+
+ case _PC_CHOWN_RESTRICTED:
+ case _PC_NO_TRUNC: /* look at string_t trunc behavior in MiG */
+ *value = 1;
+ break;
+
+ case _PC_PRIO_IO:
+ case _PC_SYNC_IO:
+ case _PC_ASYNC_IO:
+ *value = 0;
+ break;
+
+ case _PC_FILESIZEBITS:
+ *value = 32;
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+ return 0;
+}
diff --git a/libnetfs/io-read.c b/libnetfs/io-read.c
new file mode 100644
index 00000000..a4b1b2e2
--- /dev/null
+++ b/libnetfs/io-read.c
@@ -0,0 +1,104 @@
+/*
+ Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+#include <fcntl.h>
+#include <sys/mman.h>
+
+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;
+ 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;
+}
diff --git a/libnetfs/io-readable.c b/libnetfs/io-readable.c
new file mode 100644
index 00000000..ad6bf3c1
--- /dev/null
+++ b/libnetfs/io-readable.c
@@ -0,0 +1,49 @@
+
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <fcntl.h>
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_readable (struct protid *user,
+ mach_msg_type_number_t *amount)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ if (!(user->po->openstat & O_READ))
+ return EINVAL;
+
+ mutex_lock (&user->po->np->lock);
+ err = netfs_validate_stat (user->po->np, user->user);
+ if (!err)
+ {
+ if (user->po->np->nn_stat.st_size > user->po->filepointer)
+ *amount = user->po->np->nn_stat.st_size - user->po->filepointer;
+ else
+ *amount = 0;
+ }
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
diff --git a/libnetfs/io-reauthenticate.c b/libnetfs/io-reauthenticate.c
new file mode 100644
index 00000000..c88e773d
--- /dev/null
+++ b/libnetfs/io-reauthenticate.c
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_reauthenticate (struct protid *user, mach_port_t rend_port)
+{
+ struct protid *newpi;
+ error_t err;
+ mach_port_t newright;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ newpi = netfs_make_protid (user->po, 0);
+
+ newright = ports_get_right (newpi);
+ err = mach_port_insert_right (mach_task_self (), newright, newright,
+ MACH_MSG_TYPE_MAKE_SEND);
+ assert_perror (err);
+
+ newpi->user = iohelp_reauth (netfs_auth_server_port, rend_port, newright, 1);
+
+ mach_port_deallocate (mach_task_self (), rend_port);
+ mach_port_deallocate (mach_task_self (), newright);
+
+ mach_port_move_member (mach_task_self (), newpi->pi.port_right,
+ netfs_port_bucket->portset);
+
+ mutex_unlock (&user->po->np->lock);
+ ports_port_deref (newpi);
+
+ return 0;
+}
diff --git a/libnetfs/io-restrict-auth.c b/libnetfs/io-restrict-auth.c
new file mode 100644
index 00000000..9d1fda3c
--- /dev/null
+++ b/libnetfs/io-restrict-auth.c
@@ -0,0 +1,78 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+static inline int
+listmember (int *list, int query, int n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ if (list[i] == query)
+ return 1;
+ return 0;
+}
+
+error_t
+netfs_S_io_restrict_auth (struct protid *user,
+ mach_port_t *newport,
+ mach_msg_type_name_t *newporttype,
+ uid_t *uids,
+ mach_msg_type_number_t nuids,
+ gid_t *gids,
+ mach_msg_type_number_t ngids)
+{
+ struct idvec *uvec, *gvec;
+ int i;
+ struct protid *newpi;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ uvec = make_idvec ();
+ gvec = make_idvec ();
+
+ if (idvec_contains (user->user->uids, 0))
+ {
+ idvec_set_ids (uvec, uids, nuids);
+ idvec_set_ids (gvec, gids, ngids);
+ }
+ else
+ {
+ for (i = 0; i < user->user->uids->num; i++)
+ if (listmember (uids, user->user->uids->ids[i], nuids))
+ idvec_add (uvec, user->user->uids->ids[i]);
+
+ for (i = 0; i < user->user->gids->num; i++)
+ if (listmember (gids, user->user->gids->ids[i], ngids))
+ idvec_add (gvec, user->user->gids->ids[i]);
+ }
+
+ mutex_lock (&user->po->np->lock);
+ newpi = netfs_make_protid (user->po, iohelp_create_iouser (uvec, gvec));
+ *newport = ports_get_right (newpi);
+ mutex_unlock (&user->po->np->lock);
+
+ *newporttype = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ return 0;
+}
+
diff --git a/libnetfs/io-revoke.c b/libnetfs/io-revoke.c
new file mode 100644
index 00000000..a5e27802
--- /dev/null
+++ b/libnetfs/io-revoke.c
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 1999 Free Software Foundation
+ Written by Thomas Bushnell, BSG.
+
+ 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+/* Implement io_revoke as described in <hurd/io.defs>. */
+kern_return_t
+netfs_S_io_revoke (struct protid *cred)
+{
+ error_t err;
+ struct node *np;
+
+ error_t
+ iterator_function (void *port)
+ {
+ struct protid *user = port;
+
+ if ((user != cred)
+ && (user->po->np == np))
+ ports_destroy_right (user);
+ return 0;
+ }
+
+ if (!cred)
+ return EOPNOTSUPP;
+
+ np = cred->po->np;
+
+ mutex_lock (&np->lock);
+
+ err = netfs_validate_stat (np, cred->user);
+ if (!err)
+ err = fshelp_isowner (&np->nn_stat, cred->user);
+
+ mutex_unlock (&np->lock);
+
+ if (err)
+ return err;
+
+ ports_inhibit_bucket_rpcs (netfs_port_bucket);
+ ports_class_iterate (netfs_protid_class, iterator_function);
+ ports_resume_bucket_rpcs (netfs_port_bucket);
+
+ return 0;
+}
diff --git a/libnetfs/io-seek.c b/libnetfs/io-seek.c
new file mode 100644
index 00000000..1e517ff4
--- /dev/null
+++ b/libnetfs/io-seek.c
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <unistd.h>
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_seek (struct protid *user,
+ off_t offset,
+ int whence,
+ off_t *newoffset)
+{
+ error_t err;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ switch (whence)
+ {
+ case SEEK_SET:
+ err = 0;
+ user->po->filepointer = offset;
+ break;
+
+ case SEEK_CUR:
+ err = 0;
+ user->po->filepointer += offset;
+ break;
+
+ case SEEK_END:
+ err = netfs_validate_stat (user->po->np, user->user);
+ if (!err)
+ user->po->filepointer = user->po->np->nn_stat.st_size + offset;
+ break;
+
+ default:
+ err = EINVAL;
+ break;
+ }
+ *newoffset = user->po->filepointer;
+ mutex_unlock (&user->po->np->lock);
+ return err;
+}
+
diff --git a/libnetfs/io-select.c b/libnetfs/io-select.c
new file mode 100644
index 00000000..07ce9e75
--- /dev/null
+++ b/libnetfs/io-select.c
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_select (struct protid *user,
+ int *type)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ *type &= ~SELECT_URG;
+ return 0;
+}
diff --git a/libnetfs/io-set-all-openmodes.c b/libnetfs/io-set-all-openmodes.c
new file mode 100644
index 00000000..4f431459
--- /dev/null
+++ b/libnetfs/io-set-all-openmodes.c
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+#include "modes.h"
+
+error_t
+netfs_S_io_set_all_openmodes (struct protid *user, int newbits)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ user->po->openstat &= ~HONORED_STATE_MODES;
+ user->po->openstat |= (newbits & HONORED_STATE_MODES);
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-set-some-openmodes.c b/libnetfs/io-set-some-openmodes.c
new file mode 100644
index 00000000..97bd2b43
--- /dev/null
+++ b/libnetfs/io-set-some-openmodes.c
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+#include "modes.h"
+
+error_t
+netfs_S_io_set_some_openmodes (struct protid *user, int bits)
+{
+ if (!user)
+ return EOPNOTSUPP;
+
+ mutex_lock (&user->po->np->lock);
+ user->po->openstat |= (bits & HONORED_STATE_MODES);
+ mutex_unlock (&user->po->np->lock);
+ return 0;
+}
diff --git a/libnetfs/io-stat.c b/libnetfs/io-stat.c
new file mode 100644
index 00000000..5f086318
--- /dev/null
+++ b/libnetfs/io-stat.c
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+#include <string.h>
+
+error_t
+netfs_S_io_stat (struct protid *user, io_statbuf_t *statbuf)
+{
+ error_t err;
+ struct node *node;
+
+ if (! user)
+ return EOPNOTSUPP;
+
+ node = user->po->np;
+ mutex_lock (&node->lock);
+
+ err = netfs_validate_stat (node, user->user);
+ if (! err)
+ {
+ bcopy (&node->nn_stat, statbuf, sizeof (struct stat));
+
+ /* Set S_IATRANS and S_IROOT bits as appropriate. */
+ statbuf->st_mode &= ~(S_IATRANS | S_IROOT);
+ if (fshelp_translated (&node->transbox))
+ statbuf->st_mode |= S_IATRANS; /* Has an active translator. */
+ if (user->po->shadow_root == node || node == netfs_root_node)
+ statbuf->st_mode |= S_IROOT; /* Is a root node. */
+ }
+
+ mutex_unlock (&node->lock);
+
+ return err;
+}
+
diff --git a/libnetfs/io-write.c b/libnetfs/io-write.c
new file mode 100644
index 00000000..26c3c297
--- /dev/null
+++ b/libnetfs/io-write.c
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include "io_S.h"
+#include <fcntl.h>
+
+error_t
+netfs_S_io_write (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 off = offset;
+ struct node *np;
+
+ if (!user)
+ return EOPNOTSUPP;
+
+ np = user->po->np;
+
+ mutex_lock (&np->lock);
+ if ((user->po->openstat & O_WRITE) == 0)
+ {
+ mutex_unlock (&np->lock);
+ return EBADF;
+ }
+
+ *amount = datalen;
+
+ if (off == -1)
+ {
+ if (user->po->openstat & O_APPEND)
+ {
+ err = netfs_validate_stat (np, user->user);
+ if (err)
+ {
+ mutex_unlock (&np->lock);
+ return err;
+ }
+ user->po->filepointer = np->nn_stat.st_size;
+ }
+ off = user->po->filepointer;
+ }
+
+ err = netfs_attempt_write (user->user, np, off, amount, data);
+ if (offset == -1 && !err)
+ user->po->filepointer += *amount;
+ mutex_unlock (&np->lock);
+
+ return err;
+}
+
+
diff --git a/libnetfs/iostubs.c b/libnetfs/iostubs.c
new file mode 100644
index 00000000..1465b43a
--- /dev/null
+++ b/libnetfs/iostubs.c
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+
+#include "netfs.h"
+#include "io_S.h"
+
+error_t
+netfs_S_io_map (struct protid *user,
+ mach_port_t *rdobj, mach_msg_type_name_t *rdobjtype,
+ mach_port_t *wrobj, mach_msg_type_name_t *wrobjtype)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_map_cntl (struct protid *user,
+ mach_port_t *obj,
+ mach_msg_type_name_t *objtype)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_get_conch (struct protid *user)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_release_conch (struct protid *user)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_eofnotify (struct protid *user)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_prenotify (struct protid *user,
+ vm_offset_t start, vm_offset_t stop)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_postnotify (struct protid *user,
+ vm_offset_t start, vm_offset_t stop)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_readnotify (struct protid *user)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_readsleep (struct protid *user)
+{
+ return EOPNOTSUPP;
+}
+
+error_t
+netfs_S_io_sigio (struct protid *user)
+{
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/make-node.c b/libnetfs/make-node.c
new file mode 100644
index 00000000..973744e7
--- /dev/null
+++ b/libnetfs/make-node.c
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include <hurd/fshelp.h>
+
+struct node *
+netfs_make_node (struct netnode *nn)
+{
+ struct node *np = malloc (sizeof (struct node));
+
+ np->nn = nn;
+
+ mutex_init (&np->lock);
+ np->references = 1;
+ np->sockaddr = MACH_PORT_NULL;
+ np->owner = 0;
+
+ fshelp_transbox_init (&np->transbox, &np->lock, np);
+ fshelp_lock_init (&np->userlock);
+
+ return np;
+}
diff --git a/libnetfs/make-peropen.c b/libnetfs/make-peropen.c
new file mode 100644
index 00000000..92f58da0
--- /dev/null
+++ b/libnetfs/make-peropen.c
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 1995, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include <sys/file.h>
+
+struct peropen *
+netfs_make_peropen (struct node *np, int flags, struct peropen *context)
+{
+ struct peropen *po = malloc (sizeof (struct peropen));
+
+ po->filepointer = 0;
+ po->lock_status = LOCK_UN;
+ po->refcnt = 0;
+ po->openstat = flags;
+ po->np = np;
+
+ if (context)
+ {
+ po->root_parent = context->root_parent;
+ if (po->root_parent != MACH_PORT_NULL)
+ mach_port_mod_refs (mach_task_self (), po->root_parent,
+ MACH_PORT_RIGHT_SEND, 1);
+
+ po->shadow_root = context->shadow_root;
+ if (po->shadow_root)
+ netfs_nref (po->shadow_root);
+
+ po->shadow_root_parent = context->shadow_root_parent;
+ if (po->shadow_root_parent != MACH_PORT_NULL)
+ mach_port_mod_refs (mach_task_self (), po->shadow_root_parent,
+ MACH_PORT_RIGHT_SEND, 1);
+ }
+
+ netfs_nref (np);
+
+ return po;
+}
+
diff --git a/libnetfs/make-protid.c b/libnetfs/make-protid.c
new file mode 100644
index 00000000..bf18283c
--- /dev/null
+++ b/libnetfs/make-protid.c
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+
+struct protid *
+netfs_make_protid (struct peropen *po, struct iouser *cred)
+{
+ struct protid *pi;
+
+ if (cred)
+ errno = ports_create_port (netfs_protid_class, netfs_port_bucket,
+ sizeof (struct protid), &pi);
+ else
+ errno = ports_create_port_noinstall (netfs_protid_class,
+ netfs_port_bucket,
+ sizeof (struct protid), &pi);
+
+ if (errno)
+ return 0;
+
+ po->refcnt++;
+ pi->po = po;
+ pi->user = cred;
+ pi->shared_object = MACH_PORT_NULL;
+ pi->mapped = 0;
+ return pi;
+}
diff --git a/libnetfs/misc.h b/libnetfs/misc.h
new file mode 100644
index 00000000..aa942087
--- /dev/null
+++ b/libnetfs/misc.h
@@ -0,0 +1,24 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <fcntl.h>
+
+/* Bits that are turned off after open */
+#define OPENONLY_STATE_MODES (O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS|O_NONBLOCK)
diff --git a/libnetfs/modes.h b/libnetfs/modes.h
new file mode 100644
index 00000000..53125f68
--- /dev/null
+++ b/libnetfs/modes.h
@@ -0,0 +1,23 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <fcntl.h>
+#define HONORED_STATE_MODES (O_APPEND|O_ASYNC|O_FSYNC|O_NONBLOCK|O_NOATIME)
+
diff --git a/libnetfs/mutations.h b/libnetfs/mutations.h
new file mode 100644
index 00000000..ea0b8476
--- /dev/null
+++ b/libnetfs/mutations.h
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+/* Only CPP macro definitions should go in this file. */
+
+#define FILE_INTRAN protid_t begin_using_protid_port (file_t)
+#define FILE_DESTRUCTOR end_using_protid_port (protid_t)
+
+#define IO_INTRAN protid_t begin_using_protid_port (io_t)
+#define IO_DESTRUCTOR end_using_protid_port (protid_t)
+
+#define FILE_IMPORTS import "netfs.h"; import "priv.h";
+#define IO_IMPORTS import "netfs.h"; import "priv.h";
+#define FSYS_IMPORTS import "netfs.h"; import "priv.h";
+#define IFSOCK_IMPORTS import "netfs.h"; import "priv.h";
+
diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h
new file mode 100644
index 00000000..d75dfe39
--- /dev/null
+++ b/libnetfs/netfs.h
@@ -0,0 +1,345 @@
+/*
+
+ Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation
+
+ 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef _HURD_NETFS_H_
+#define _HURD_NETFS_H_
+
+#include <hurd/ports.h>
+#include <hurd/fshelp.h>
+#include <hurd/iohelp.h>
+#include <assert.h>
+
+/* This library supports client-side network file system
+ implementations. It is analogous to the diskfs library provided for
+ disk-based filesystems. */
+
+struct argp;
+
+struct protid
+{
+ struct port_info pi;
+
+ /* User identification */
+ struct iouser *user;
+
+ /* Object this refers to */
+ struct peropen *po;
+
+ /* Shared memory I/O information. */
+ memory_object_t shared_object;
+ struct shared_io *mapped;
+};
+
+/* One of these is created for each open */
+struct peropen
+{
+ off_t filepointer;
+ int lock_status;
+ int refcnt;
+ int openstat;
+
+ struct node *np;
+
+ /* The parent of the translator's root node. */
+ mach_port_t root_parent;
+
+ /* If this node is in a shadow tree, the parent of its root. */
+ mach_port_t shadow_root_parent;
+ /* If in a shadow tree, its root node in this translator. */
+ struct node *shadow_root;
+};
+
+/* A unique one of these exists for each node currently in use. */
+struct node
+{
+ struct node *next, **prevp;
+
+ /* Protocol specific stuff. */
+ struct netnode *nn;
+
+ struct stat nn_stat;
+
+ struct mutex lock;
+
+ int references;
+
+ mach_port_t sockaddr;
+
+ int owner;
+
+ struct transbox transbox;
+
+ struct lock_box userlock;
+
+ struct conch conch;
+
+ struct dirmod *dirmod_reqs;
+};
+
+/* The user must define this function. 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);
+
+/* The user must define this function. This should attempt a chmod
+ call for the user specified by CRED on node NODE, 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);
+
+/* The user must define this function. This should attempt a chauthor
+ call for the user specified by CRED on node NODE, to change the
+ author to AUTHOR. */
+error_t netfs_attempt_chauthor (struct iouser *cred, struct node *np,
+ uid_t author);
+
+/* The user must define this function. This should attempt a chmod
+ call for the user specified by CRED on 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);
+
+/* The user must define this function. Attempt to turn NODE (user CRED)
+ into a symlink with target NAME. */
+error_t netfs_attempt_mksymlink (struct iouser *cred, struct node *np,
+ char *name);
+
+/* The user must define this function. Attempt to turn NODE (user
+ CRED) into a device. TYPE is either S_IFBLK or S_IFCHR. */
+error_t netfs_attempt_mkdev (struct iouser *cred, struct node *np,
+ mode_t type, dev_t indexes);
+
+/* The user may define this function. Attempt to set the passive
+ translator record for FILE to ARGZ (of length ARGZLEN) for user
+ CRED. */
+error_t netfs_set_translator (struct iouser *cred, struct node *np,
+ char *argz, size_t argzlen);
+
+/* The user may define this function (but should define it together with
+ netfs_set_translator). 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);
+
+/* The user must define this function. This should attempt a chflags
+ call for the user specified by CRED on node NODE, to change the
+ flags to FLAGS. */
+error_t netfs_attempt_chflags (struct iouser *cred, struct node *np,
+ int flags);
+
+/* The user must define this function. This should attempt a utimes
+ call for the user specified by CRED on node NODE, 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);
+
+/* The user must define this function. This should attempt to set the
+ size of the file NODE (for user CRED) to SIZE bytes long. */
+error_t netfs_attempt_set_size (struct iouser *cred, struct node *np,
+ off_t size);
+
+/* The user must define this function. This should attempt to fetch
+ filesystem status information for the remote filesystem, for the
+ user CRED. */
+error_t netfs_attempt_statfs (struct iouser *cred, struct node *np,
+ struct statfs *st);
+
+/* The user must define this function. This should sync the file NP
+ completely to disk, for the user CRED. If WAIT is set, return
+ only after sync is completely finished. */
+error_t netfs_attempt_sync (struct iouser *cred, struct node *np,
+ int wait);
+
+/* The user must define this function. This should sync the entire
+ remote filesystem. If WAIT is set, return only after
+ sync is completely finished. */
+error_t netfs_attempt_syncfs (struct iouser *cred, int wait);
+
+/* The user must define this function. Lookup NAME in DIR 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, this call should unlock DIR no matter what.) */
+error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
+ char *name, struct node **np);
+
+/* The user must define this function. Delete NAME in DIR for USER. */
+error_t netfs_attempt_unlink (struct iouser *user, struct node *dir,
+ char *name);
+
+/* Note that in this one call, 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);
+
+/* The user must define this function. Attempt to create a new
+ directory named NAME in DIR for USER with mode MODE. */
+error_t netfs_attempt_mkdir (struct iouser *user, struct node *dir,
+ char *name, mode_t mode);
+
+/* The user must define this function. Attempt to remove directory
+ named NAME in DIR for USER. */
+error_t netfs_attempt_rmdir (struct iouser *user,
+ struct node *dir, char *name);
+
+
+/* The user must define this function. 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, but 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);
+
+/* The user must define this function. Attempt to create an anonymous
+ file related to DIR 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);
+
+/* The user must define this function. Attempt to create a file named
+ NAME in DIR 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);
+
+/* The user must define this function. Read the contents of NP (a symlink),
+ for USER, into BUF. */
+error_t netfs_attempt_readlink (struct iouser *user, struct node *np,
+ char *buf);
+
+/* The user must define this function. Node NP is being opened by USER,
+ with FLAGS. NEWNODE is nonzero if we just created this node. Return
+ an error if we should not permit the open to complete because of a
+ permission restriction. */
+error_t netfs_check_open_permissions (struct iouser *user, struct node *np,
+ int flags, int newnode);
+
+/* The user must define this function. Read from the 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);
+
+/* The user must define this function. Write to the file NP for user
+ CRED starting at OFSET and continuing for up to *LEN bytes from
+ DATA. Set *LEN to the amount seccessfully written upon return. */
+error_t netfs_attempt_write (struct iouser *cred, struct node *np,
+ off_t offset, size_t *len, void *data);
+
+/* The user must define this function. Return the valid access
+ types (bitwise OR of O_READ, O_WRITE, and O_EXEC) in *TYPES for
+ file NP and user CRED. */
+error_t netfs_report_access (struct iouser *cred, struct node *np,
+ int *types);
+
+/* The user must define this function. 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);
+
+/* The user must define this function. Node NP is all done; free
+ all its associated storage. */
+void netfs_node_norefs (struct node *np);
+
+error_t netfs_get_dirents (struct iouser *, struct node *, int, int, char **,
+ mach_msg_type_number_t *, vm_size_t, int *);
+
+/* Option parsing */
+
+/* Parse and execute the runtime options in ARGZ & ARGZ_LEN. EINVAL is
+ returned if some option is unrecognized. The default definition of this
+ routine will parse them using NETFS_RUNTIME_ARGP, which see. */
+error_t netfs_set_options (char *argz, size_t argz_len);
+
+/* Append to the malloced string *ARGZ of length *ARGZ_LEN a NUL-separated
+ list of the arguments to this translator. The default definition of this
+ routine simply calls netfs_append_std_options. */
+error_t netfs_append_args (char **argz, unsigned *argz_len);
+
+/* If this is defined or set to a pointer to an argp structure, it will be
+ used by the default netfs_set_options to handle runtime option parsing.
+ The default definition is initialized to a pointer to
+ NETFS_STD_RUNTIME_ARGP. Setting this variable is the usual way to add
+ option parsing to a program using libnetfs. */
+extern struct argp *netfs_runtime_argp;
+
+/* An argp for the standard netfs runtime options. The default definition
+ of NETFS_RUNTIME_ARGP points to this, although if the user redefines
+ that, he may chain this onto his argp as well. */
+extern const struct argp netfs_std_runtime_argp;
+
+/* An argp structure for the standard netfs command line arguments. The
+ user may call argp_parse on this to parse the command line, chain it onto
+ the end of his own argp structure, or ignore it completely. */
+extern const struct argp netfs_std_startup_argp;
+
+/* *Appends* to ARGZ & ARGZ_LEN '\0'-separated options describing the standard
+ netfs option state (note that unlike netfs_get_options, ARGZ & ARGZ_LEN
+ must already have a sane value). */
+error_t netfs_append_std_options (char **argz, size_t *argz_len);
+
+/* Definitions provided by netfs. */
+struct node *netfs_make_node (struct netnode *);
+
+mach_port_t netfs_startup (mach_port_t, int);
+
+extern spin_lock_t netfs_node_refcnt_lock;
+
+extern int netfs_maxsymlinks;
+
+void netfs_init (void);
+void netfs_server_loop (void);
+struct protid *netfs_make_protid (struct peropen *, struct iouser *);
+
+/* Create and return a new peropen structure on node NP with open
+ flags FLAGS. The initial values for the root_parent, shadow_root, and
+ shadow_root_parent fields are copied from CONTEXT if it's non-zero,
+ otherwise zerod. */
+struct peropen *netfs_make_peropen (struct node *, int,
+ struct peropen *context);
+
+void netfs_drop_node (struct node *);
+void netfs_release_protid (void *);
+void netfs_release_peropen (struct peropen *);
+int netfs_demuxer (mach_msg_header_t *, mach_msg_header_t *);
+error_t netfs_shutdown (int);
+
+extern struct port_class *netfs_protid_class;
+extern struct port_class *netfs_control_class;
+extern struct port_bucket *netfs_port_bucket;
+extern struct node *netfs_root_node;
+extern mach_port_t netfs_fsys_identity;
+extern auth_t netfs_auth_server_port;
+
+void netfs_nref (struct node *np);
+void netfs_nrele (struct node *np);
+void netfs_nput (struct node *np);
+
+
+/* Mig gook. */
+typedef struct protid *protid_t;
+
+
+#endif /* _HURD_NETFS_H_ */
diff --git a/libnetfs/nput.c b/libnetfs/nput.c
new file mode 100644
index 00000000..1d19482a
--- /dev/null
+++ b/libnetfs/nput.c
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, 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. */
+
+#include "priv.h"
+
+void
+netfs_nput (struct node *np)
+{
+ spin_lock (&netfs_node_refcnt_lock);
+ assert (np->references);
+ np->references--;
+ if (np->references == 0)
+ netfs_drop_node (np);
+ else
+ {
+ spin_unlock (&netfs_node_refcnt_lock);
+ mutex_unlock (&np->lock);
+ }
+}
+
diff --git a/libnetfs/nref.c b/libnetfs/nref.c
new file mode 100644
index 00000000..f5a970da
--- /dev/null
+++ b/libnetfs/nref.c
@@ -0,0 +1,29 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, 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. */
+
+#include "priv.h"
+
+void
+netfs_nref (struct node *np)
+{
+ spin_lock (&netfs_node_refcnt_lock);
+ np->references++;
+ spin_unlock (&netfs_node_refcnt_lock);
+}
diff --git a/libnetfs/nrele.c b/libnetfs/nrele.c
new file mode 100644
index 00000000..0104e01d
--- /dev/null
+++ b/libnetfs/nrele.c
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, 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. */
+
+#include "priv.h"
+
+void
+netfs_nrele (struct node *np)
+{
+ spin_lock (&netfs_node_refcnt_lock);
+ assert (np->references);
+ np->references--;
+ if (np->references == 0)
+ {
+ mutex_lock (&np->lock);
+ netfs_drop_node (np);
+ }
+ else
+ spin_unlock (&netfs_node_refcnt_lock);
+}
diff --git a/libnetfs/parse-runtime-options.c b/libnetfs/parse-runtime-options.c
new file mode 100644
index 00000000..1a179736
--- /dev/null
+++ b/libnetfs/parse-runtime-options.c
@@ -0,0 +1,30 @@
+/* A default netfs_parse_runtime_options routine
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+
+error_t
+netfs_parse_runtime_options (int argc, char **argv,
+ const struct argp *standard_argp)
+{
+ return argp_parse (standard_argp, argc, argv,
+ ARGP_NO_ERRS | ARGP_NO_HELP | ARGP_PARSE_ARGV0,
+ 0, 0);
+}
diff --git a/libnetfs/priv.h b/libnetfs/priv.h
new file mode 100644
index 00000000..5afbae7f
--- /dev/null
+++ b/libnetfs/priv.h
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include <hurd/hurd_types.h>
+
+#include "netfs.h"
+
+extern inline struct protid *
+begin_using_protid_port (file_t port)
+{
+ return ports_lookup_port (netfs_port_bucket, port, netfs_protid_class);
+}
+
+extern inline void
+end_using_protid_port (struct protid *cred)
+{
+ if (cred)
+ ports_port_deref (cred);
+}
diff --git a/libnetfs/release-peropen.c b/libnetfs/release-peropen.c
new file mode 100644
index 00000000..9a52184b
--- /dev/null
+++ b/libnetfs/release-peropen.c
@@ -0,0 +1,46 @@
+/*
+ Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+
+void
+netfs_release_peropen (struct peropen *po)
+{
+ mutex_lock (&po->np->lock);
+ if (--po->refcnt)
+ mutex_unlock (&po->np->lock);
+ else
+ {
+ if (po->root_parent)
+ mach_port_deallocate (mach_task_self (), po->root_parent);
+
+ if (po->shadow_root && po->shadow_root != po->np)
+ {
+ mutex_lock (&po->shadow_root->lock);
+ netfs_nput (po->shadow_root);
+ }
+ if (po->shadow_root_parent)
+ mach_port_deallocate (mach_task_self (), po->shadow_root_parent);
+
+ netfs_nput (po->np);
+
+ free (po);
+ }
+}
diff --git a/libnetfs/release-protid.c b/libnetfs/release-protid.c
new file mode 100644
index 00000000..b1bac0eb
--- /dev/null
+++ b/libnetfs/release-protid.c
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+#include <sys/mman.h>
+
+void
+netfs_release_protid (void *arg)
+{
+ struct protid *user = arg;
+
+ iohelp_free_iouser (user->user);
+ if (user->shared_object)
+ mach_port_deallocate (mach_task_self (), user->shared_object);
+ if (user->mapped)
+ munmap (user->mapped, vm_page_size);
+ netfs_release_peropen (user->po);
+}
diff --git a/libnetfs/runtime-argp.c b/libnetfs/runtime-argp.c
new file mode 100644
index 00000000..ae787fe2
--- /dev/null
+++ b/libnetfs/runtime-argp.c
@@ -0,0 +1,23 @@
+/* Default definition for netfs_runtime_argp
+
+ Copyright (C) 1996 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+
+struct argp *netfs_runtime_argp = (struct argp *)&netfs_std_runtime_argp;
diff --git a/libnetfs/set-get-trans.c b/libnetfs/set-get-trans.c
new file mode 100644
index 00000000..5d5d7729
--- /dev/null
+++ b/libnetfs/set-get-trans.c
@@ -0,0 +1,44 @@
+/* Default versions of netfs_set_translator & netfs_get_translator
+
+ Copyright (C) 1997 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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. */
+
+#include "netfs.h"
+
+/* The user may define this function. Attempt to set the passive
+ translator record for FILE to ARGZ (of length ARGZLEN) for user
+ CRED. */
+error_t
+netfs_set_translator (struct iouser *cred, struct node *np,
+ char *argz, size_t argzlen)
+{
+ return EOPNOTSUPP;
+}
+
+/* The user may define this function (but should define it together with
+ netfs_set_translator). 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;
+}
diff --git a/libnetfs/set-options.c b/libnetfs/set-options.c
new file mode 100644
index 00000000..416d9123
--- /dev/null
+++ b/libnetfs/set-options.c
@@ -0,0 +1,30 @@
+/* Parse run-time options
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+
+error_t
+netfs_set_options (char *argz, size_t argz_len)
+{
+ if (netfs_runtime_argp)
+ return fshelp_set_options (netfs_runtime_argp, 0, argz, argz_len, 0);
+ else
+ return EOPNOTSUPP;
+}
diff --git a/libnetfs/shutdown.c b/libnetfs/shutdown.c
new file mode 100644
index 00000000..8e4c7a68
--- /dev/null
+++ b/libnetfs/shutdown.c
@@ -0,0 +1,28 @@
+/*
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell, p/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. */
+
+#include "netfs.h"
+
+error_t
+netfs_shutdown (int flags)
+{
+ return EBUSY;
+}
+
diff --git a/libnetfs/startup-argp.c b/libnetfs/startup-argp.c
new file mode 100644
index 00000000..d922f698
--- /dev/null
+++ b/libnetfs/startup-argp.c
@@ -0,0 +1,49 @@
+/* Standard startup-time command line parser
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <stdio.h>
+#include <argp.h>
+
+#include "netfs.h"
+
+static const struct argp_option
+startup_options[] =
+{
+ {0}
+};
+
+static error_t
+parse_startup_opt (int opt, char *arg, struct argp_state *state)
+{
+ switch (opt)
+ {
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static const struct argp
+startup_argp =
+ { startup_options, parse_startup_opt };
+
+const struct argp *netfs_startup_argp = &startup_argp;
diff --git a/libnetfs/std-runtime-argp.c b/libnetfs/std-runtime-argp.c
new file mode 100644
index 00000000..9e2ad1d6
--- /dev/null
+++ b/libnetfs/std-runtime-argp.c
@@ -0,0 +1,24 @@
+/* Parse standard run-time options
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <argp.h>
+#include "netfs.h"
+
+const struct argp netfs_std_runtime_argp = { 0 };
diff --git a/libnetfs/std-startup-argp.c b/libnetfs/std-startup-argp.c
new file mode 100644
index 00000000..3de84a57
--- /dev/null
+++ b/libnetfs/std-startup-argp.c
@@ -0,0 +1,27 @@
+/* Standard startup-time command line parser
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <argp.h>
+#include "netfs.h"
+
+const struct argp
+netfs_std_startup_argp = { 0 };
diff --git a/libnetfs/trans-callback.c b/libnetfs/trans-callback.c
new file mode 100644
index 00000000..8452b005
--- /dev/null
+++ b/libnetfs/trans-callback.c
@@ -0,0 +1,79 @@
+/* Callback functions for starting translators
+
+ Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "priv.h"
+#include <fcntl.h>
+
+/* Callback function needed for calls to fshelp_fetch_root. See
+ <hurd/fshelp.h> for the interface description. */
+static error_t
+_netfs_translator_callback1_fn (void *cookie1, void *cookie2,
+ uid_t *uid, gid_t *gid,
+ char **argz, size_t *argz_len)
+{
+ error_t err;
+ struct node *np = cookie1;
+
+ if (! (np->nn_stat.st_mode & S_IPTRANS))
+ return ENOENT;
+
+ err = netfs_get_translator (np, argz, argz_len);
+ if (err)
+ return err;
+
+ *uid = np->nn_stat.st_uid;
+ *gid = np->nn_stat.st_gid;
+
+ return 0;
+}
+
+/* Callback function needed for calls to fshelp_fetch_root. See
+ <hurd/fshelp.h> for the interface description. */
+static error_t
+_netfs_translator_callback2_fn (void *cookie1, void *cookie2, int flags,
+ mach_port_t *underlying,
+ mach_msg_type_name_t *underlying_type)
+{
+ struct protid *cred;
+ struct idvec *uids, *gids;
+ struct node *node = cookie1;
+
+ uids = make_idvec ();
+ gids = make_idvec ();
+ idvec_set_ids (uids, &node->nn_stat.st_uid, 1);
+ idvec_set_ids (gids, &node->nn_stat.st_gid, 1);
+
+ cred = netfs_make_protid (netfs_make_peropen (node, flags, cookie2),
+ iohelp_create_iouser (uids, gids));
+ if (cred)
+ {
+ *underlying = ports_get_right (cred);
+ *underlying_type = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (cred);
+ return 0;
+ }
+ else
+ return errno;
+}
+
+fshelp_fetch_root_callback1_t _netfs_translator_callback1 =
+ _netfs_translator_callback1_fn;
+fshelp_fetch_root_callback2_t _netfs_translator_callback2 =
+ _netfs_translator_callback2_fn;
diff --git a/libnetfs/unparse-runtime-options.c b/libnetfs/unparse-runtime-options.c
new file mode 100644
index 00000000..4596600c
--- /dev/null
+++ b/libnetfs/unparse-runtime-options.c
@@ -0,0 +1,33 @@
+/* A default netfs_unparse_runtime_options routine
+
+ Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "netfs.h"
+
+/* The user may define this function, in which case it is called when the the
+ filesystem receives a get-options request. ARGZ & ARGZ_LEN will contain
+ information on `standard' netfs options; the user may extend them
+ (probably by using argz_add), or ignore them, in which case case ARGZ
+ should be freed, as it is malloced. The default implementation simply
+ leaves ARGZ & ARGZ_LEN unmodified and returns sucess (0). */
+error_t
+netfs_unparse_runtime_options (char **argz, size_t *argz_len)
+{
+ return 0;
+}