aboutsummaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rw-r--r--www/assets/res/css/todos.css20
-rw-r--r--www/content/notes/_index.md5
-rw-r--r--www/content/notes/cheat-sheet.md14
-rw-r--r--www/content/notes/hurd.md (renamed from www/content/hurd/_index.md)105
-rw-r--r--www/content/notes/hurd/todos.md (renamed from www/content/hurd/todos.md)14
-rw-r--r--www/content/notes/todos.md (renamed from www/content/todos.md)2
-rw-r--r--www/content/posts/_index.md (renamed from www/content/posts/_index.html)0
-rw-r--r--www/content/posts/c-func-ext.md94
-rw-r--r--www/layouts/_default/list.html11
-rw-r--r--www/layouts/index.html21
-rw-r--r--www/layouts/shortcodes/todo.html6
11 files changed, 184 insertions, 108 deletions
diff --git a/www/assets/res/css/todos.css b/www/assets/res/css/todos.css
index e9a595d..7802812 100644
--- a/www/assets/res/css/todos.css
+++ b/www/assets/res/css/todos.css
@@ -1,14 +1,24 @@
.todo {
-
- &::before {
+ h3::before {
font-family: monospace;
}
- &.working::before {
+ &.working h3::before {
content: "* ";
}
- &.done::before {
+ &.done h3::before {
content: "✓ ";
}
-} \ No newline at end of file
+
+ &.give-up {
+ &, a:link, a:visited {
+ color: grey;
+ }
+
+ h3:before {
+ content: "orz ✖ ";
+ }
+ }
+}
+
diff --git a/www/content/notes/_index.md b/www/content/notes/_index.md
new file mode 100644
index 0000000..3c736ed
--- /dev/null
+++ b/www/content/notes/_index.md
@@ -0,0 +1,5 @@
+---
+title: "Notes"
+params:
+ recursive: true
+---
diff --git a/www/content/notes/cheat-sheet.md b/www/content/notes/cheat-sheet.md
new file mode 100644
index 0000000..efb3b35
--- /dev/null
+++ b/www/content/notes/cheat-sheet.md
@@ -0,0 +1,14 @@
+---
+title: "Cheat Sheet"
+date: 2025-04-01T23:09:53+08:00
+lastmod: 2025-04-01T23:09:53+08:00
+---
+
+Update GRUB after `grub` package is updated. Replace `/boot` with your mount
+point of the EFI partition in `--efi-directory=/boot`. Replace `GRUB` with your
+bootloader id in `--bootloader-id=GRUB`.
+
+```bash-session
+grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
+grub-mkconfig -o /boot/grub/grub.cfg
+```
diff --git a/www/content/hurd/_index.md b/www/content/notes/hurd.md
index b4c727c..67b8df9 100644
--- a/www/content/hurd/_index.md
+++ b/www/content/notes/hurd.md
@@ -2,12 +2,11 @@
title: "Hurd"
date: 2025-03-03T15:34:41+08:00
lastmod: 2025-03-03T23:28:46+08:00
-layout: single
---
{{< mono >}}
-[TODOS](/hurd/todos)
+[TODOS](/notes/hurd/todos)
{{< /mono >}}
@@ -41,100 +40,48 @@ refs:
## *_MAX patch
-TODO: Move to separate page.
-
-```c
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static inline char *xreadlink(const char *restrict path) {
- char *buffer;
- size_t allocated = 128;
- ssize_t len;
-
- while (1) {
- buffer = (char *)malloc(allocated);
- if (!buffer) {
- return NULL;
- }
- len = readlink(path, buffer, allocated);
- if (len < (ssize_t)allocated) {
- return buffer;
- }
- free(buffer);
- if (len >= (ssize_t)allocated) {
- allocated *= 2;
- continue;
- }
- return NULL;
- }
-}
-
-static inline char *xgethostname() {
- long max_host_name;
- char *buffer;
-
- max_host_name = sysconf(_SC_HOST_NAME_MAX);
- buffer = malloc(max_host_name + 1);
-
- if (gethostname(buffer, max_host_name + 1)) {
- free(buffer);
- return NULL;
- }
-
- buffer[max_host_name] = '\0';
- return buffer;
-}
-
-static inline char *xgetcwd() {
- char *buffer;
- size_t allocated = 128;
-
- while (1) {
- buffer = (char *)malloc(allocated);
- if (!buffer) {
- return NULL;
- }
- getcwd(buffer, allocated);
- if (buffer)
- return buffer;
- free(buffer);
- if (errno == ERANGE) {
- allocated *= 2;
- continue;
- }
- return NULL;
- }
-}
-```
+See [this](posts/c-func-ext.md)
## git repos
+Clone all at once:
+
+```sh
+# glibc is too big, so not clone here.
+for repo in hurd gnumach mig web; do
+ if [ ! -d $repo ]; then
+ git clone "https://crupest.life/git/hurd/$repo.git"
+ pushd $repo
+ git remote add upstream "https://git.savannah.gnu.org/git/hurd/$repo.git"
+ popd
+ fi
+done
+```
+
{{< link-group >}}
hurd
-cru: <https://crupest.life/git/cru-hurd/hurd.git>
+cru: <https://crupest.life/git/hurd/hurd.git>
upstream: <https://git.savannah.gnu.org/git/hurd/hurd.git>
debian: <https://salsa.debian.org/hurd-team/hurd>
{{< /link-group >}}
{{< link-group >}}
gnumach
-cru: <https://crupest.life/git/cru-hurd/gnumach.git>
+cru: <https://crupest.life/git/hurd/gnumach.git>
upstream: <https://git.savannah.gnu.org/git/hurd/gnumach.git>
debian: <https://salsa.debian.org/hurd-team/gnumach>
{{< /link-group >}}
{{< link-group >}}
mig
-cru: <https://crupest.life/git/cru-hurd/mig.git>
+cru: <https://crupest.life/git/hurd/mig.git>
upstream: <https://git.savannah.gnu.org/git/hurd/mig.git>
debian: <https://salsa.debian.org/hurd-team/mig>
{{< /link-group >}}
{{< link-group >}}
glibc
-cru: <https://crupest.life/git/cru-hurd/glibc.git>
+cru: <https://crupest.life/git/hurd/glibc.git>
upstream: <git://sourceware.org/git/glibc.git>
debian: <https://salsa.debian.org/glibc-team/glibc>
mirror: <https://mirrors.tuna.tsinghua.edu.cn/git/glibc.git>
@@ -142,7 +89,7 @@ mirror: <https://mirrors.tuna.tsinghua.edu.cn/git/glibc.git>
{{< link-group >}}
web
-cru: <https://crupest.life/git/cru-hurd/web.git>
+cru: <https://crupest.life/git/hurd/web.git>
upstream: <https://git.savannah.gnu.org/git/hurd/web.git>
{{< /link-group >}}
@@ -151,14 +98,18 @@ upstream: <https://git.savannah.gnu.org/git/hurd/web.git>
Start qemu
```sh
-qemu-system-x86_64 -enable-kvm -m 4G -net nic -net user,hostfwd=tcp::3222-:22 -vga vmware -drive cache=writeback,file=[...]
+qemu-system-x86_64 -enable-kvm -m 4G \
+ -net nic -net user,hostfwd=tcp::3222-:22 \
+ -vga vmware -drive cache=writeback,file=[...]
```
Configure/Setup network
```sh
-settrans -fgap /servers/socket/2 /hurd/pfinet -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
-fsysopts /servers/socket/2 /hurd/pfinet -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
+settrans -fgap /servers/socket/2 /hurd/pfinet \
+ -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
+fsysopts /servers/socket/2 /hurd/pfinet \
+ -i /dev/eth0 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
fsysopts /server/socket/2 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0
```
diff --git a/www/content/hurd/todos.md b/www/content/notes/hurd/todos.md
index f8273fb..cd93f01 100644
--- a/www/content/hurd/todos.md
+++ b/www/content/notes/hurd/todos.md
@@ -9,7 +9,7 @@ params:
## Porting
-### {{< todo name=pam state=working >}}
+{{< todo name=pam state=give-up >}}
{{< link-group >}}
git
@@ -23,7 +23,9 @@ mail
<https://lists.debian.org/debian-hurd/2025/02/msg00018.html>
{{< /link-group >}}
-### {{< todo name=abseil state=working >}}
+{{< /todo >}}
+
+{{< todo name=abseil state=working >}}
{{< link-group >}}
git
@@ -38,7 +40,9 @@ mail
<https://lists.debian.org/debian-hurd/2025/02/msg00035.html>
{{< /link-group >}}
-### {{< todo name=libgav1 state=done >}}
+{{< /todo >}}
+
+{{< todo name=libgav1 state=done >}}
{{< link-group >}}
git
@@ -52,3 +56,7 @@ misc
mail: <https://lists.debian.org/debian-hurd/2025/02/msg00016.html>
gerrit: <https://chromium-review.googlesource.com/c/codecs/libgav1/+/6239812>
{{< /link-group >}}
+
+{{< /todo >}}
+
+
diff --git a/www/content/todos.md b/www/content/notes/todos.md
index a790e24..1625362 100644
--- a/www/content/todos.md
+++ b/www/content/notes/todos.md
@@ -4,4 +4,4 @@ date: 2025-03-03T15:34:53+08:00
lastmod: 2025-03-03T23:28:46+08:00
---
-[Hurd](/hurd/todos)
+[Hurd](/notes/hurd/todos)
diff --git a/www/content/posts/_index.html b/www/content/posts/_index.md
index 76fa783..76fa783 100644
--- a/www/content/posts/_index.html
+++ b/www/content/posts/_index.md
diff --git a/www/content/posts/c-func-ext.md b/www/content/posts/c-func-ext.md
index f5ab8fb..7106fad 100644
--- a/www/content/posts/c-func-ext.md
+++ b/www/content/posts/c-func-ext.md
@@ -8,16 +8,92 @@ tags:
- posix
---
-Recently, I've been working on porting libraries to GNU/Hurd. The maintainers of GNU/Hurd
-have a strong belief that [`*_MAX` macros on POSIX system interfaces](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/nframe.html)
-are very evil things. This is indeed true as a lot of (old) libraries relying on those macros
-to determine the buffer size. In modern programming world, it is definitely a bad
-idea to use fixed values for buffer sizes without considering possible overflow, unless
-you are certain that size is sufficient.
-
-When you get rid of some old things, you will always meet compatibility problems. In these
-case, old source codes using these macros just do not compile now. So here are some
+Recently, I’ve been working on porting some libraries to GNU/Hurd. Many (old)
+libraries use [`*_MAX` constants on POSIX system
+interfaces](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/nframe.html)
+to calculate buffer sizes. However, the GNU/Hurd maintainers urge against the
+blind use of them and refuse to define them in system headers. When old APIs are
+gone, compatibility problems come. To make my life easier, I'll put some
+reusable code snippets here to help *fix `*_MAX` bugs*.
<!--more-->
+```c
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+static inline char *xreadlink(const char *restrict path) {
+ char *buffer;
+ size_t allocated = 128;
+ ssize_t len;
+
+ while (1) {
+ buffer = (char*) malloc(allocated);
+ if (!buffer) { return NULL; }
+ len = readlink(path, buffer, allocated);
+ if (len < (ssize_t) allocated) { return buffer; }
+ free(buffer);
+ if (len >= (ssize_t) allocated) { allocated *= 2; continue; }
+ return NULL;
+ }
+ }
+
+
+static inline char *xgethostname(void) {
+ long max_host_name;
+ char *buffer;
+
+ max_host_name = sysconf(_SC_HOST_NAME_MAX);
+ buffer = malloc(max_host_name + 1);
+
+ if (gethostname(buffer, max_host_name + 1)) {
+ free(buffer);
+ return NULL;
+ }
+
+ buffer[max_host_name] = '\0';
+ return buffer;
+}
+
+static inline char *xgetcwd(void) {
+ char *buffer;
+ size_t allocated = 128;
+
+ while (1) {
+ buffer = (char*) malloc(allocated);
+ if (!buffer) { return NULL; }
+ getcwd(buffer, allocated);
+ if (buffer) return buffer;
+ free(buffer);
+ if (errno == ERANGE) { allocated *= 2; continue; }
+ return NULL;
+ }
+}
+
+static inline __attribute__((__format__(__printf__, 2, 3))) int
+xsprintf(char **buf_ptr, const char *restrict format, ...) {
+ char *buffer;
+ int ret;
+
+ va_list args;
+ va_start(args, format);
+
+ ret = snprintf(NULL, 0, format, args);
+ if (ret < 0) { goto out; }
+
+ buffer = malloc(ret + 1);
+ if (!buffer) { ret = -1; goto out; }
+
+ ret = snprintf(NULL, 0, format, args);
+ if (ret < 0) { free(buffer); goto out; }
+
+ *buf_ptr = buffer;
+out:
+ va_end(args);
+ return ret;
+}
+```
diff --git a/www/layouts/_default/list.html b/www/layouts/_default/list.html
index c7c6cce..5bb0b5e 100644
--- a/www/layouts/_default/list.html
+++ b/www/layouts/_default/list.html
@@ -4,9 +4,14 @@
{{ define "content" }}
{{ partial "nav.html" . }}
- <h1>Posts</h1>
+ <h1>{{ .Title }}</h1>
+ {{ $pages := .RegularPages }}
+ {{ if .Param "recursive" }}
+ {{ $pages = .RegularPagesRecursive }}
+ {{ end }}
{{ partial "preview/posts.html" (dict
- "h" "h3"
- "pages" (.RegularPages.ByDate.Reverse.Limit 3))
+ "h" "h3"
+ "pages" $pages
+ )
}}
{{ end }}
diff --git a/www/layouts/index.html b/www/layouts/index.html
index 7c608f1..e05af03 100644
--- a/www/layouts/index.html
+++ b/www/layouts/index.html
@@ -26,23 +26,26 @@
<hr />
<section>
<p>Welcome to my home page! Nice to meet you here! 🥰</p>
- <p>If you have something interesting to share with me, feel free to email me at
- <a rel="noopener noreferrer" href="mailto:crupest@crupest.life">crupest@crupest.life</a>.
- You can also create an issue in any of my repos on GitHub to talk anything to me.
+ <p>If you have something interesting to share with me, feel free to email me
+ at <a rel="noopener noreferrer" href="mailto:crupest@crupest.life">crupest@crupest.life</a>.
+ You can also create an issue in any of my repos
+ on <a rel="noopener noreferrer" href="https://github.com/crupest">GitHub</a> to talk
+ anything to me.
</p>
<div id="links" class="mono-link">
- links:
+ goto:
<ul>
- <li><a href="{{ .RelPermalink }}">home</a></li>
<li><a href="{{ absURL "/git/" }}">git</a></li>
- {{ with .GetPage "/hurd" }}
+ {{ with .GetPage "/notes/hurd" }}
<li><a href="{{ .RelPermalink }}">hurd</a></li>
{{ end }}
- {{ with .GetPage "/todos" }}
+ {{ with .GetPage "/notes/todos" }}
<li><a href="{{ .RelPermalink }}">todos</a></li>
{{ end }}
- <li><a rel="noopener noreferrer" href="https://github.com/crupest">github</a></li>
- </ul>
+ {{ with .GetPage "/notes/cheat-sheet" }}
+ <li><a href="{{ .RelPermalink }}">cheat-sheet</a></li>
+ {{ end }}
+ </ul>
</div>
</section>
<hr>
diff --git a/www/layouts/shortcodes/todo.html b/www/layouts/shortcodes/todo.html
index 1327b31..b4fc680 100644
--- a/www/layouts/shortcodes/todo.html
+++ b/www/layouts/shortcodes/todo.html
@@ -1 +1,5 @@
-<span class="todo {{ .Get "state" }}">{{ .Get "name" }}</span> \ No newline at end of file
+<section class="todo {{ .Get "state" }}">
+ <h3>{{ .Get "name" }}</h3>
+ {{ .Inner }}
+</section>
+