Hi,
I've changed diskfs_create_protid not to duplicate the iouser passed into it. This diskfs_create_protid and netfs_make_protid the same semantics wrt the iouser passed to them. 2002-04-06 James A. Morrison <[EMAIL PROTECTED]> libdiskfs: * io-restrict-auth.c (diskfs_S_io_restrict_auth): Free USER only on failure. * trans-callback.c (_diskfs_translator_callback2_fn): Likewise. * io-duplicate.c (diskfs_S_io_duplicate): Created an iouser, USER, for the NEWPI protid. * init-startup.c (diskfs_startup_diskfs): Created an iouser, USER, for the ROOTPI protid. * fsys-getroot.c (diskfs_S_fsys_getroot): Make iouser USER a heap struct and free USER when NEWPI cannot be created. * dir-mkfile.c (diskfs_S_dir_mkfile): Duplicate CRED->USER for NEWPI. * file-exec.c (diskfs_S_file_exec): Likewise. * file-reparent.c (diskfs_S_file_reparent): Likewise. * fsys-getfile.c (diskfs_S_fsys_getfile): Free USER only on failure. * dir-lookup.c (diskfs_S_dir_lookup): Free iouser USER only on failure. (diskfs_S_dir_lookup): Duplicate DIRCRED->USER for NEWPI. * boot-start.c (diskfs_S_fsys_init): Created an iouser for the ROOTPI protid. (diskfs_start_bootstrap): Likewise. (diskfs_S_exec_startup_get_info): Likewise. (diskfs_execboot_fsys_startup): Likewise. Index: libdiskfs/boot-start.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/boot-start.c,v retrieving revision 1.60 diff -u -p -r1.60 boot-start.c --- libdiskfs/boot-start.c 26 Mar 2002 14:59:52 -0000 1.60 +++ libdiskfs/boot-start.c 7 Apr 2002 20:16:43 -0000 @@ -101,6 +101,7 @@ diskfs_start_bootstrap () const char *initname; size_t exec_argvlen, exec_envlen; struct port_info *bootinfo; + struct iouser *user; struct protid *rootpi; struct peropen *rootpo; mach_port_t diskfs_exec; @@ -110,7 +111,10 @@ diskfs_start_bootstrap () &rootpo); assert_perror (err); - err = diskfs_create_protid (rootpo, 0, &rootpi); + err = iohelp_create_simple_iouser (&user, 0, 0); + assert_perror (err); + + err = diskfs_create_protid (rootpo, user, &rootpi); assert_perror (err); /* Get us a send right to copy around. */ @@ -309,6 +313,7 @@ diskfs_S_exec_startup_get_info (mach_por mach_port_t *portarray, *dtable; mach_port_t rootport; struct ufsport *upt; + struct iouser *user; struct protid *rootpi; struct peropen *rootpo; @@ -344,7 +349,10 @@ diskfs_S_exec_startup_get_info (mach_por err = diskfs_make_peropen (diskfs_root_node, O_READ | O_EXEC, 0, &rootpo); assert_perror (err); - err = diskfs_create_protid (rootpo, 0, &rootpi); + err = iohelp_create_simple_iouser (&user, 0, 0); + assert_perror (err); + + err = diskfs_create_protid (rootpo, user, &rootpi); assert_perror (err); rootport = ports_get_right (rootpi); @@ -376,6 +384,7 @@ diskfs_execboot_fsys_startup (mach_port_ string_t pathbuf; enum retry_type retry; struct port_info *pt; + struct iouser *user; struct protid *rootpi; struct peropen *rootpo; mach_port_t rootport; @@ -386,7 +395,9 @@ diskfs_execboot_fsys_startup (mach_port_ err = diskfs_make_peropen (diskfs_root_node, flags, 0, &rootpo); assert_perror (err); - err = diskfs_create_protid (rootpo, 0, &rootpi); + err = iohelp_create_simple_iouser (&user, 0, 0); + assert_perror (err); + err = diskfs_create_protid (rootpo, user, &rootpi); assert_perror (err); rootport = ports_get_send_right (rootpi); ports_port_deref (rootpi); @@ -451,6 +462,7 @@ diskfs_S_fsys_init (mach_port_t port, mach_port_t host, startup; error_t err; mach_port_t root_pt; + struct iouser *user; struct protid *rootpi; struct peropen *rootpo; @@ -543,9 +555,11 @@ diskfs_S_fsys_init (mach_port_t port, /* Get a port to the root directory to put in the library's data structures. */ + err = iohelp_create_simple_iouser (&user, 0, 0); + assert_perror (err); err = diskfs_make_peropen (diskfs_root_node, O_READ|O_EXEC, 0, &rootpo); assert_perror (err); - err = diskfs_create_protid (rootpo, 0, &rootpi); + err = diskfs_create_protid (rootpo, user, &rootpi); assert_perror (err); root_pt = ports_get_send_right (rootpi); ports_port_deref (rootpi); Index: libdiskfs/dir-lookup.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/dir-lookup.c,v retrieving revision 1.51 diff -u -p -r1.51 dir-lookup.c --- libdiskfs/dir-lookup.c 26 Mar 2002 14:59:52 -0000 1.51 +++ libdiskfs/dir-lookup.c 7 Apr 2002 20:16:43 -0000 @@ -53,6 +53,7 @@ diskfs_S_dir_lookup (struct protid *dirc int mustbedir = 0; int amt; int type; + struct iouser *user; struct protid *newpi; struct peropen *newpo; @@ -211,7 +212,6 @@ diskfs_S_dir_lookup (struct protid *dirc || fshelp_translated (&np->transbox))) { mach_port_t dirport; - struct iouser *user; /* A callback function for short-circuited translators. Symlink & ifsock are handled elsewhere. */ @@ -258,10 +258,13 @@ diskfs_S_dir_lookup (struct protid *dirc { error = diskfs_create_protid (newpo, user, &newpi); if (error) - diskfs_release_peropen (newpo); + { + diskfs_release_peropen (newpo); + iohelp_free_iouser (user); + } } - - iohelp_free_iouser (user); + else + iohelp_free_iouser (user); } if (error) @@ -456,14 +459,23 @@ diskfs_S_dir_lookup (struct protid *dirc && (fshelp_isowner (&np->dn_stat, dircred->user) == EPERM)) flags &= ~O_NOATIME; - error = diskfs_make_peropen (np, (flags &~OPENONLY_STATE_MODES), - dircred->po, &newpo); - - if (! error) + error = iohelp_dup_iouser (&user, dircred->user); + if (! error) { - error = diskfs_create_protid (newpo, dircred->user, &newpi); - if (error) - diskfs_release_peropen (newpo); + + error = diskfs_make_peropen (np, (flags &~OPENONLY_STATE_MODES), + dircred->po, &newpo); + if (! error) + { + error = diskfs_create_protid (newpo, user, &newpi); + if (error) + { + diskfs_release_peropen (newpo); + iohelp_free_iouser (user); + } + } + else + iohelp_free_iouser (user); } if (! error) Index: libdiskfs/dir-mkfile.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/dir-mkfile.c,v retrieving revision 1.18 diff -u -p -r1.18 dir-mkfile.c --- libdiskfs/dir-mkfile.c 26 Mar 2002 14:59:52 -0000 1.18 +++ libdiskfs/dir-mkfile.c 7 Apr 2002 20:16:43 -0000 @@ -33,6 +33,7 @@ diskfs_S_dir_mkfile (struct protid *cred { struct node *dnp, *np; error_t err; + struct iouser *user; struct protid *newpi; struct peropen *newpo; @@ -70,12 +71,21 @@ diskfs_S_dir_mkfile (struct protid *cred flags &= ~OPENONLY_STATE_MODES; /* These bits are all meaningless here. */ - err = diskfs_make_peropen (np, flags, cred->po, &newpo); + err = iohelp_dup_iouser (&user, cred->user); if (! err) { - err = diskfs_create_protid (newpo, cred->user, &newpi); - if (err) - diskfs_release_peropen (newpo); + err = diskfs_make_peropen (np, flags, cred->po, &newpo); + if (! err) + { + err = diskfs_create_protid (newpo, user, &newpi); + if (err) + { + diskfs_release_peropen (newpo); + iohelp_free_iouser (user); + } + } + else + iohelp_free_iouser (user); } if (! err) Index: libdiskfs/file-exec.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/file-exec.c,v retrieving revision 1.39 diff -u -p -r1.39 file-exec.c --- libdiskfs/file-exec.c 26 Mar 2002 14:59:52 -0000 1.39 +++ libdiskfs/file-exec.c 7 Apr 2002 20:16:43 -0000 @@ -145,12 +145,22 @@ diskfs_S_file_exec (struct protid *cred, the exec server can turn this peropen into a file descriptor in the target process and permit it to exec its /dev/fd/N pseudo-file. */ { - err = diskfs_make_peropen (np, O_READ|O_EXEC, cred->po, &newpo); + struct iouser *user; + err = iohelp_dup_iouser (&user, cred->user); if (! err) { - err = diskfs_create_protid (newpo, cred->user, &newpi); - if (err) - diskfs_release_peropen (newpo); + err = diskfs_make_peropen (np, O_READ|O_EXEC, cred->po, &newpo); + if (! err) + { + err = diskfs_create_protid (newpo, user, &newpi); + if (err) + { + diskfs_release_peropen (newpo); + iohelp_free_iouser (user); + } + } + else + iohelp_free_iouser (user); } } Index: libdiskfs/file-reparent.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/file-reparent.c,v retrieving revision 1.5 diff -u -p -r1.5 file-reparent.c --- libdiskfs/file-reparent.c 26 Mar 2002 14:59:52 -0000 1.5 +++ libdiskfs/file-reparent.c 7 Apr 2002 20:16:43 -0000 @@ -25,10 +25,11 @@ error_t diskfs_S_file_reparent (struct protid *cred, mach_port_t parent, - mach_port_t *new, mach_msg_type_name_t *new_type) + mach_port_t *new, mach_msg_type_name_t *new_type) { error_t err; struct node *node; + struct iouser *user; struct protid *new_cred; struct peropen *new_po; @@ -38,12 +39,21 @@ diskfs_S_file_reparent (struct protid *c node = cred->po->np; mutex_lock (&node->lock); - err = diskfs_make_peropen (node, cred->po->openstat, cred->po, &new_po); + err = iohelp_dup_iouser (&user, cred->user); if (! err) { - err = diskfs_create_protid (new_po, cred->user, &new_cred); - if (err) - diskfs_release_peropen (new_po); + err = diskfs_make_peropen (node, cred->po->openstat, cred->po, &new_po); + if (! err) + { + err = diskfs_create_protid (new_po, user, &new_cred); + if (err) + { + diskfs_release_peropen (new_po); + iohelp_free_iouser (user); + } + } + else + iohelp_free_iouser (user); } mutex_unlock (&node->lock); Index: libdiskfs/fsys-getfile.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/fsys-getfile.c,v retrieving revision 1.9 diff -u -p -r1.9 fsys-getfile.c --- libdiskfs/fsys-getfile.c 26 Mar 2002 14:59:52 -0000 1.9 +++ libdiskfs/fsys-getfile.c 7 Apr 2002 20:16:43 -0000 @@ -92,10 +92,13 @@ diskfs_S_fsys_getfile (mach_port_t fsys, { err = diskfs_create_protid (new_po, user, &new_cred); if (err) - diskfs_release_peropen (new_po); + { + diskfs_release_peropen (new_po); + iohelp_free_iouser (user); + } } - - iohelp_free_iouser (user); + else + iohelp_free_iouser (user); diskfs_nput (node); ports_port_deref (pt); Index: libdiskfs/fsys-getroot.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/fsys-getroot.c,v retrieving revision 1.38 diff -u -p -r1.38 fsys-getroot.c --- libdiskfs/fsys-getroot.c 26 Mar 2002 14:59:52 -0000 1.38 +++ libdiskfs/fsys-getroot.c 7 Apr 2002 20:16:43 -0000 @@ -46,7 +46,7 @@ diskfs_S_fsys_getroot (fsys_t controlpor mode_t type; struct protid *newpi; struct peropen *newpo; - struct iouser user; + struct iouser *user; struct peropen peropen_context = { root_parent: dotdot, @@ -59,11 +59,13 @@ diskfs_S_fsys_getroot (fsys_t controlpor flags &= O_HURD; - user.uids = make_idvec (); - user.gids = make_idvec (); - idvec_set_ids (user.uids, uids, nuids); - idvec_set_ids (user.gids, gids, ngids); -#define drop_idvec() idvec_free (user.gids); idvec_free (user.uids) + error = iohelp_create_iouser (&user, make_idvec (), make_idvec ()); + if (error) + return error; + + idvec_set_ids (user->uids, uids, nuids); + idvec_set_ids (user->gids, gids, ngids); +#define drop_idvec() idvec_free (user->gids); idvec_free (user->uids) rwlock_reader_lock (&diskfs_fsys_lock); mutex_lock (&diskfs_root_node->lock); @@ -79,7 +81,7 @@ diskfs_S_fsys_getroot (fsys_t controlpor && !(flags & O_NOTRANS)) { error = fshelp_fetch_root (&diskfs_root_node->transbox, - &peropen_context, dotdot, &user, flags, + &peropen_context, dotdot, user, flags, _diskfs_translator_callback1, _diskfs_translator_callback2, retry, retryname, returned_port); @@ -146,10 +148,10 @@ diskfs_S_fsys_getroot (fsys_t controlpor error = EOPNOTSUPP; if (!error && (flags & O_READ)) - error = fshelp_access (&diskfs_root_node->dn_stat, S_IREAD, &user); + error = fshelp_access (&diskfs_root_node->dn_stat, S_IREAD, user); if (!error && (flags & O_EXEC)) - error = fshelp_access (&diskfs_root_node->dn_stat, S_IEXEC, &user); + error = fshelp_access (&diskfs_root_node->dn_stat, S_IEXEC, user); if (!error && (flags & (O_WRITE))) { @@ -159,7 +161,7 @@ diskfs_S_fsys_getroot (fsys_t controlpor error = EROFS; else error = fshelp_access (&diskfs_root_node->dn_stat, - S_IWRITE, &user); + S_IWRITE, user); } if (error) @@ -171,7 +173,7 @@ diskfs_S_fsys_getroot (fsys_t controlpor } if ((flags & O_NOATIME) - && (fshelp_isowner (&diskfs_root_node->dn_stat, &user) + && (fshelp_isowner (&diskfs_root_node->dn_stat, user) == EPERM)) flags &= ~O_NOATIME; @@ -181,10 +183,15 @@ diskfs_S_fsys_getroot (fsys_t controlpor &peropen_context, &newpo); if (! error) { - error = diskfs_create_protid (newpo, &user, &newpi); + error = diskfs_create_protid (newpo, user, &newpi); if (error) - diskfs_release_peropen (newpo); + { + diskfs_release_peropen (newpo); + iohelp_free_iouser (user); + } } + else + iohelp_free_iouser (user); mach_port_deallocate (mach_task_self (), dotdot); Index: libdiskfs/init-startup.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/init-startup.c,v retrieving revision 1.30 diff -u -p -r1.30 init-startup.c --- libdiskfs/init-startup.c 26 Mar 2002 19:06:49 -0000 1.30 +++ libdiskfs/init-startup.c 7 Apr 2002 20:16:43 -0000 @@ -41,6 +41,7 @@ diskfs_startup_diskfs (mach_port_t boots /* The boot options requested we change to a subdirectory and treat that as the root of the filesystem. */ struct node *np, *old; + struct iouser *user; struct protid *rootpi; struct peropen *rootpo; @@ -51,10 +52,12 @@ diskfs_startup_diskfs (mach_port_t boots mutex_lock (&diskfs_root_node->lock); /* Create a protid we can use in diskfs_lookup. */ + err = iohelp_create_simple_iouser (&user, 0, 0); + assert_perror (err); err = diskfs_make_peropen (diskfs_root_node, O_READ|O_EXEC, 0, &rootpo); assert_perror (err); - err = diskfs_create_protid (rootpo, 0, &rootpi); + err = diskfs_create_protid (rootpo, user, &rootpi); assert_perror (err); /* Look up the directory name. */ Index: libdiskfs/io-duplicate.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/io-duplicate.c,v retrieving revision 1.8 diff -u -p -r1.8 io-duplicate.c --- libdiskfs/io-duplicate.c 13 Nov 1996 00:18:59 -0000 1.8 +++ libdiskfs/io-duplicate.c 7 Apr 2002 20:16:43 -0000 @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 2002 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 @@ -25,6 +25,7 @@ diskfs_S_io_duplicate (struct protid *cr mach_msg_type_name_t *portpoly) { error_t err; + struct iouser *user; struct protid *newpi; if (!cred) @@ -32,12 +33,18 @@ diskfs_S_io_duplicate (struct protid *cr mutex_lock (&cred->po->np->lock); - err = diskfs_create_protid (cred->po, cred->user, &newpi); + err = iohelp_dup_iouser (&user, cred->user); if (! err) - { - *port = ports_get_right (newpi); - *portpoly = MACH_MSG_TYPE_MAKE_SEND; - ports_port_deref (newpi); + { + err = diskfs_create_protid (cred->po, user, &newpi); + if (! err) + { + *port = ports_get_right (newpi); + *portpoly = MACH_MSG_TYPE_MAKE_SEND; + ports_port_deref (newpi); + } + else + iohelp_free_iouser (user); } mutex_unlock (&cred->po->np->lock); Index: libdiskfs/io-restrict-auth.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/io-restrict-auth.c,v retrieving revision 1.12 diff -u -p -r1.12 io-restrict-auth.c --- libdiskfs/io-restrict-auth.c 16 Jun 2001 20:23:09 -0000 1.12 +++ libdiskfs/io-restrict-auth.c 7 Apr 2002 20:16:43 -0000 @@ -1,5 +1,5 @@ /* - Copyright (C) 1994,95,96,2001 Free Software Foundation + Copyright (C) 1994,95,96,2001,02 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 @@ -103,8 +103,9 @@ diskfs_S_io_restrict_auth (struct protid *newportpoly = MACH_MSG_TYPE_MAKE_SEND; ports_port_deref (newpi); } + else + iohelp_free_iouser (user); mutex_unlock (&cred->po->np->lock); - iohelp_free_iouser (user); return err; } Index: libdiskfs/protid-make.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/protid-make.c,v retrieving revision 1.14 diff -u -p -r1.14 protid-make.c --- libdiskfs/protid-make.c 16 Jun 2001 20:23:09 -0000 1.14 +++ libdiskfs/protid-make.c 7 Apr 2002 20:16:43 -0000 @@ -1,5 +1,5 @@ /* - Copyright (C) 1994,95,96,2001 Free Software Foundation + Copyright (C) 1994,95,96,2001,02 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 @@ -44,11 +44,7 @@ diskfs_finish_protid (struct protid *cre { error_t err; - if (!user) - err = iohelp_create_simple_iouser (&cred->user, 0, 0); - else - err = iohelp_dup_iouser (&cred->user, user); - assert_perror (err); + cred->user = user; err = mach_port_move_member (mach_task_self (), cred->pi.port_right, diskfs_port_bucket->portset); Index: libdiskfs/trans-callback.c =================================================================== RCS file: /cvsroot/hurd/hurd/libdiskfs/trans-callback.c,v retrieving revision 1.17 diff -u -p -r1.17 trans-callback.c --- libdiskfs/trans-callback.c 26 Mar 2002 14:59:52 -0000 1.17 +++ libdiskfs/trans-callback.c 7 Apr 2002 20:16:45 -0000 @@ -68,10 +68,13 @@ _diskfs_translator_callback2_fn (void *c { err = diskfs_create_protid (po, user, &cred); if (err) - diskfs_release_peropen (po); + { + diskfs_release_peropen (po); + iohelp_free_iouser (user); + } } - - iohelp_free_iouser (user); + else + iohelp_free_iouser (user); if (! err) { _______________________________________________ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd