bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH] settrans -gl only kills the active translator


From: Neal H Walfield
Subject: Re: [PATCH] settrans -gl only kills the active translator
Date: Fri, 15 Jun 2001 22:06:07 -0500
User-agent: Mutt/1.3.18i

On Tue, May 15, 2001 at 01:00:35AM -0400, Roland McGrath wrote:
> I agree with Neal that a FS_TRANS_* flag is more appropriate--that leaves
> goaway_flags as purely flags passed on to the fsys_goaway RPC, which is a
> clear and easy thing to understand.  I think we should call the new flag
> FS_TRANS_ORPHAN, and the settrans option --orphan (perhaps
> --detach-old-translator as an alias).  I think the "orphaned child
> filesystem" metaphor stands up, as I imagine that children become orphans
> unceremoniously by finding themselves suddenly unable to find their
> parents, rather than by receiving a friendly request to absent themselves
> from the family and quietly commit suicide, while retaining veto power on
> the whole decision.

Here it is; a sample run:

Script started on Fri Jun 15 22:04:17 2001
neal@desdemona:~ (0)$ ps -A | grep hello
neal       369 p3 Sf    0:00.01 grep hello
neal@desdemona:~ (0)$ settrans -ac foo /hurd/hello
neal@desdemona:~ (0)$ cat foo
Hello, world!
neal@desdemona:~ (0)$ ps -A | grep hello
neal       372  - So    0:00.02 /hurd/hello
neal       375 p3 S     0:00.01 grep hello
neal@desdemona:~ (0)$ settrans -ao foo
neal@desdemona:~ (0)$ ps -A | grep hello
neal       372  - So    0:00.02 /hurd/hello
neal       379 p3 S     0:00.00 grep hello
neal@desdemona:~ (0)$ cat foo
neal@desdemona:~ (0)$ kill 372
neal@desdemona:~ (0)$ exit
Script done on Fri Jun 15 22:04:56 2001

and the patch:

hurd/ChangeLog:

2001-06-15  Neal H Walfield  <neal@cs.uml.edu>

        * hurd_types.h: New macro, FS_TRANS_ORPHAN.

libdiskfs/ChangeLog:


2001-06-15  Neal H Walfield  <neal@cs.uml.edu>

        * file-set-trans.c (diskfs_S_file_set_translator):  If
        FS_TRANS_ORPHAN is set, do not ask the active translator to go
        away, just disconnect it.

utils/ChangeLog:

2001-06-15  Neal H Walfield  <neal@cs.uml.edu>

        * settrans.c (options): New option `--orphan'.
        Fix other comments to aviod confusion.
        (main): Add FS_TRANS_ORPHAN to ACTIVE_FLAGS if `--orphan' is
        specified.

Index: hurd/hurd_types.h
===================================================================
RCS file: /home/neal/cvs/hurd/hurd/hurd_types.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 hurd_types.h
--- hurd/hurd_types.h   2001/06/03 20:53:19     1.1.1.1
+++ hurd/hurd_types.h   2001/06/16 02:50:18
@@ -1,5 +1,5 @@
 /* C declarations for Hurd server interfaces
-   Copyright (C) 1993, 94, 95, 96, 98, 99 Free Software Foundation, Inc.
+   Copyright (C) 1993,94,95,96,98,99,2001 Free Software Foundation, Inc.
 
 This file is part of the GNU Hurd.
 
@@ -81,6 +81,7 @@
 #define FS_TRANS_FORCE     0x00000001 /* Must use translator(no sht circuit) */
 #define FS_TRANS_EXCL      0x00000002 /* Don't do it if already translated.  */
 #define FS_TRANS_SET      0x00000004 /* Set or clear translator */
+#define FS_TRANS_ORPHAN    0x00000008 /* Orphan the active translator.  */
 
 /* Values for retry field in fs.defs:dir_pathtrans call: */
 enum retry_type
