[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
follow up on make-protid
From: |
James A Morrison |
Subject: |
follow up on make-protid |
Date: |
Sun, 24 Mar 2002 19:15:35 -0500 (EST) |
Hi,
Here is the follow-up patch that allows netfs_make_protid to only set errno
on failure. I've followed the examples uses of netfs_make_protid
already in libnetfs, so this should confirm the interface for
netfs_make_protid.
I've included the diff for make-protid as well.
I did a quick look through the translators that I know use libnetfs and none
of them called make_protid directly.
libnetfs/io-restrict-auth.c: err is set to ENOMEM on failure instead of errno.
I don't see a reason for this, so I changed it. I also move ports_port_deref
into the block that executes when netfs_make_protid succeeds.
2002-03-24 James A. Morrison <ja2morri@uwaterloo.ca>
* fsys-getroot.c (netfs_S_fsys_getroot): Check if netfs_make_protid
fails.
* io-duplicate.c (netfs_S_io_duplicate): Likewise.
* io-reauthenticate.c (netfs_S_io_reauthenticate): Likewise.
* io-restrict-auth.c (netfs_S_io_restrict_auth): Return the error
the occured in netfs_make_protid, instead of ENOMEM.
Dereference the port returned from netfs_make_protid only on
a successful call to netfs_make_protid.
* make-protid (netfs_make_protid): Use err, not errno. Set errno,
only on failure.
Index: fsys-getroot.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/fsys-getroot.c,v
retrieving revision 1.10
diff -u -p -r1.10 fsys-getroot.c
--- fsys-getroot.c 16 Jun 2001 20:23:29 -0000 1.10
+++ fsys-getroot.c 24 Mar 2002 23:50:49 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -130,6 +130,12 @@ netfs_S_fsys_getroot (mach_port_t cntl,
newpi = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
&peropen_context),
cred);
+ if (! newpi)
+ {
+ err = errno;
+ goto out;
+ }
+
mach_port_deallocate (mach_task_self (), dotdot);
*do_retry = FS_RETRY_NORMAL;
Index: io-duplicate.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/io-duplicate.c,v
retrieving revision 1.3
diff -u -p -r1.3 io-duplicate.c
--- io-duplicate.c 16 Jun 2001 20:23:29 -0000 1.3
+++ io-duplicate.c 24 Mar 2002 23:50:49 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995,96,2001 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2001, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -36,9 +36,14 @@ netfs_S_io_duplicate (struct protid *use
mutex_lock (&user->po->np->lock);
newpi = netfs_make_protid (user->po, clone);
- *newport = ports_get_right (newpi);
- mutex_unlock (&user->po->np->lock);
- *newporttp = MACH_MSG_TYPE_MAKE_SEND;
- ports_port_deref (newpi);
- return 0;
+ if (newpi)
+ {
+ *newport = ports_get_right (newpi);
+ mutex_unlock (&user->po->np->lock);
+ *newporttp = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ return 0;
+ }
+ else
+ return errno;
}
Index: io-reauthenticate.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/io-reauthenticate.c,v
retrieving revision 1.10
diff -u -p -r1.10 io-reauthenticate.c
--- io-reauthenticate.c 16 Jun 2001 20:23:29 -0000 1.10
+++ io-reauthenticate.c 24 Mar 2002 23:50:49 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995,96,2000,01 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2000,01, 02 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -34,20 +34,26 @@ netfs_S_io_reauthenticate (struct protid
mutex_lock (&user->po->np->lock);
newpi = netfs_make_protid (user->po, 0);
- newright = ports_get_send_right (newpi);
- assert (newright != MACH_PORT_NULL);
+ if (newpi)
+ {
- err = iohelp_reauth (&newpi->user, netfs_auth_server_port, rend_port,
- newright, 1);
-
- mach_port_deallocate (mach_task_self (), rend_port);
- mach_port_deallocate (mach_task_self (), newright);
-
- mach_port_move_member (mach_task_self (), newpi->pi.port_right,
- netfs_port_bucket->portset);
-
- mutex_unlock (&user->po->np->lock);
- ports_port_deref (newpi);
-
- return err;
+ newright = ports_get_send_right (newpi);
+ assert (newright != MACH_PORT_NULL);
+
+ err = iohelp_reauth (&newpi->user, netfs_auth_server_port, rend_port,
+ newright, 1);
+
+ mach_port_deallocate (mach_task_self (), rend_port);
+ mach_port_deallocate (mach_task_self (), newright);
+
+ mach_port_move_member (mach_task_self (), newpi->pi.port_right,
+ netfs_port_bucket->portset);
+
+ mutex_unlock (&user->po->np->lock);
+ ports_port_deref (newpi);
+
+ return err;
+ }
+ else
+ return errno;
}
Index: io-restrict-auth.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/io-restrict-auth.c,v
retrieving revision 1.4
diff -u -p -r1.4 io-restrict-auth.c
--- io-restrict-auth.c 16 Jun 2001 20:37:39 -0000 1.4
+++ io-restrict-auth.c 24 Mar 2002 23:50:49 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995,96,2001 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2001, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -102,15 +102,15 @@ netfs_S_io_restrict_auth (struct protid
*newport = ports_get_right (newpi);
mutex_unlock (&user->po->np->lock);
*newporttype = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ return 0;
}
else
{
mutex_unlock (&user->po->np->lock);
iohelp_free_iouser (new_user);
- err = ENOMEM;
+ return errno;
}
- ports_port_deref (newpi);
- return err;
}
Index: make-protid.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/make-protid.c,v
retrieving revision 1.6
diff -u -p -r1.6 make-protid.c
--- make-protid.c 18 Nov 1996 23:51:10 -0000 1.6
+++ make-protid.c 24 Mar 2002 23:50:49 -0000
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 2002 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -23,18 +23,22 @@
struct protid *
netfs_make_protid (struct peropen *po, struct iouser *cred)
{
+ error_t err;
struct protid *pi;
if (cred)
- errno = ports_create_port (netfs_protid_class, netfs_port_bucket,
- sizeof (struct protid), &pi);
+ err = ports_create_port (netfs_protid_class, netfs_port_bucket,
+ sizeof (struct protid), &pi);
else
- errno = ports_create_port_noinstall (netfs_protid_class,
- netfs_port_bucket,
- sizeof (struct protid), &pi);
+ err = ports_create_port_noinstall (netfs_protid_class,
+ netfs_port_bucket,
+ sizeof (struct protid), &pi);
- if (errno)
- return 0;
+ if (err)
+ {
+ errno = err;
+ return 0;
+ }
po->refcnt++;
pi->po = po;
- follow up on make-protid,
James A Morrison <=