Re: [PATCH 0/1] Rewrite /hurd/symlink on top of trivfs OFF TOPIC PRAISE

2021-07-28 Thread Sergey Bugaev
On Wed, Jul 28, 2021 at 10:39 PM  wrote:
> Thanks for working on this!

I don't believe it: I finally got my own "OFF TOPIC PRAISE" letter!
Thank you for your kind words :)

> I'm wanting to learn more about trivfs for my caesar
> cipher eventually, but looking that how to write trivial translators makes
> me a little curious...I'll learn more about it someday.  :)
>
> It would be cool to have a gemini translator.  It would only take a few 100
> lines of code.

Oh yes, a Gemini translator actually sounds like a perfect exercise!
It's not as simple as /hurd/hello or /dev/yes, but still simple
enough, and would be actually useful for the end users.

Why don't you start working on it? If you run into any trouble (or are
unsure where to start from), feel free to ask me! — I'd be glad to
help you, in so much as I understand things myself (which may not be
that much, actually). Perhaps others on this list would be interested
in helping you too.

One particular thing that may turn out to be complicated: TLS, which
is mandatory in Gemini. I admit I don't have any experience
interacting with TLS from C myself, and I hear that things are indeed
complicated there [0]. So what I would do is ignore the TLS
requirement for now and implement just cleartext Gemini, even though
it's against the spec; then once things are working figure out TLS.

[0]: 
https://blogs.gnome.org/mcatanzaro/2018/11/11/the-gnome-and-webkitgtk-networking-stack/

Sergey



Re: [PATCH 0/1] Rewrite /hurd/symlink on top of trivfs OFF TOPIC PRAISE

2021-07-28 Thread jbranso
June 21, 2021 9:22 AM, "Sergey Bugaev"  wrote:

> Hello,
> 
> I came by this issue [0], which basically states that /hurd/symlink was
> behaving in a weird way. Namely, when opened with O_NOLINK, it would
> appear to be an empty file, not a symlink. The report talks about broken
> symlinks, but the issue is more fundamental:

Thanks for working on this!  I'm wanting to learn more about trivfs for my 
caesar
cipher eventually, but looking that how to write trivial translators makes
me a little curious...I'll learn more about it someday.  :)

It would be cool to have a gemini translator.  It would only take a few 100 
lines of code.

> 
> $ settrans -ac /tmp/demo /hurd/symlink /etc/hostname
> $ cat /tmp/demo
> sergey-hurd-box
> $ file /tmp/demo
> /tmp/demo: empty
> $ ls -l /tmp/demo
> -rw-r--r-- 1 sergey sergey 0 Jun 21 15:52 /tmp/demo
> $ fsysopts /tmp/demo
> ext2fs --writable --relatime --no-inherit-dir-group --store-type=typed 
> device:hd0s1
> 
> [0]: https://www.gnu.org/software/hurd/open_issues/symlink_translator.html
> 
> I took a look at trans/symlink.c, and found out that:
> 
> * It was not using libtrivs, as I would expect it to.
> 
> * It was treating O_NOLINK like O_NOTRANS; namely by returning the underlying
> node. This is the cause of the issue: O_NOLINK has very different semantics.
> It should open the link itself, and then suppport io_stat () and io_read ()
> on it, returning S_IFLNK | 0777 for the mode, and the link target as
> contents.
> 
> * It was leaking ports (should deallocate dotdot when not MOVE_SEND'ing it),
> and skipping some error checks.
> 
> So I thought I'd try rewriting /hurd/symlink to use trivfs. This is possible
> because trivfs has this convenient trivfs_getroot_hook mechanism, which lets 
> me
> either handle fsys_getroot () any way I want to, or continue with the default
> implementation found in trivfs (for O_NOLINK).
> 
> End result: it seems to work great. Absolute, relative; file, ls, ls -l, stat,
> readlink, cat; everything just does what I'd expect it to. Even fsysopts now
> shows the invocation properly. Some demos:
> 
> $ settrans -ac /tmp/demo trans/symlink /etc/hostname
> $ cat /etc/hostname
> sergey-hurd-box
> $ cat /tmp/demo
> sergey-hurd-box
> $ file /tmp/demo
> /tmp/demo: symbolic link to /etc/hostname
> $ ls -l /tmp/demo
> lrwxrwxrwx 1 sergey sergey 13 Jun 21 16:11 /tmp/demo -> /etc/hostname
> $ fsysopts /tmp/demo
> trans/symlink /etc/hostname
> 
> $ settrans -ac /tmp/demo trans/symlink no-such-file
> $ cat /tmp/demo
> cat: /tmp/demo: No such file or directory
> $ file /tmp/demo
> /tmp/demo: broken symbolic link to no-such-file
> $ ls -l /tmp/demo
> lrwxrwxrwx 1 sergey sergey 12 Jun 21 16:11 /tmp/demo -> no-such-file
> 
> Sergey Bugaev (1):
> trans/symlink.c: Rewrite on top of trivfs
> 
> trans/Makefile | 10 +-
> trans/symlink.c | 243 +++-
> 2 files changed, 137 insertions(+), 116 deletions(-)
> 
> -- 
> 2.31.1