summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhaoming Luo <zhmingluo@163.com>2025-01-02 09:55:23 +0800
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-01-02 11:22:54 +0100
commitaedaf285a0809cdf16f30fd07120b3f24954b6b4 (patch)
tree4d652197233d9eb93d7906900469d3bc1429571c
parent4f8b7ec44c90a7f64ede667d1eb3b75c10dbac51 (diff)
Translator: Add the introduction to the rtc translator
* hurd/translator.mdwn: Add an entry for the rtc translator * hurd/translator/rtc.mdwn: Add the introduction to the rtc translator Message-ID: <20250102015524.1253093-1-zhmingluo@163.com>
-rw-r--r--hurd/translator.mdwn1
-rw-r--r--hurd/translator/rtc.mdwn31
2 files changed, 32 insertions, 0 deletions
diff --git a/hurd/translator.mdwn b/hurd/translator.mdwn
index 324c5f8c..fe669a12 100644
--- a/hurd/translator.mdwn
+++ b/hurd/translator.mdwn
@@ -121,6 +121,7 @@ The [[concept|concepts]] of translators creates its own problems, too:
* [[term]]
* [[checkperms]]
* [[usermux]]
+* [[rtc]]
* ...
diff --git a/hurd/translator/rtc.mdwn b/hurd/translator/rtc.mdwn
new file mode 100644
index 00000000..7a917b46
--- /dev/null
+++ b/hurd/translator/rtc.mdwn
@@ -0,0 +1,31 @@
+[[!meta copyright="Copyright © 2025 Free Software Foundation, Inc."]]
+
+[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable
+id="license" text="Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License, Version 1.2 or
+any later version published by the Free Software Foundation; with no Invariant
+Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license
+is included in the section entitled [[GNU Free Documentation
+License|/fdl]]."]]"""]]
+
+The *rtc* translator implements a real-time clock driver. It can be used to add
+the `rtc` device files, with those files, we can access the underlying
+real-time clock using `ioctl()`. The description of `ioctl()` can be found
+[here](https://www.gnu.org/software/libc/manual/html_node/IOCTLs.html).
+
+The operation macros are required to access the real-time clock. They are
+defined as `RTC_*` in `hurd/rtc.h`.
+
+The `hwclock` command from `util-linux` can use the `rtc` device files to
+access the real-time clock devices.
+
+# Usage Example
+Setup a `rtc` device file in `/tmp`:
+
+ settrans -c /tmp/rtc /hurd/rtc
+
+Read the time value through the `rtc` device file:
+
+ int fd = open("/tmp/rtc", O_RDONLY);
+ struct rtc_time time;
+ ioctl(fd, RTC_RD_TIME, &time);