[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 30/87: utils/settrans: implement settrans --start
From: |
Samuel Thibault |
Subject: |
[hurd] 30/87: utils/settrans: implement settrans --start |
Date: |
Sun, 09 Nov 2014 11:05:01 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 370f2fcb4ae7901e34caba64d31027f8cf69a858
Author: Justus Winter <address@hidden>
Date: Wed Jun 11 11:54:18 2014 +0200
utils/settrans: implement settrans --start
Start the translator specified by the NODE's passive translator record
and set it as NODE's active translator. This is the equivalent of
doing:
% settrans --active /node $(showtrans /node)
* utils/settrans.c (argp_option): Add --start.
(parse_opt): Handle --start.
(main): Retrieve the passive translator record if --start is given.
---
utils/settrans.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/utils/settrans.c b/utils/settrans.c
index ecc6d75..84b271a 100644
--- a/utils/settrans.c
+++ b/utils/settrans.c
@@ -1,6 +1,7 @@
/* Set a file's translator.
- Copyright (C) 1995,96,97,98,2001,02,13 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,98,2001,02,13,14
+ Free Software Foundation, Inc.
Written by Miles Bader <address@hidden>
This program is free software; you can redistribute it and/or
@@ -47,6 +48,7 @@ const char *argp_program_version = STANDARD_HURD_VERSION
(settrans);
static struct argp_option options[] =
{
{"active", 'a', 0, 0, "Start TRANSLATOR and set it as NODE's active
translator" },
+ {"start", 's', 0, 0, "Start the translator specified by the NODE's
passive translator record and set it as NODE's active translator" },
{"passive", 'p', 0, 0, "Change NODE's passive translator record
(default)" },
{"create", 'c', 0, 0, "Create NODE if it doesn't exist" },
{"dereference", 'L', 0, 0, "If a translator exists, put the new one on top"},
@@ -107,6 +109,7 @@ main(int argc, char *argv[])
/* Various option flags. */
int passive = 0, active = 0, keep_active = 0, pause = 0, kill_active = 0,
orphan = 0;
+ int start = 0;
char *pid_file = NULL;
int excl = 0;
int timeout = DEFAULT_TIMEOUT * 1000; /* ms */
@@ -122,6 +125,9 @@ main(int argc, char *argv[])
node_name = arg;
else /* command */
{
+ if (start)
+ argp_error (state, "both --start and TRANSLATOR given");
+
error_t err =
argz_create (state->argv + state->next - 1, &argz, &argz_len);
if (err)
@@ -135,6 +141,10 @@ main(int argc, char *argv[])
return EINVAL;
case 'a': active = 1; break;
+ case 's':
+ start = 1;
+ active = 1; /* start implies active */
+ break;
case 'p': passive = 1; break;
case 'k': keep_active = 1; break;
case 'g': kill_active = 1; break;
@@ -212,6 +222,26 @@ main(int argc, char *argv[])
active_flags = FS_TRANS_SET | FS_TRANS_EXCL;
}
+ if (start)
+ {
+ /* Retrieve the passive translator record in argz. */
+ mach_port_t node = file_name_lookup (node_name, lookup_flags, 0);
+ if (node == MACH_PORT_NULL)
+ error (4, errno, "%s", node_name);
+
+ char buf[1024];
+ argz = buf;
+ argz_len = sizeof (buf);
+
+ err = file_get_translator (node, &argz, &argz_len);
+ if (err == EINVAL)
+ error (4, 0, "%s: no passive translator record found", node_name);
+ if (err)
+ error (4, err, "%s", node_name);
+
+ mach_port_deallocate (mach_task_self (), node);
+ }
+
if ((active || chroot_command) && argz_len > 0)
{
/* Error during file lookup; we use this to avoid duplicating error
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 38/87: trans/fakeroot: fix error handling, (continued)
- [hurd] 38/87: trans/fakeroot: fix error handling, Samuel Thibault, 2014/11/09
- [hurd] 39/87: libports: avoid realloc(3) corner case, Samuel Thibault, 2014/11/09
- [hurd] 40/87: libdiskfs: add permission check to file_chflags, Samuel Thibault, 2014/11/09
- [hurd] 31/87: Merge branch 'merge-random', Samuel Thibault, 2014/11/09
- [hurd] 41/87: libdiskfs: expose the ST_NOATIME flag, Samuel Thibault, 2014/11/09
- [hurd] 43/87: ext2fs: use correct type for block numbers, Samuel Thibault, 2014/11/09
- [hurd] 42/87: libdiskfs: fix deadlock, Samuel Thibault, 2014/11/09
- [hurd] 44/87: libpipe: fix calls to pipe_send with no data, Samuel Thibault, 2014/11/09
- [hurd] 24/87: ext2fs: fix type of retry_dotdot, Samuel Thibault, 2014/11/09
- [hurd] 23/87: ext2fs: fix type of blockaddr, Samuel Thibault, 2014/11/09
- [hurd] 30/87: utils/settrans: implement settrans --start,
Samuel Thibault <=
- [hurd] 25/87: Prepare the random translator to be merged into the Hurd sources, Samuel Thibault, 2014/11/09
- [hurd] 46/87: libpipe: fix spurious calls to pipe_send, Samuel Thibault, 2014/11/09
- [hurd] 48/87: Make settrans return value returned by chroot command, Samuel Thibault, 2014/11/09
- [hurd] 51/87: Fix ifsock permission check, Samuel Thibault, 2014/11/09
- [hurd] 55/87: libihash: fix comparison between signed and unsigned integer, Samuel Thibault, 2014/11/09
- [hurd] 54/87: trans/mtab: use setnullauth to drop privileges, Samuel Thibault, 2014/11/09
- [hurd] 21/87: ext2fs: fix compiler warning, Samuel Thibault, 2014/11/09
- [hurd] 49/87: Add missing linefeed, Samuel Thibault, 2014/11/09
- [hurd] 58/87: libdiskfs: fix /servers/exec lookup, Samuel Thibault, 2014/11/09
- [hurd] 59/87: hurd: make memory_object parameter polymorphic, Samuel Thibault, 2014/11/09