summaryrefslogtreecommitdiff
path: root/debian/patches/fixes0001-utils-settrans-implement-active-translator-stacking.patch
blob: 544ca9321f0b3050090ce8e7c8af315736c50909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 1a6818d5ff3d897c2636c9585e1cb94db5d6368e Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Sat, 23 Apr 2016 17:39:47 +0200
Subject: [PATCH hurd 1/3] utils/settrans: implement active translator stacking

* utils/settrans.c (OPT_STACK): New macro.
(options): New option.
(main): Handle new option.
(open_node): Use different flags for the lookup of the underlying
node.
---
 utils/settrans.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/utils/settrans.c b/utils/settrans.c
index e01906b..ee7cba5 100644
--- a/utils/settrans.c
+++ b/utils/settrans.c
@@ -47,6 +47,7 @@ const char *argp_program_version = STANDARD_HURD_VERSION (settrans);
 #define STRINGIFY(arg) _STRINGIFY (arg)
 
 #define OPT_CHROOT_CHDIR	-1
+#define OPT_STACK		-2
 
 static struct argp_option options[] =
 {
@@ -66,6 +67,8 @@ static struct argp_option options[] =
 			     "(do not ask it to go away)"},
   {"underlying",  'U', "NODE", 0, "Open NODE and hand it to the translator "
 				  "as the underlying node"},
+  {"stack", OPT_STACK, 0, 0, "Replace an existing translator, but keep it "
+			     "running, and put the new one on top"},
 
   {"chroot",      'C', 0, 0,
    "Instead of setting the node's translator, take following arguments up to"
@@ -156,10 +159,12 @@ main(int argc, char *argv[])
   int passive = 0, active = 0, keep_active = 0, pause = 0, kill_active = 0,
       orphan = 0;
   int start = 0;
+  int stack = 0;
   char *pid_file = NULL;
   int excl = 0;
   int timeout = DEFAULT_TIMEOUT * 1000; /* ms */
   char *underlying_node_name = NULL;
+  int underlying_lookup_flags;
   char **chroot_command = 0;
   char *chroot_chdir = "/";
 
@@ -193,6 +198,11 @@ main(int argc, char *argv[])
 	  start = 1;
 	  active = 1;	/* start implies active */
 	  break;
+	case OPT_STACK:
+	  stack = 1;
+	  active = 1;	/* stack implies active */
+	  orphan = 1;	/* stack implies orphan */
+	  break;
 	case 'p': passive = 1; break;
 	case 'k': keep_active = 1; break;
 	case 'g': kill_active = 1; break;
@@ -261,6 +271,14 @@ main(int argc, char *argv[])
 
   argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, 0);
 
+  if (stack)
+    {
+      underlying_node_name = node_name;
+      underlying_lookup_flags = lookup_flags && ~O_NOTRANS;
+    }
+  else
+    underlying_lookup_flags = lookup_flags;
+
   if (!active && !passive && !chroot_command)
     passive = 1;		/* By default, set the passive translator.  */
 
@@ -341,7 +359,8 @@ main(int argc, char *argv[])
 	  if (underlying_node_name)
 	    {
 	      *underlying = file_name_lookup (underlying_node_name,
-					      flags | lookup_flags, 0666);
+					      flags | underlying_lookup_flags,
+					      0666);
 	      if (! MACH_PORT_VALID (*underlying))
 		{
 		  /* For the error message.  */
-- 
2.1.4