bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 1/2] streamio: Implement trivfs_append_args ()


From: Sergey Bugaev
Subject: [PATCH 1/2] streamio: Implement trivfs_append_args ()
Date: Thu, 18 May 2023 19:57:18 +0300

This enables me to run 'fsysopts /dev/mach-console' and get:

/hurd/streamio --writable console
---
 trans/streamio.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

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;
-- 
2.40.1




reply via email to

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