News for hackers. Stuff that matters.

henesy

Re:Writing UTF-8 Programs in Plan 9 on Monday February 28, 2022 @03:05PM (#30504419)
The other comments are correct that there's value in returning a value even if it was passed in to make chaining functional calls easier.

This can get a little tricky when ownership comes in to play since you don't want to end up in a situation where (not in the above program's situation, but in general) the caller might pass out a value that never gets freed and you can easily create memory leaks.

You wouldn't want to do, for example:

  print("%s\n", smprint("%s", L"世界"));
Since smprint(2)'s return value was allocated and will need to be freed, but we have no way of doing that after the value is passed.

You'd need to do:

  char *buf = smprint("%s", L"世界");
  print("%s\n", buf);
  free(buf);
Re:Writing UTF-8 Programs in Plan 9 on Monday February 28, 2022 @02:53AM (#30497442)
The first version I implemented did allocate and return the allocated output buffer, but I scrapped that design

I never changed the return value after I did this and didn’t see an issue at the time

For the record, this program was written casually on a live stream and is hardly a textbook definition of correctness :)

Re:Writing UTF-8 Programs in Plan 9 on Sunday February 27, 2022 @10:38PM (#30496104)
Author here.

While the other comments are correct, the exact reason for this use of providing in/out is that the reversal is called on a subset of the incoming array.

  line = Brdstr(in, '\n', 1);
will give us a null-terminated string, but we don't want to flip the null and truncate the string, so to lazily avoid that we do:

  rlen = runestrlen(rstr);
  rev = calloc(rlen+1, sizeof (Rune));
  reverse(rstr, rev, rlen);
so we get the number of runes in the input, add 1 for the \0, then reverse the pre-\0 characters.

We could have the reverse() function allocate n+1 elements for the string and return an always null-delimited string, but then we need to pass it a string that doesn't have a \0, or make it assume that it will always get a \0 and treat that some way.

Passing in both items and the number to iterate felt less noisy for a quick solution :)

