bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 06/17] libdiskfs: add fsys_get_children


From: Justus Winter
Subject: [PATCH 06/17] libdiskfs: add fsys_get_children
Date: Thu, 11 Jul 2013 18:09:09 +0200

---
 libdiskfs/Makefile            |    3 ++-
 libdiskfs/dead-name.c         |    4 +++-
 libdiskfs/file-set-trans.c    |   19 +++++++++++++++
 libdiskfs/fsys-get-children.c |   51 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 2 deletions(-)
 create mode 100644 libdiskfs/fsys-get-children.c

diff --git a/libdiskfs/Makefile b/libdiskfs/Makefile
index 3c8de4c..1a0edd0 100644
--- a/libdiskfs/Makefile
+++ b/libdiskfs/Makefile
@@ -34,7 +34,8 @@ IOSRCS= io-async-icky.c io-async.c io-duplicate.c 
io-get-conch.c io-revoke.c \
        io-reauthenticate.c io-rel-conch.c io-restrict-auth.c io-seek.c \
        io-select.c io-stat.c io-stubs.c io-write.c io-version.c io-sigio.c
 FSYSSRCS=fsys-getroot.c fsys-goaway.c fsys-startup.c fsys-getfile.c \
-       fsys-options.c fsys-syncfs.c fsys-forward.c
+       fsys-options.c fsys-syncfs.c fsys-forward.c \
+       fsys-get-children.c
 IFSOCKSRCS=ifsock.c
 OTHERSRCS = conch-fetch.c conch-set.c dir-clear.c dir-init.c dir-renamed.c \
        extern-inline.c \
diff --git a/libdiskfs/dead-name.c b/libdiskfs/dead-name.c
index 760b36f..6ca208e 100644
--- a/libdiskfs/dead-name.c
+++ b/libdiskfs/dead-name.c
@@ -40,6 +40,8 @@ ports_dead_name (void *notify, mach_port_t dead_name)
       else
        pthread_mutex_unlock (&np->lock);
     }
-  
+
+  fshelp_remove_active_translator (dead_name);
+
   ports_interrupt_notified_rpcs (notify, dead_name, MACH_NOTIFY_DEAD_NAME);
 }
diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c
index 49303e7..5366880 100644
--- a/libdiskfs/file-set-trans.c
+++ b/libdiskfs/file-set-trans.c
@@ -18,6 +18,7 @@
 #include "priv.h"
 #include "fs_S.h"
 #include <hurd/paths.h>
+#include <hurd/fshelp.h>
 #include <hurd/fsys.h>
 
 /* Implement file_set_translator as described in <hurd/fs.defs>. */
@@ -206,5 +207,23 @@ diskfs_S_file_set_translator (struct protid *cred,
     }
 
   pthread_mutex_unlock (&np->lock);
+
+  if (! error && cred->po->path)
+    {
+      error = fshelp_set_translator (cred->po->path,
+                                     passive_flags, active_flags,
+                                     !!passivelen, active);
+    }
+
+  if (! error && active != MACH_PORT_NULL)
+    {
+      mach_port_t old;
+      error = mach_port_request_notification (mach_task_self (), active,
+                                              MACH_NOTIFY_DEAD_NAME, 0,
+                                              cred->pi.port_right,
+                                              MACH_MSG_TYPE_MAKE_SEND_ONCE,
+                                              &old);
+    }
+
   return error;
 }
diff --git a/libdiskfs/fsys-get-children.c b/libdiskfs/fsys-get-children.c
new file mode 100644
index 0000000..9d4c4b3
--- /dev/null
+++ b/libdiskfs/fsys-get-children.c
@@ -0,0 +1,51 @@
+/* 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; 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"
+
+/* Return any passive and active translators bound to nodes of the
+   receiving filesystem. children is a argz vector containing file
+   names relative to the root of the receiving translator.  */
+error_t
+diskfs_S_fsys_get_children (mach_port_t server,
+                            mach_port_t reply,
+                            mach_msg_type_name_t replyPoly,
+                            char **children,
+                            mach_msg_type_number_t *children_len)
+{
+  error_t err;
+
+  char *c = NULL;
+  size_t c_len = 0;
+
+  err = fshelp_get_translators (&c, &c_len);
+  if (err)
+    goto errout;
+
+  err = iohelp_return_malloced_buffer (c, c_len, children, children_len);
+  c = NULL; /* c was freed by iohelp_return_malloced_buffer. */
+
+ errout:
+  free (c);
+  return err;
+}
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]