Index: libdiskfs/file-set-trans.c
===================================================================
RCS file: /home/neal/cvs/hurd/libdiskfs/file-set-trans.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 file-set-trans.c
--- libdiskfs/file-set-trans.c  2001/06/03 20:53:19     1.1.1.1
+++ libdiskfs/file-set-trans.c  2001/06/16 02:50:18
@@ -1,5 +1,5 @@
 /* libdiskfs implementation of fs.defs: file_set_translator
-   Copyright (C) 1992, 93, 94, 95, 96, 99 Free Software Foundation, Inc.
+   Copyright (C) 1992,93,94,95,96,99,2001 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -57,7 +57,8 @@
       return error;
     }
 
-  if (active_flags & FS_TRANS_SET)
+  if (active_flags & FS_TRANS_SET
+      && ! (active_flags & FS_TRANS_ORPHAN))
     {
       error = fshelp_fetch_control (&np->transbox, &control);
       if (error)
Index: utils/settrans.c
===================================================================
RCS file: /home/neal/cvs/hurd/utils/settrans.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 settrans.c
--- utils/settrans.c    2001/06/03 20:53:21     1.1.1.1
+++ utils/settrans.c    2001/06/16 02:50:21
@@ -1,6 +1,6 @@
 /* Set a file's translator.
 
-   Copyright (C) 1995, 96, 97, 98 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,2001 Free Software Foundation, Inc.
 
    Written by Miles Bader <miles@gnu.ai.mit.edu>
 
@@ -49,15 +49,18 @@
      " wait for a newline on stdin before completing the startup handshake"},
   {"timeout",     't',"SEC",0, "Timeout for translator startup, in seconds"
      " (default " STRINGIFY (DEFAULT_TIMEOUT) "); 0 means no timeout"},
-  {"exclusive",   'x', 0, 0, "Only set the translator if there is none 
already"},
+  {"exclusive",   'x', 0, 0, "Only set the translator if there is not one 
already"},
+  {"orphan",      'o', 0, 0, "Disconnect the translator from the filesystem "
+                            "(do not ask it to go away)"},
 
   {0,0,0,0, "When setting the passive translator, if there's an active 
translator:"},
-  {"goaway",      'g', 0, 0, "Make the active translator go away"},
-  {"keep-active", 'k', 0, 0, "Leave the existing active translator running"},
+  {"goaway",      'g', 0, 0, "Ask the active translator to go away"},
+  {"keep-active", 'k', 0, 0, "Leave any existing active translator running"},
 
   {0,0,0,0, "When an active translator is told to go away:"},
   {"recursive",   'R', 0, 0, "Shutdown its children too"},
-  {"force",       'f', 0, 0, "If it doesn't want to die, force it"},
+  {"force",       'f', 0, 0, "Ask it to ignore current users and shutdown "
+                            "anyway." },
   {"nosync",      'S', 0, 0, "Don't sync it before killing it"},
 
   {0, 0}
@@ -91,7 +94,8 @@
   int goaway_flags = 0;
 
   /* Various option flags.  */
-  int passive = 0, active = 0, keep_active = 0, pause = 0, kill_active = 0;
+  int passive = 0, active = 0, keep_active = 0, pause = 0, kill_active = 0,
+      orphan = 0;
   int excl = 0;
   int timeout = DEFAULT_TIMEOUT * 1000; /* ms */
 
@@ -123,6 +127,7 @@
        case 'g': kill_active = 1; break;
        case 'x': excl = 1; break;
        case 'P': pause = 1; break;
+       case 'o': orphan = 1; break;
 
        case 'c': lookup_flags |= O_CREAT; break;
        case 'L': lookup_flags &= ~O_NOTRANS; break;
@@ -149,7 +154,8 @@
   if (passive)
     passive_flags = FS_TRANS_SET | (excl ? FS_TRANS_EXCL : 0);
   if (active)
-    active_flags = FS_TRANS_SET | (excl ? FS_TRANS_EXCL : 0);
+    active_flags = FS_TRANS_SET | (excl ? FS_TRANS_EXCL : 0)
+                  | (orphan ? FS_TRANS_ORPHAN : 0);
 
   if (passive && !active)
     {

Attachment: pgp_ddIki69Jl.pgp
Description: PGP signature


reply via email to

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