diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/.markdownlint.json | 5 | ||||
-rw-r--r-- | www/.markdownlintrc | 4 | ||||
-rw-r--r-- | www/assets/res/css/article.css | 10 | ||||
-rw-r--r-- | www/assets/res/css/base.css | 26 | ||||
-rw-r--r-- | www/assets/res/css/home.css | 6 | ||||
-rw-r--r-- | www/assets/res/css/single.css | 8 | ||||
-rw-r--r-- | www/assets/res/css/todos.css | 15 | ||||
-rw-r--r-- | www/assets/res/js/color-scheme.ts | 18 | ||||
-rw-r--r-- | www/config/_default/hugo.yaml | 4 | ||||
-rw-r--r-- | www/content/hurd/_index.md | 182 | ||||
-rw-r--r-- | www/content/notes/_index.md | 16 | ||||
-rw-r--r-- | www/content/notes/cheat-sheet.md | 129 | ||||
-rw-r--r-- | www/content/notes/hurd/_index.md | 15 | ||||
-rw-r--r-- | www/content/notes/hurd/cheat-sheet.md | 68 | ||||
-rw-r--r-- | www/content/notes/hurd/links.md | 88 | ||||
-rw-r--r-- | www/content/notes/hurd/todos.md (renamed from www/content/hurd/todos.md) | 12 | ||||
-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.md | 94 | ||||
-rw-r--r-- | www/content/todos.md | 7 | ||||
-rw-r--r-- | www/layouts/_partials/css-res.html (renamed from www/layouts/partials/css-res.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/css.html (renamed from www/layouts/partials/css.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/date.html (renamed from www/layouts/partials/date.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/highlight.html (renamed from www/layouts/partials/highlight.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/js.html (renamed from www/layouts/partials/js.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/nav.html (renamed from www/layouts/partials/nav.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/preview/article.html (renamed from www/layouts/partials/preview/article.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/preview/post.html (renamed from www/layouts/partials/preview/post.html) | 0 | ||||
-rw-r--r-- | www/layouts/_partials/preview/posts.html | 13 | ||||
-rw-r--r-- | www/layouts/_shortcodes/link-group.html (renamed from www/layouts/shortcodes/link-group.html) | 0 | ||||
-rw-r--r-- | www/layouts/baseof.html (renamed from www/layouts/_default/baseof.html) | 5 | ||||
-rw-r--r-- | www/layouts/home.html (renamed from www/layouts/index.html) | 40 | ||||
-rw-r--r-- | www/layouts/list.html (renamed from www/layouts/_default/list.html) | 8 | ||||
-rw-r--r-- | www/layouts/partials/preview/posts.html | 7 | ||||
-rw-r--r-- | www/layouts/shortcodes/mono.html | 3 | ||||
-rw-r--r-- | www/layouts/shortcodes/todo.html | 1 | ||||
-rw-r--r-- | www/layouts/single.html (renamed from www/layouts/_default/single.html) | 6 |
36 files changed, 478 insertions, 312 deletions
diff --git a/www/.markdownlint.json b/www/.markdownlint.json new file mode 100644 index 0000000..12bc65e --- /dev/null +++ b/www/.markdownlint.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json", + "default": true, + "MD013": false +} diff --git a/www/.markdownlintrc b/www/.markdownlintrc deleted file mode 100644 index 22879bc..0000000 --- a/www/.markdownlintrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "default": true -} - diff --git a/www/assets/res/css/article.css b/www/assets/res/css/article.css index 9629597..93f86ef 100644 --- a/www/assets/res/css/article.css +++ b/www/assets/res/css/article.css @@ -2,9 +2,6 @@ font-size: 0.95em; padding-inline: 0.5em; padding-block: 0.5em; - margin-block-end: 0.5em; - border-radius: 3px; - background-color: hsl(33, 100%, 98%); & > p { font-size: 0.9em; @@ -20,8 +17,8 @@ & > .date { font-size: small; + margin-top: 0.3em; float: right; - margin-inline-end: 1.5em; color: hsl(0, 0%, 25%); } @@ -40,3 +37,8 @@ html[data-theme="dark"] { } } } + +hr.article-preview-hr { + border: none; + border-top: 1.5px dashed currentColor; +} diff --git a/www/assets/res/css/base.css b/www/assets/res/css/base.css index c628271..77cd804 100644 --- a/www/assets/res/css/base.css +++ b/www/assets/res/css/base.css @@ -20,6 +20,12 @@ body { background-color: var(--body-bg-color); } +/* https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/Heading_Elements#specifying_a_uniform_font_size_for_h1 */ +h1 { + margin-block: 0.67em; + font-size: 2em; +} + .mono { font-family: monospace; } @@ -39,7 +45,7 @@ table { border-collapse: collapse; &, :is(td,th) { - padding: 0.4em; + padding: 0.2em 0.4em; border: 1px solid var(--table-border-color); } } @@ -70,19 +76,6 @@ nav { font-size: large; } -#slogan { - color: white; - width: 100%; - padding: 0.5em 1em; - text-align: center; - background-color: dodgerblue; - user-select: none; - - & > * { - user-select: text; - } -} - #main-article { position: relative; left: 50%; @@ -147,9 +140,4 @@ html[data-theme="dark"] { & a:visited { color:#abcac4; } - - & #slogan { - color: var(--body-fg-color); - background-color: midnightblue; - } } diff --git a/www/assets/res/css/home.css b/www/assets/res/css/home.css index 3df42ff..60c9ac7 100644 --- a/www/assets/res/css/home.css +++ b/www/assets/res/css/home.css @@ -1,9 +1,3 @@ -#slogan { - position: sticky; - z-index: 1; - top: 0; -} - #avatar { float: right; } diff --git a/www/assets/res/css/single.css b/www/assets/res/css/single.css index 70325d1..3d8ee0f 100644 --- a/www/assets/res/css/single.css +++ b/www/assets/res/css/single.css @@ -10,11 +10,3 @@ margin-inline-end: auto; } } - -.end-hr { - border: none; - width: 8em; - margin-block-start: 1.5em; - margin-inline-start: 0; - border-top: 1px dashed black; -} diff --git a/www/assets/res/css/todos.css b/www/assets/res/css/todos.css index e9a595d..f9aa23b 100644 --- a/www/assets/res/css/todos.css +++ b/www/assets/res/css/todos.css @@ -1,14 +1,17 @@ -.todo { - +h3.todo { &::before { - font-family: monospace; + font-size: small; } &.working::before { - content: "* "; + content: "(working) "; } &.done::before { - content: "✓ "; + content: "(done) "; + } + + &.give-up::before { + content: "(give up) "; } -}
\ No newline at end of file +} diff --git a/www/assets/res/js/color-scheme.ts b/www/assets/res/js/color-scheme.ts index db6a3aa..fb4accf 100644 --- a/www/assets/res/js/color-scheme.ts +++ b/www/assets/res/js/color-scheme.ts @@ -90,21 +90,3 @@ function next(): Scheme | null { } } } - -window.addEventListener("load", () => { - const slogon = document.getElementById("slogan")! - let clicks: number = 0 - - const reset = createResetTimer(() => { - clicks = 0 - }) - - slogon.addEventListener("click", () => { - reset() - clicks += 1 - if (clicks === 3) { - saveScheme(next()) - clicks = 0 - } - }) -}) diff --git a/www/config/_default/hugo.yaml b/www/config/_default/hugo.yaml index b913177..289b0b4 100644 --- a/www/config/_default/hugo.yaml +++ b/www/config/_default/hugo.yaml @@ -18,6 +18,10 @@ frontmatter: markup: goldmark: + parser: + attribute: + block: true + title: true extensions: table: true highlight: diff --git a/www/content/hurd/_index.md b/www/content/hurd/_index.md deleted file mode 100644 index b4c727c..0000000 --- a/www/content/hurd/_index.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -title: "Hurd" -date: 2025-03-03T15:34:41+08:00 -lastmod: 2025-03-03T23:28:46+08:00 -layout: single ---- - -{{< mono >}} - -[TODOS](/hurd/todos) - -{{< /mono >}} - -## links - -{{< mono >}} - -| name | link | -| --- | --- | -| kernel-list-archive | <https://lists.gnu.org/archive/html/bug-hurd/> | -| debian-list-archive | <https://lists.debian.org/debian-hurd/> | -| irc-archive | <https://logs.guix.gnu.org/hurd/> | -| kernel-home | <https://www.gnu.org/software/hurd/index.html> | -| debian-home | <https://www.debian.org/ports/hurd/> | - -{{< /mono >}} - -refs: - -{{< mono >}} - -| name | link | -| --- | --- | -| c | <https://en.cppreference.com/w/c> | -| posix latest | <https://pubs.opengroup.org/onlinepubs/9799919799/> | -| posix 2013 | <https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/> | -| posix 2008 | <https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/> | -| glibc | <https://sourceware.org/glibc/manual/2.41/html_mono/libc.html> | - -{{< /mono >}} - -## *_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; - } -} -``` - -## git repos - -{{< link-group >}} -hurd -cru: <https://crupest.life/git/cru-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> -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> -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> -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> -{{< /link-group >}} - -{{< link-group >}} -web -cru: <https://crupest.life/git/cru-hurd/web.git> -upstream: <https://git.savannah.gnu.org/git/hurd/web.git> -{{< /link-group >}} - -## cheatsheet - -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=[...] -``` - -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 -fsysopts /server/socket/2 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0 -``` - -Setup apt - -```sh -apt-get --allow-unauthenticated --allow-insecure-repositories update -apt-get --allow-unauthenticated upgrade -``` - -## mailing lists / irc - -{{< mono >}} - -| name | address | -| --- | --- | -| hurd | <bug-hurd@gnu.org> | -| debian | <debian-hurd@lists.debian.org> | -| irc | librechat #hurd | - -{{< /mono >}} diff --git a/www/content/notes/_index.md b/www/content/notes/_index.md new file mode 100644 index 0000000..3f96f73 --- /dev/null +++ b/www/content/notes/_index.md @@ -0,0 +1,16 @@ +--- +title: "Notes" +date: 2025-06-14T21:24:00+08:00 +lastmod: 2025-06-14T21:24:00+08:00 +layout: single +--- + +- [Cheat Sheet](/notes/cheat-sheet) + +- [Hurd](/notes/hurd) + + - [Cheat Sheet](/notes/hurd/cheat-sheet) + + - [Todos](/notes/hurd/todos) + + - [Useful Links](/notes/hurd/links) diff --git a/www/content/notes/cheat-sheet.md b/www/content/notes/cheat-sheet.md new file mode 100644 index 0000000..2f30140 --- /dev/null +++ b/www/content/notes/cheat-sheet.md @@ -0,0 +1,129 @@ +--- +title: "Cheat Sheet" +date: 2025-04-01T23:09:53+08:00 +lastmod: 2025-06-12T01:09:39+08:00 +--- + +goto: [Hurd Cheat Sheet (in a separated page)](/notes/hurd/cheat-sheet) +{class="mono"} + +## GRUB + +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`. + +```sh +grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB +grub-mkconfig -o /boot/grub/grub.cfg +``` + +## (Private) My Service Infrastructure Management + +All commands should be run at the project root path. + +### Install Deno + +Script from <https://docs.deno.com/runtime/getting_started/installation/> + +```sh +curl -fsSL https://deno.land/install.sh | sh +``` + +### Add Git Server User / Set Password + +```sh +docker run -it --rm -v "./data/git/user-info:/user-info" httpd htpasswd /user-info [username] +``` + +### Certbot + +A complete command is `[prefix] [docker (based on challenge kind)] [command] [challenge] [domains] [test] [misc]` + +| part | for | segment | +| :-: | :-: | --- | +| prefix | * | `docker run -it --rm --name certbot -v "./data/certbot/certs:/etc/letsencrypt" -v "./data/certbot/data:/var/lib/letsencrypt"` | +| docker | challenge standalone | `-p "0.0.0.0:80:80"` | +| docker | challenge nginx | `-v "./data/certbot/webroot:/var/www/certbot"` | +| command | create/expand/shrink | `certonly` | +| command | renew | `renew` | +| challenge | standalone | `--standalone` | +| challenge | nginx | `--webroot -w /var/www/certbot` | +| domains | * | `[-d [domain]]...` | +| test | * | `--test-cert --dry-run` | +| misc | agree tos | `--agree-tos` | +| misc | cert name | `--cert-name [name]` | +| misc | email | `--email [email]` | + +For example, **test** create/expand/shrink with standalone server: + +```sh +docker run -it --rm --name certbot \ + -v "./data/certbot/certs:/etc/letsencrypt" -v "./data/certbot/data:/var/lib/letsencrypt"` \ + -p "0.0.0.0:80:80" \ + certonly \ + --standalone \ + -d crupest.life -d mail.crupest.life \ + --test-cert --dry-run +``` + +## System Setup + +### Debian setup + +#### Setup SSL Certificates and Curl + +```sh +apt-get update +apt-get install ca-certificates curl +install -m 0755 -d /etc/apt/keyrings +``` + +### Docker Setup + +#### Uninstall Packages Provided by Stock Repo + +```bash +for pkg in docker.io docker-doc docker-compose \ + podman-docker containerd runc; do + apt-get remove $pkg; +done +``` + +#### Install Certs From Docker + +Remember to [setup ssl and curl](#setup-ssl-certificates-and-curl) first. + +```sh +curl -fsSL https://download.docker.com/linux/debian/gpg \ + -o /etc/apt/keyrings/docker.asc +chmod a+r /etc/apt/keyrings/docker.asc +``` + +#### Add Docker Repos + +```bash +echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ + https://download.docker.com/linux/debian \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null +``` + +#### Install Docker Packages + +```sh +apt-get update +apt-get install docker-ce docker-ce-cli containerd.io \ + docker-buildx-plugin docker-compose-plugin +``` + +#### Start And Enable Docker + +Remember to log out and log back to let user group change take effects. + +```sh +systemctl enable docker +systemctl start docker +groupadd -f docker +usermod -aG docker $USER +``` diff --git a/www/content/notes/hurd/_index.md b/www/content/notes/hurd/_index.md new file mode 100644 index 0000000..8faf70b --- /dev/null +++ b/www/content/notes/hurd/_index.md @@ -0,0 +1,15 @@ +--- +title: "Hurd" +date: 2025-03-03T15:34:41+08:00 +lastmod: 2025-06-12T01:09:39+08:00 +layout: single +--- + +This is the gateway page for various notes about +[GNU/Hurd](https://www.gnu.org/software/hurd/) written by me. + +- [Cheat Sheet](/notes/hurd/cheat-sheet) + +- [Todos](/notes/hurd/todos) + +- [Useful Links](/notes/hurd/links) diff --git a/www/content/notes/hurd/cheat-sheet.md b/www/content/notes/hurd/cheat-sheet.md new file mode 100644 index 0000000..6fe5ccd --- /dev/null +++ b/www/content/notes/hurd/cheat-sheet.md @@ -0,0 +1,68 @@ +--- +title: "Hurd Cheat Sheet" +date: 2025-06-12T00:59:16+08:00 +lastmod: 2025-06-14T20:34:06+08:00 +--- + +## Mirrors + +The mirror has to be `debian-ports`, not `debian`, and many mirror sites do not +provide it. Following is aliyun mirror: + +```txt +/etc/apt/sources.list +--- +deb https://mirrors.aliyun.com/debian-ports/ unstable main +deb https://mirrors.aliyun.com/debian-ports/ unreleased main +deb-src https://mirrors.aliyun.com/debian/ unstable main +``` + +The hurd-amd64 deb-src seems to not work. + +## Use QEMU Virtual Machine + +For i386, use + +```sh +qemu-system-x86_64 -enable-kvm -m 4G \ + -net nic -net user,hostfwd=tcp::3222-:22 \ + -vga vmware -drive cache=writeback,file=[...] +``` + +For x86_64, use + +```sh +qemu-system-x86_64 -enable-kvm -m 8G -machine q35 \ + -net nic -net user,hostfwd=tcp::3223-:22 \ + -vga vmware -drive cache=writeback,file=[...] +``` + +GRUB in the image seems to use hard-coded path of `/dev/*` block file as the +root partition in the kernel command line rather than GUID, so if the hard disk +bus is changed in QEMU and the path is changed accordingly, the system can't +boot on. + +QEMU cli arguments `-machine q35` enables AHCI and SATA, and is **required for +official x86_64 image to boot**. As for i386, I haven't checked now. + +There is [a Deno script](https://github.com/crupest/crupest/blob/dev/deno/tools/manage-vm.ts) +written by me to help define and build QEMU cli arguments of VMs. + +## Inside Hurd + +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 +fsysopts /server/socket/2 -a 10.0.2.15 -g 10.0.2.2 -m 255.255.255.0 +``` + +Setup apt + +```sh +apt-get --allow-unauthenticated --allow-insecure-repositories update +apt-get --allow-unauthenticated upgrade +``` diff --git a/www/content/notes/hurd/links.md b/www/content/notes/hurd/links.md new file mode 100644 index 0000000..1e966d4 --- /dev/null +++ b/www/content/notes/hurd/links.md @@ -0,0 +1,88 @@ +--- +title: "Hurd Useful Links" +date: 2025-06-14T20:34:06+08:00 +lastmod: 2025-06-14T20:34:06+08:00 +--- + +## links + +| name | link | +| --- | --- | +| kernel-list-archive | <https://lists.gnu.org/archive/html/bug-hurd/> | +| debian-list-archive | <https://lists.debian.org/debian-hurd/> | +| irc-archive | <https://logs.guix.gnu.org/hurd/> | +| kernel-home | <https://www.gnu.org/software/hurd/index.html> | +| debian-home | <https://www.debian.org/ports/hurd/> | + +refs: + +| name | link | +| --- | --- | +| c | <https://en.cppreference.com/w/c> | +| posix latest | <https://pubs.opengroup.org/onlinepubs/9799919799/> | +| posix 2013 | <https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/> | +| posix 2008 | <https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/> | +| glibc | <https://sourceware.org/glibc/manual/2.41/html_mono/libc.html> | + +## mailing lists / irc + +| name | address | +| --- | --- | +| hurd | <bug-hurd@gnu.org> | +| debian | <debian-hurd@lists.debian.org> | +| irc | librechat #hurd | + +## *_MAX patch + +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/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/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/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/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> +{{< /link-group >}} + +{{< link-group >}} +web +cru: <https://crupest.life/git/hurd/web.git> +upstream: <https://git.savannah.gnu.org/git/hurd/web.git> +{{< /link-group >}} diff --git a/www/content/hurd/todos.md b/www/content/notes/hurd/todos.md index f8273fb..2dbded3 100644 --- a/www/content/hurd/todos.md +++ b/www/content/notes/hurd/todos.md @@ -1,7 +1,7 @@ --- title: "Hurd Todos" date: 2025-03-03T21:22:35+08:00 -lastmod: 2025-03-03T23:28:46+08:00 +lastmod: 2025-06-14T20:34:06+08:00 params: css: - todos @@ -9,7 +9,11 @@ params: ## Porting -### {{< todo name=pam state=working >}} +### hurd-fs4 {class="todo working"} + +<https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/872> + +### pam {class="todo give-up"} {{< link-group >}} git @@ -23,7 +27,7 @@ mail <https://lists.debian.org/debian-hurd/2025/02/msg00018.html> {{< /link-group >}} -### {{< todo name=abseil state=working >}} +### abseil {class="todo working"} {{< link-group >}} git @@ -38,7 +42,7 @@ mail <https://lists.debian.org/debian-hurd/2025/02/msg00035.html> {{< /link-group >}} -### {{< todo name=libgav1 state=done >}} +### libgav1 {class="todo done"} {{< link-group >}} git 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..1f5f822 100644 --- a/www/content/posts/c-func-ext.md +++ b/www/content/posts/c-func-ext.md @@ -8,16 +8,94 @@ 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. +(I've given up on this, at least for linux pam.) -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/content/todos.md b/www/content/todos.md deleted file mode 100644 index a790e24..0000000 --- a/www/content/todos.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: "Todos" -date: 2025-03-03T15:34:53+08:00 -lastmod: 2025-03-03T23:28:46+08:00 ---- - -[Hurd](/hurd/todos) diff --git a/www/layouts/partials/css-res.html b/www/layouts/_partials/css-res.html index 6fabf67..6fabf67 100644 --- a/www/layouts/partials/css-res.html +++ b/www/layouts/_partials/css-res.html diff --git a/www/layouts/partials/css.html b/www/layouts/_partials/css.html index 12d3353..12d3353 100644 --- a/www/layouts/partials/css.html +++ b/www/layouts/_partials/css.html diff --git a/www/layouts/partials/date.html b/www/layouts/_partials/date.html index 9769e4e..9769e4e 100644 --- a/www/layouts/partials/date.html +++ b/www/layouts/_partials/date.html diff --git a/www/layouts/partials/highlight.html b/www/layouts/_partials/highlight.html index 28c510e..28c510e 100644 --- a/www/layouts/partials/highlight.html +++ b/www/layouts/_partials/highlight.html diff --git a/www/layouts/partials/js.html b/www/layouts/_partials/js.html index 16dafa4..16dafa4 100644 --- a/www/layouts/partials/js.html +++ b/www/layouts/_partials/js.html diff --git a/www/layouts/partials/nav.html b/www/layouts/_partials/nav.html index 42c9ad1..42c9ad1 100644 --- a/www/layouts/partials/nav.html +++ b/www/layouts/_partials/nav.html diff --git a/www/layouts/partials/preview/article.html b/www/layouts/_partials/preview/article.html index 6245434..6245434 100644 --- a/www/layouts/partials/preview/article.html +++ b/www/layouts/_partials/preview/article.html diff --git a/www/layouts/partials/preview/post.html b/www/layouts/_partials/preview/post.html index f0c6fb5..f0c6fb5 100644 --- a/www/layouts/partials/preview/post.html +++ b/www/layouts/_partials/preview/post.html diff --git a/www/layouts/_partials/preview/posts.html b/www/layouts/_partials/preview/posts.html new file mode 100644 index 0000000..291c4b2 --- /dev/null +++ b/www/layouts/_partials/preview/posts.html @@ -0,0 +1,13 @@ +{{ $h := .h }} +{{ $is_first := true}} +{{ range .pages }} + {{ if $is_first }} + {{ $is_first = false }} + {{ else }} + <hr class="article-preview-hr"> + {{ end }} + {{ partial "preview/post.html" (dict + "h" $h + "page" .) + }} +{{ end }}
\ No newline at end of file diff --git a/www/layouts/shortcodes/link-group.html b/www/layouts/_shortcodes/link-group.html index b16c2bc..b16c2bc 100644 --- a/www/layouts/shortcodes/link-group.html +++ b/www/layouts/_shortcodes/link-group.html diff --git a/www/layouts/_default/baseof.html b/www/layouts/baseof.html index 621aea1..b9cd715 100644 --- a/www/layouts/_default/baseof.html +++ b/www/layouts/baseof.html @@ -19,9 +19,6 @@ {{ end }} </head> <body> - <div id="slogan"> - <span>🙃The world is full of pain, but we can fix it with love!</span> - </div> {{ block "pre-article" .}} {{ end }} <article id="main-article"> @@ -29,6 +26,8 @@ {{ end }} <hr/> <footer class="mono-link"> + {{ block "footer" . }} + {{ end }} <p id="license"> <small>This work is licensed under <a rel="license noopener noreferrer" diff --git a/www/layouts/index.html b/www/layouts/home.html index 7c608f1..38f7604 100644 --- a/www/layouts/index.html +++ b/www/layouts/home.html @@ -26,26 +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> + <p>Feel free to contact me via my email address <a href="mailto:crupest@crupest.life">crupest@crupest.life</a>, + or just create an issue in any of my <a rel="noopener noreferrer" href="https://github.com/crupest">GitHub</a> + repos. I love talking with people a lot.</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" }} + <li><a href="{{ .RelPermalink }}">notes</a></li> + {{ end }} + {{ with .GetPage "/notes/hurd" }} <li><a href="{{ .RelPermalink }}">hurd</a></li> {{ end }} - {{ with .GetPage "/todos" }} - <li><a href="{{ .RelPermalink }}">todos</a></li> + {{ with .GetPage "/notes/cheat-sheet" }} + <li><a href="{{ .RelPermalink }}">cheat-sheet</a></li> {{ end }} - <li><a rel="noopener noreferrer" href="https://github.com/crupest">github</a></li> - </ul> + </ul> </div> </section> - <hr> + <hr/> {{ with .GetPage "/posts" }} <section id="recent-posts"> <h2>Recent Posts <a class="mono-link" href="{{ .RelPermalink }}">(all)</a></h2> @@ -55,7 +55,7 @@ }} </section> {{ end }} - <hr> + <hr/> <section> <h2 id="friends">My Friends <small>(more links are being collected ...)</small></h2> <div id="friends-container"> @@ -75,18 +75,4 @@ {{ end }} </div> </section> - <hr> - <section> - <h2>Always Remember</h2> - <figure class="citation"> - <blockquote> - <p>Die Philosophen haben die Welt nur verschieden interpretiert, es kömmt aber darauf an, sie zu verändern.</p> - <p><small>Translated from German:</small> - The philosophers have only interpreted the world in various ways, the point is to change it.</p> - </blockquote> - <figcaption> - <cite>Karl Marx, Theses on Feuerbach (1845)</cite> - </figcaption> - </figure> - </section> {{ end }} diff --git a/www/layouts/_default/list.html b/www/layouts/list.html index c7c6cce..1d4ec56 100644 --- a/www/layouts/_default/list.html +++ b/www/layouts/list.html @@ -4,9 +4,11 @@ {{ define "content" }} {{ partial "nav.html" . }} - <h1>Posts</h1> + <h1>{{ .Title }}</h1> + <hr/> {{ partial "preview/posts.html" (dict - "h" "h3" - "pages" (.RegularPages.ByDate.Reverse.Limit 3)) + "h" "h3" + "pages" .RegularPages + ) }} {{ end }} diff --git a/www/layouts/partials/preview/posts.html b/www/layouts/partials/preview/posts.html deleted file mode 100644 index f2cb640..0000000 --- a/www/layouts/partials/preview/posts.html +++ /dev/null @@ -1,7 +0,0 @@ -{{ $h := .h }} -{{ range .pages }} - {{ partial "preview/post.html" (dict - "h" $h - "page" .) - }} -{{ end }}
\ No newline at end of file diff --git a/www/layouts/shortcodes/mono.html b/www/layouts/shortcodes/mono.html deleted file mode 100644 index ab183a5..0000000 --- a/www/layouts/shortcodes/mono.html +++ /dev/null @@ -1,3 +0,0 @@ -<div class="mono-container"> - {{ .Inner | .Page.RenderString }} -</div> diff --git a/www/layouts/shortcodes/todo.html b/www/layouts/shortcodes/todo.html deleted file mode 100644 index 1327b31..0000000 --- a/www/layouts/shortcodes/todo.html +++ /dev/null @@ -1 +0,0 @@ -<span class="todo {{ .Get "state" }}">{{ .Get "name" }}</span>
\ No newline at end of file diff --git a/www/layouts/_default/single.html b/www/layouts/single.html index cd0e9c5..33360b4 100644 --- a/www/layouts/_default/single.html +++ b/www/layouts/single.html @@ -18,6 +18,8 @@ {{ end}} </p> {{ .Content }} - <hr class="end-hr"/> - {{ partial "nav.html" . }} {{ end }} + +{{ define "footer" }} + {{ partial "nav.html" . }} +{{ end }}
\ No newline at end of file |