diff options
Diffstat (limited to 'libtrivfs')
86 files changed, 4961 insertions, 0 deletions
diff --git a/libtrivfs/ChangeLog b/libtrivfs/ChangeLog new file mode 100644 index 00000000..d3e16951 --- /dev/null +++ b/libtrivfs/ChangeLog @@ -0,0 +1,905 @@ +1999-11-08 Roland McGrath <roland@baalperazim.frob.com> + + * io-write.c: Include <fcntl.h>. + + * fsys-getroot.c (trivfs_S_fsys_getroot): Fix typo. + + * io-write.c (trivfs_S_io_write): Return EBADF if trivfs_allow_open + doesn't include O_WRITE. + + * io-modes-get.c (trivfs_S_io_get_openmodes): Remove assert. + The default implementation ought to be fine for this. + + * io-owner-get.c (trivfs_S_io_get_owner): Remove asserts. + It is entirely reasonable to have EOPNOTSUPP be the default + implementation for these calls that files are not obligated to provide. + * io-owner-mod.c (trivfs_S_io_mod_owner): Likewise. + * io-map.c (trivfs_S_io_map): Likewise. + * io-async.c (trivfs_S_io_async): Likewise. + * io-async-icky.c (trivfs_S_io_get_icky_async_id): Likewise. + + * fsys-getroot.c (trivfs_S_fsys_getroot): Return EROFS or EACCES for a + disallowed open attempt, instead of EOPNOTSUPP. EOPNOTSUPP results in + the confusing result of ENOTDIR being delivered to the user. + +1999-10-11 Roland McGrath <roland@baalperazim.frob.com> + + * dir-readdir.c (trivfs_S_dir_readdir): Take DATA_DEALLOC parameter. + + * dir-lookup.c (trivfs_S_dir_lookup): Duplicate CRED->user to pass it + to trivfs_open. Add ref to CRED->realnode when used by trivfs_open. + + * trivfs.h (trivfs_open_hook): New variable. + * fsys-getroot.c (trivfs_S_fsys_getroot): Use it. + +1999-09-13 Roland McGrath <roland@baalperazim.frob.com> + + * Makefile, io-map.c, io-map-segment.c: Reverted changes related to + io_map_segment. + +1999-09-07 Thomas Bushnell, BSG <tb@mit.edu> + + * io-map-segment.c (trivfs_S_io_map): New file. + * io-map.c (trivfs_S_io_map): Just call trivfs_S_io_map_segment. + * Makefile (IOSRCS): Add io-map-segment.c. + +Mon Mar 15 14:36:33 1999 Thomas Bushnell, BSG <tb@mit.edu> + + * migsupport.c (trivfs_begin_using_protid): In first branch, + protect work against PI being null, and call ports_port_deref with + the proper value. + (trivfs_begin_using_control): Likewise. + Reported by Mark Kettenis (kettenis@wins.uva.nl). + +1999-02-06 Mark Kettenis <kettenis@gnu.org> + + * trivfs.h (trivfs_check_access_hook): New variable. + * fsys-getroot.c (trivfs_S_fsys_getroot): Use + trivfs_check_acces_hook. + * dir-lookup.c (trivfs_S_dir_lookup): Likewise. + * file-access.c (trivfs_S_file_check_access): Likewise. + +1999-02-16 Roland McGrath <roland@baalperazim.frob.com> + + * io-revoke.c: Add reply, reply_type args. + +Tue Feb 16 05:47:57 1999 Thomas Bushnell, BSG <tb@mit.edu> + + * io-revoke.c: New file. + * Makefile (IOSRCS): Add io-revoke.c. + +1999-02-12 Gordon Matzigkeit <gord@trick.fig.org> + + * open.c (trivfs_open): Add missing `=' from last change. + +1999-02-05 Mark Kettenis <kettenis@gnu.org> + + * open.c (trivfs_open): Correctly initialize NEW->isroot. + +Sun Jan 31 18:29:22 1999 Thomas Bushnell, BSG <tb@mit.edu> + + * times.c (trivfs_set_atime, trivefs_set_mtime): Take advantage of + new semantics for file_utimes. + +1998-08-20 Roland McGrath <roland@baalperazim.frob.com> + + * file-get-fs-options.c (trivfs_S_file_get_fs_options): + fshelp_return_malloced_buffer renamed to iohelp_*. + * fsys-get-options.c (trivfs_S_fsys_get_options): Likewise. + +1998-07-20 Roland McGrath <roland@baalperazim.frob.com> + + * dir-lookup.c (trivfs_S_dir_lookup): Fix brainos in last change. + +Tue Jul 14 16:47:28 1998 Thomas Bushnell, n/BSG <tb@mit.edu> + + * dir-lookup.c (trivfs_S_dir_lookup): In null-pathname case, this + should work even for non-directories, so actually do it, making + this a simpler case of trivfs_S_fsys_getroot. + +Thu Feb 20 13:13:13 1997 Miles Bader <miles@gnu.ai.mit.edu> + + * protid-classes.c (trivfs_protid_portclasses, + trivfs_protid_nportclasses): Make common. + * cntl-classes.c (trivfs_cntl_portclasses, + trivfs_cntl_nportclasses): Likewise. + +Tue Feb 18 19:47:16 1997 Miles Bader <miles@gnu.ai.mit.edu> + + * cntl-create.c (trivfs_create_control): Put the actual port + creation call back in! + +Fri Feb 14 02:10:50 1997 Miles Bader <miles@gnu.ai.mit.edu> + + * dyn-classes.c: New file. + * cntl-create.c (trivfs_create_control): Possibly allocate and add + the port classes/buckets to the list of ones recognized by trivfs. + * migsupport.c + (trivfs_begin_using_protid): Support dynamic protid port classes. + (trivfs_begin_using_control): Support dynamic control port classes. + * cntl-clean.c (trivfs_clean_cntl): Clean up dynamic port + classes/buckets. + * trivfs.h (trivfs_add_control_port_class, + trivfs_add_protid_port_class, trivfs_add_port_bucket, + trivfs_remove_control_port_class, trivfs_remove_protid_port_class, + trivfs_remove_port_bucket): New declarations. + Doc fixes. + * priv.h (trivfs_dynamic_protid_port_classes, + trivfs_num_dynamic_protid_port_classes, + trivfs_dynamic_control_port_classes, + trivfs_num_dynamic_control_port_classes, + trivfs_dynamic_port_buckets, trivfs_num_dynamic_port_buckets): + New declarations. + * Makefile (OTHERSRCS): Add dyn-classes.c, protid-classes.c, & + cntl-classes.c. + +Thu Feb 13 18:30:45 1997 Miles Bader <miles@gnu.ai.mit.edu> + + * trivfs.h (trivfs_getroot_hook): New declaration. + * fsys-getroot.c (trivfs_S_fsys_getroot): Use trivfs_getroot_hook. + * Makefile (FSSRCS): Replace dir-reparent.c by file-reparent.c. + +Mon Jan 20 16:37:04 1997 Miles Bader <miles@gnu.ai.mit.edu> + + * dir-reparent.c (trivfs_S_dir_reparent): New file. + * Makefile (FSSRCS): Add dir-reparent.c. + +Tue Nov 19 22:36:49 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * io-stat.c (trivfs_S_io_stat): Clear S_ITRANS and set S_IROOT in + ST->st_mode (before calling trivfs_modify_stat). + +Mon Nov 18 18:13:42 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * io-stat.c (trivfs_S_io_stat): Make the mode specify IFCHR by + default. + +Sat Nov 16 17:20:15 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * Makefile (HURDLIBS): Add `iohelp'. + +Thu Nov 14 13:13:10 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * io-restrict-auth.c (trivfs_S_io_restrict_auth): idvec_set -> + idvec_set_ids. Fix unrelated typos. + + * protid-dup.c (trivfs_protid_dup): Use iouser_dup_iouser instead + of copying old arrays by hand. + * protid-clean.c (trivfs_clean_protid): Free CRED->user instead of + CRED->uids and CRED->gids. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Args for + io_restrict_auth now come from the new structure definitions. + * open.c (trivfs_open): Pass correct first arg to idvec_contains. + + * open.c (trivfs_open): Delete variable I. + + * trivfs.h: Include <hurd/iohelp.h> + +Thu Nov 7 17:05:02 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * io-restrict-auth.c (trivfs_S_io_restrict_auth): If CRED has + root, use the requested id sets verbatim. + +Thu Nov 7 01:01:05 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Rewrite to use + idvecs. + +Wed Nov 6 23:40:50 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * trivfs.h (struct trivfs_protid): Delete members `uids', `gids', + `nuids', and `ngids'. Replace with `user'. + (trivfs_check_open_hook): Delete args `uids', `nuids', `gids', + `ngids'. Replace with new arg `user'. All callers changed. + (trivfs_open): Likewise. + * open.c (trivfs_open): Change to match new declaration. + + * trivfs.h (struct trivfs_protid): Delete members `uids', `gids', + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Use new + iohelp_reauth call. + +Thu Sep 26 14:25:29 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * file-access.c (trivfs_S_file_check_access): Return + CRED->realnode's access bits rather than always 0. + +Mon Sep 23 17:20:08 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * file-get-fs-options.c <argz.h>: New include. + + * trivfs.h (trivfs_append_args): Make ARGZ_LEN `size_t *'. + * append-args.c (trivfs_append_args): Likewise. + +Thu Sep 19 18:00:42 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * Makefile (HURDLIBS): Add shouldbeinlibc. + +Wed Sep 18 12:47:54 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * fsys-get-options.c (trivfs_S_fsys_get_options): Initialize ARGZ + with the program name, and call trivfs_append_args instead of + trivfs_get_options. + * file-get-fs-options.c (trivfs_S_file_get_fs_options): Likewise. + * trivfs.h (trivfs_append_args): New declaration. + (trivfs_get_options): Declaration removed. + * Makefile (OTHERSRCS): Replace get-options.c with apend-args.c. + * append-args.c (trivfs_append_args): New file. + +Thu Sep 12 16:23:15 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * Makefile (HURDLIBS): New variable. + (libtrivfs.so): Delete special depedency. + +Fri Aug 16 19:24:45 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * migsupport.c (trivfs_end_using_protid): Only call + ports_port_deref if CRED is set. + (trivfs_end_using_control): Likewise. + +Thu Aug 15 16:14:33 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu> + + * io-pathconf.c (trivfs_S_io_pathconf): Implement by calling + underlying node. + +Thu Jul 18 23:14:44 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Use noinstall + version of ports_create_port. Put it in the port set after the + node has been fully initialized. + +Sat Jul 13 20:15:56 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Repeat + ports_create_port, auth_server_authenticate, io_restrict_auth, and + *trivfs_protid_create_hook for as long as we get EINTR. Deal with + other errors without crashing. + +Sun Jul 7 16:06:37 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Don't use + MACH_MSG_TYPE_MOVE_SEND; it's unreliable. + +Thu Jun 20 22:54:01 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * file-get-fs-options.c (trivfs_S_file_get_fs_options): + Call trivfs_get_options, and package up the results. + * fsys-get-options.c (trivfs_S_fsys_get_options): Likewise. + * fsys-set-options.c (trivfs_S_fsys_set_options): Call + trivfs_set_options. + * set-options.c, get-options.c: New files. + * trivfs.h: Add trivfs_set_options & trivfs_get_options. + * Makefile (OTHERSRCS): Add set-options.c & get-options.c. + +Wed Jun 19 21:29:45 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * trivfs.h (trivfs_runtime_argp): New declaration. + * fsys-set-options.c (trivfs_S_fsys_set_options): Use + trivfs_runtime_argp to parse options. + * runtime-argp.c: New file. + * Makefile (OTHERSRCS): Add runtime-argp.c. + +Sat Jun 15 19:50:37 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * fsys-stubs.c (trivfs_S_fsys_set_options, trivfs_S_fsys_get_options, + trivfs_S_file_get_fs_options): Functions removed. + * fsys-set-options.c, fsys-get-options.c, file-get-fs-options.c: + New files. + * Makefile (FSSRCS): Add file-get-fs-options.c + (FSYSSRCS): Add fsys-set-options.c & fsys-get-options.c. + +Thu May 9 20:03:28 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * io-identity.c: New file. + * Makefile (IOSRCS): Add io-identity.c. + * cntl-clean.c (trivfs_clean_cntl): Destroy filesys_id and file_id + members. + * cntl-create.c (trivfs_create_control): Initialize filesys_id and + file_id members of new control. + * trivfs.h (trivfs_control): New members `filesys_id' and + `file_id'. + +Thu May 9 16:58:31 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * file-get-storage-info.c (trivfs_S_file_get_storage_info): Change + to new interface. + +Thu May 9 15:32:38 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Don't send + right for CRED to auth_server_authenticate. + + * fsys-stubs.c (trivfs_S_fsys_get_options): Expect (and ignore) + reply port args. + + * file-syncfs.c (trivfs_S_file_syncfs): Provide new third arg to + file_sync. + * fsys-syncfs.c (trivfs_S_fsys_syncfs): Likewise. + * file-sync.c (trivfs_S_file_sync): Accept and pass through new + omitmeta parm. + + * file-statfs.c (trivfs_S_file_statfs): Use new struct statfs + format. + + * dir-rename.c (trivfs_S_dir_rename): Accept new excl parm. + * dir-link.c (trivfs_S_dir_link): Likewise. + + * Makefile (OTHERSRCS): Delete handle-port.c. + * trivfs.h (trivfs_handle_port): Delete declaration. + * handle-port.c: Delete file. + +Thu May 9 12:16:38 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * io-select.c (trivfs_S_io_select): Remove TAG arg. + +Tue May 7 16:14:10 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * file-get-storage-info.c (trivfs_S_file_get_storage_info): Swap + PORTS_TYPE and NUM_PORTS args. + +Mon May 6 20:16:20 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * file-get-storage-info.c (trivfs_S_file_get_storage_info): + Rewrite for new interface. + +Mon Apr 29 15:19:26 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * handle-port.c: Comment out warning addition. + +Sun Apr 28 15:22:16 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> + + * handle-port.c: Add obsolescence link warning. + +Thu Apr 11 18:03:31 1996 Michael I. Bushnell, p/BSG <mib@gnu.ai.mit.edu> + + * Makefile (MIGSFLAGS): Reference fsmutations.h in $(srcdir). + +Thu Jan 25 16:19:29 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * cntl-create.c (trivfs_create_control): New function. + * trivfs.h (trivfs_create_control): New declaration. + * startup.c (trivfs_startup): Use trivfs_create_control. + * handle-port.c (trivfs_handle_port): Likewise. + * Makefile (OTHERSRCS): Add cntl-create.c. + + * open.c (trivfs_open): Use ports_create_port instead of + ports_allocate_port, and return any error. + * protid-dup.c (trivfs_protid_dup): Likewise. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + +Mon Jan 15 12:02:49 1996 Miles Bader <miles@gnu.ai.mit.edu> + + * protid-clean.c (trivfs_clean_protid): Don't hold + CRED->po->cntl->lock while calling TRIVFS_PEROPEN_DESTROY_HOOK. + +SUN Nov 5 00:01:53 1995 Miles Bader <miles@gnu.ai.mit.edu> + + * fsys-stubs.c (trivfs_S_fsys_get_options, + trivfs_S_file_get_fs_options): New functions. + + * file-get-storage-info.c (trivfs_S_file_get_storage_info): Add + FLAGS arg. + + * dir-chg.c (trivfs_S_dir_notice_changes): Waste some time adding + reply port args that no one will use. + * dir-link.c (trivfs_S_dir_link): Ditto. + * dir-lookup.c (trivfs_S_dir_lookup): Ditto. + * file-utimes.c (trivfs_S_file_utimes): Ditto. + * file-statfs.c (trivfs_S_file_statfs)Ditto. + * file-set-trans.c (trivfs_S_file_set_translator): Ditto. + * file-lock.c (trivfs_S_file_lock, trivfs_S_file_lock_stat): Ditto. + * file-getlinknode.c (trivfs_S_file_getlinknode): Ditto. + * file-getfh.c (trivfs_S_file_getfh): Ditto. + * file-get-transcntl.c (trivfs_S_file_get_translator_cntl): Ditto. + * file-get-trans.c (trivfs_S_file_get_translator): Ditto. + * file-get-storage-info.c (trivfs_S_file_get_storage_info): Ditto. + * file-chown.c (trivfs_S_file_chown): Ditto. + * file-chflags.c (trivfs_S_file_chflags): Ditto. + * file-chg.c (trivfs_S_file_notice_changes): Ditto. + * dir-unlink.c (trivfs_S_dir_unlink): Ditto. + * dir-rmdir.c (trivfs_S_dir_rmdir): Ditto. + * dir-rename.c (trivfs_S_dir_rename): Ditto. + * dir-readdir.c (trivfs_S_dir_readdir): Ditto. + * dir-mkfile.c (trivfs_S_dir_mkfile): Ditto. + * dir-mkdir.c (trivfs_S_dir_mkdir): Ditto. + * file-chmod.c (trivfs_S_file_chmod): Ditto. + * file-chauthor.c (trivfs_S_file_chauthor): Ditto. + +Wed Nov 1 15:53:38 1995 Miles Bader <miles@gnu.ai.mit.edu> + + * startup.c (trivfs_startup): Add FLAGS arg, passed to fsys_startup. + * trivfs.h (trivfs_startup): Add FLAGS arg. + * fsys-stubs.c (trivfs_S_fsys_startup): Ditto. + +Sat Oct 7 05:04:02 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * fsys-stubs.c (trivfs_S_fsys_getpriv): Add poly args. + + * Makefile (libtrivfs.so): Depend on ../libports/libports.so. + +Fri Oct 6 17:44:08 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * migsupport.c: Remove leading _ from function names. + * fsmutations.h: Likewise. + * trivfs.h (trivfs_{begin,end}_using_{protid,control}): Declare them. + +Fri Oct 6 17:28:07 1995 Miles Bader <miles@gnu.ai.mit.edu> + + * dir-link.c (trivfs_S_dir_link): Swap first two arguments. + + * file-get-storage-info.c (trivfs_S_file_get_storage_info): Change + type of RUNS to off_t **, and add the BLOCK_SIZE parameter. + +Thu Oct 5 00:41:33 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * Makefile (FSSRCS): Add file-get-storage-info.c. + * file-get-storage-info.c: New file. + +Mon Sep 18 14:29:37 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * file-set-size.c (trivfs_S_file_set_size): Renamed from + file-truncate.c:trivfs_s_file_truncate. + * io-pathconf.c (trivfs_S_io_pathconf): Renamed from + file-pathconf.c:trivfs_S_file_pathconf. + (trivfs_S_io_pathconf): Add reply port to args. + * Makefile (FSSRCS): Remove file-pathconf.c. + (IOSRCS): Add io-pathconf.c. + (FSSRCS): Rename file-truncate.c to file-set-size.c. + +Wed Sep 6 10:33:03 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * demuxer.c (trivfs_demuxer): Use ports_notify_server and + ports_interrupt_server instead of our own versions. + * Makefile (SRCS): Removed $(NOTIFYSRCS) and $(INTSRCS). + (NOTIFYSRCS, INTSRCS): Removed. + (MIGSTUBS): Removed notifyServer.o and interruptServer.o. + * interrupt.c: File deleted. + +Fri Aug 25 12:11:26 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * interrupt.c (trivfs_S_interrupt_operation): Use ports_interrupt_rpc. + +Thu Aug 24 11:46:19 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * fsys-forward.c (trivfs_S_fsys_forward): New file. + +Wed Aug 23 15:09:31 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * Makefile (REMHDRS): Removed. + (FSYSSRCS): Added fsys-forward.c. + +Mon Aug 21 15:25:36 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * handle-port.c (trivfs_handle_port): Initialize the hook field. + * io-stat.c (trivfs_S_io_stat): Pass CRED to trivfs_modify_stat. + * fsys-goaway.c (trivfs_S_fsys_goaway): Use new args for trivfs_goaway. + * trivfs.h (struct trivfs_control): Add the hook field. + (trivfs_goaway): Pass the control structure directly instead of + random fields from it. + (trivfs_modify_stat): Pass in the node as well. + +Mon Aug 21 10:51:24 1995 Michael I. Bushnell, p/BSG <mib@duality.gnu.ai.mit.edu> + + * protid-dup.c: Doc fix. + +Fri Aug 11 14:01:41 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * open.c (trivfs_open): Actually set the PO field to what we create. + * Makefile (OTHERSRCS): Add protid-dup.c and open.c. + +Tue Aug 8 14:07:04 1995 Miles Bader <miles@geech.gnu.ai.mit.edu> + + * open.c: New file, containing trivfs_open. + * fsys-getroot.c (trivfs_S_fsys_getroot): Guts (except for + protection check) moved into trivfs_open. + * protid-dup.c: New file, containing trivfs_protid_dup. + * io-duplicate.c (trivfs_S_io_duplicate): Guts moved into + trivfs_protid_dup. + + * trivfs.h (trivfs_protid_create_hook, trivfs_peropen_create_hook): + Change the declarations now that these return an error code. + * fsys-getroot.c (trivfs_S_fsys_getroot): Allow + trivfs_protid_create_hook and trivfs_peropen_create_hook to return + an error code, and abort if either does. + * protid-clean.c (trivfs_clean_protid): Only call + trivfs_protid_destroy_hook hook on CRED if it was fully initialized. + * io-duplicate.c (trivfs_S_io_duplicate): Allow + trivfs_protid_create_hook to return an error code. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Ditto. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Ditto. + +Fri Jul 21 17:01:12 1995 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * fsys-getroot.c (trivfs_S_fsys_getroot): Free initial reference + created by ports_allocate_port. + * handle-port.c (trivfs_handle_port): Likewise. + * io-duplicate.c (trivfs_S_io_duplicate): Likewise. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + +Sun Jul 16 13:00:44 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * trivfs.h: Protect against including twice, and add includes that + we depend on. + +Thu Jul 6 15:38:48 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu> + + * Makefile: Removed dependencies that are now automatically + generated. + +Tue Jun 27 10:55:16 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu> + + * fsys-goaway.c (trivfs_S_fsys_goaway): Call trivfs_goaway the new + way. + * startup.c (trivfs_startup): New parms CONTROL_BUCKET and + PROTID_BUCKET; pass them to trivfs_handle_port. Use new ports + interface. + * protid-clean.c (trivfs_clean_protid): Use new ports interface. + Use PREdecrement in reference counting check. + * nosenders.c (trivfs_do_mach_notify_no_senders): Use new ports + interface. + * migsupport.c (_trivfs_begin_using_protid, + _trivfs_end_using_protid, _trivfs_begin_using_oontrol, + _trivfs_end_using_control): Use new ports interface. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Use new ports + interface. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Use new ports + interface. + * io-duplicate.c (trivfs_S_io_duplicate): Use new ports interface. + * handle-port.c (trivfs_handle_port): Take new parms; use new + ports interface; initialize CNTL->protid_bucket. + * fsys-getroot.c (trivfs_S_fsys_getroot): Use new form of + ports_allocate_port call. + * trivfs.h (trivfs_protid_portclasses): Renamed from + trivfs_protid_porttypes. Change type to `struct port_class *'. + (trivfs_protid_nportclasses): Renamed from trivfs_protid_nporttypes. + (trivfs_cntl_portclasses): Renamed from trivfs_cntl_porttypes. Change + type to `struct port_class *'. + (trivfs_cntl_nportclasses): Renamed from trivfs_cntl_nporttypes. + (trivfs_startup): Pass port classes instead of integer types. New + parms CONTROL_BUCKET and PROTID_BUCKET. + (trivfs_handle_port): Pass port classes instead of integer types. + New parms CONTROL_BUCKET and PROTID_BUCKET. + (trivfs_goaway): Pass port classes instead of integer types. + (struct trivfs_control): Renamed member `protid_types' to be + `protid_class' and changed type to be `stroct port_class *'. + New member `protid_bucket'. + +Fri May 12 19:05:46 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * fsys-stubs.c (trivfs_S_fsys_set_options, + trivfs_S_fsys_mod_readonly): Change from mod_readonly to set_options. + +Sun Apr 9 00:36:36 1995 Miles Bader <miles@churchy.gnu.ai.mit.edu> + + * io-stat.c (trivfs_S_io_stat): Before calling trivfs_modify_stat, + set the st_fstype & st_fsid fields to trivfs_fstype & trivfs_fsid. + But first, if trivfs_fsid is zero, set it to our process id, which + should be a nice unique value. + * file-statfs.c (trivfs_S_file_statfs): Ditto about the PID. + + * startup.c (trivfs_startup): New function, which implements a + common sequence of steps when starting up a new trivfs. + * trivfs.h: Declare trivfs_startup. + * Makefile (OTHERSRCS): Add startup.c. + +Thu Mar 30 12:27:59 1995 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * trivfs.h (trivfs_check_open_hook): Doc fix. + (trivfs_complete_open): Delete declaration. + (struct trivfs_control): Delete members `openshead' and + `openstail'. + * fsys-getroot.c (trivfs_S_fsys_getroot): Strip out old + hack for blocking. + (struct pending_open): Delete type. + (trivfs_complete_open): Delete function. + + * trivfs.h (struct trivfs_control): New member `lock'. + * handle-port.c (trivfs_handle_port): Initialize CNTL->lock. + * io-duplicate.c (trivfs_S_io_duplicate): Lock + CRED->po->cntl->lock around relevant code. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + * protid-clean.c (trivfs_clean_protid): Likewise. + +Tue Jan 17 19:00:28 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * io-select.c: Updated for new io_select interface. + +Fri Dec 9 01:35:54 1994 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * io-write.c: Use mach_msg_type_number_t in place of unsigned int + and int. + * io-read.c: Likewise. + * io-readable.c: Likewise. + +Tue Oct 25 10:54:06 1994 Michael I Bushnell <mib@churchy.gnu.ai.mit.edu> + + * fsys-getroot.c (trivfs_S_fsys_getroot): Don't clear O_NONBLOCK. + +Tue Aug 30 13:23:55 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * fsys-syncfs.c: New file. + * Makefile (FSYSSRCS): Added fsys-syncfs.c. + * fsys-stubs.c (trivfs_S_fsys_mod_readonly): New function. + + * Makefile (FSSRCS): Remove dir-pathtrans.c; add dir-lookup.c. + * dir-lookup.c: Renamed from dir-pathtrans.c + * dir-pathtrans.c (trivfs_S_dir_lookup): Renamed from + trivfs_S_dir_pathtrans. + + * fsys-getroot.c (trivfs_S_fsys_getroot): Use FS_RETRY_NORMAL + instead of FS_RETRY_NONE. + (trivfs_complete_open): Likewise. + + * file-set-trans.c (trivfs_S_file_set_translator): Change to args + as for new file_set_translator procotol. + +Mon Aug 29 12:52:43 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Use new + authentication protocol. + +Wed Aug 17 20:11:29 1994 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * io-select.c (trivfs_S_io_select): Take poly arg for notify port. + +Thu Aug 11 11:58:48 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * io-version.c (trivfs_S_io_server_version): Fix typo in name. + +Fri Jul 22 12:41:55 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * fsys-goaway.c: Include fsys_S.h with " not with <>. + * handle-port.c: Include priv.h with " not with <>. + + * Makefile: Converted to use new scheme. + * fsmutations.h (SERVERPREFIX): Deleted macro. + * fsys-getroot.c: Include "fsys_reply_U.h" instead of "fsys_reply.h". + +Wed Jul 20 15:59:36 1994 Michael I Bushnell <mib@geech.gnu.ai.mit.edu> + + * file-inv.c: New file. + * Makefile (FSSRCS): Added file-inv.c. + +Tue Jul 19 19:23:33 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * fsys-stubs.c (trivfs_S_fsys_startup): Deleted dotdot args. + * fsys-getroot.c (trivfs_S_fsys_getroot): New arg `dotdot'; + don't do anything with it. + +Mon Jul 11 14:49:03 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * trivfs.h (trivfs_set_atime, trivfs_set_mtime): New functions. + * times.c: New file. + * Makefile (OTHERSRCS): Added `times.c'. + +Thu Jul 7 10:39:04 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * Makefile (DIST_FILES): Add priv.h. + +Tue Jul 5 13:24:59 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * Makefile (DIST_FILES): Added fsmutations.h. + (TAGSHDRS): New variable. + + * fsys-getroot.c: Include "fsys_reply.h". + (trivfs_S_fsys_getroot, trivfs_complete_open): + Uncomment code now that we have reply ports. + (struct pending_open): Delete USERS_PORT, add CRED. + (trivfs_S_fsys_getroot): When creating PENDO, don't call + ports_get_right, call ports_port_ref; store CRED in PENDO. + (trivfs_complete_open): Deal with errors properly. When sending + port to user, call ports_get_right. Always call + ports_done_with_port when freeing pending open struct. + * Makefile (MIGSTUBS): Added fsys_replyUser.o. + (fsys_reply.h fsys_replyUser.c): New rule. + (fsys-getroot.c): Add dependency on fsys_reply.h. + + * fsmutations.h (REPLY_PORTS): New macro, affecting io and fsys + interfaces. + * io-async-icky.c (trivfs_S_io_get_icky_async_id): Added new + REPLY and REPLYTYPE args. + * io-async.c (trivfs_S_io_async): Likewise. + * io-duplicate.c (trivfs_S_io_duplicate): Likewise. + * io-map.c (trivfs_S_io_map): Likewise. + * io-modes-get.c (trivfs_S_io_get_openmodes): Likewise. + * io-modes-off.c (trivfs_S_io_clear_some_openmodes): Likewise. + * io-modes-on.c (trivfs_S_io_set_some_openmodes): Likewise. + * io-modes-set.c (trivfs_S_io_set_all_openmodes): Likewise. + * io-owner-get.c (trivfs_S_io_get_owner): Likewise. + * io-owner-mod.c (trivfs_S_io_mod_owner): Likewise. + * io-read.c (trivfs_S_io_read): Likewise. + * io-readable.c (trivfs_S_io_readable): Likewise. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + * io-seek.c (trivfs_S_io_seek): Likewise. + * io-select.c (trivfs_S_io_select): Likewise. + * io-stat.c (trivfs_S_io_stat): Likewise. + * io-stubs.c (trivfs_S_io_map_cntl): Likewise. + (trivfs_S_io_get_conch): Likewise. + (trivfs_S_io_release_conch): Likewise. + (trivfs_S_io_eofnotify): Likewise. + (trivfs_S_io_prenotify): Likewise. + (trivfs_S_io_postnotify): Likewise. + (trivfs_S_io_readsleep): Likewise. + (trivfs_S_io_sigio): Likewise. + (trivfs_S_io_readnotify): Likewise. + * io-write.c (trivfs_S_io_write): Likewise. + * io-version.c (trivfs_S_trivfs_io_server_version): Likewise. + * fsys-getroot.c (trivfs_S_fsys_getroot): Likewise. + * fsys-goaway.c (trivfs_S_fsys_goaway): Likewise. + * fsys-stubs.c (trivfs_S_fsys_startup): Likewise. + (trivfs_S_fsys_getpriv): Likewise. + (trivfs_S_fsys_init): Likewise. + (trivfs_S_fsys_getfile): Likewise. + +Wed Jun 29 13:02:17 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * io-read.c (trivfs_S_io_read): Always return EOPNOTSUPP. + * io-write.c (trivfs_S_io_write): Likewise. + * file-truncate.c (trivfs_S_file_truncate): Likewise. + * io-readable.c (trivfs_S_io_readable): Likewise. + * io-select.c (trivfs_S_io_select): Likewise. + + * fsys-getroot.c (trivfs_S_fsys_getroot): Use trivfs_allow_open + instead of trivfs_support_* vars. + + * trivfs.h (trivfs_allow_open): New variable. + + * dir-pathtrans.c (trivfs_S_dir_pathtrans): Delete unused var + `newcred'. + +Mon Jun 27 15:05:06 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * fsys-getroot.c: Comment out code for blocking opens; don't + permit trivfs_check_open_hook to return EWOULDBLOCK. + +Thu Jun 23 12:28:49 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * fsys-getroot.c (trivfs_S_fsys_getroot): Don't call + ports_done_with_port for CNTL; the MiG destructor function does + that for us. + + * fsys-getroot.c (trivfs_S_fsys_getroot): Call trivfs_check_open_hook + to allow trivfs users to block or restrict opens. + * trivfs.h (trivfs_check_open_hook, trivfs_complete_open): New + declarations. + (struct trivfs_control): New members `openshead' and `openstail'. + +Wed Jun 22 14:49:00 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * fsys-getroot.c (trivfs_S_fsys_getroot): Initialize both hook + members to 0. + * io-duplicate.c (trivfs_S_io_duplicate): Copy NEWCRED->hook + from CRED->hook. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + + * fsys-getroot.c (trivfs_S_fsys_getroot): Don't force read/write + systems to redefine this function. If O_foo is set, but + trivfs_support_foo isn't, then return EACCES. Call + io_restrict_auth at the front so we can check open permission + using the result. Initialise CRED->po->openmodes. + + * trivfs.h (trivfs_peropen): New member `openmodes'. + * io-modes-get.c (trivfs_S_io_get_openmodes): Set bits from + CRED->po->openmodes, but only if we are not a read/write + server; otherwise the server might be hiding bits elsewhere. + + * dir-pathtrans.c (trivfs_S_dir_pathtrans): Strip out code; always + return ENOTDIR. + +Tue Jun 21 13:21:07 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * file-access.c: New file. + * dir-chg.c: New file. + * file-chg.c: New file. + * Makefile (FSSRCS): Added file-access.c, dir-chg.c, and file-chg.c. + +Mon Jun 20 14:42:12 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir-readdir.c (trivfs_S_dir_readdir): Declare args in accord + with fs.defs interface change. + * fsys-getroot.c (trivfs_S_fsys_getroot): Likewise. Set + DO_RETRY and RETRY_NAME appropriately. + * file-get-transcntl.c (trivfs_S_file_get_translator_cntl): + CNTL_TYPE is a pointer. + +Fri Jun 17 11:23:47 1994 Roland McGrath (roland@geech.gnu.ai.mit.edu) + + * file-get-transcntl.c (trivfs_S_file_get_translator_cntl): Add + missing poly arg. + +Wed Jun 15 21:27:20 1994 Michael I Bushnell (mib@churchy.gnu.ai.mit.edu) + + * dir-pathtrans.c: Include <string.h> for bcopy. + * fsys-getroot.c: Likewise. + * io-duplicate.c: Likewise. + * io-reauthenticate.c: Likewise. + * io-restrict-auth.c: Likewise. + +Wed Jun 15 16:58:02 1994 Michael I Bushnell (mib@geech.gnu.ai.mit.edu) + + * trivfs.h (trivfs_goaway): New args REALNODE, CNTLTYPE, + PROTIDTYPE. All callers changed. + + * fsmutations.h (FSYS_DESTRUCTOR, FSYS_INTRAN): New macros. + * priv.h (trivfs_control_t): New type. + (_trivfs_begin_using_control, _trivfs_end_using_control): New + declarations. + * migsupport.c (_trivfs_begin_using_control, + _trivfs_end_using_control): New functions. + * fsys-getroot.c (trivfs_S_fsys_getroot): First arg is now + `struct trivfs_control *'; don't call ports_check_port_type + ourselves or ports_done_with_port. + * fsys-goaway.c (trivfs_S_fsys_goaway): Likewise. + * fsys-stubs.c (trivfs_S_fsys_startup, trivfs_S_fsys_getpriv, + trivfs_S_fsys_init, trivfs_S_fsys_getfile): Declare first + arg as `struct trivfs_control *'. + + * trivfs.h (trivfs_protid_porttype, trivfs_cntl_porttype): + Deleted vars. + (trivfs_protid_porttypes, trivfs_cntl_porttypes, + trivfs_protid_nporttypes, trivfs_cntl_nporttypes): New vars. + (trivfs_control): New member protidtypes. + (trivfs_handle_port): New args PROTIDTYPE and CNTLTYPE. + * migsupport.h (_trivfs_begin_using_protid): Check + against all the members of trivfs_protid_porttypes. + * dir-pathtrans.c (trivfs_S_dir_pathtrans): Copy type of new port + from existing port. + * io-duplicate.c (trivfs_S_io_duplicate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * handle-port.c (trivfs_handle_port): Allocate port of type + from new arg CNTLTYPE. Initialize CNTL->protidtypes from new arg + PROTIDTYPE. + * fsys-getroot (trivfs_S_fsys_getroot): Allocate port of type + from CNTL->protidtypes. + + * trivfs.h (struct trivfs_protid) [hook]: New member. + (trivfs_protid_create_hook, trivfs_peropen_create_hook, + trivfs_protid_destroy_hook, trivfs_peropen_destroy_hook): New + hook functions. + * dir-pathtrans.c (trivfs_S_dir_pathtrans): Call + trivfs_peropen_create_hook. + * fsys-getroot.c (trivfs_S_fsys_getroot): Likewise. + * dir-pathtrans.c (trivfs_S_dir_pathtrans): Call + trivfs_protid_create_hook. + * fsys-getroot.c (trivfs_S_fsys_getroot): Likewise. + * io-duplicate.c (trivfs_S_io_duplicate): Likewise. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + * protid-clean.c (trivfs_clean_protid): Call + trivfs_protid_destroy_hook and trivfs_peropen_destroy_hook. + + * trivfs.h (struct trivfs_protid) [po]: New member. + (struct trivfs_protid) [cntl]: Deleted member. + (struct trivfs_peropen): New type. + * file-getcontrol.c (trivfs_S_file_getcontrol): Fetch control + port through peropen structure. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Likewise. + * fsys-getroot.c (trivfs_S_fsys_getroot): Likewise. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Reference + peropen, not cntl. + * io-restrict-auth.c (trivfs_S_io_restrict_auth): Likewise. + * io-duplicate.c (trivfs_S_io_duplicate): Likewise. + * fsys-getroot.c (trivfs_S_fsys_getroot): Create new peropen + and reference it. + * dir-pathtrans (trivfs_S_dir_pathtrans): Actually create new + peropen and cred. + * protid-clean.c (trivfs_clean_protid): Drop reference on peropen, + deallocating it if necessary. + + * trivfs.h (struct trivfs_protid) [uids, gids, nuids, ngids]: New + members. + * io-reauthenticate.c (trivfs_S_io_reauthenticate): Save received + ids in newly created protid. + * io-restrict-auth.c (listmember): New function. + (trivfs_S_io_restrict_auth): Save uids and gids in newly created + protid. + * io-duplicate.c (trivfs_S_io_duplicate): Copy uids and gids. + * protid-clean.c (trivfs_clean_protid): Free CRED->uids and + CRED->gids. + * fsys-getroot.c (trivfs_S_fsys_getroot): Initialize uids + and gids. diff --git a/libtrivfs/Makefile b/libtrivfs/Makefile new file mode 100644 index 00000000..58322c15 --- /dev/null +++ b/libtrivfs/Makefile @@ -0,0 +1,56 @@ +# +# 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. + +dir := libtrivfs +makemode := library + +FSSRCS= dir-link.c dir-mkdir.c dir-mkfile.c dir-lookup.c dir-readdir.c \ + dir-rename.c dir-rmdir.c dir-unlink.c file-chauthor.c \ + file-chflags.c file-chmod.c file-chown.c file-get-trans.c \ + file-get-transcntl.c file-getcontrol.c file-getfh.c \ + file-getlinknode.c file-lock.c file-set-trans.c file-statfs.c \ + file-sync.c file-syncfs.c file-set-size.c file-utimes.c file-exec.c \ + file-access.c dir-chg.c file-chg.c file-inv.c file-get-storage-info.c \ + file-get-fs-options.c file-reparent.c + +IOSRCS=io-async-icky.c io-async.c io-duplicate.c io-map.c io-modes-get.c \ + io-modes-off.c io-modes-on.c io-modes-set.c io-owner-get.c \ + io-owner-mod.c io-pathconf.c io-read.c io-readable.c io-revoke.c \ + io-reauthenticate.c io-restrict-auth.c io-seek.c io-select.c \ + io-stat.c io-stubs.c io-write.c io-version.c io-identity.c + +FSYSSRCS=fsys-getroot.c fsys-goaway.c fsys-stubs.c fsys-syncfs.c \ + fsys-forward.c fsys-set-options.c fsys-get-options.c + +OTHERSRCS=demuxer.c protid-clean.c protid-dup.c cntl-create.c \ + cntl-clean.c migsupport.c times.c startup.c open.c \ + runtime-argp.c set-options.c append-args.c dyn-classes.c \ + protid-classes.c cntl-classes.c + +SRCS=$(FSSRCS) $(IOSRCS) $(FSYSSRCS) $(OTHERSRCS) + +MIGSTUBS=fsServer.o ioServer.o fsysServer.o fsys_replyUser.o + +libname = libtrivfs +HURDLIBS = iohelp ports shouldbeinlibc +OBJS= $(sort $(subst .c,.o,$(SRCS)) $(MIGSTUBS)) +LCLHDRS = trivfs.h fsmutations.h priv.h +MIGSFLAGS=-imacros $(srcdir)/fsmutations.h +MIGCOMSFLAGS = -prefix trivfs_ +installhdrs = trivfs.h + +include ../Makeconf diff --git a/libtrivfs/append-args.c b/libtrivfs/append-args.c new file mode 100644 index 00000000..d5c3d4a3 --- /dev/null +++ b/libtrivfs/append-args.c @@ -0,0 +1,30 @@ +/* Append current command line arguments + + Copyright (C) 1996 Free Software Foundation + + 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 "priv.h" + +/* Append to the malloced string *ARGZ of length *ARGZ_LEN a NUL-separated + list of the arguments to this translator. */ +error_t +trivfs_append_args (struct trivfs_control *fsys, + char **argz, size_t *argz_len) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/cntl-classes.c b/libtrivfs/cntl-classes.c new file mode 100644 index 00000000..356c9e92 --- /dev/null +++ b/libtrivfs/cntl-classes.c @@ -0,0 +1,22 @@ +/* Defaults for TRIVFS_CNTL_[N]PORTCLASSES + + Copyright (C) 1997 Free Software Foundation, Inc. + + 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 "trivfs.h" + +struct port_class *trivfs_cntl_portclasses[1]; +int trivfs_cntl_nportclasses; diff --git a/libtrivfs/cntl-clean.c b/libtrivfs/cntl-clean.c new file mode 100644 index 00000000..a010828f --- /dev/null +++ b/libtrivfs/cntl-clean.c @@ -0,0 +1,35 @@ +/* + Copyright (C) 1994, 1996, 1997 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. */ + +#include "priv.h" + +/* Clean pointers in a struct trivfs_control when its last reference + vanishes before it's freed. */ +void +trivfs_clean_cntl (void *arg) +{ + struct trivfs_control *cntl = arg; + + mach_port_destroy (mach_task_self (), cntl->filesys_id); + mach_port_destroy (mach_task_self (), cntl->file_id); + mach_port_deallocate (mach_task_self (), cntl->underlying); + + trivfs_remove_control_port_class (cntl->pi.class); + trivfs_remove_port_bucket (cntl->pi.bucket); + trivfs_remove_protid_port_class (cntl->protid_class); + trivfs_remove_port_bucket (cntl->protid_bucket); +} diff --git a/libtrivfs/cntl-create.c b/libtrivfs/cntl-create.c new file mode 100644 index 00000000..f103ed48 --- /dev/null +++ b/libtrivfs/cntl-create.c @@ -0,0 +1,101 @@ +/* Create a new trivfs control port + + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + + Written by Miles Bader <miles@gnu.ai.mit.edu> + + 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 "trivfs.h" + +/* Create a new trivfs control port, with underlying node UNDERLYING, and + return it in CONTROL. CONTROL_CLASS & CONTROL_BUCKET are passed to + the ports library to create the control port, and PROTID_CLASS & + PROTID_BUCKET are used when creating ports representing opens of this + node. */ +error_t +trivfs_create_control (mach_port_t underlying, + struct port_class *control_class, + struct port_bucket *control_bucket, + struct port_class *protid_class, + struct port_bucket *protid_bucket, + struct trivfs_control **control) +{ + error_t err; + + /* Perhaps allocate, and perhaps add the specified port classes the ones + recognized by trivfs. */ + err = trivfs_add_control_port_class (&control_class); + if (! err) + err = trivfs_add_protid_port_class (&protid_class); + else + protid_class = 0; + + /* Perhaps allocate new port buckets. */ + if (! err) + err = trivfs_add_port_bucket (&control_bucket); + else + control_bucket = 0; + if (! err) + { + if (! protid_bucket) + /* By default, use the same port bucket for both. */ + protid_bucket = control_bucket; + err = trivfs_add_port_bucket (&protid_bucket); + } + else + protid_bucket = 0; + + if (! err) + err = ports_create_port (control_class, control_bucket, + sizeof (struct trivfs_control), control); + + if (! err) + { + (*control)->underlying = underlying; + (*control)->protid_class = protid_class; + (*control)->protid_bucket = protid_bucket; + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &(*control)->filesys_id); + if (err) + { + ports_port_deref (*control); + goto out; + } + + err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, + &(*control)->file_id); + if (err) + { + mach_port_destroy (mach_task_self (), (*control)->filesys_id); + ports_port_deref (*control); + goto out; + } + + (*control)->hook = 0; + mutex_init (&(*control)->lock); + } + +out: + if (err) + { + trivfs_remove_control_port_class (control_class); + trivfs_remove_protid_port_class (protid_class); + trivfs_remove_port_bucket (control_bucket); + trivfs_remove_port_bucket (protid_bucket); + } + + return err; +} diff --git a/libtrivfs/demuxer.c b/libtrivfs/demuxer.c new file mode 100644 index 00000000..27777468 --- /dev/null +++ b/libtrivfs/demuxer.c @@ -0,0 +1,39 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" + +int +trivfs_demuxer (mach_msg_header_t *inp, + mach_msg_header_t *outp) +{ + int trivfs_fs_server (mach_msg_header_t *, mach_msg_header_t *); + int trivfs_io_server (mach_msg_header_t *, mach_msg_header_t *); + int trivfs_fsys_server (mach_msg_header_t *, mach_msg_header_t *); + + return (trivfs_io_server (inp, outp) + || trivfs_fs_server (inp, outp) + || ports_notify_server (inp, outp) + || trivfs_fsys_server (inp, outp) + || ports_interrupt_server (inp, outp)); +} + + diff --git a/libtrivfs/dir-chg.c b/libtrivfs/dir-chg.c new file mode 100644 index 00000000..6c9a9faf --- /dev/null +++ b/libtrivfs/dir-chg.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_notice_changes (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t notify) +{ + return cred ? ENOTDIR : EOPNOTSUPP; +} diff --git a/libtrivfs/dir-link.c b/libtrivfs/dir-link.c new file mode 100644 index 00000000..0f4833d0 --- /dev/null +++ b/libtrivfs/dir-link.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_link (struct trivfs_protid *dir, + mach_port_t reply, mach_msg_type_name_t reply_type, + struct trivfs_protid *file, char *name, int excl) +{ + if (!file) + return EOPNOTSUPP; + if (!dir) + return EXDEV; + return ENOTDIR; +} + + diff --git a/libtrivfs/dir-lookup.c b/libtrivfs/dir-lookup.c new file mode 100644 index 00000000..604df8cc --- /dev/null +++ b/libtrivfs/dir-lookup.c @@ -0,0 +1,85 @@ +/* + Copyright (C) 1994, 1998, 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. */ + +#include "priv.h" +#include "fs_S.h" +#include <assert.h> +#include <fcntl.h> +#include <string.h> + +kern_return_t +trivfs_S_dir_lookup (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char *filename, + int flags, + mode_t mode, + retry_type *retry_type, + char *retry_name, + mach_port_t *retrypt, + mach_msg_type_name_t *retrypt_type) +{ + int perms; + error_t err; + struct trivfs_protid *newcred; + + if (!cred) + return EOPNOTSUPP; + + if (filename[0]) + return ENOTDIR; + + /* This is a null-pathname "reopen" call; do the right thing. */ + + /* Burn off flags we don't actually implement */ + flags &= O_HURD; + flags &= ~(O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS); + + /* Validate permissions */ + if (! trivfs_check_access_hook) + file_check_access (cred->realnode, &perms); + else + (*trivfs_check_access_hook) (cred->po->cntl, cred->user, + cred->realnode, &perms); + if ((flags & (O_READ|O_WRITE|O_EXEC) & perms) + != (flags & (O_READ|O_WRITE|O_EXEC))) + return EACCES; + + /* Execute the open */ + err = 0; + if (trivfs_check_open_hook) + err = (*trivfs_check_open_hook) (cred->po->cntl, cred->user, flags); + if (!err) + { + struct iouser *user = iohelp_dup_iouser (cred->user); + err = trivfs_open (cred->po->cntl, user, flags, + cred->realnode, &newcred); + if (err) + iohelp_free_iouser (user); + else + mach_port_mod_refs (mach_task_self (), cred->realnode, + MACH_PORT_RIGHT_SEND, +1); + } + if (err) + return err; + + *retry_type = FS_RETRY_NORMAL; + *retry_name = '\0'; + *retrypt = ports_get_right (newcred); + *retrypt_type = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (newcred); + return 0; +} diff --git a/libtrivfs/dir-mkdir.c b/libtrivfs/dir-mkdir.c new file mode 100644 index 00000000..f41dfdbe --- /dev/null +++ b/libtrivfs/dir-mkdir.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_mkdir (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char *name, mode_t mode) +{ + return cred ? ENOTDIR : EOPNOTSUPP; +} diff --git a/libtrivfs/dir-mkfile.c b/libtrivfs/dir-mkfile.c new file mode 100644 index 00000000..aaaa7ad9 --- /dev/null +++ b/libtrivfs/dir-mkfile.c @@ -0,0 +1,30 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_mkfile (struct trivfs_protid *file, + mach_port_t reply, mach_msg_type_name_t reply_type, + int flags, + mode_t mode, + mach_port_t *newnod, + mach_msg_type_name_t *newnodetype) +{ + return file ? ENOTDIR : EOPNOTSUPP; +} diff --git a/libtrivfs/dir-readdir.c b/libtrivfs/dir-readdir.c new file mode 100644 index 00000000..eebfabc8 --- /dev/null +++ b/libtrivfs/dir-readdir.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1994, 1999 Free Software Foundation, Inc. + + 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 "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_readdir (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char **data, + u_int *datalen, + boolean_t *data_dealloc, + int entry, + int nentries, + vm_size_t bufsiz, + int *amount) +{ + return cred ? ENOTDIR : EOPNOTSUPP; +} diff --git a/libtrivfs/dir-rename.c b/libtrivfs/dir-rename.c new file mode 100644 index 00000000..48fff625 --- /dev/null +++ b/libtrivfs/dir-rename.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_rename (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char *name, + struct trivfs_protid *cred2, char *name2, int excl) +{ + if (!cred) + return EOPNOTSUPP; + if (!cred2) + return EXDEV; + return ENOTDIR; +} diff --git a/libtrivfs/dir-rmdir.c b/libtrivfs/dir-rmdir.c new file mode 100644 index 00000000..ab9d8f41 --- /dev/null +++ b/libtrivfs/dir-rmdir.c @@ -0,0 +1,29 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_rmdir (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char *name) +{ + return cred ? ENOTDIR : EOPNOTSUPP; +} + + diff --git a/libtrivfs/dir-unlink.c b/libtrivfs/dir-unlink.c new file mode 100644 index 00000000..d86ad324 --- /dev/null +++ b/libtrivfs/dir-unlink.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_dir_unlink (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char *name) +{ + return cred ? ENOTDIR : EOPNOTSUPP; +} diff --git a/libtrivfs/dyn-classes.c b/libtrivfs/dyn-classes.c new file mode 100644 index 00000000..5f73f8f3 --- /dev/null +++ b/libtrivfs/dyn-classes.c @@ -0,0 +1,269 @@ +/* Dynamically allocated port classes/buckets recognized by trivfs + + Copyright (C) 1997 Free Software Foundation, Inc. + + Written by Miles Bader <miles@gnu.ai.mit.edu> + + 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 "priv.h" + +/* Auxiliary info for each vector element. */ +struct aux +{ + void (*free_el)(); + unsigned refs; +}; + +/* Vectors of dynamically allocated port classes/buckets. */ + +/* Protid port classes. */ +struct port_class **trivfs_dynamic_protid_port_classes = 0; +size_t trivfs_num_dynamic_protid_port_classes = 0; +static struct aux *dynamic_protid_port_classes_aux = 0; +static size_t dynamic_protid_port_classes_sz = 0; + +/* Control port classes. */ +struct port_class **trivfs_dynamic_control_port_classes = 0; +size_t trivfs_num_dynamic_control_port_classes = 0; +static struct aux *dynamic_control_port_classes_aux = 0; +static size_t dynamic_control_port_classes_sz = 0; + +/* Port buckets. */ +struct port_bucket **trivfs_dynamic_port_buckets = 0; +size_t trivfs_num_dynamic_port_buckets = 0; +static struct aux *dynamic_port_buckets_aux = 0; +static size_t dynamic_port_buckets_sz = 0; + +/* Lock used to control access to all the above vectors. */ +static struct mutex dyn_lock = MUTEX_INITIALIZER; + +/* Add EL to the vector pointed to by VEC_V, which should point to a vector + of pointers of some type, and has a length stored in *SZ; If there's + already a pointer to EL in VEC_V, nothing will actually be added, but the + reference count for that element will be increased. *NUM is the actual + number of non-null elements in the vector, and will be incremented if + something is actually added. AUX_VEC is a pointer to a vector of struct + aux elements, that contains information parralleling VEC_V. FREE_EL, if + non-zero, should be a function that takes a single argument of the same + type as EL, and deallocates it; this function is called in the following + cases: (1) An error is encountered trying to grow one of the vectors, (2) + when the element is eventually freed by drop_el. */ +static error_t +add_el (void *el, void (*free_el)(), + void *vec_v, struct aux **aux_vec, + size_t *sz, size_t *num) +{ + int i; + size_t new_sz; + void ***vec, **new_vec; + struct aux *new_aux_vec; + + if (! el) + return ENOMEM; + + mutex_lock (&dyn_lock); + + vec = vec_v; + + for (i = 0; i < *sz; i++) + if (! (*vec)[i]) + { + (*vec)[i] = el; + (*aux_vec)[i].free_el = free_el; + (*aux_vec)[i].refs = 1; + (*num)++; + mutex_unlock (&dyn_lock); + return 0; + } + else if ((*vec)[i] == el) + { + (*aux_vec)[i].refs++; + mutex_unlock (&dyn_lock); + return 0; + } + + new_sz = *sz + 4; + new_vec = realloc (*vec, new_sz * sizeof (void *)); + new_aux_vec = realloc (*aux_vec, new_sz * sizeof (struct aux)); + + if (!new_vec || !new_aux_vec) + { + if (free_el) + (*free_el) (el); + /* One of the vectors might be the wrong size, but who cares. */ + return ENOMEM; + } + + for (i = *sz; i < new_sz; i++) + new_vec[i] = 0; + + new_vec[*sz] = el; + new_aux_vec[*sz].free_el = free_el; + new_aux_vec[*sz].refs = 1; + (*num)++; + + *vec = new_vec; + *aux_vec = new_aux_vec; + *sz = new_sz; + + mutex_unlock (&dyn_lock); + + return 0; +} + +/* Scan VEC_V, which should be a vector of SZ pointers of the same type as + EL, for EL; if it is found, then decrement its reference count, and if + that goes to zero, decrement *NUM and free EL if it had an associated free + routine passed to add_el. */ +static void +drop_el (void *el, void *vec_v, struct aux *aux_vec, + size_t sz, size_t *num) +{ + int i; + void **vec; + + if (! el) + return; + + mutex_lock (&dyn_lock); + + vec = vec_v; + + for (i = 0; i < sz; i++) + if (vec[i] == el) + { + if (aux_vec[i].refs == 1) + { + if (aux_vec[i].free_el) + (*aux_vec[i].free_el) (el); + vec[i] = 0; + (*num)--; + } + else + aux_vec[i].refs--; + break; + } + + mutex_unlock (&dyn_lock); +} + +/* Add the port class *CLASS to the list of control port classes recognized + by trivfs; if *CLASS is 0, an attempt is made to allocate a new port + class, which is stored in *CLASS. */ +error_t +trivfs_add_control_port_class (struct port_class **class) +{ + /* XXX Gee, there *is no* way of freeing port classes or buckets! So we + actually never free anything! */ + + if (! *class) + { + *class = ports_create_class (trivfs_clean_cntl, 0); + if (! *class) + return ENOMEM; + } + + return + add_el (*class, 0, + &trivfs_dynamic_control_port_classes, + &dynamic_control_port_classes_aux, + &dynamic_control_port_classes_sz, + &trivfs_num_dynamic_control_port_classes); +} + +/* Remove the previously added dynamic control port class CLASS, freeing it + if it was allocated by trivfs_add_control_port_class. */ +void +trivfs_remove_control_port_class (struct port_class *class) +{ + drop_el (class, + trivfs_dynamic_control_port_classes, + dynamic_control_port_classes_aux, + dynamic_control_port_classes_sz, + &trivfs_num_dynamic_control_port_classes); +} + +/* Add the port class *CLASS to the list of protid port classes recognized by + trivfs; if *CLASS is 0, an attempt is made to allocate a new port class, + which is stored in *CLASS. */ +error_t +trivfs_add_protid_port_class (struct port_class **class) +{ + /* XXX Gee, there *is no* way of freeing port classes or buckets! So we + actually never free anything! */ + + if (! *class) + { + *class = ports_create_class (trivfs_clean_protid, 0); + if (! *class) + return ENOMEM; + } + + return + add_el (*class, 0, + &trivfs_dynamic_protid_port_classes, + &dynamic_protid_port_classes_aux, + &dynamic_protid_port_classes_sz, + &trivfs_num_dynamic_protid_port_classes); +} + +/* Remove the previously added dynamic protid port class CLASS, freeing it + if it was allocated by trivfs_add_protid_port_class. */ +void +trivfs_remove_protid_port_class (struct port_class *class) +{ + drop_el (class, + trivfs_dynamic_protid_port_classes, + dynamic_protid_port_classes_aux, + dynamic_protid_port_classes_sz, + &trivfs_num_dynamic_protid_port_classes); +} + +/* Add the port bucket *BUCKET to the list of dynamically allocated port + buckets; if *bucket is 0, an attempt is made to allocate a new port + bucket, which is then stored in *bucket. */ +error_t +trivfs_add_port_bucket (struct port_bucket **bucket) +{ + /* XXX Gee, there *is no* way of freeing port bucketes or buckets! So we + actually never free anything! */ + + if (! *bucket) + { + *bucket = ports_create_bucket (); + if (! *bucket) + return ENOMEM; + } + + return + add_el (*bucket, 0, + &trivfs_dynamic_port_buckets, + &dynamic_port_buckets_aux, + &dynamic_port_buckets_sz, + &trivfs_num_dynamic_port_buckets); +} + +/* Remove the previously added dynamic port bucket BUCKET, freeing it + if it was allocated by trivfs_add_port_bucket. */ +void +trivfs_remove_port_bucket (struct port_bucket *bucket) +{ + drop_el (bucket, + trivfs_dynamic_port_buckets, + dynamic_port_buckets_aux, + dynamic_port_buckets_sz, + &trivfs_num_dynamic_port_buckets); +} diff --git a/libtrivfs/file-access.c b/libtrivfs/file-access.c new file mode 100644 index 00000000..91b5427a --- /dev/null +++ b/libtrivfs/file-access.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "fs_S.h" + +error_t +trivfs_S_file_check_access (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int *allowed) +{ + if (! cred) + return EOPNOTSUPP; + + if (! trivfs_check_access_hook) + file_check_access (cred->realnode, allowed); + else + (*trivfs_check_access_hook) (cred->po->cntl, cred->user, + cred->realnode, allowed); + + return 0; +} diff --git a/libtrivfs/file-chauthor.c b/libtrivfs/file-chauthor.c new file mode 100644 index 00000000..5f61743a --- /dev/null +++ b/libtrivfs/file-chauthor.c @@ -0,0 +1,28 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_chauthor (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + uid_t auth) +{ + return cred ? file_chauthor (cred->realnode, auth) : EOPNOTSUPP; +} + diff --git a/libtrivfs/file-chflags.c b/libtrivfs/file-chflags.c new file mode 100644 index 00000000..8d3d4577 --- /dev/null +++ b/libtrivfs/file-chflags.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_chflags (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int flags) +{ + return cred ? file_chflags (cred->realnode, flags) : EOPNOTSUPP; +} diff --git a/libtrivfs/file-chg.c b/libtrivfs/file-chg.c new file mode 100644 index 00000000..a7df7e1d --- /dev/null +++ b/libtrivfs/file-chg.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_notice_changes (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t notify) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-chmod.c b/libtrivfs/file-chmod.c new file mode 100644 index 00000000..f4a8cdb3 --- /dev/null +++ b/libtrivfs/file-chmod.c @@ -0,0 +1,28 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_chmod (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mode_t mode) +{ + /* Is this right? */ + return cred ? file_chmod (cred->realnode, mode) : EOPNOTSUPP; +} diff --git a/libtrivfs/file-chown.c b/libtrivfs/file-chown.c new file mode 100644 index 00000000..4eb664c5 --- /dev/null +++ b/libtrivfs/file-chown.c @@ -0,0 +1,30 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_chown (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + uid_t uid, gid_t gid) +{ + return cred ? file_chown (cred->realnode, uid, gid) : EOPNOTSUPP; +} + + + diff --git a/libtrivfs/file-exec.c b/libtrivfs/file-exec.c new file mode 100644 index 00000000..d39af5fd --- /dev/null +++ b/libtrivfs/file-exec.c @@ -0,0 +1,43 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" + +kern_return_t +trivfs_S_file_exec (trivfs_protid_t exec_file, + mach_port_t exec_task, + int flags, + data_t argv, + mach_msg_type_number_t argvCnt, + data_t envp, + mach_msg_type_number_t envpCnt, + portarray_t fdarray, + mach_msg_type_number_t fdarrayCnt, + portarray_t portarray, + mach_msg_type_number_t portarrayCnt, + intarray_t intarray, + mach_msg_type_number_t intarrayCnt, + mach_port_array_t deallocnames, + mach_msg_type_number_t deallocnamesCnt, + mach_port_array_t destroynames, + mach_msg_type_number_t destroynamesCnt) +{ + return EOPNOTSUPP; +} + + + diff --git a/libtrivfs/file-get-fs-options.c b/libtrivfs/file-get-fs-options.c new file mode 100644 index 00000000..a244778d --- /dev/null +++ b/libtrivfs/file-get-fs-options.c @@ -0,0 +1,52 @@ +/* Get runtime options given a file handle + + Copyright (C) 1996, 1998 Free Software Foundation + + 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 <argz.h> +#include <hurd/fshelp.h> + +#include "priv.h" +#include "fsys_S.h" + +error_t +trivfs_S_file_get_fs_options (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t reply_type, + char **data, mach_msg_type_number_t *len) +{ + error_t err; + char *argz = 0; + size_t argz_len = 0; + + if (! cred) + return EOPNOTSUPP; + + err = argz_add (&argz, &argz_len, program_invocation_name); + if (err) + return err; + + err = trivfs_append_args (cred->po->cntl, &argz, &argz_len); + if (! err) + /* Put ARGZ into vm_alloced memory for the return trip. */ + err = iohelp_return_malloced_buffer (argz, argz_len, data, len); + else + free (argz); + + return err; +} diff --git a/libtrivfs/file-get-storage-info.c b/libtrivfs/file-get-storage-info.c new file mode 100644 index 00000000..7e4073ad --- /dev/null +++ b/libtrivfs/file-get-storage-info.c @@ -0,0 +1,34 @@ +/* Stub for the file_get_storage_info RPC as described in <hurd/fs.defs>. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. + + 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 "priv.h" +#include "fs_S.h" + +error_t +trivfs_S_file_get_storage_info (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t reply_type, + 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) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-get-trans.c b/libtrivfs/file-get-trans.c new file mode 100644 index 00000000..15f5a003 --- /dev/null +++ b/libtrivfs/file-get-trans.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_get_translator (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char **trans, u_int *translen) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-get-transcntl.c b/libtrivfs/file-get-transcntl.c new file mode 100644 index 00000000..0367fff2 --- /dev/null +++ b/libtrivfs/file-get-transcntl.c @@ -0,0 +1,28 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_get_translator_cntl (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t *cntl, + mach_msg_type_name_t *cntl_type) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-getcontrol.c b/libtrivfs/file-getcontrol.c new file mode 100644 index 00000000..c75472ab --- /dev/null +++ b/libtrivfs/file-getcontrol.c @@ -0,0 +1,34 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_getcontrol (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t *cntl, mach_msg_type_name_t *cntltype) +{ + if (!cred) + return EOPNOTSUPP; + if (!cred->isroot) + return EPERM; + + *cntl = ports_get_right (cred->po->cntl); + *cntltype = MACH_MSG_TYPE_MAKE_SEND; + return 0; +} diff --git a/libtrivfs/file-getfh.c b/libtrivfs/file-getfh.c new file mode 100644 index 00000000..eeb9e3d1 --- /dev/null +++ b/libtrivfs/file-getfh.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_getfh (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + char **data, u_int *datalen) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-getlinknode.c b/libtrivfs/file-getlinknode.c new file mode 100644 index 00000000..56ac3dff --- /dev/null +++ b/libtrivfs/file-getlinknode.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_getlinknode (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t *linknode, + mach_msg_type_name_t *linknodetype) +{ + if (!cred) + return EOPNOTSUPP; + *linknode = cred->realnode; + *linknodetype = MACH_MSG_TYPE_COPY_SEND; + return 0; +} diff --git a/libtrivfs/file-inv.c b/libtrivfs/file-inv.c new file mode 100644 index 00000000..37f85660 --- /dev/null +++ b/libtrivfs/file-inv.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994 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. */ + +/* Unused stub */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_invoke_translator (struct trivfs_protid *cred, + int flags, + retry_type *retry, + char *retry_name, + mach_port_t *retrypt, + mach_msg_type_name_t *type) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-lock.c b/libtrivfs/file-lock.c new file mode 100644 index 00000000..10d39736 --- /dev/null +++ b/libtrivfs/file-lock.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_lock (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int flags) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_file_lock_stat (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int *mystatus, int *otherstat) +{ + return EOPNOTSUPP; +} + diff --git a/libtrivfs/file-reparent.c b/libtrivfs/file-reparent.c new file mode 100644 index 00000000..d2e06c83 --- /dev/null +++ b/libtrivfs/file-reparent.c @@ -0,0 +1,31 @@ +/* Reparent a directory + + Copyright (C) 1997 Free Software Foundation + + 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 "priv.h" +#include "fs_S.h" + +error_t +trivfs_S_file_reparent (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + mach_port_t parent, + mach_port_t *new, mach_msg_type_name_t *new_type) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-set-size.c b/libtrivfs/file-set-size.c new file mode 100644 index 00000000..eb174e46 --- /dev/null +++ b/libtrivfs/file-set-size.c @@ -0,0 +1,29 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_file_set_size (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + off_t size) +{ + assert (!trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-set-trans.c b/libtrivfs/file-set-trans.c new file mode 100644 index 00000000..36e9bd21 --- /dev/null +++ b/libtrivfs/file-set-trans.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_set_translator (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int actflags, + int passflags, + int oldtransflags, + char *trans, + u_int translen, + mach_port_t existing) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/file-statfs.c b/libtrivfs/file-statfs.c new file mode 100644 index 00000000..8b306623 --- /dev/null +++ b/libtrivfs/file-statfs.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "fs_S.h" +#include <string.h> +#include <unistd.h> + +kern_return_t +trivfs_S_file_statfs (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + struct statfs *stb) +{ + if (!trivfs_fsid) + trivfs_fsid = getpid(); + + bzero (stb, sizeof (struct statfs)); + stb->f_type = trivfs_fstype; + stb->f_fsid = trivfs_fsid; + + return 0; +} diff --git a/libtrivfs/file-sync.c b/libtrivfs/file-sync.c new file mode 100644 index 00000000..54076f67 --- /dev/null +++ b/libtrivfs/file-sync.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_sync (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int wait, int omitmeta) +{ + return cred ? file_sync (cred->realnode, wait, omitmeta) : EOPNOTSUPP; +} diff --git a/libtrivfs/file-syncfs.c b/libtrivfs/file-syncfs.c new file mode 100644 index 00000000..1f74e395 --- /dev/null +++ b/libtrivfs/file-syncfs.c @@ -0,0 +1,28 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_syncfs (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int wait, + int dochildren) +{ + return cred ? file_sync (cred->realnode, wait, 0) : EOPNOTSUPP; +} diff --git a/libtrivfs/file-utimes.c b/libtrivfs/file-utimes.c new file mode 100644 index 00000000..916a8d8a --- /dev/null +++ b/libtrivfs/file-utimes.c @@ -0,0 +1,27 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "fs_S.h" + +kern_return_t +trivfs_S_file_utimes (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + time_value_t atime, time_value_t mtime) +{ + return cred ? file_utimes (cred->realnode, atime, mtime) : EOPNOTSUPP; +} diff --git a/libtrivfs/fsmutations.h b/libtrivfs/fsmutations.h new file mode 100644 index 00000000..cb716c8d --- /dev/null +++ b/libtrivfs/fsmutations.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 1994, 1995 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. */ + +/* Only CPP macro definitions should go in this file. */ + +#define REPLY_PORTS + +#define FILE_INTRAN trivfs_protid_t trivfs_begin_using_protid (file_t) +#define FILE_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t) + +#define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t) +#define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t) + +#define FSYS_INTRAN trivfs_control_t trivfs_begin_using_control (fsys_t) +#define FSYS_DESTRUCTOR trivfs_end_using_control (trivfs_control_t) + +#define FILE_IMPORTS import "priv.h"; +#define IO_IMPORTS import "priv.h"; +#define FSYS_IMPORTS import "priv.h"; diff --git a/libtrivfs/fsys-forward.c b/libtrivfs/fsys-forward.c new file mode 100644 index 00000000..b7127a24 --- /dev/null +++ b/libtrivfs/fsys-forward.c @@ -0,0 +1,39 @@ +/* fsys_forward + + Copyright (C) 1995 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 the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "priv.h" +#include "fsys_S.h" + +/* Ask SERVER to provide fsys translation service for us. REQUESTOR is + the bootstrap port supplied to the original translator, and ARGV are + the command line arguments. If the recipient accepts the request, he + (or some delegate) should send fsys_startup to REQUESTOR to start the + filesystem up. */ +error_t +trivfs_S_fsys_forward (mach_port_t server, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t requestor, + char *argz, size_t argz_len) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/fsys-get-options.c b/libtrivfs/fsys-get-options.c new file mode 100644 index 00000000..abb2dfeb --- /dev/null +++ b/libtrivfs/fsys-get-options.c @@ -0,0 +1,51 @@ +/* Get runtime options + + Copyright (C) 1996, 1998 Free Software Foundation + + 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 <argz.h> +#include <hurd/fshelp.h> + +#include "priv.h" +#include "fsys_S.h" + +error_t +trivfs_S_fsys_get_options (struct trivfs_control *fsys, + mach_port_t reply, mach_msg_type_name_t reply_type, + char **data, mach_msg_type_number_t *len) +{ + error_t err; + char *argz = 0; + size_t argz_len = 0; + + if (! fsys) + return EOPNOTSUPP; + + err = argz_add (&argz, &argz_len, program_invocation_name); + if (err) + return err; + + err = trivfs_append_args (fsys, &argz, &argz_len); + if (! err) + /* Put ARGZ into vm_alloced memory for the return trip. */ + err = iohelp_return_malloced_buffer (argz, argz_len, data, len); + else + free (argz); + + return err; +} diff --git a/libtrivfs/fsys-getroot.c b/libtrivfs/fsys-getroot.c new file mode 100644 index 00000000..d91b9fa8 --- /dev/null +++ b/libtrivfs/fsys-getroot.c @@ -0,0 +1,123 @@ +/* + Copyright (C) 1993,94,95,97,99 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 the GNU Hurd; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "fsys_S.h" +#include "fsys_reply_U.h" +#include <assert.h> +#include <fcntl.h> +#include <string.h> + +kern_return_t +trivfs_S_fsys_getroot (struct trivfs_control *cntl, + mach_port_t reply_port, + mach_msg_type_name_t reply_port_type, + mach_port_t dotdot, + uid_t *uids, u_int nuids, + uid_t *gids, u_int ngids, + int flags, + retry_type *do_retry, + char *retry_name, + mach_port_t *newpt, + mach_msg_type_name_t *newpttype) +{ + int perms; + error_t err = 0; + mach_port_t new_realnode; + struct trivfs_protid *cred; + struct iouser *user; + struct idvec *uvec, *gvec; + + if (!cntl) + return EOPNOTSUPP; + + if (trivfs_getroot_hook) + { + err = (*trivfs_getroot_hook) (cntl, reply_port, reply_port_type, dotdot, + uids, nuids, gids, ngids, flags, + do_retry, retry_name, newpt, newpttype); + if (err != EAGAIN) + return err; + } + + if ((flags & O_WRITE & trivfs_allow_open) != (flags & O_WRITE)) + return EROFS; + if ((flags & (O_READ|O_WRITE|O_EXEC) & trivfs_allow_open) + != (flags & (O_READ|O_WRITE|O_EXEC))) + return EACCES; + + /* O_CREAT and O_EXCL are not meaningful here; O_NOLINK and O_NOTRANS + will only be useful when trivfs supports translators (which it doesn't + now). */ + flags &= O_HURD; + flags &= ~(O_CREAT|O_EXCL|O_NOLINK|O_NOTRANS); + + err = io_restrict_auth (cntl->underlying, + &new_realnode, uids, nuids, gids, ngids); + if (err) + return err; + + uvec = make_idvec (); + gvec = make_idvec (); + idvec_set_ids (uvec, uids, nuids); + idvec_set_ids (gvec, gids, ngids); + user = iohelp_create_iouser (uvec, gvec); /* XXX check return value? */ + + /* Validate permissions. */ + if (! trivfs_check_access_hook) + file_check_access (new_realnode, &perms); + else + (*trivfs_check_access_hook) (cntl, user, new_realnode, &perms); + if ((flags & (O_READ|O_WRITE|O_EXEC) & perms) + != (flags & (O_READ|O_WRITE|O_EXEC))) + err = EACCES; + + if (!err && trivfs_check_open_hook) + err = (*trivfs_check_open_hook) (cntl, user, flags); + if (!err) + { + if (! trivfs_open_hook) + { + err = trivfs_open (cntl, user, flags, new_realnode, &cred); + if (!err) + mach_port_deallocate (mach_task_self (), dotdot); + } + else + err = (*trivfs_open_hook) (cntl, user, dotdot, flags, new_realnode, + &cred); + } + + if (err) + { + mach_port_deallocate (mach_task_self (), new_realnode); + iohelp_free_iouser (user); + } + else + { + *do_retry = FS_RETRY_NORMAL; + *retry_name = '\0'; + *newpt = ports_get_right (cred); + *newpttype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (cred); + } + + return err; +} diff --git a/libtrivfs/fsys-goaway.c b/libtrivfs/fsys-goaway.c new file mode 100644 index 00000000..747e9f0e --- /dev/null +++ b/libtrivfs/fsys-goaway.c @@ -0,0 +1,35 @@ +/* + Copyright (C) 1994, 1995 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "fsys_S.h" + +kern_return_t +trivfs_S_fsys_goaway (struct trivfs_control *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int flags) +{ + if (!cred) + return EOPNOTSUPP; + + return trivfs_goaway (cred, flags); +} diff --git a/libtrivfs/fsys-set-options.c b/libtrivfs/fsys-set-options.c new file mode 100644 index 00000000..507bd442 --- /dev/null +++ b/libtrivfs/fsys-set-options.c @@ -0,0 +1,36 @@ +/* Set runtime options + + Copyright (C) 1996 Free Software Foundation + + 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 <hurd/fshelp.h> + +#include "priv.h" +#include "fsys_S.h" + +error_t +trivfs_S_fsys_set_options (struct trivfs_control *cntl, + mach_port_t reply, mach_msg_type_name_t reply_type, + char *data, mach_msg_type_number_t len, + int do_children) +{ + if (cntl) + return trivfs_set_options (cntl, data, len); + else + return EOPNOTSUPP; +} diff --git a/libtrivfs/fsys-stubs.c b/libtrivfs/fsys-stubs.c new file mode 100644 index 00000000..4457b231 --- /dev/null +++ b/libtrivfs/fsys-stubs.c @@ -0,0 +1,72 @@ +/* + Copyright (C) 1994, 1995, 1996 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "fsys_S.h" + +kern_return_t +trivfs_S_fsys_startup (mach_port_t bootport, + mach_port_t reply, + mach_msg_type_name_t replytype, + int flags, + mach_port_t cntl, + mach_port_t *realnode, + mach_port_t *realnodetype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_fsys_getpriv (struct trivfs_control *cntl, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *host, mach_msg_type_name_t *host_privPoly, + mach_port_t *dev, mach_msg_type_name_t *devPoly, + mach_port_t *fstask, mach_msg_type_name_t *fstPoly) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_fsys_init (struct trivfs_control *control, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t proc, + auth_t auth) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_fsys_getfile (struct trivfs_control *cntl, + mach_port_t reply, + mach_msg_type_name_t replytype, + uid_t *genuids, + u_int ngenuids, + uid_t *gengids, + u_int ngengids, + char *handle, + u_int handlesize, + mach_port_t *file, + mach_msg_type_name_t *filetype) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/fsys-syncfs.c b/libtrivfs/fsys-syncfs.c new file mode 100644 index 00000000..6059adfd --- /dev/null +++ b/libtrivfs/fsys-syncfs.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994, 1996 Free Software Foundation, Inc. + 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. */ + +#include "priv.h" +#include "fsys_S.h" + +kern_return_t +trivfs_S_fsys_syncfs (struct trivfs_control *cntl, + mach_port_t reply, + mach_msg_type_name_t replytype, + int wait, + int dochildren) +{ + return cntl ? file_sync (cntl->underlying, wait, 0) : EOPNOTSUPP; +} diff --git a/libtrivfs/handle-port.c b/libtrivfs/handle-port.c new file mode 100644 index 00000000..9568b88a --- /dev/null +++ b/libtrivfs/handle-port.c @@ -0,0 +1,48 @@ +/* + Copyright (C) 1994, 1995, 1996 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. */ + +#include "priv.h" + +/* Backwards compatibility. Use trivfs_create_control. */ +mach_port_t +trivfs_handle_port (mach_port_t realnode, + struct port_class *control_class, + struct port_bucket *control_bucket, + struct port_class *protid_class, + struct port_bucket *protid_bucket) +{ + mach_port_t right; + struct trivfs_control *control; + error_t err = + trivfs_create_control (realnode, + control_class, control_bucket, + protid_class, protid_bucket, + &control); + + if (err) + return MACH_PORT_NULL; + + right = ports_get_right (control); + ports_port_deref (control); + + return right; +} + +#if 0 +#include "linkwarn.h" +obslete (trivfs_handle_port, trivfs_create_control) +#endif diff --git a/libtrivfs/interrupt.c b/libtrivfs/interrupt.c new file mode 100644 index 00000000..3b3bd211 --- /dev/null +++ b/libtrivfs/interrupt.c @@ -0,0 +1,34 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "interrupt_S.h" + +error_t +trivfs_S_interrupt_operation (mach_port_t port) +{ + struct port_info *pi = ports_lookup_port (0, port, 0); + if (!pi) + return EOPNOTSUPP; + ports_interrupt_rpc (pi); + ports_port_deref (pi); + return 0; +} diff --git a/libtrivfs/io-async-icky.c b/libtrivfs/io-async-icky.c new file mode 100644 index 00000000..8c394732 --- /dev/null +++ b/libtrivfs/io-async-icky.c @@ -0,0 +1,34 @@ +/* + Copyright (C) 1993, 1994, 1999 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_get_icky_async_id (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *id, + mach_msg_type_name_t *idtype) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-async.c b/libtrivfs/io-async.c new file mode 100644 index 00000000..c664c067 --- /dev/null +++ b/libtrivfs/io-async.c @@ -0,0 +1,35 @@ +/* + Copyright (C) 1993, 1994, 1999 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_async (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t notify, + mach_port_t *id, + mach_msg_type_name_t *idtype) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-duplicate.c b/libtrivfs/io-duplicate.c new file mode 100644 index 00000000..4b20bb99 --- /dev/null +++ b/libtrivfs/io-duplicate.c @@ -0,0 +1,49 @@ +/* + Copyright (C) 1993, 1994, 1995 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <string.h> + +kern_return_t +trivfs_S_io_duplicate (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *newport, + mach_msg_type_name_t *newporttype) +{ + error_t err; + struct trivfs_protid *newcred; + + if (!cred) + return EOPNOTSUPP; + + err = trivfs_protid_dup (cred, &newcred); + if (!err) + { + *newport = ports_get_right (newcred); + *newporttype = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (newcred); + } + + return err; +} + diff --git a/libtrivfs/io-identity.c b/libtrivfs/io-identity.c new file mode 100644 index 00000000..1232dcb4 --- /dev/null +++ b/libtrivfs/io-identity.c @@ -0,0 +1,51 @@ +/* Fetching identity port + 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 "priv.h" +#include "io_S.h" + +error_t +trivfs_S_io_identity (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *idport, + mach_msg_type_name_t *idport_type, + mach_port_t *fsidport, + mach_msg_type_name_t *fsidport_type, + int *fileno) +{ + error_t err; + struct stat st; + + if (!cred) + return EOPNOTSUPP; + + err = io_stat (cred->realnode, &st); + if (err) + return err; + trivfs_modify_stat (cred, &st); + + *idport = cred->po->cntl->file_id; + *idport_type = MACH_MSG_TYPE_MAKE_SEND; + *fsidport = cred->po->cntl->filesys_id; + *fsidport_type = MACH_MSG_TYPE_MAKE_SEND; + *fileno = st.st_ino; + return 0; +} diff --git a/libtrivfs/io-map.c b/libtrivfs/io-map.c new file mode 100644 index 00000000..1dc93c22 --- /dev/null +++ b/libtrivfs/io-map.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_map (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *rdobj, + mach_msg_type_name_t *rdtype, + mach_port_t *wrobj, + mach_msg_type_name_t *wrtype) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-modes-get.c b/libtrivfs/io-modes-get.c new file mode 100644 index 00000000..d0da546c --- /dev/null +++ b/libtrivfs/io-modes-get.c @@ -0,0 +1,39 @@ +/* + Copyright (C) 1993,94,99 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 the GNU Hurd; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_get_openmodes (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int *bits) +{ + if (!cred) + return EOPNOTSUPP; + else + { + *bits = cred->po->openmodes; + return 0; + } +} diff --git a/libtrivfs/io-modes-off.c b/libtrivfs/io-modes-off.c new file mode 100644 index 00000000..c78791e9 --- /dev/null +++ b/libtrivfs/io-modes-off.c @@ -0,0 +1,34 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_clear_some_openmodes (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int bits) +{ + assert (!trivfs_support_read && !trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-modes-on.c b/libtrivfs/io-modes-on.c new file mode 100644 index 00000000..8ca82bcf --- /dev/null +++ b/libtrivfs/io-modes-on.c @@ -0,0 +1,34 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_set_some_openmodes (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int bits) +{ + assert (!trivfs_support_read && !trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-modes-set.c b/libtrivfs/io-modes-set.c new file mode 100644 index 00000000..c1bc7405 --- /dev/null +++ b/libtrivfs/io-modes-set.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include <assert.h> + +error_t +trivfs_S_io_set_all_openmodes (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int mode) +{ + assert (!trivfs_support_read && !trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-owner-get.c b/libtrivfs/io-owner-get.c new file mode 100644 index 00000000..82fe9211 --- /dev/null +++ b/libtrivfs/io-owner-get.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_get_owner (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + pid_t *owner) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-owner-mod.c b/libtrivfs/io-owner-mod.c new file mode 100644 index 00000000..2e70159f --- /dev/null +++ b/libtrivfs/io-owner-mod.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_mod_owner (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + pid_t owner) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-pathconf.c b/libtrivfs/io-pathconf.c new file mode 100644 index 00000000..c24e1801 --- /dev/null +++ b/libtrivfs/io-pathconf.c @@ -0,0 +1,30 @@ +/* + Copyright (C) 1994, 1996 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. */ + +#include "priv.h" +#include "io_S.h" + +kern_return_t +trivfs_S_io_pathconf (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type, + int name, int *val) +{ + if (cred) + return io_pathconf (cred->realnode, name, val); + else + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-read.c b/libtrivfs/io-read.c new file mode 100644 index 00000000..24f3642a --- /dev/null +++ b/libtrivfs/io-read.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_read (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + char **data, + mach_msg_type_number_t *datalen, + off_t off, + mach_msg_type_number_t amt) +{ + assert (!trivfs_support_read); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-readable.c b/libtrivfs/io-readable.c new file mode 100644 index 00000000..975ab44b --- /dev/null +++ b/libtrivfs/io-readable.c @@ -0,0 +1,30 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_readable (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_msg_type_number_t *amount) +{ + assert (!trivfs_support_read); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-reauthenticate.c b/libtrivfs/io-reauthenticate.c new file mode 100644 index 00000000..3754ff72 --- /dev/null +++ b/libtrivfs/io-reauthenticate.c @@ -0,0 +1,97 @@ +/* + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> +#include <string.h> + +kern_return_t +trivfs_S_io_reauthenticate (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t rendport) +{ + struct trivfs_protid *newcred; + error_t err; + auth_t auth; + mach_port_t newright; + + if (cred == 0) + return EOPNOTSUPP; + + do + err = ports_create_port_noinstall (cred->po->cntl->protid_class, + cred->po->cntl->protid_bucket, + sizeof (struct trivfs_protid), + &newcred); + while (err == EINTR); + if (err) + return err; + + auth = getauth (); + newright = ports_get_right (newcred); + err = mach_port_insert_right (mach_task_self (), newright, newright, + MACH_MSG_TYPE_MAKE_SEND); + assert_perror (err); + + newcred->user = iohelp_reauth (auth, rendport, newright, 1); + if (idvec_contains (newcred->user->uids, 0)) + newcred->isroot = 1; + + mach_port_deallocate (mach_task_self (), rendport); + mach_port_deallocate (mach_task_self (), newright); + mach_port_deallocate (mach_task_self (), auth); + + newcred->hook = cred->hook; + + mutex_lock (&cred->po->cntl->lock); + newcred->po = cred->po; + newcred->po->refcnt++; + mutex_unlock (&cred->po->cntl->lock); + + do + err = io_restrict_auth (newcred->po->cntl->underlying, &newcred->realnode, + newcred->user->uids->ids, + newcred->user->uids->num, + newcred->user->gids->ids, + newcred->user->gids->num); + while (err == EINTR); + if (!err && trivfs_protid_create_hook) + { + do + err = (*trivfs_protid_create_hook) (newcred); + while (err == EINTR); + if (err) + mach_port_deallocate (mach_task_self (), newcred->realnode); + } + + if (err) + /* Signal that the user destroy hook shouldn't be called on NEWCRED. */ + newcred->realnode = MACH_PORT_NULL; + + mach_port_move_member (mach_task_self (), newcred->pi.port_right, + cred->po->cntl->protid_bucket->portset); + + ports_port_deref (newcred); + + return err; +} diff --git a/libtrivfs/io-restrict-auth.c b/libtrivfs/io-restrict-auth.c new file mode 100644 index 00000000..a1324410 --- /dev/null +++ b/libtrivfs/io-restrict-auth.c @@ -0,0 +1,121 @@ +/* + Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <string.h> + +/* Tell if the array LIST (of size N) contains a member equal to QUERY. */ +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; +} + +kern_return_t +trivfs_S_io_restrict_auth (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *newport, + mach_msg_type_name_t *newporttype, + uid_t *uids, u_int nuids, + uid_t *gids, u_int ngids) +{ + int i; + error_t err = 0; + struct trivfs_protid *newcred; + struct idvec *uvec, *gvec; + struct iouser *user; + + if (!cred) + return EOPNOTSUPP; + + uvec = make_idvec (); + gvec = make_idvec (); + + user = iohelp_create_iouser (uvec, gvec); + + if (cred->isroot) + { + /* CRED has root access, and so may use any ids. */ + idvec_set_ids (uvec, uids, nuids); + idvec_set_ids (gvec, gids, ngids); + } + else + { + /* Otherwise, use any of the requested ids that CRED already has. */ + for (i = 0; i < cred->user->uids->num; i++) + if (listmember (uids, cred->user->uids->ids[i], nuids)) + idvec_add (uvec, cred->user->uids->ids[i]); + for (i = 0; i < cred->user->gids->num; i++) + if (listmember (gids, cred->user->gids->ids[i], ngids)) + idvec_add (gvec, cred->user->gids->ids[i]); + } + + err = ports_create_port (cred->po->cntl->protid_class, + cred->po->cntl->protid_bucket, + sizeof (struct trivfs_protid), + &newcred); + if (err) + { + iohelp_free_iouser (user); + return err; + } + + newcred->isroot = 0; + mutex_lock (&cred->po->cntl->lock); + newcred->po = cred->po; + newcred->po->refcnt++; + mutex_unlock (&cred->po->cntl->lock); + if (cred->isroot && idvec_contains (uvec, 0)) + newcred->isroot = 1; + newcred->user = user; + newcred->hook = cred->hook; + + err = io_restrict_auth (cred->realnode, &newcred->realnode, + user->uids->ids, user->uids->num, + user->gids->ids, user->gids->num); + if (!err && trivfs_protid_create_hook) + { + err = (*trivfs_protid_create_hook) (newcred); + if (err) + mach_port_deallocate (mach_task_self (), newcred->realnode); + } + + if (err) + /* Signal that the user destroy hook shouldn't be called on NEWCRED. */ + newcred->realnode = MACH_PORT_NULL; + else + { + *newport = ports_get_right (newcred); + *newporttype = MACH_MSG_TYPE_MAKE_SEND; + } + + /* This will destroy NEWCRED if we got an error and didn't do the + ports_get_right above. */ + ports_port_deref (newcred); + + return 0; +} diff --git a/libtrivfs/io-revoke.c b/libtrivfs/io-revoke.c new file mode 100644 index 00000000..37f0f4a3 --- /dev/null +++ b/libtrivfs/io-revoke.c @@ -0,0 +1,33 @@ +/* + 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 "priv.h" +#include "io_S.h" + +/* Implement io_revoke as described in <hurd/io.defs>. */ +kern_return_t +trivfs_S_io_revoke (struct trivfs_protid *cred, + mach_port_t reply, mach_msg_type_name_t reply_type) +{ + /* Revoke of the underlying node is actually generally right, + because that will cause actual calls to fail. In any case, + we don't have the ability to check permissions ourselves + correctly. */ + + return cred ? io_revoke (cred->realnode) : EOPNOTSUPP; +} diff --git a/libtrivfs/io-seek.c b/libtrivfs/io-seek.c new file mode 100644 index 00000000..8d810786 --- /dev/null +++ b/libtrivfs/io-seek.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_seek (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + off_t off, + int whence, + off_t *newp) +{ + assert (!trivfs_support_read && !trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-select.c b/libtrivfs/io-select.c new file mode 100644 index 00000000..7788da6e --- /dev/null +++ b/libtrivfs/io-select.c @@ -0,0 +1,39 @@ +/* Stub io_select RPC for trivfs library. + Copyright (C) 1993, 1994, 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 the GNU Hurd; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <assert.h> + +kern_return_t +trivfs_S_io_select (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + int *seltype) +{ + if (!cred) + return EOPNOTSUPP; + if (*seltype & (SELECT_READ|SELECT_URG)) + assert (!trivfs_support_read); + if (*seltype & (SELECT_WRITE|SELECT_URG)) + assert (!trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-stat.c b/libtrivfs/io-stat.c new file mode 100644 index 00000000..9e6c9585 --- /dev/null +++ b/libtrivfs/io-stat.c @@ -0,0 +1,52 @@ +/* + Copyright (C) 1993, 1994, 1996 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" +#include <unistd.h> + +kern_return_t +trivfs_S_io_stat (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + struct stat *st) +{ + error_t err; + if (!cred) + return EOPNOTSUPP; + + err = io_stat (cred->realnode, st); + + if (!err) + { + if (! trivfs_fsid) + trivfs_fsid = getpid(); + + st->st_fstype = trivfs_fstype; + st->st_fsid = trivfs_fsid; + st->st_mode = (st->st_mode & ~S_IFMT & ~S_ITRANS) | S_IFCHR | S_IROOT; + + trivfs_modify_stat (cred, st); + } + + return err; +} + diff --git a/libtrivfs/io-stubs.c b/libtrivfs/io-stubs.c new file mode 100644 index 00000000..2c4f7330 --- /dev/null +++ b/libtrivfs/io-stubs.c @@ -0,0 +1,101 @@ +/* + Copyright (C) 1993, 1994 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "io_S.h" + +kern_return_t +trivfs_S_io_map_cntl (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + mach_port_t *obj, + mach_msg_type_name_t *objtype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_get_conch (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_release_conch (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_eofnotify (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_prenotify (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + vm_offset_t start, + vm_offset_t end) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_postnotify (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + vm_offset_t start, + vm_offset_t end) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_readsleep (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_sigio (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype) +{ + return EOPNOTSUPP; +} + +kern_return_t +trivfs_S_io_readnotify (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-version.c b/libtrivfs/io-version.c new file mode 100644 index 00000000..3df9a0d3 --- /dev/null +++ b/libtrivfs/io-version.c @@ -0,0 +1,30 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" + +kern_return_t +trivfs_S_io_server_version (mach_port_t obj, + mach_port_t reply, + mach_msg_type_name_t replytype, + char *name, + int *maj, + int *min, + int *edit) +{ + return EOPNOTSUPP; +} diff --git a/libtrivfs/io-write.c b/libtrivfs/io-write.c new file mode 100644 index 00000000..cdc8900d --- /dev/null +++ b/libtrivfs/io-write.c @@ -0,0 +1,37 @@ +/* + Copyright (C) 1994, 1999 Free Software Foundation, Inc. + + 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 "priv.h" +#include "io_S.h" +#include <assert.h> +#include <fcntl.h> + +kern_return_t +trivfs_S_io_write (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t replytype, + char *data, + mach_msg_type_number_t datalen, + off_t off, + mach_msg_type_number_t *amt) +{ + if (!(trivfs_allow_open & O_WRITE)) + return EBADF; + + assert (!trivfs_support_write); + return EOPNOTSUPP; +} diff --git a/libtrivfs/migsupport.c b/libtrivfs/migsupport.c new file mode 100644 index 00000000..b2d98e16 --- /dev/null +++ b/libtrivfs/migsupport.c @@ -0,0 +1,86 @@ +/* + 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. */ + +#include "priv.h" + +struct trivfs_protid * +trivfs_begin_using_protid (mach_port_t port) +{ + if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1) + { + struct port_info *pi = ports_lookup_port (0, port, 0); + int i; + + if (pi) + { + for (i = 0; i < trivfs_protid_nportclasses; i++) + if (pi->class == trivfs_protid_portclasses[i]) + return (struct trivfs_protid *) pi; + for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) + if (pi->class == trivfs_dynamic_protid_port_classes[i]) + return (struct trivfs_protid *) pi; + ports_port_deref (pi); + } + + return 0; + } + else if (trivfs_protid_nportclasses == 1) + return ports_lookup_port (0, port, trivfs_protid_portclasses[0]); + else + return ports_lookup_port (0, port, trivfs_dynamic_protid_port_classes[0]); +} + +void +trivfs_end_using_protid (struct trivfs_protid *cred) +{ + if (cred) + ports_port_deref (cred); +} + +struct trivfs_control * +trivfs_begin_using_control (mach_port_t port) +{ + if (trivfs_cntl_nportclasses + trivfs_num_dynamic_control_port_classes > 1) + { + struct port_info *pi = ports_lookup_port (0, port, 0); + int i; + + if (pi) + { + for (i = 0; i < trivfs_cntl_nportclasses; i++) + if (pi->class == trivfs_cntl_portclasses[i]) + return (struct trivfs_control *) pi; + for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) + if (pi->class == trivfs_dynamic_control_port_classes[i]) + return (struct trivfs_control *) pi; + ports_port_deref (pi); + } + + return 0; + } + else if (trivfs_cntl_nportclasses == 1) + return ports_lookup_port (0, port, trivfs_cntl_portclasses[0]); + else + return ports_lookup_port (0, port, trivfs_dynamic_control_port_classes[0]); +} + +void +trivfs_end_using_control (struct trivfs_control *cred) +{ + if (cred) + ports_port_deref (cred); +} diff --git a/libtrivfs/nosenders.c b/libtrivfs/nosenders.c new file mode 100644 index 00000000..2b4abef6 --- /dev/null +++ b/libtrivfs/nosenders.c @@ -0,0 +1,43 @@ +/* + Copyright (C) 1993, 1994, 1995 Free Software Foundation + +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. */ + +/* Written by Michael I. Bushnell. */ + +#include "priv.h" +#include "notify_S.h" + +/* Called by the kernel when a port has no more senders. We arrange + to have this sent to the port which is out of senders (NOTIFY). MSCOUNT + is the make-send count of the port when the notification was generated. */ +kern_return_t +trivfs_do_mach_notify_no_senders (mach_port_t notify, + mach_port_mscount_t mscount) +{ + struct port_info *pt; + + pt = ports_lookup_port (0, notify, 0); + if (!pt) + return EOPNOTSUPP; + + ports_no_senders (pt, mscount); + + ports_port_deref (pt); + + return 0; +} diff --git a/libtrivfs/notify-stubs.c b/libtrivfs/notify-stubs.c new file mode 100644 index 00000000..448984a4 --- /dev/null +++ b/libtrivfs/notify-stubs.c @@ -0,0 +1,53 @@ +/* + Copyright (C) 1994 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. */ + +#include "priv.h" +#include "notify_S.h" + +kern_return_t +trivfs_do_mach_notify_port_deleted (mach_port_t notify, + mach_port_t name) +{ + return 0; +} + +kern_return_t +trivfs_do_mach_notify_msg_accepted (mach_port_t notify, + mach_port_t name) +{ + return 0; +} + +kern_return_t +trivfs_do_mach_notify_port_destroyed (mach_port_t notify, + mach_port_t name) +{ + return 0; +} + +kern_return_t +trivfs_do_mach_notify_send_once (mach_port_t notify) +{ + return 0; +} + +kern_return_t +trivfs_do_mach_notify_dead_name (mach_port_t notify, + mach_port_t name) +{ + return 0; +} diff --git a/libtrivfs/open.c b/libtrivfs/open.c new file mode 100644 index 00000000..f64d2ffd --- /dev/null +++ b/libtrivfs/open.c @@ -0,0 +1,87 @@ +/* Make a new trivfs peropen/protid + + Copyright (C) 1993, 1994, 1995, 1996, 1999 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 the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <string.h> /* For bcopy() */ + +#include "priv.h" + +/* Return a new protid pointing to a new peropen in CRED, with REALNODE as + the underlying node reference, with the given identity, and open flags in + FLAGS. CNTL is the trivfs control object. */ +error_t +trivfs_open (struct trivfs_control *cntl, + struct iouser *user, + unsigned flags, + mach_port_t realnode, + struct trivfs_protid **cred) +{ + error_t err = 0; + struct trivfs_peropen *po = malloc (sizeof (struct trivfs_peropen)); + + if (!po) + return ENOMEM; + + ports_port_ref (cntl); + + po->refcnt = 1; + po->cntl = cntl; + po->openmodes = flags; + po->hook = 0; + + if (trivfs_peropen_create_hook) + err = (*trivfs_peropen_create_hook) (po); + if (!err) + { + struct trivfs_protid *new; + + err = ports_create_port (cntl->protid_class, cntl->protid_bucket, + sizeof (struct trivfs_protid), &new); + if (! err) + { + new->user = user; + new->isroot = idvec_contains (user->uids, 0); + + new->po = po; + new->hook = 0; + new->realnode = realnode; + + if (!err && trivfs_protid_create_hook) + err = (*trivfs_protid_create_hook) (new); + + if (err) + { + /* Setting REALNODE to null signals the clean routine not to + call the destroy hook, which we deallocate below anyway. */ + new->realnode = MACH_PORT_NULL; + ports_port_deref (new); + } + else + *cred = new; + } + } + + if (err) + { + ports_port_deref (cntl); + free (po); + } + + return err; +} diff --git a/libtrivfs/priv.h b/libtrivfs/priv.h new file mode 100644 index 00000000..585a319e --- /dev/null +++ b/libtrivfs/priv.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 1994, 1997 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 TRIVFS_PRIV_H_INCLUDED + +#include <mach.h> +#include <hurd.h> +#include <hurd/ports.h> +#include "trivfs.h" + +/* For the sake of MiG. */ +typedef struct trivfs_protid *trivfs_protid_t; +typedef struct trivfs_control *trivfs_control_t; + +struct trivfs_protid *_trivfs_begin_using_protid (mach_port_t); +void _trivfs_end_using_protid (struct trivfs_protid *); +struct trivfs_control *_trivfs_begin_using_control (mach_port_t); +void _trivfs_end_using_control (struct trivfs_control *); + +/* Vectors of dynamically allocated port classes/buckets. */ + +/* Protid port classes. */ +extern struct port_class **trivfs_dynamic_protid_port_classes; +extern size_t trivfs_num_dynamic_protid_port_classes; + +/* Control port classes. */ +extern struct port_class **trivfs_dynamic_control_port_classes; +extern size_t trivfs_num_dynamic_control_port_classes; + +/* Port buckets. */ +extern struct port_bucket **trivfs_dynamic_port_buckets; +extern size_t trivfs_num_dynamic_port_buckets; + +#define TRIVFS_PRIV_H_INCLUDED +#endif diff --git a/libtrivfs/protid-classes.c b/libtrivfs/protid-classes.c new file mode 100644 index 00000000..204548d8 --- /dev/null +++ b/libtrivfs/protid-classes.c @@ -0,0 +1,22 @@ +/* Defaults for TRIVFS_PROTID_[N]PORTCLASSES + + Copyright (C) 1997 Free Software Foundation, Inc. + + 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 "trivfs.h" + +struct port_class *trivfs_protid_portclasses[1]; +int trivfs_protid_nportclasses; diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c new file mode 100644 index 00000000..b76b202e --- /dev/null +++ b/libtrivfs/protid-clean.c @@ -0,0 +1,54 @@ +/* + Copyright (C) 1994, 1995, 1996 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. */ + +#include "priv.h" + +/* Clean pointers in a struct trivfs_protid when its last reference vanishes + before it's freed. */ +void +trivfs_clean_protid (void *arg) +{ + struct trivfs_protid *cred = arg; + + if (trivfs_protid_destroy_hook && cred->realnode != MACH_PORT_NULL) + /* Allow the user to clean up; If the realnode field is null, then CRED + wasn't initialized to the point of needing user cleanup. */ + (*trivfs_protid_destroy_hook) (cred); + + /* If we hold the only reference to the peropen, try to get rid of it. */ + mutex_lock (&cred->po->cntl->lock); + if (cred->po->refcnt == 1 && trivfs_peropen_destroy_hook) + { + mutex_unlock (&cred->po->cntl->lock); + (*trivfs_peropen_destroy_hook) (cred->po); + mutex_lock (&cred->po->cntl->lock); + } + if (--cred->po->refcnt == 0) + { + ports_port_deref (cred->po->cntl); + free (cred->po); + } + mutex_unlock (&cred->po->cntl->lock); + + iohelp_free_iouser (cred->user); + + if (cred->realnode != MACH_PORT_NULL) + mach_port_deallocate (mach_task_self (), cred->realnode); +} + + + diff --git a/libtrivfs/protid-dup.c b/libtrivfs/protid-dup.c new file mode 100644 index 00000000..097ab55b --- /dev/null +++ b/libtrivfs/protid-dup.c @@ -0,0 +1,67 @@ +/* Duplicate a protid + + Copyright (C) 1993, 1994, 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 the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include <string.h> +#include "priv.h" + +/* Return a duplicate of CRED in DUP, sharing the same peropen and hook. A + non-null hook may be used to detect that this is a duplicate by + trivfs_protid_create_hook. */ +error_t +trivfs_protid_dup (struct trivfs_protid *cred, struct trivfs_protid **dup) +{ + struct trivfs_protid *new; + error_t err = ports_create_port (cred->po->cntl->protid_class, + cred->po->cntl->protid_bucket, + sizeof (struct trivfs_protid), + &new); + + if (! err) + { + mutex_lock (&cred->po->cntl->lock); + new->po = cred->po; + new->po->refcnt++; + mutex_unlock (&cred->po->cntl->lock); + + new->isroot = cred->isroot; + + new->user = iohelp_dup_iouser (cred->user); + + new->realnode = cred->realnode; + mach_port_mod_refs (mach_task_self (), new->realnode, + MACH_PORT_RIGHT_SEND, 1); + + new->hook = cred->hook; + + if (trivfs_protid_create_hook) + err = (*trivfs_protid_create_hook) (new); + if (err) + { + mach_port_deallocate (mach_task_self (), new->realnode); + /* Signal that the user destroy hook shouldn't be called on NEW. */ + new->realnode = MACH_PORT_NULL; + ports_port_deref (new); + } + else + *dup = new; + } + + return err; +} diff --git a/libtrivfs/runtime-argp.c b/libtrivfs/runtime-argp.c new file mode 100644 index 00000000..3082b8fa --- /dev/null +++ b/libtrivfs/runtime-argp.c @@ -0,0 +1,23 @@ +/* Default definition for trivfs_runtime_argp + + Copyright (C) 1996 Free Software Foundation + + 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 "priv.h" + +struct argp *trivfs_runtime_argp = 0; diff --git a/libtrivfs/set-options.c b/libtrivfs/set-options.c new file mode 100644 index 00000000..af5355f1 --- /dev/null +++ b/libtrivfs/set-options.c @@ -0,0 +1,33 @@ +/* Set runtime options + + Copyright (C) 1996 Free Software Foundation + + 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 <hurd/fshelp.h> + +#include "priv.h" + +/* Set runtime options for FSYS to ARGZ & ARGZ_LEN. */ +error_t +trivfs_set_options (struct trivfs_control *fsys, char *argz, size_t argz_len) +{ + if (trivfs_runtime_argp) + return fshelp_set_options (trivfs_runtime_argp, 0, argz, argz_len, fsys); + else + return EOPNOTSUPP; +} diff --git a/libtrivfs/startup.c b/libtrivfs/startup.c new file mode 100644 index 00000000..3783efc2 --- /dev/null +++ b/libtrivfs/startup.c @@ -0,0 +1,68 @@ +/* Contact parent filesystem and establish ourselves as the translator. + + Copyright (C) 1995 Free Software Foundation, Inc. + + Written by Miles Bader <miles@gnu.ai.mit.edu> + + 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 <hurd.h> +#include <hurd/fsys.h> +#include <assert.h> + +#include "priv.h" + +/* Creates a control port for this filesystem and sends it to BOOTSTRAP with + fsys_startup. CONTROL_TYPE is the ports library type for the control + port, and PROTID_TYPE is the type for ports representing opens of this + node. If CONTROL isn't NULL, the trivfs control port is return in it. If + any error occurs sending fsys_startup, it is returned, otherwise 0. + FLAGS specifies how to open the underlying node (O_*). */ +error_t +trivfs_startup(mach_port_t bootstrap, int flags, + struct port_class *control_class, + struct port_bucket *control_bucket, + struct port_class *protid_class, + struct port_bucket *protid_bucket, + struct trivfs_control **control) +{ + mach_port_t underlying, right; + struct trivfs_control *fsys; + error_t err = + trivfs_create_control (MACH_PORT_NULL, + control_class, control_bucket, + protid_class, protid_bucket, + &fsys); + + if (err) + return err; + + right = ports_get_right (fsys); + + /* Contact whoever started us. */ + err = fsys_startup (bootstrap, flags, right, MACH_MSG_TYPE_MAKE_SEND, + &underlying); + + if (! err) + fsys->underlying = underlying; + + ports_port_deref (fsys); + + /* Pass back what we got, unless the caller doesn't want it. */ + if (!err && control) + *control = fsys; + + return err; +} diff --git a/libtrivfs/times.c b/libtrivfs/times.c new file mode 100644 index 00000000..b57fa981 --- /dev/null +++ b/libtrivfs/times.c @@ -0,0 +1,52 @@ +/* + Copyright (C) 1994, 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. */ + +#include "priv.h" + +error_t +trivfs_set_atime (struct trivfs_control *cntl) +{ + struct stat st; + time_value_t atime; + time_value_t mtime; + + io_stat (cntl->underlying, &st); + mtime.seconds = st.st_mtime; + mtime.microseconds = st.st_mtime_usec; + atime.microseconds = -1; + file_utimes (cntl->underlying, atime, mtime); + return 0; +} + +error_t +trivfs_set_mtime (struct trivfs_control *cntl) +{ + struct stat st; + time_value_t atime; + time_value_t mtime; + + io_stat (cntl->underlying, &st); + atime.seconds = st.st_atime; + atime.microseconds = st.st_atime_usec; + mtime.microseconds = -1; + file_utimes (cntl->underlying, atime, mtime); + return 0; +} + + + + diff --git a/libtrivfs/trivfs.h b/libtrivfs/trivfs.h new file mode 100644 index 00000000..dc32b0e4 --- /dev/null +++ b/libtrivfs/trivfs.h @@ -0,0 +1,264 @@ +/* + 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 __TRIVFS_H__ +#define __TRIVFS_H__ + +#include <errno.h> +#include <cthreads.h> /* for mutexes &c */ +#include <sys/types.h> /* for uid_t &c */ +#include <mach/mach.h> +#include <hurd/ports.h> +#include <hurd/iohelp.h> + +struct trivfs_protid +{ + struct port_info pi; + struct iouser *user; + int isroot; + /* REALNODE will be null if this protid wasn't fully created (currently + only in the case where trivfs_protid_create_hook returns an error). */ + mach_port_t realnode; /* restricted permissions */ + void *hook; /* for user use */ + struct trivfs_peropen *po; +}; + +/* These can be used as `intran' and `destructor' functions for + a MiG port type, to have the stubs called with the protid pointer. */ +struct trivfs_protid *trivfs_begin_using_protid (mach_port_t); +void trivfs_end_using_protid (struct trivfs_protid *); + +struct trivfs_peropen +{ + void *hook; /* for user use */ + int openmodes; + int refcnt; + struct trivfs_control *cntl; +}; + +struct trivfs_control +{ + struct port_info pi; + struct mutex lock; + struct port_class *protid_class; + struct port_bucket *protid_bucket; + mach_port_t filesys_id; + mach_port_t file_id; + mach_port_t underlying; + void *hook; /* for user use */ +}; + +/* These can be used as `intran' and `destructor' functions for + a MiG port type, to have the stubs called with the control pointer. */ +struct trivfs_control *trivfs_begin_using_control (mach_port_t); +void trivfs_end_using_control (struct trivfs_control *); + + +/* The user must define these variables. */ +extern int trivfs_fstype; +extern int trivfs_fsid; + +/* Set these if trivfs should allow read, write, + or execute of file. */ +extern int trivfs_support_read; +extern int trivfs_support_write; +extern int trivfs_support_exec; + +/* Set this some combination of O_READ, O_WRITE, and O_EXEC; + trivfs will only allow opens of the specified modes. + (trivfs_support_* is not used to validate opens, only actual + operations.) */ +extern int trivfs_allow_open; + +/* If the user defines these, they should be vectors (and the associated + sizes) of port classes that will be translated into control & protid + pointers for passing to rpcs, in addition to those passed to or created by + trivfs_create_control (or trivfs_startup) will automatically be + recognized. */ +extern struct port_class *trivfs_protid_portclasses[]; +extern int trivfs_protid_nportclasses; +extern struct port_class *trivfs_cntl_portclasses[]; +extern int trivfs_cntl_nportclasses; + +/* The user must define this function. This should modify a struct + stat (as returned from the underlying node) for presentation to + callers of io_stat. It is permissable for this function to do + nothing. */ +void trivfs_modify_stat (struct trivfs_protid *cred, struct stat *); + +/* If this variable is set, it is called to find out what access this + file permits to USER instead of checking the underlying node. + REALNODE is the underlying node, and CNTL is the trivfs control + object. The access permissions are returned in ALLOWED. */ +error_t (*trivfs_check_access_hook) (struct trivfs_control *cntl, + struct iouser *user, + mach_port_t realnode, + int *allowed); + +/* If this variable is set, it is called every time an open happens. + USER and FLAGS are from the open; CNTL identifies the + node being opened. This call need not check permissions on the underlying + node. This call can block as necessary, unless O_NONBLOCK is set + in FLAGS. Any desired error can be returned, which will be reflected + to the user and prevent the open from succeeding. */ +error_t (*trivfs_check_open_hook) (struct trivfs_control *cntl, + struct iouser *user, int flags); + +/* If this variable is set, it is called in place of `trivfs_open' (below). */ +error_t (*trivfs_open_hook) (struct trivfs_control *fsys, + struct iouser *user, + mach_port_t dotdot, + int flags, + mach_port_t realnode, + struct trivfs_protid **cred); + +/* If this variable is set, it is called every time a new protid + structure is created and initialized. */ +error_t (*trivfs_protid_create_hook) (struct trivfs_protid *); + +/* If this variable is set, it is called every time a new peropen + structure is created and initialized. */ +error_t (*trivfs_peropen_create_hook) (struct trivfs_peropen *); + +/* If this variable is set, it is called every time a protid structure + is about to be destroyed. */ +void (*trivfs_protid_destroy_hook) (struct trivfs_protid *); + +/* If this variable is set, it is called every time a peropen structure + is about to be destroyed. */ +void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *); + +/* If this variable is set, it is called by trivfs_S_fsys_getroot before any + other processing takes place; if the return value is EAGAIN, normal trivfs + getroot processing continues, otherwise the rpc returns with that return + value. */ +error_t (*trivfs_getroot_hook) (struct trivfs_control *cntl, + mach_port_t reply_port, + mach_msg_type_name_t reply_port_type, + mach_port_t dotdot, + uid_t *uids, u_int nuids, uid_t *gids, u_int ngids, + int flags, + retry_type *do_retry, char *retry_name, + mach_port_t *node, mach_msg_type_name_t *node_type); + +/* Creates a control port for this filesystem and sends it to BOOTSTRAP with + fsys_startup. CONTROL_CLASS & CONTROL_BUCKET are passed to the ports + library to create the control port, and PROTID_CLASS & PROTID_BUCKET are + used when creating ports representing opens of this node; any of these may + be zero, in which case an appropriate port class/bucket is created. If + CONTROL isn't NULL, the trivfs control port is return in it. If any error + occurs sending fsys_startup, it is returned, otherwise 0. FLAGS specifies + how to open the underlying node (O_*). */ +error_t trivfs_startup (mach_port_t bootstrap, int flags, + struct port_class *control_class, + struct port_bucket *control_bucket, + struct port_class *protid_class, + struct port_bucket *protid_bucket, + struct trivfs_control **control); + +/* Create a new trivfs control port, with underlying node UNDERLYING, and + return it in CONTROL. CONTROL_CLASS & CONTROL_BUCKET are passed to + the ports library to create the control port, and PROTID_CLASS & + PROTID_BUCKET are used when creating ports representing opens of this + node; any of these may be zero, in which case an appropriate port + class/bucket is created. */ +error_t +trivfs_create_control (mach_port_t underlying, + struct port_class *control_class, + struct port_bucket *control_bucket, + struct port_class *protid_class, + struct port_bucket *protid_bucket, + struct trivfs_control **control); + +/* Install these as libports cleanroutines for trivfs_protid_class + and trivfs_cntl_class respectively. */ +void trivfs_clean_protid (void *); +void trivfs_clean_cntl (void *); + +/* This demultiplees messages for trivfs ports. */ +int trivfs_demuxer (mach_msg_header_t *, mach_msg_header_t *); + +/* Return a new protid pointing to a new peropen in CRED, with REALNODE as + the underlying node reference, with the given identity, and open flags in + FLAGS. CNTL is the trivfs control object. */ +error_t trivfs_open (struct trivfs_control *fsys, + struct iouser *user, + unsigned flags, + mach_port_t realnode, + struct trivfs_protid **cred); + +/* Return a duplicate of CRED in DUP, sharing the same peropen and hook. A + non-null hook may be used to detect that this is a duplicate by + trivfs_peropen_create_hook. */ +error_t trivfs_protid_dup (struct trivfs_protid *cred, + struct trivfs_protid **dup); + +/* The user must define this function. Someone wants the filesystem + CNTL to go away. FLAGS are from the set FSYS_GOAWAY_*. */ +error_t trivfs_goaway (struct trivfs_control *cntl, int flags); + +/* Call this to set atime for the node to the current time. */ +error_t trivfs_set_atime (struct trivfs_control *cntl); + +/* Call this to set mtime for the node to the current time. */ +error_t trivfs_set_mtime (struct trivfs_control *cntl); + +/* If this is defined or set to an argp structure, it will be used by the + default trivfs_set_options to handle runtime options parsing. Redefining + this is the normal way to add option parsing to a trivfs program. */ +extern struct argp *trivfs_runtime_argp; + +/* Set runtime options for FSYS to ARGZ & ARGZ_LEN. The default definition + for this routine simply uses TRIVFS_RUNTIME_ARGP (supply FSYS as the argp + input field). */ +error_t trivfs_set_options (struct trivfs_control *fsys, + 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 diskfs_append_std_options. */ +error_t trivfs_append_args (struct trivfs_control *fsys, + char **argz, size_t *argz_len); + +/* Add the port class *CLASS to the list of control port classes recognized + by trivfs; if *CLASS is 0, an attempt is made to allocate a new port + class, which is stored in *CLASS. */ +error_t trivfs_add_control_port_class (struct port_class **class); + +/* Remove the previously added dynamic control port class CLASS, freeing it + if it was allocated by trivfs_add_control_port_class. */ +void trivfs_remove_control_port_class (struct port_class *class); + +/* Add the port class *CLASS to the list of protid port classes recognized by + trivfs; if *CLASS is 0, an attempt is made to allocate a new port class, + which is stored in *CLASS. */ +error_t trivfs_add_protid_port_class (struct port_class **class); + +/* Remove the previously added dynamic protid port class CLASS, freeing it + if it was allocated by trivfs_add_protid_port_class. */ +void trivfs_remove_protid_port_class (struct port_class *class); + +/* Add the port bucket *BUCKET to the list of dynamically allocated port + buckets; if *bucket is 0, an attempt is made to allocate a new port + bucket, which is then stored in *bucket. */ +error_t trivfs_add_port_bucket (struct port_bucket **bucket); + +/* Remove the previously added dynamic port bucket BUCKET, freeing it + if it was allocated by trivfs_add_port_bucket. */ +void trivfs_remove_port_bucket (struct port_bucket *bucket); + +#endif /* __TRIVFS_H__ */ |