diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2023-05-18 19:57:18 +0300 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-21 21:24:25 +0200 |
commit | c944947a507e32c71c694e5f6fd8c694a03e9330 (patch) | |
tree | 9f4d12d9f7fa4dc36187e0033839388faf0470ba /trans | |
parent | 5d95e1d0983b4485f22c2e39035f6ba05be46047 (diff) | |
download | hurd-c944947a507e32c71c694e5f6fd8c694a03e9330.tar.gz hurd-c944947a507e32c71c694e5f6fd8c694a03e9330.tar.bz2 hurd-c944947a507e32c71c694e5f6fd8c694a03e9330.zip |
streamio: Implement trivfs_append_args ()
This enables me to run 'fsysopts /dev/mach-console' and get:
/hurd/streamio --writable console
Message-Id: <20230518165719.90745-1-bugaevc@gmail.com>
Diffstat (limited to 'trans')
-rw-r--r-- | trans/streamio.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/trans/streamio.c b/trans/streamio.c index 2d40a5d3..272a002c 100644 --- a/trans/streamio.c +++ b/trans/streamio.c @@ -23,7 +23,9 @@ #include <stdio.h> #include <fcntl.h> #include <argp.h> +#include <argz.h> #include <error.h> +#include <sys/sysmacros.h> #include <mach.h> #include <device/device.h> @@ -722,6 +724,43 @@ trivfs_S_file_syncfs (struct trivfs_protid *cred, return err; } +error_t +trivfs_append_args (struct trivfs_control *fsys, + char **argz, size_t *argz_len) +{ + error_t err; + + switch (trivfs_allow_open & O_RDWR) + { + default: + assert_backtrace (!"Bad trivfs_allow_open"); + case O_READ: + err = argz_add (argz, argz_len, "--readonly"); + break; + case O_WRITE: + err = argz_add (argz, argz_len, "--writeonly"); + break; + case O_RDWR: + err = argz_add (argz, argz_len, "--writable"); + break; + } + + if (err) + return err; + + if (rdev != (dev_t) 0) + { + char buf[40]; + snprintf (buf, sizeof (buf), "--rdev=%d,%d", + gnu_dev_major (rdev), gnu_dev_minor (rdev)); + err = argz_add (argz, argz_len, buf); + if (err) + return err; + } + + return argz_add (argz, argz_len, stream_name); +} + /* This flag is set if there is an outstanding device_write. */ static int output_pending; |