From 9366d6b2e48ba409366adc0516825c41a86dec9b Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Thu, 30 Jan 2014 10:53:46 +0100
Subject: hurd: fix the get-children and get-source procedures
* hurd/fs.defs: Add file_get_children and file_get_source.
* hurd/fsys.defs: Remove fsys_get_children and fsys_get_source.
* libdiskfs/fsys-get-children.c: Rename and adapt accordingly.
* libdiskfs/fsys-get-source.c: Likewise.
* libnetfs/fsys-get-children.c: Likewise.
* libnetfs/fsys-get-source.c: Likewise.
* libtrivfs/fsys-get-children.c: Likewise.
* libtrivfs/fsys-get-source.c: Likewise.
* libdiskfs/diskfs.h: Adapt prototype and comment.
* libnetfs/netfs.h: Likewise.
* libtrivfs/trivfs.h: Likewise.
* libdiskfs/get-source.c: Adapt default implementation, provide
diskfs_disk_name by default.
* libnetfs/netfs.h: Adapt default implementation.
* libtrivfs/get-source.c: Likewise.
* libdiskfs/Makefile: Adapt accordingly.
* libnetfs/Makefile: Likewise.
* libtrivfs/Makefile: Likewise.
* trans/symlink.c: Likewise.
* trans/mtab.c: Likewise.
---
libnetfs/Makefile | 2 +-
libnetfs/file-get-children.c | 108 +++++++++++++++++++++++++++++++++++++++++
libnetfs/file-get-source.c | 37 ++++++++++++++
libnetfs/fsys-get-children.c | 112 -------------------------------------------
libnetfs/fsys-get-source.c | 34 -------------
libnetfs/get-source.c | 2 +-
libnetfs/netfs.h | 9 ++--
7 files changed, 152 insertions(+), 152 deletions(-)
create mode 100644 libnetfs/file-get-children.c
create mode 100644 libnetfs/file-get-source.c
delete mode 100644 libnetfs/fsys-get-children.c
delete mode 100644 libnetfs/fsys-get-source.c
(limited to 'libnetfs')
diff --git a/libnetfs/Makefile b/libnetfs/Makefile
index 1a71b499..c3830c03 100644
--- a/libnetfs/Makefile
+++ b/libnetfs/Makefile
@@ -45,7 +45,7 @@ IOSRCS= io-read.c io-readable.c io-seek.c io-write.c io-stat.c io-async.c \
io-version.c
FSYSSRCS= fsys-syncfs.c fsys-getroot.c fsys-get-options.c fsys-set-options.c \
- fsys-goaway.c fsysstubs.c fsys-get-children.c fsys-get-source.c
+ fsys-goaway.c fsysstubs.c file-get-children.c file-get-source.c
IFSOCKSRCS=
OTHERSRCS= drop-node.c init-init.c make-node.c make-peropen.c make-protid.c \
diff --git a/libnetfs/file-get-children.c b/libnetfs/file-get-children.c
new file mode 100644
index 00000000..80a727f5
--- /dev/null
+++ b/libnetfs/file-get-children.c
@@ -0,0 +1,108 @@
+/* file_get_children
+
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ Written by Justus Winter <4winter@informatik.uni-hamburg.de>
+
+ 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. If not, see . */
+
+#include "priv.h"
+
+#include
+
+/* Return any active translators bound to nodes of the receiving
+ filesystem. CHILDREN is an argz vector containing file names
+ relative to the root of the receiving translator. */
+error_t
+netfs_S_file_get_children (struct protid *cred,
+ char **children,
+ mach_msg_type_number_t *children_len)
+{
+ error_t err;
+ if (! cred
+ || cred->pi.bucket != netfs_port_bucket
+ || cred->pi.class != netfs_protid_class)
+ return EOPNOTSUPP;
+
+ /* check_access performs the same permission check as is normally
+ done, i.e. it checks that all but the last path components are
+ executable by the requesting user and that the last component is
+ readable. */
+ error_t check_access (const char *path)
+ {
+ error_t err;
+ char *elements = NULL;
+ size_t elements_len = 0;
+
+ err = argz_create_sep (path, '/', &elements, &elements_len);
+ if (err)
+ return err;
+
+ struct node *dp = netfs_root_node;
+
+ /* Lock the root node. netfs_attempt_lookup expects the directory to
+ be locked. */
+ pthread_mutex_lock (&dp->lock);
+
+ /* Increase the reference count, it will be decremented in the loop
+ ahead. */
+ netfs_nref (dp);
+
+ for (char *entry = elements;
+ entry;
+ entry = argz_next (elements, elements_len, entry))
+ {
+ struct node *next;
+ err = netfs_attempt_lookup (cred->user, dp, entry, &next);
+ /* netfs_attempt_lookup has unlocked dp and returned next
+ locked, so there is no locking to do here. */
+
+ /* Decrease reference count. */
+ netfs_nrele (dp);
+
+ if (err)
+ goto errout;
+
+ dp = next;
+ }
+
+ err = fshelp_access (&dp->nn_stat, S_IRUSR, cred->user);
+
+ errout:
+ /* Unlock and unreference the last node. */
+ netfs_nput (dp);
+
+ free (elements);
+ return err;
+ }
+
+ char *c = NULL;
+ size_t c_len = 0;
+
+ err = fshelp_get_active_translators (&c, &c_len, check_access);
+ if (err)
+ goto errout;
+
+ err = iohelp_return_malloced_buffer (c, c_len, children, children_len);
+ if (err)
+ goto errout;
+
+ c = NULL; /* c was freed by iohelp_return_malloced_buffer. */
+
+ errout:
+ free (c);
+ return err;
+}
diff --git a/libnetfs/file-get-source.c b/libnetfs/file-get-source.c
new file mode 100644
index 00000000..8b73d5a1
--- /dev/null
+++ b/libnetfs/file-get-source.c
@@ -0,0 +1,37 @@
+/* file_get_source
+
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ Written by Justus Winter <4winter@informatik.uni-hamburg.de>
+
+ 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. If not, see . */
+
+#include "priv.h"
+#include "fs_S.h"
+
+/* Return information about the source of the receiving
+ filesystem. */
+error_t
+netfs_S_file_get_source (struct protid *cred,
+ char *source)
+{
+ if (! cred
+ || cred->pi.bucket != netfs_port_bucket
+ || cred->pi.class != netfs_protid_class)
+ return EOPNOTSUPP;
+
+ return netfs_get_source (cred, source, 1024 /* XXX */);
+}
diff --git a/libnetfs/fsys-get-children.c b/libnetfs/fsys-get-children.c
deleted file mode 100644
index fb3af914..00000000
--- a/libnetfs/fsys-get-children.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* fsys_get_children
-
- Copyright (C) 2013 Free Software Foundation, Inc.
-
- Written by Justus Winter <4winter@informatik.uni-hamburg.de>
-
- 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. If not, see . */
-
-#include "priv.h"
-
-#include
-
-/* Return any active translators bound to nodes of the receiving
- filesystem. CHILDREN is an argz vector containing file names
- relative to the root of the receiving translator. */
-error_t
-netfs_S_fsys_get_children (fsys_t server,
- mach_port_t reply,
- mach_msg_type_name_t replyPoly,
- char **children,
- mach_msg_type_number_t *children_len)
-{
- error_t err;
-
- struct protid *cred = ports_lookup_port (netfs_port_bucket,
- server,
- netfs_protid_class);
- if (! cred)
- return EOPNOTSUPP;
-
- /* check_access performs the same permission check as is normally
- done, i.e. it checks that all but the last path components are
- executable by the requesting user and that the last component is
- readable. */
- error_t check_access (const char *path)
- {
- error_t err;
- char *elements = NULL;
- size_t elements_len = 0;
-
- err = argz_create_sep (path, '/', &elements, &elements_len);
- if (err)
- return err;
-
- struct node *dp = netfs_root_node;
-
- /* Lock the root node. netfs_attempt_lookup expects the directory to
- be locked. */
- pthread_mutex_lock (&dp->lock);
-
- /* Increase the reference count, it will be decremented in the loop
- ahead. */
- netfs_nref (dp);
-
- for (char *entry = elements;
- entry;
- entry = argz_next (elements, elements_len, entry))
- {
- struct node *next;
- err = netfs_attempt_lookup (cred->user, dp, entry, &next);
- /* netfs_attempt_lookup has unlocked dp and returned next
- locked, so there is no locking to do here. */
-
- /* Decrease reference count. */
- netfs_nrele (dp);
-
- if (err)
- goto errout;
-
- dp = next;
- }
-
- err = fshelp_access (&dp->nn_stat, S_IRUSR, cred->user);
-
- errout:
- /* Unlock and unreference the last node. */
- netfs_nput (dp);
-
- free (elements);
- return err;
- }
-
- char *c = NULL;
- size_t c_len = 0;
-
- err = fshelp_get_active_translators (&c, &c_len, check_access);
- if (err)
- goto errout;
-
- err = iohelp_return_malloced_buffer (c, c_len, children, children_len);
- if (err)
- goto errout;
-
- c = NULL; /* c was freed by iohelp_return_malloced_buffer. */
-
- errout:
- free (c);
- return err;
-}
diff --git a/libnetfs/fsys-get-source.c b/libnetfs/fsys-get-source.c
deleted file mode 100644
index 6143d10b..00000000
--- a/libnetfs/fsys-get-source.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* fsys_get_source
-
- Copyright (C) 2013 Free Software Foundation, Inc.
-
- Written by Justus Winter <4winter@informatik.uni-hamburg.de>
-
- 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. If not, see . */
-
-#include "priv.h"
-#include "fsys_S.h"
-
-/* Return information about the source of the receiving
- filesystem. */
-error_t
-netfs_S_fsys_get_source (fsys_t server,
- mach_port_t reply,
- mach_msg_type_name_t replyPoly,
- char *source)
-{
- return netfs_get_source (source);
-}
diff --git a/libnetfs/get-source.c b/libnetfs/get-source.c
index 71a96390..73e48be8 100644
--- a/libnetfs/get-source.c
+++ b/libnetfs/get-source.c
@@ -22,7 +22,7 @@
#include "priv.h"
error_t
-netfs_get_source (char *source)
+netfs_get_source (struct protid *cred, char *source, size_t source_len)
{
return EOPNOTSUPP;
}
diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h
index e10ccae0..5d50f57d 100644
--- a/libnetfs/netfs.h
+++ b/libnetfs/netfs.h
@@ -315,10 +315,11 @@ error_t netfs_file_get_storage_info (struct iouser *cred,
mach_msg_type_number_t *data_len);
/* The user may define this function. The function must set source to
- the source device of the filesystem. The function may return an
- EOPNOTSUPP to indicate that the concept of a source device is not
- applicable. The default function always returns EOPNOTSUPP. */
-error_t netfs_get_source (char *source);
+ the source of CRED. The function may return an EOPNOTSUPP to
+ indicate that the concept of a source device is not applicable. The
+ default function always returns EOPNOTSUPP. */
+error_t netfs_get_source (struct protid *cred,
+ char *source, size_t source_len);
/* Option parsing */
--
cgit v1.2.3