[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] libnetfs: Behave more like diskfs_startup_diskfs
From: |
Damien Zammit |
Subject: |
[PATCH 1/4] libnetfs: Behave more like diskfs_startup_diskfs |
Date: |
Tue, 2 Mar 2021 22:41:34 +1100 |
---
libnetfs/dir-lookup.c | 30 +++++++++++++++++++++---------
libnetfs/dir-readdir.c | 3 ---
libnetfs/file-getcontrol.c | 13 ++++++-------
libnetfs/init-startup.c | 5 ++---
libnetfs/make-protid.c | 8 +-------
5 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index 23adeb33..9bf78225 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -50,9 +50,6 @@ netfs_S_dir_lookup (struct protid *dircred,
struct protid *newpi = NULL;
struct iouser *user;
- if (!dircred)
- return EOPNOTSUPP;
-
create = (flags & O_CREAT);
excl = (flags & O_EXCL);
@@ -73,6 +70,12 @@ netfs_S_dir_lookup (struct protid *dircred,
*do_retry = FS_RETRY_NORMAL;
*retry_name = '\0';
+ if (!dircred)
+ {
+ dircred = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
0), 0);
+ dircred->po->path = filename;
+ }
+
if (*filename == '\0')
{
/* Set things up in the state expected by the code from gotit: on. */
@@ -423,15 +426,24 @@ netfs_S_dir_lookup (struct protid *dircred,
flags &= ~OPENONLY_STATE_MODES;
- err = iohelp_dup_iouser (&user, dircred->user);
- if (err)
- goto out;
+ if (dircred->user)
+ {
+ err = iohelp_dup_iouser (&user, dircred->user);
+ if (err)
+ goto out;
+ }
+ else
+ {
+ user = NULL;
+ err = 0;
+ }
+
+ newpi = netfs_make_protid (netfs_make_peropen (np, flags, dircred->po),
user);
- newpi = netfs_make_protid (netfs_make_peropen (np, flags, dircred->po),
- user);
if (! newpi)
{
- iohelp_free_iouser (user);
+ if (user)
+ iohelp_free_iouser (user);
err = errno;
goto out;
}
diff --git a/libnetfs/dir-readdir.c b/libnetfs/dir-readdir.c
index 3d40dfa5..83dbf2d4 100644
--- a/libnetfs/dir-readdir.c
+++ b/libnetfs/dir-readdir.c
@@ -36,9 +36,6 @@ netfs_S_dir_readdir (struct protid *user,
error_t err;
struct node *np;
- if (!user)
- return EOPNOTSUPP;
-
np = user->po->np;
pthread_mutex_lock (&np->lock);
diff --git a/libnetfs/file-getcontrol.c b/libnetfs/file-getcontrol.c
index 0e29ccf9..833fe196 100644
--- a/libnetfs/file-getcontrol.c
+++ b/libnetfs/file-getcontrol.c
@@ -31,13 +31,12 @@ netfs_S_file_getcontrol (struct protid *user,
error_t err;
struct port_info *pi;
- if (!user)
- return EOPNOTSUPP;
-
- err = fshelp_iscontroller (&netfs_root_node->nn_stat, user->user);
- if (err)
- return err;
-
+ if (user)
+ {
+ err = fshelp_iscontroller (&netfs_root_node->nn_stat, user->user);
+ if (err)
+ return err;
+ }
/* They've have the appropriate credentials; give it to them. */
err = ports_create_port (netfs_control_class, netfs_port_bucket,
sizeof (struct port_info), &pi);
diff --git a/libnetfs/init-startup.c b/libnetfs/init-startup.c
index e17c4f16..7aed3b62 100644
--- a/libnetfs/init-startup.c
+++ b/libnetfs/init-startup.c
@@ -30,8 +30,9 @@ netfs_startup (mach_port_t bootstrap, int flags)
mach_port_t realnode, right;
struct port_info *newpi;
+ /* If we have a bootstrap port we must call fsys_startup */
if (bootstrap == MACH_PORT_NULL)
- error (10, 0, "Must be started as a translator");
+ task_get_bootstrap_port (mach_task_self (), &bootstrap);
err = ports_create_port (netfs_control_class, netfs_port_bucket,
sizeof (struct port_info), &newpi);
@@ -46,8 +47,6 @@ netfs_startup (mach_port_t bootstrap, int flags)
if (err)
error (11, err, "Translator startup failure: fsys_startup");
- mach_port_deallocate (mach_task_self (), bootstrap);
-
/* Mark us as important. */
mach_port_t proc = getproc ();
if (proc == MACH_PORT_NULL)
diff --git a/libnetfs/make-protid.c b/libnetfs/make-protid.c
index 995ac1ea..2087f220 100644
--- a/libnetfs/make-protid.c
+++ b/libnetfs/make-protid.c
@@ -25,14 +25,8 @@ netfs_make_protid (struct peropen *po, struct iouser *cred)
{
struct protid *pi;
- if (cred)
- errno = ports_create_port (netfs_protid_class, netfs_port_bucket,
+ errno = ports_create_port (netfs_protid_class, netfs_port_bucket,
sizeof (struct protid), &pi);
- else
- errno = ports_create_port_noinstall (netfs_protid_class,
- netfs_port_bucket,
- sizeof (struct protid), &pi);
-
if (errno)
return 0;
--
2.30.0