Re:Git/serve: A Git server for Plan 9 on Wednesday September 09, 2020 @06:34PM (#24426680)
Love this
Yes, /bin is a directory where the bind[1] command can be used to multiplex/union other directories on top. The / directory in general is built this way as a virtual top directory, with the disk root being stored on /root and being bound over /.

Platform-specific files are stored in /$architecture and binaries in /$architecture/bin. Shell scripts are stored in /rc/bin. For the home directory, traditionally, this style is reversed so your shell scripts would be in $home/bin/rc.

The namespace for any process can be enumerated, so in my default shell, I can see which directories are currently bound (and how) on /bin:

  tenshi% ns | grep 'bind' | grep '/bin' 
  bind  /amd64/bin /bin 
  bind -a /rc/bin /bin 
  bind -b /usr/seh/bin/rc /bin 
  bind -b /usr/seh/bin/amd64 /bin 
  bind -a /sys/go/bin /bin 
  bind -a /usr/seh/go/bin /bin 
  tenshi% 
[1] http://man.cat-v.org/9front/1/bind
Re:How Containers Work: Overlayfs on Monday November 18, 2019 @10:40PM (#21570471)
s/o to unionfs for plan9 by kvik: http://code.a-b.xyz/unionfs

Userspace implementation of union directories with control of which half of the union made gets precedence for certain operations such as file creation, etc.

Re:The Language Agnostic, All-Purpose, Incredible, Makefile on Monday November 18, 2019 @10:34PM (#21570445)
I generally prefer mk to make, I just find the way multiple mkfiles compose and some of the syntax changes pleasant.

A small change, but being able to just do $foo instead of $(foo) is so nice.

Re:Inferno Operating System on Sunday July 21, 2019 @03:31AM (#20490353)
It's a really early draft, but here's the base for an awesome-inferno repository: https://github.com/henesy/awesome-inferno
Re:Inferno Operating System on Sunday July 21, 2019 @01:25AM (#20490093)
Inferno instances are really meant to be compartments for individual programs more than a desktop OS in and of itself.

Dis VM instances are super light… you wouldn't really be needing to worry much about running a large number of them.

Point aside in many cases you can sandbox applications in crafted namespaces using spawn and flags like NODEVS.

Re:Inferno Operating System on Saturday July 20, 2019 @09:18PM (#20489355)
Yeah zones especially, I agree.
Re:Inferno Operating System on Saturday July 20, 2019 @08:14PM (#20489131)
This exists and to a pleasant effect!

http://doc.cat-v.org/inferno/4th_edition/styx-on-a-brick/

The ev3dev project is partially inspired by everything is a file and I've used it in the past for educational purposes by making the business of controlling/using motors/sensors as trivial as read/write.

https://www.ev3dev.org/

Re:Inferno Operating System on Saturday July 20, 2019 @07:35PM (#20488965)
Linux containers feel like a very weak imitation of what they could be under an environment like Plan9 imo.

Linux lacks a lot of core abstraction properties that would make containers elegant to implement under something like the Plan9 model, at least.

Cool project inspired partially by Linux containers: https://doc.9gridchan.org/guides/spawngrid

Re:Inferno Operating System on Saturday July 20, 2019 @07:32PM (#20488953)
As long as your processor supports vmx ofc

Just ask aux/icanhasvmx :)

Manuals:

- http://man.cat-v.org/9front/1/vmx

- http://man.cat-v.org/9front/3/vmx

Re:Inferno Operating System on Saturday July 20, 2019 @07:30PM (#20488949)
s/o to the wip 9front ports tree, too: http://code.9front.org/hg/ports
Re:Inferno Operating System on Saturday July 20, 2019 @07:26PM (#20488935)
The concept here is fairly profound and you could make the analogy of power to something like Lisp.

Lisp everything is a symbol, in Plan9 everything is a file and all namespaces are mutable. This concept is combined in the Interim OS experiment[1]. The idea of everything is a file is very literal and very serious compared to say, unix.

It's worth noting that 9p, while a filesystem protocol, is closer in concept to a REST api than something like say ext4.

In Plan9, the kernel could be thought of as a 9p connection router/multiplexer and all system resources and all servers must express themselves as 9p filesystems. The tooling 9p provides allows you to take trees of named objects (filesystems) and rearrange them however you please and place child processes under rules for modifying their own trees and how they can break scope, if at all.

Forking is more dynamic as provided by rfork[2] where you can give a child a specific subset of your process's namespace. So you could make a child who can only see specific files, executables, or resources and make it so that the child can't mount, unmount, etc.

[1] Interim OS: https://github.com/mntmn/interim

[2] http://man.cat-v.org/9front/2/fork

Some cool manuals:

- http://man.cat-v.org/9front/1/bind

- http://man.cat-v.org/9front/1/ns

- http://man.cat-v.org/9front/3/proc

- http://man.cat-v.org/9front/5/intro

Re:Inferno Operating System on Saturday July 20, 2019 @07:02PM (#20488870)
Yeah idk why people have this notion.

Last 9front commit was… 3 days ago: http://code.9front.org/hg/plan9front/

Re:Inferno Operating System on Saturday July 20, 2019 @07:01PM (#20488865)
Source: http://code.9front.org/hg/purgatorio/

Purgatorio 64-bit is a ways away, but is a goal.

It'll happen eventually, but the more eyes the better.

Re:Inferno Operating System on Saturday July 20, 2019 @06:58PM (#20488855)
Yeah Richard Miller just put out tentative support for the Raspberry Pi 4 for his pi port.

https://9p.io/sources/contrib/miller/9/bcm/

Re:Inferno Operating System on Saturday July 20, 2019 @06:52PM (#20488831)
Nice to see Inferno posted!

Some Inferno related stuff:

- Limbo by Example: https://github.com/henesy/limbobyexample

- The Inferno Shell: http://debu.gs/entries/inferno-part-1-shell

- Try Inferno in the browser: http://tryinferno.rekka.io/

- Cat-v Inferno resources: http://doc.cat-v.org/inferno

- Experiments in Inferno/Limbo: https://github.com/caerwynj/inferno-lab/

- Inferno Programming with Limbo: https://web.archive.org/web/20160304092801/http://www.gemuse... (also on cat-v)

- Developing Limbo modules in C: https://powerman.name/doc/Inferno/c_module_en

- Simple FS example in Limbo: https://github.com/henesy/simplefs-limbo

- Inferno client for Redis: https://github.com/pete/iredis

- Inferno for Nintendo DS: https://bitbucket.org/mjl/inferno-ds/src/default/

- Inferno as an Android app: https://github.com/bhgv/Inferno-OS_Android

- Inferno replacing Android (hellaphone): https://bitbucket.org/floren/inferno/wiki/Home

- Porting Inferno to Raspberry Pi: https://github.com/yshurik/inferno-rpi

Re:A Raspberry Pi Grimoire For The Command Line Wizard on Tuesday February 26, 2019 @10:43AM (#19255173)
Make one a Plan 9/9front terminal :)
Re:A Plan 9 C compiler for RISC-V [pdf] on Friday October 26, 2018 @09:46PM (#18313931)
Great to see RISC-V news make it public. Always glad to find more Plan 9 hobby projects to learn from :)
Re:Fuchsia is not Linux on Thursday April 12, 2018 @05:53PM (#16825231)
Plan 9?
Re:Nobody's just reading your code on Tuesday February 27, 2018 @03:51AM (#16472027)
A fun tidbit from the Plan 9 compilers only really able to be found by reading the source: https://groups.google.com/forum/#!msg/comp.os.plan9/uMF7A4gk...
Re:Nobody's just reading your code on Tuesday February 27, 2018 @03:47AM (#16472004)
One of the best parts of the Plan 9 system is that all of the kernel/command/library source is on hand and readily available to consult at any given time.

Jointly, an important detail is that the complexity of said source is kept to a sane minimum and general style trends mean that most, if not all, of the source is formatted similarly and legibly. The system is so compact that you can keep most of the system source in your head at one time if you really need to.

Re:Nobody's just reading your code on Tuesday February 27, 2018 @03:44AM (#16471988)
Being able to browse the Go source so easily and clearly is a fantastic way to both learn and grow in understanding of the language. It's definitely helped me as I've learned and written in Go over the years.
Re:Ask HN: What has HN given you? on Tuesday February 20, 2018 @01:57AM (#16418337)
This is the real answer.

Older »