Posts
4782
Following
319
Followers
489
Linux kernel hacker and maintainer etc.

OpenPGP: 3AB05486C7752FE1

Jarkko Sakkinen

This is a fish function:

function cargo-registry --argument-names query
  set -l r \
    ~/.cargo/registry/src/index.crates.io-*/
  set -l c (
    ls -d $r*/ 2>/dev/null \
    | xargs -n 1 basename
  )

  if test -z "$query"
    printf '%s\n' $c \
    | sort
  else
    printf '%s\n' $c \
    | grep -i "$query" \
    | sort
  end
end

And what it does is:

❯ cargo-registry|head
ab_glyph_rasterizer-0.1.9
ab_glyph-0.2.31
accesskit_consumer-0.28.0
accesskit_macos-0.20.0
accesskit_winit-0.27.0
accesskit-0.19.0
adler2-2.0.1
adler2-2.0.1
ahash-0.8.12
ahash-0.8.12
aho-corasick-1.1.3
allocator-api2-0.2.21
allocator-api2-0.2.21
anstream-0.6.19
anstream-0.6.19
anstyle-1.0.11
anstyle-1.0.11
anstyle-parse-0.2.7
anstyle-parse-0.2.7
anstyle-query-1.1.3
# ...

And also:

❯ cargo-registry egui
egui_glow-0.32.0
egui-0.32.0
egui-wgpu-0.32.0
egui-winit-0.32.0

#fish #shell

1
0
1

Jarkko Sakkinen

Edited 1 month ago
derive_more is a gem when it comes to rust crates

makes is so much less involved
0
0
0

Jarkko Sakkinen

Edited 1 month ago
USB is interesting in the way that identifying USB devices is a non-existent feature.

E.g., a librarian for USB mass storage would have to base identifying to filesystem labels, and obviously user would have to have a process for labeling for that to actually work.

And if a malicious stick is attached, as long as it provides sane description of itself (i.e. naming a legit device, vendor, class etc.), computer can't tell the difference.
1
0
0

Jarkko Sakkinen

Edited 1 month ago

This is as done as lsiommu can ever be, or at least as far as I’m concerned so it’s a release time:

https://github.com/puavo-org/lsiommu/releases/tag/1.0.0

I.e. I spent last night making it do less from the almost nothing it was doing already ;-) That’s the point of these tools…

That enumerated to:

  • Reverted back to heap sort.
  • Carved 64 kB of data section for JSON builder.
  • Hammered STRING_BUFFER() to migrate most of the strings to stack (except JSON builder
  • Bunch of fixes…

This sums up to zero mallocs from the main application (while libudev probably does bunch of them when not compiled with make DISCOVER=sysfs).

Motivation to do was this shitty python script:

#!/usr/bin/env python3
#
# Copyright (c) 2022-2023 Jarkko Sakkinen <jarkko.sakkinen@iki.fi>

import os
import sys

IOMMU_SYSFS = '/sys/kernel/iommu_groups'
IOMMU_GROUP_MAX = 128 # an arbitrary choice

def get_iommu_devices():
    groups = [None for group in range(IOMMU_GROUP_MAX)]

    with os.scandir(IOMMU_SYSFS) as group_it:
        for group in group_it:
            devices = []

            group_sysfs = IOMMU_SYSFS + '/' + group.name + '/devices'
            with os.scandir(group_sysfs) as device_it:
                for device in device_it:
                    devices.append(device.name)

            index = int(group.name)
            if index >= IOMMU_GROUP_MAX:
                print('Overflow')
                sys.exit(1)

            groups[index] = devices

    return groups

if __name__ == "__main__":
    groups = get_iommu_devices()

    for i in range(len(groups)):
        group = groups[i]
        if group == None:
            break

        print('IOMMU Group %d' % (i))

        group.sort()

        for device in group:
            # FIXME: Replace with pure Python code:
            os.system('lspci -nns ' + device)

#linux #kernel #iommu #kvm

0
0
0

Jarkko Sakkinen

I'm happy now with mailweb for my own needs but I wrote down in detail the tasks for expanding it to TUI file managers:

https://codeberg.org/jarkko/mailweb/issues

I could easily cope with approaches if it makes sense to me. I just wrote, mainly as a reminder, steps to a working implementation done if I really had to :-)
0
0
0

Jarkko Sakkinen

i'll add text/plain support to mailweb in the next update. it's obsolete feature for mutt or aerc but for file manager such as midnight command and ranger that'll make it a generic email file opener as it shows eml/mbox files correctly (i.e. with pics not cids).

With "--browse" it just forwards the result to the mime handler.
0
0
0

Jarkko Sakkinen

i wanted to change the name of my html mail tool multidepart as it is used by some funding organization or similar:

https://www.eiturbanmobility.eu/projects/multidepart/

the new name is mailweb as it is a tool that literally does that i.e., it converts text/html mail to a static website (despite archaic) ;-)

https://crates.io/crates/mailweb

also bumped the minor to add clarity for the change.
0
0
0

Jarkko Sakkinen

Through some indeterministic process that I don't understand from time to time I have to "warn up" gpg to not fail on "git tag -s" like this:

❯ git tag -s ihatemylife
error: gpg failed to sign the data
error: unable to sign the tag
The tag message has been left in .git/TAG_EDITMSG

~/work/codeberg.org/jarkko/multidepart main ⇡
❯ gpg -s README.md

After the latter command, tag signing suddenly works.

#git #gpg #yubikey
0
0
1

Jarkko Sakkinen

i've been using 2021 edition of rust up until now because i only now realized that i need to run rustup update occasionally :-)

i was wondering for months shouldn't 2024 be out and why i'm stuck with 2021 edition lol.

rust starts to be mature enough that probably once next version is debian is out i start to use distro toolchain (if kernel requires newer my [buildroot](https://codeberg.org/jarkko/linux-tpmdd-test) shenanigans will provide me a toolchain :-) ), which is like where any native language should evolve.

this is what i do with python i.e., work in the limits of distribution packaged stuff. it makes software translate more easily and your upstream is in a way always ready for packaging.
1
1
1

Jarkko Sakkinen

great now the deps are in the reasonable level for this type of tool :-) (and meson replaced with plain make).

using cjson was not a great idea in the first place as when doing json output for small and trivial low-level tools like this instead of dumping big continuous json string is also really the best option (vs pretty printing).

maybe i soon tag a release and put this debian packaging pipeline :-)
0
0
0

Jarkko Sakkinen

Edited 1 month ago

I’m using mutt so need to ask this before updating readme.

This what I have for mutt:

macro index F10 "<pipe-message>multidepart --browse\n" "View HTML in browser"
macro pager F10 "<pipe-message>multidepart --browse\n" "View HTML in browser"

This is what I presume would be correct for aerc (in ~/.config/aerc/binds.conf):

[messages]
F10= :pipe -p multidepart --browse<Enter>
[view]
F10= :pipe -p multidepart --browse<Enter>

Does that look about right?

#aerc #mutt #email #html

1
0
1

Jarkko Sakkinen

Edited 1 month ago
Something i had forgotten from crates.io: never use "license-file" in Cargo.toml. It's broken, and crates.io leaves the license undefined.
1
0
0

Jarkko Sakkinen

This is along the lines clone of viewhtmlmail (popular among #mutt users).

https://codeberg.org/jarkko/multidepart

It's pretty much done for crates.io at least :-)

#email
1
1
0

Jarkko Sakkinen

One perhaps not so obvious observations from Rust that at least I've gathered over time is answer to this question:

- There are traits and dynamic traits.
- Which one to pick by defacto?

Dynamic traits are most of the time the best pick in my opinion, and I base it on:

1. Smaller binary size.
2. Shorter compilation times.

#rust #rustlang
1
1
3

Jarkko Sakkinen

I rewrote the USB factory program that I've been talking about now in Rust based on my C PoC and the patterns for using io_uring while using it.

Reality hit and there's need to also talk to my program for managing things like USB hubs and ports, and images used as sources for them.

I first did JSON protocol yesterday, but it really makes the ad-hoc testing heavy. It's probably great when you have a product shipped and JSON is spoken by computers to each other but for human on terminal interaction it is a nightmare.

Today I found like ultimate solution for client-side of this: Clap. You need exactly one parser for a simple command-language, and then the commands that are typed are subcommands of that parser. And Clap has rich set of features what those contains.

Stuff coming back from program is still JSON (like listing of stuff) but since it is always data (vs not code + data) I will million great ways to fixup that part :-)

Definitely a trick to my hat of tricks that I will re-use also on other languages to get quickly ad-hoc command languages setup!

#rust #rustlang #clap
1
1
0

Jarkko Sakkinen

Edited 1 month ago
There's coding conventions, commit message conventions (kernel has one, there's conventional commits etc.) but is there log message recommendations?

I'm mainly thinking in context of system daemons (not web services or internet exposing stuff).

You can e.g., say that something "failed" or alternatively you are "unable" to perform that task etc. I've worked on this small daemon for two weeks and this is the stuff where I don't know what I'm doing.

Actually, I often have hard times reviewing log messages even as a kernel maintainer. I don't really have any guidelines for klog messages that would stick on me. Maybe there should be a document for this like we have for coding conventions and patch submissions. I dunno.
1
1
2

Jarkko Sakkinen

I don't know how smart it is but sometimes when I have access to a machine with no ability to change the shell, I'll add this to the end of .bashrc:

exec fish -l

I've migrated from Zsh to Fish for that same exact reason after 4.0 came out: if you cannot install packages, you can still do cargo install.

Ubiquity is really everything in debugging and hacking for me. Sometimes it goes other way around. E.g., I understand the benefits of neovim but I stick to regular vim it's usually already there (even in macOS). And in my experience it does better in extreme conditions e.g., system-on-FPGA through serial port (probably because of lack of client-server and thus less steps) 8-)
1
0
2

Jarkko Sakkinen

Happy 40th annivesary to #Commodore #Amiga! 🎂
0
2
4

🎙️PODCAST ALERT: Linaro's expert Alex Bennée recently featured on the Way podcast where he talked about the emulator project and how it helps the open source ecosystem. Check out the podcast here 👉 https://ow.ly/zV7h50Wtc2Z

0
3
0
Show older