IRC channel logs

2025-10-20.log

back to list of logs

<stikonas>Guest91|2: don't we need to make sure rdx = 0 before the first call
<stikonas>when we call open to set "mode
<stikonas>to set "mode" to 0
<stikonas>it's probably less important for reads
<stikonas>but probably better to do so
<Guest91|2>"man open" says mode is ignored for O_RDONLY, but it doesn't hurt zeroing it there--but the comment should make it clear that it's more important for the 2nd open call
<Guest91|2>or maybe just move it down--hex1 doesn't zero it for the first call
<Guest91|2>speaking of hex1, I was working on that one. It seems very hard to understand right now, or is that just me? How do you feel about all the global state accessed and read syscalls issued from everywhere?
<Guest91|2>easiest fix to make it much more maintainable and auditable would be to make pass1 and pass2 exactly the same and adding another lseek for the outfile
<stikonas>well, feel free to try to improve it and create a PR :)
<stikonas>especially if it's less code in hex1, that will be good
<stikonas>also hex0 has been significanty rewritten a year or so ago
<stikonas>it went down in size a lot then
<stikonas>whereas hex1 was untouched and used similar code that hex0 had
<Guest91|2>did you do the rewrite?
<stikonas>depends on the definition
<stikonas>somebody did the rewrite of x86 version
<stikonas>I think I then ported it to amd64
<stikonas>and also to stage0-uefi
<stikonas>but original rewrite idea was not mine
<stikonas> https://github.com/oriansj/bootstrap-seeds/pull/44
<stikonas>that was shrinking it from 256 to 190 bytes
<stikonas>I think later I managed to shrink it to 181 byte on x86
<stikonas>worth looking at that pr is you compare hex0 and hex1
<Guest91|2>thanks for the link
<Guest91|2>Why are strcmp and printf avoided in mescc-tools-extra in favor of match and puts?
<Googulator>Probably so it's easier to build with a minimal libc
<Googulator>I guess M2libc had no printf when they were written
<matrix_bridge><Andrius Štikonas> yes, printf is very recent, from this year
<matrix_bridge><Andrius Štikonas> before that M2-Planet couldn't support it as it had no support for varargs at all
<matrix_bridge><Andrius Štikonas> strcmp could be used in mescc-tools-extra
<Guest91|2>Should printf still be avoided?
<matrix_bridge><Andrius Štikonas> they are fine mescc-tools-extra I guess
<matrix_bridge><Andrius Štikonas> but not in M2-Planet M1 or hex2 I think
<matrix_bridge><Andrius Štikonas> need to double check about hex2, perhaps hex2 is fine
<matrix_bridge><Andrius Štikonas> but at least one of M1 / hex2 needs to be buildable with a simplified bootstrap M2libc
<matrix_bridge><Andrius Štikonas> so no advanced features
<Guest91|2>Why does match exist?
<Guest91|2>the function, not the program
<matrix_bridge><Andrius Štikonas> I think it even predates M2libc
<stikonas>probably oriansj wrote something simple to compare strings
<Guest91|2>Wait, is it more than a strcmp equivalent? I've just encountered it as a strcmp replacement
<stikonas>it is equivalent
<stikonas>before we had strcmp
<stikonas>we are not trying to replace strcmp
<stikonas>also see https://github.com/oriansj/M2libc/issues/74
<stikonas>and discussion in the ticket
<Guest91|2>Thanks
<Guest91|2>Is it expected that there is a segfault when you fgetc from a file >= 1G?
<Googulator87>I guess M2libc had no printf when they were written
<Googulator87>oops...
<Googulator87>meant to change my nick
<fossy>Guest91|2: to be honest, I would guess no one has tried that
<fossy>FILE* is handled very oddly in the M2-* ecosystem though
<fossy>so wouldnt be surprised if theres weird things going on with it
<Guest91|2>Is fossy fosslinux on github?
<fossy>yep!
<fossy>:wave:
<Guest91|2>Hi
<Guest91|2>Could you explain this comment: https://github.com/oriansj/mescc-tools-extra/blob/master/cp.c#L110
<Guest91|2>I don't understand what M2-Planet has to do with the return value of a syscall
<Guest91|2>(I think the chdir trick can be replaced by just trying to write to maybe_dir/basename first; nevertheless I'd like to understand what's going on there)
<fossy>tbh, I'm pretty unsure what I meant too
<fossy>it does seem wholly irrelevant doesn't it
<Googulator>and AFAIK it doesn't even work with builder-hex0, which doesn't distinguish between files and directories
<Googulator>directories just have a 0-byte body by default
<Guest91|2>would the heuristic I just described work?
<Googulator>probably not - regular files with a real content body having child files is allowed on builder-hex0
<Googulator>and probably also by some real-world file systems (NTFS comes to mind)
<Googulator>in live-bootstrap, make_fiwix_initrd just assumes that every 0-byte file is meant to be a directory
<Guest91|2>So no way at all to distinguish between a file and a directory?
<Guest91|2>Do you mean alternate data streams in NTFS?
<Guest91|2>Why is there support for CR as an alternative newline character in hex1?
<Guest91|2>Googulator74: I couldn't verify that there are filesystems behaving this way. NTFS has alternate data streams, but they are referenced as filename:streamname, not filename/streamname
<Guest91|2>Googulator50: Is there any way at all to detect if something is a file or a directory on builder-hex0?
<matrix_bridge><Andrius Štikonas> Guest91|2: where exactly is alternative newline implemented?
<Guest91|2> https://github.com/oriansj/stage0-posix-amd64/blob/master/hex1_AMD64.hex0#L231
<matrix_bridge><gtker> stikonas: Currently all the arches have their own "bootstrap.c" file https://github.com/oriansj/M2libc/blob/main/armv7l/linux/bootstrap.c, would you be against moving all the non-assembly functions out into a shared file? It would be breaking, but keeping 6+ implementations in sync is also annoying
<matrix_bridge><gtker> Guest91: I remember seeing an implementation for a PE file header somewhere, so possibly somebody wanted to add Windows support at some point
<matrix_bridge><Andrius Štikonas> gtker: Fine with me but would be good to confirm with oriansj...
<matrix_bridge><Andrius Štikonas> As for newline, it's not that hard to ignore CR, so perhaps it was just done anyway...
<matrix_bridge><Andrius Štikonas> There are some not strictly required features in hex files
<matrix_bridge><Andrius Štikonas> E.g. both lowercase and uppercase hex numbers are supported
<matrix_bridge><Andrius Štikonas> There are 2 types of comments