Commit Graph

6606 Commits (master)

Author SHA1 Message Date
Ori Bernstein 7f697e822b lex: fix uninitialized fds (thanks きゐ) 2021-06-16 00:28:01 +00:00
Anthony Martin 1210b12f28 troff: fix mangled fonts and character files
All of these files appear to have been imported from sources in a
case-insensitive manner and consequently lost their original content.

- Hx, Hb, and Hi fonts should be narrow versions of Helvetica

- c[1-3] fonts should be condensed versions of Century Old Style

- the lH character should be a filled left hand symbol

- the rh character should be a stroked right hand symbol

- the rc character should be the right ceiling symbol

I've verified that these are the only files that collide with others
when ignoring case (aside from rc/bin/[Kk]ill but those are correct).
2021-06-15 16:13:59 +00:00
Ori Bernstein 7c3ff53574 git/import: handle mails with line wrapping and mime
git/import expected a patch, however upas/fs serves
either a raw file without any of the mime decoding
and line joining, or a directory, with the headers
and body split out.

This makes it a pain to apply some mails.

So, here we teach git to import upas dirs natively,
making it easy to handle all patches that come in
as emails.
2021-06-15 21:29:22 +00:00
Ori Bernstein a73a964e51 python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
2021-06-14 00:00:37 +00:00
Ori Bernstein 8ab397c23c git/push, git/send: get better about erroring out early
git/push died within a subshell, which prevented the
whole program from exiting, and lead to an incorrect
ref update line that confused people.

git/send would eventually error out, but would push
all the data before that happened; this was annoying.
2021-06-13 12:48:49 +00:00
Ori Bernstein 4aef95e205 git/branch: preserve checked in permissions on branch update
we need to copy the files, and we should copy them with the
permissions that exist in the repo.
2021-06-13 01:20:46 +00:00
Fulton Browne 1c30bd451e B, sam: remove sam srv file
No need for 2 programs doing the same job.
2021-06-12 17:20:53 +00:00
Ori Bernstein 73db7a20f7 git/add: clear qid cache as side effect
this is an occasionally useful side effect when
doing surgery on repos, so let's have it.
2021-06-12 14:57:58 +00:00
Ori Bernstein aacf368c6d mothra: read the content-type header over file(1) to determine type (thanks james palmer)
this fixes some pages being classified as xml by file(1),
meaning they would be rendered as plain text rather than as html.
2021-06-12 14:32:16 +00:00
kemal 09b0eb0d1a git/conf: check in /sys/lib/git/config as a fallback to user-wide config 2021-06-08 20:13:57 +00:00
kvik a859d53145 git/revert: fork the namespace before running git/fs 2021-06-08 20:20:06 +00:00
Ori Bernstein 8aa69e55b6 git: avoid uninterruptible temporary warning
dont' fall into the rathole.
2021-06-06 23:50:45 +00:00
Ori Bernstein 8d578014cf rio: match background screen color format (thanks noam) 2021-06-06 22:44:36 +00:00
Ori Bernstein d1d5f21992 distproto: sync with hg 2021-06-06 13:21:53 -04:00
Ori Bernstein ce30e785b1 git/branch: diff clean and dirty lists correctly
no spaces in our lists.
2021-06-06 13:07:51 -04:00
Ori Bernstein fb15534c78 git/branch: revert optimization fully
it doesn't help *that* much, and confuses the code.
2021-06-06 13:07:51 -04:00
Ori Bernstein 78d2064a7c git/branch: somewhere in the syncing, the fix for junk files was lost
bring it back.
2021-06-06 13:07:51 -04:00
Ori Bernstein a2a0717c99 git/send: allow the remote to have refs that we don't
It's not fatal for someone else to push a branch
with objects that we don't have. We should deal
with it gracefully, and act as though it doesn't
exist.
2021-06-06 13:07:51 -04:00
Ori Bernstein 74912993de git/commit: allow passing absolute paths
we would treat paths as relative, and not
step past leading '/'s, leading to an infinte
loop.
2021-06-06 13:07:51 -04:00
glenda 706aad3d94 git/branch: merge correct set of files
we were switching branches before we got the full list
of modified files, which could garble what we were trying
to merge.
2021-06-05 18:50:20 +00:00
Ori Bernstein fd9679d97b git: handle absolute paths better
we were catting $gitrel onto absolute paths. stop it.
2021-06-05 13:40:28 +00:00
Alex Musolino 347b552b18 merge 2021-06-05 01:42:10 +09:30
Alex Musolino 3568348260 upas/Mail: fix bug where Redraw must be executed twice to have an effect
In showlist, call bwindata instead of bwinopen in order to use a
pre-existing fd to write to the data file.  This existing fd will
properly honour any address set by a previous write to the addr file.
Specifically, the redraw function sets addr to "," before calling
showlist in order to overwrite the entire contents of the window.
2021-06-05 01:21:55 +09:30
cinap_lenrek 5a34cc86a8 git: allow local repository directories as remote uri's
This is implemented by checking first if the uri is
a directory containing the .git/ subdirectory.
If this is the case, we fork git/serve serving the
repository on a pipe.
2021-06-04 17:47:26 +02:00
cinap_lenrek 4dd461e440 git/serve: remove undocumented -n namespace option and -r /usr/git default
This makes it easier to serve local repositories where the sandboxing
gets in the way.
2021-06-04 17:44:29 +02:00
Ori Bernstein db5ca0017c git/log: show first commit as file change
We checked if the file was changed from its parents.
If there were no parents, the answer was no, but it
should be yes.
2021-06-03 16:15:16 -07:00
Ori Bernstein b42111117b git/init: create fs dir 2021-05-31 19:30:07 -07:00
Ori Bernstein 1160919f81 git/send: pick minimal delta set correctly (thanks igor)
We weren't giving all objects to the twixt() function, and
it was making bad life choices -- gambling, smoking, drinking,
and packing in too much data.

With more information, it doesn't do the last.
2021-05-31 18:02:23 -07:00
Ori Bernstein c297482269 sdvirtio: accept multi-queue devices
Sdvirtio supports multiple queues per device.
We only use one queue, but we shouldn't skip the
devices because of that.
2021-05-31 10:59:45 -07:00
Ori Bernstein f0bb6bbcb7 git/branch: ...all the debug prints. 2021-05-30 19:21:57 -07:00
Ori Bernstein 519ff30098 git/branch: remove debug prints 2021-05-30 19:07:11 -07:00
Ori Bernstein 31fc689ad9 git/branch: reduce execs to sync working dir
We were execing a lot to copy the data -- do less of it.
2021-05-30 19:06:01 -07:00
Ori Bernstein 12e952e684 git/fs: move mount point to $repo/.git/fs
Moving the mount point to within the repo
directory means that we can have multiple
git repos mounted at once with no conflict.
2021-05-30 17:46:21 -07:00
cinap_lenrek 1af2546e96 vac: add -t flag to exclude temporary files and directories (thanks foura) 2021-05-30 14:30:50 +02:00
cinap_lenrek a624902621 merge 2021-05-29 14:20:04 +02:00
cinap_lenrek c2297ce5c1 kernel: use 64-bit virtual entry point for expanded header, document behaviour in a.out(6)
For 64-bit architectures, the a.out header has the HDR_MAGIC flag set
in the magic and is expanded by 8 bytes containing the 64-bit virtual
address of the programs entry point. While Exec.entry contains physical
address for kernel images.

Our sysexec() would always use Exec.entry, even for 64-bit a.out binaries,
which worked because PADDR(entry) == entry for userspace pointers.

This change fixes it, having the kernel use the 64-bit entry point
and document the behaviour in the manpage.
2021-05-29 14:18:35 +02:00
Sigrid 8ac28a3e21 zuke: treat toggle as play in stopped state 2021-05-28 13:02:58 +02:00
Sigrid e18da032f0 zuke: fix seeking in paused mode 2021-05-27 07:47:10 +02:00
cinap_lenrek d168b89ab1 mkpaqfs(8): allow setting compression level 2021-05-23 17:06:14 +02:00
Ori Bernstein 1ee1bfaa8c git: got git?
Add a snapshot of git9 to 9front.
2021-05-16 18:49:45 -07:00
foura e72da62915 ip/ftpd: Add explict and implicit FTPS support.
Removed:
- Challenge reponse auth.
- Noworld login.
- Anonymous users writing files to /incoming.
2021-05-02 15:29:43 +01:00
james palmer 9633c9fc65 libpanel: fix text sliding around in libpanel text entry widgets. 2021-05-13 21:29:19 +01:00
cinap_lenrek 15b903c4e1 pc64: avoid getcr3() in mmuflushtlb()
it turns out that calculating physical address of pml4 is faster
than reading the machine register, so pass it explicitely.
2021-05-12 22:40:51 +02:00
cinap_lenrek 18b3847aef devvmx: remove unncessary locking in gotcmd() sleep test function 2021-05-12 22:24:36 +02:00
cinap_lenrek 682414ce0d vmx: fix 9p debug server and make it compatible to /proc
The 9p debug server was broken as it assumed the first
tree file added would have a qid of 0 (it has a qid
of 1 as the root directory is using 0 already).

Instead, just compare File* pointers and get rid of
the table (less code).

When passing 64-bit unsigned addresses as 64-bit signed
file offsets, we have to make sure to not pass negative
offsets (filtered out by kernel and lib9p)!
This is solved by clearing and sign bit in encoding and
63-bit sign extension on decoding.

Make the mem file writable (needed for acid).

The 9p debug server provided a single directory containing
mem and regs files. This patch renames the regs file
(which is in vmx specific text format) to "xregs" and
adds "regs" and "kregs" file which use the same format
as exported by the kernels /proc filesystem.

This allows one to bind the vmx directory over a proc
directory and attach acid to a running system like:

mount -b /srv/vmx /proc/1
acid -k -lkernel 1 /sys/src/9/pc64/9pc64
2021-05-12 18:17:06 +02:00
cinap_lenrek 532c7479e9 vmx: avoid strdup() register names for register cache
If we tokenize the register file contents in a static buffer,
we can avoid having to duplicate the register names.

All callers to rpoke() provide constant register arguments
so they also do not need to be duplicated.
2021-05-12 18:04:25 +02:00
cinap_lenrek 67eac97a81 vmx: implement long mode page table translation
This allows vmx to translate virtual addresses to physical
when the gues runs in long mode.
2021-05-12 18:00:46 +02:00
qwx 7048f1ca11 games/opl3: use correct sampling rate
games/dmid uses the same sample rate as the chip for music, but other
applications do not.  opl3 and its older version opl2 (not in 9front)
read an input stream of commands in basically IMF format, something
used in other id Software games and some others, which assumes a
given input sampling rate:  700 Hz for Wolfenstein 3D music, 560 Hz
for Commander Keen, 60 Hz for Ultima 6, etc.

The opl3 emulation on the other hand is not really intended to run at
a sampling rate different that the chip's 49.716 kHz sampling rate.
Previously, we assumed it runs at 44.1 kHz and just used the input
rate as a divisor to get the number of samples per delay tic.

From what I understand, the correct way to use it for accurate
emulation is to run the opl chip emulator at its intended sampling
frequency, then downsample to 44.1 kHz.  This means better output
but more code.  The alternative is to basically do the same as
before rev 8433, except with no buffering, but at accuracy/quality
loss.  This change implements the former and just forks pcmconv to
deal with resampling.
2021-05-05 16:57:19 +02:00
cinap_lenrek ebaddcf030 merge 2021-05-05 01:51:20 +02:00
cinap_lenrek 7c1e0be919 cpu: properly handle end of file in readstr() 2021-05-05 01:50:09 +02:00
Sigrid 5e81cc48bd libtags: upstream updates 2021-05-03 21:04:39 +02:00
Ori Bernstein b66bffe91c Mail: remove message about cyclic threads
They happen, and we break the cycle. There's nothing
the user can do, so there's no point in warning.
2021-05-01 15:33:31 -04:00
cinap_lenrek ee289c2415 lib9p: remove Srv.srvfd, make postsrv() and threadpostsrv() return the mountable file descriptor, update documentation
Now that we have these new functions,
we can also make them return an error
instead of calling sysfatal() like
postmountsrv().

Remove the confusing Srv.srvfd, as it
is only temporarily used and return
it from postsrv() instead.
2021-05-01 19:58:58 +02:00
cinap_lenrek 57c21ae441 lib9p: remove unneccesary headers 2021-05-01 17:03:03 +02:00
cinap_lenrek f6509078ed lib9p: expose Srv.forker handler and srvforker(), threadsrvforker() and threadsrv() functions
To use srvrease()/srvaquire() we need to have a way to spawn
new processes to handle the service loop. This functionality
was provided by the internal _forker() function which was
eigther rfork or libthread based implementation depending on
if postmountsrv() or threadpostmountsrv() where called.

For servers who want to use srv() directly, _forker would not
be initialized so srvrelease() could not be used.

To untangle this, we get rid of the global _forker handler
and put the handler in the Srv structure. Which will get
initialized (when nil) to eigther srvforker() or threadsrvforker()
depending on if the thread or non-thread entry points where used.

For symmetry, we provde new threadsrv() and threadpostsrv()
functions which handle the default initialization of Srv.forker.

This also allows a user to provide his own forker function,
maybe to conserve stack space.

To avoid dead code, we put each of these function in their
own object file. Note, this also allows a user to define its
own srvforker() symbol.
2021-05-01 16:37:00 +02:00
Sigrid 013b498314 libtags: use nelem 2021-04-30 12:36:01 +02:00
Sigrid dd86214d77 libtags: trim text tags and ignore empty values 2021-04-30 00:20:39 +02:00
Sigrid e5535fad32 libtags: modules: ignore empty title 2021-04-29 23:35:52 +02:00
Sigrid 7cff84371d libtags: use CP437 as the default encoding for module formats 2021-04-29 21:44:06 +02:00
qwx af2f7ea236 games/opl3: don't buffer output and simplify (thanks umbraticus)
this fixes real-time applications.

-n previously specified a rate divisor rather than the rate itself,
which was used for specific applications outside of 9front.  instead,
just set the rate directly, more useful and straightforward.
2021-04-27 09:48:14 +02:00
Sigrid 51ead1072b file: partially revert 8419 to detect <?xml as html 2021-04-25 21:49:01 +02:00
cinap_lenrek c0d4498ab8 kernel: clean up Mach structure
Remove unused fields and factor common fields into a
new PMach struct in port/portdat.h.

The fields machno, splpc and proc are not moved to
PMach as they are part of the known offsets from
assembly (l.s).
2021-04-25 17:41:34 +02:00
cinap_lenrek 9f54c28317 bcm: try ATAGS/DTB pointer from R2 on entry 2021-04-25 17:36:11 +02:00
cinap_lenrek 6b4b8e405a rio: avoid re-triggering clicks on resize/hide/unhide and send wctl when focus is lost 2021-04-25 12:41:20 +02:00
cinap_lenrek e0cf0261d0 resample: improve performance (thanks José Miguel Sánchez García)
Resample is well known for taking a long time to resize an image. This
patch brings an important performance boost (in my test image, time
was reduced from ~2850ms to ~500ms). It does that by extracting FP
multiplication and division out of the innermost loop of
resamplex/resampley.

The results differ slightly from the current implementation: in my
test: ~0.3% of the bytes had a ±2 difference in their value, which I
attribute to rounding errors. I'm personally not concerned with that
deviation, given the performance gains. However, I recommend testing
it just to be sure I didn't overlook anything.

José Miguel Sánchez García
2021-04-25 12:16:40 +02:00
Sigrid b0e2ea4e5f libtags, zuke: add *.mod support (thanks kemal) 2021-04-24 16:07:24 +02:00
Sigrid 83277da309 zuke: fix middle-click restarting playback if held while mouse pointer is moving 2021-04-23 11:20:30 +02:00
Sigrid 1919e9183b zuke: fix position formatter using a wrong type 2021-04-22 08:40:50 +02:00
Humm b2ef0ff49d plumber: fix substrings in match rules
Unmatched substrings are nil, so we can't rely on nil terminating the
array of substrings.
2021-04-21 08:28:32 +02:00
Sigrid 192c1fd73a nusbrc: rndis with csp 0104ef 2021-04-20 18:12:54 +02:00
Sigrid f5db3bf0e0 nusb/ether: rndis: add standard class code (tested by jmi2k with OnePlus 8) 2021-04-20 18:08:58 +02:00
kemal 2cdc8075f8 file: recognize executable scripts, etc.
The patch does the following:

1. Adds recognition of executable script (shebang) files.
2. Returns correct MIME type for mbox files (RFC 4155).
3. Returns XML instead of HTML type in some cases.
2021-04-20 01:40:31 +02:00
cinap_lenrek 52a367f3ea devloopback: fix wrong device character (thanks romano)
devloopback was changed from using #X to #λ awhile ago; one bit was missed.
2021-04-18 16:20:04 +02:00
unobe f7ae890ecb patch for imap when imap fails
changeset:   8411:19f6a88ea241
branch:      mbp-2011
user:        Romano <unobe@cpan.org>
date:        Sat Apr 17 14:35:21 2021 -0700
files:       sys/src/cmd/upas/fs/imap.c
description:
When an imap fetch fails, it's helpful at times to know the underlying
cause.  This provides more details by providing the underlying error
message.
2021-04-17 18:52:11 -07:00
Ori Bernstein 9923ea348c Mail: remove impliicit headers (thanks unobe)
Setting headers from Mail can cause conflicts
with the headers that upas/marshal adds when
sending attachments.

So, let's not set them.
2021-04-17 18:46:02 -07:00
Ori Bernstein 0256a34560 acme: fix border size, autoindent undo: imported from plan9port (thanks jxy)
origin:

https://github.com/9fans/plan9port/pull/493
https://github.com/9fans/plan9port/pull/489
https://github.com/9fans/plan9port/pull/461
2021-04-14 20:30:24 -07:00
Sigrid a90a801685 zuke: include libtags in CFLAGS 2021-04-13 15:55:19 +02:00
Sigrid ff220ea29b zuke: remove -G option (old playlists not supported anymore) 2021-04-13 13:28:31 +02:00
Sigrid c613382caf remove juke (use play or zuke instead) 2021-04-13 13:25:24 +02:00
Sigrid c6cdee420d audio/: zuke, mkplist, readtags 2021-04-13 13:20:27 +02:00
Ori Bernstein fd4e8eef0b Mail: correctly track the number of messages (thanks igor)
We forgot to update the message count when deleting
messages in mail, meaning we could access trailing
messages that had been freed.
2021-04-12 09:22:48 -07:00
qwx dc8da7c232 crop: allow no-ops for pipelines
unlike other tools like iconv(1), a crop(1) without arguments or with
ones resulting in a no-op, like `-t 0 0', errors out.  other options
like `-i 0' do not error.  this breaks assumptions and results in
tedious intermediary steps or hacks like:

	foo | {crop -t $1 $2 >[2]/null || cat} > baz.bit

instead, just ignore the check.  subsequent code doesn't make
assumptions on that.
2021-04-12 10:29:54 +02:00
cinap_lenrek 5fb37e15b6 ip/tftpd: add a syslog message about what error we return to the client on a NAK 2021-04-11 23:58:30 +02:00
cinap_lenrek a89bee7373 ip/dhcpd: work around raspberry pi pxe firmware by providing dhcp option 66
The raspberry pi 4 PXE firmware insists on finding the tftp
server address by parsing dhcp option 66 as an ip address
string.
2021-04-11 20:20:41 +02:00
cinap_lenrek d9bf5d074d ip/ipconfig: ODtftpserver (dhcp option 66) is of type string 2021-04-11 20:18:03 +02:00
Humm 5e040b3a2b libthread: generate correct acid files
/sys/src/cmd/mksyslib uses `{basename $stem .$objtype}^.c to get the
source file name for *.acid files.  /sys/lib/acid/thread expects
sched.$objtype.acid.  This lets /sys/src/libthread/mkfile generate
that file.
2021-04-09 16:48:07 +02:00
Humm 50d23b6acc page: fix for kerTeX dvi 2021-04-09 16:40:56 +02:00
Humm d6ce7969ed disk/fdisk: add OpenBSD partition type 2021-04-09 16:11:48 +02:00
Humm fe1c8010de printfont: load all fonts for `printfont all` 2021-04-09 16:09:31 +02:00
Humm a0997f38c4 trofftable.rc: make work 2021-04-09 16:05:30 +02:00
cinap_lenrek 777b1949b2 nusbrc: ignore rndis ethernet in /rc/bin/nusbed, handled by /sys/src/9/boot/nusbrc (thanks romano) 2021-04-08 21:57:24 +02:00
Stephen Gregoratto 4c981d440d [9front] walk: properly format permissions
This patch adds dirmodefmt from fcall.h to pretty-print file
permissions, similarly to ls -l. I didn't notice any performance
degradation.

I hope no-one relied on the old behaviour.
2021-04-06 14:43:38 +02:00
cinap_lenrek d41c867696 file: detect webp files (thanks kemal)
this patch adds a small check to the "iff" function, so this
way file can detect webp files. tested with a webp file i
found randomly.
2021-04-03 19:32:47 +02:00
cinap_lenrek 958b476499 games/glendy: your complication had a complication (god damn it kemal) 2021-04-02 22:23:40 +02:00
cinap_lenrek 74befadb14 games/glendy: don't use lucida sans in menus by default and bugfix (thanks kemal)
i have found one bug. when i put glenda in a position like this

i somehow win, but the glenda can escape from there.

in addition, i have changed the games manpage to include more info about glendy.
2021-04-02 22:05:15 +02:00
cinap_lenrek 295acd7e0d kernel: get rid of physical page bank array and use conf.mem[] instead
We can take advantage of the fact that xinit() allocates
kernel memory from conf.mem[] banks always at the beginning
of a bank, so the separate palloc.mem[] array can be eleminated
as we can calculate the amount of non-kernel memory like:

upages = cm->npage - (PGROUND(cm->klimit - cm->kbase)/BY2PG)

for the number of reserved kernel pages,
we provide the new function: ulong nkpages(Confmem*)

This eleminates the error case of running out of slots in
the array and avoids wasting memory in ports that have simple
memory configurations (compared to pc/pc64).
2021-04-02 20:23:25 +02:00
cinap_lenrek afa5800b5b acme: fix suicide *and* resource leak in ecmd.c (thanks igor)
To reproduce the suicide try running the following in acme:

• 'Edit B <ls lib'

by select and middle clicking in a window that is in your $home.

There is a very high chance acme will commit suicide like this:

<snip>
cpu% broke
echo kill>/proc/333310/ctl # acme
cpu% acid 333310
/proc/333310/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
edittext(nr=0x31,q=0x0,r=0x45aa10)+0x8 /sys/src/cmd/acme/ecmd.c:135
xfidwrite(x=0x461230)+0x28a /sys/src/cmd/acme/xfid.c:479
        w=0x0
        qid=0x5
        fc=0x461390
        t=0x1
        nr=0x100000031
        r=0x45aa10
        eval=0x3100000000
        a=0x405621
        nb=0x500000001
        err=0x419310
        q0=0x100000000
        tq0=0x80
        tq1=0x8000000000
        buf=0x41e8d800000000
xfidctl(arg=0x461230)+0x35 /sys/src/cmd/acme/xfid.c:52
        x=0x461230
launcheramd64(arg=0x461230,f=0x22357e)+0x10 /sys/src/libthread/amd64.c:11
0xfefefefefefefefe ?file?:0
</snap>

The suicide issue is caused by the following chain of events:

• /sys/src/cmd/acme/ecmd.c:/^edittext is called at
/sys/src/cmd/acme/xfid.c:479 passing nil as its first parameter:

<snip>
...
        case QWeditout:
                r = fullrunewrite(x, &nr);
                if(w)
                        err = edittext(w, w->wrselrange.q1, r, nr);
                else
                        err = edittext(nil, 0, r, nr);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
</snap>

...and /sys/src/cmd/acme/ecmd.c:/^edittext dereferences the
first parameter that is *nil* at the first statement:

<snip>
char*
edittext(Window *w, int q, Rune *r, int nr)
{
        File *f;

        f = w->body.file;
^^^^^^^^^^^^^^^^^^^^^
This will crash if 'w' is *nil*

        switch(editing){
...
</snap>

Moving the the derefernce of 'w' into the case where it is
needed (see above patch) fixes the suicude.

The memory leak is fixed in /sys/src/cmd/acme/ecmd.c:/^filelist.  The
current implementation of filelist(...) breaks its contract with its
caller, thereby leading to a memory leak in /sys/src/cmd/acme/ecmd.c:/^B_cmd
and /sys/src/cmd/acme/ecmd.c:/^D_cmd.

The contract /sys/src/cmd/acme/ecmd.c:/^filelist seems to have with
its callers is that in case of success it fills up a 'collection' that
callers can then clear with a call to clearcollection(...).

The fix above honours this contract and thereby removes the leak.

After you apply the patch the following two tests should succeed:

• Execute by select and middle click in a Tag:
        'Edit B lib/profile'

• Execute by select and middle click in a Tag:
        'Edit B <ls lib'

The former lead to a resource leak that is now fixed.

The latter lead to a suicide that is now fixed by moving the statement
that dereferences the parameter to the location where it is needed,
which is not the path used in the case of 'Edit B <ls'.

Cheers,
Igor
2021-04-02 15:51:15 +02:00
Romano a398a09783 [9front] [patch] nusb/ether -t rndis 2021-04-01 12:54:08 +02:00
cinap_lenrek a2ebe5c79a devfs: fix locking and ignore undocumented "fsdev:\n" configuration signature
The confstr was shared between readers so seprintconf() could
write concurrently to that buffer which is not safe.

This replaces the shared static confstr[Maxconf] buffer with a
pointer that is initially nil and a buffer that is alloced on
demand.

The new confstr pointer (and buffer) is now only updated while
wlock()ed from the new setconfstr() function.

This is now done by mconfig() / mdelctl() just before releasing
the wlock.

Now, rdconf() will check if confstr has been initialized, and
test for it again while wlock()ed; making sure the configuration
is read only once.

Also, rdconf() used to check for a undocumented "fsdev:\n" string
at the beginning of config data tho that was never documented.

This changes mconfig() to ignore that particular signature so
the example from the manpage will work as documented.
2021-03-31 17:49:10 +02:00
cinap_lenrek 4a83ce37c6 libsunrpc: work around arm64 compiler bug in sunStringUnpack()
The sunStringUnpack() routine was miscompiled by 7c, as
pointer arithmetic is done in 64 bit but the constant -1
offset got expended to a unsigned 32 bit integer.
2021-03-29 17:13:50 +02:00
cinap_lenrek 3841a46421 kernel: remove ucalloc.c duplicates 2021-03-13 14:57:53 +01:00
cinap_lenrek 7c62c12701 kernel: use 64-bit mask to avoid compiler warning in port/pci.c 2021-03-13 14:20:00 +01:00
cinap_lenrek 9de5aac7a2 5c, 6c, 7c, 8c, kc, qc, vc: use explicit gmove(... , nn) in cgen() for result of OAS*, OPREINC, OPOSTINC
The expression value of the assignment operation was
returned implicitely by relying on regalloc() on the
right hand side "nod" borrowing the register from nn.

But this only works if nn is a register.

In case of 6c, it can also be a ONAME from a .safe
rathole returned by regsalloc().

This change adds explicit gmove() calls to assign the
expression value. Note that gmove() checks if source
and destination are the same register so it wont emit
redundant move operations in the common case.

The same is applied also to OPREINC and OPOSTINC operations.
2021-03-13 13:56:40 +01:00
rgl 2fc22d067d correct off-by-one nul termination. 2021-03-11 19:37:44 +01:00
Ori Bernstein 9162533526 Mail: separate deletion from relinking messages
Mutating lists that are being iterated is needlessly error
prone, and we were removing the wrong message in some cases
if it the dummy got inserted in the right place.

Separating deletion into a redraw/relink and zap phase
simplifies the problem.
2021-03-10 16:49:17 -08:00
cinap_lenrek b5783b1e39 rio: make window focus changes deterministic, cleanup wind.c
Switching window focus used to be non deterministic
as the current window in focus (Window *input) was set
concurrently while processing window messages such as
Resized and Topped.

This implements a new approach where wcurrent() and
wuncurrent() are responsible for the synchronization
and switch of the input.

It is implemented by sending a Repaint message to the
old input window first, neccesarily waiting until that
window releases the focus and then input is updated
and then a Topped or Reshaped message is send to the
new input window.

Note, that when the whole screen is resized that no
input changes need to happening anymore.
2021-03-07 20:26:30 +01:00
Sigrid 5ac3fa0257 mothra: "d": use lite version, disable redirect 2021-03-02 08:41:02 +01:00
Sigrid 2aba7615af mothra: add "d" command to search for a text on the internet (using duckduckgo) 2021-03-02 08:21:56 +01:00
Ori Bernstein f234b29c7f Mail: revert 096538d64724 2021-03-01 19:23:13 -08:00
cinap_lenrek a0404ff582 devpccard, pci: fix pccard support and handle pci expansion roms
let pci.c deal with the special cardbus controller bar0 and
expansion roms.

handle apic interrupt routing for devices behind a cardbus slot.

do not free the pcidev on card removal, as the drivers
most certanly are not prepared to handle this yet.
instead, we provide a pcidevfree() function that just unlinks
the device from pcilist and the parent bridge.
2021-03-01 17:24:54 +01:00
Ori Bernstein 3555843110 Mail: fix infinite deletion loop
When deleting messages that came in just
the right order, we would end up stuck in
a loop deleting and reinserting a dummy
parent, rather than the messages we wanted
to remove.
2021-02-28 16:36:42 -08:00
cinap_lenrek be782ef435 bcm: change color chan to RGB24 (thanks p.kosyh)
p.kosyh writes:

Hello!  I finally bought rpi4 4Gb specially for 9front. It seems,
that default bpp of framebuffer is 16.  I changed it to 24 (via
cmdline.txt and config.txt) and found, that rendering is much faster!
(May be due removing overheads in 16->24 conversions?)

But on rpi4 r and b channels are swapped.  So, i changed BGR24 to
RGB24 in bcm/screen.c and now it works fine!
2021-02-28 13:31:49 +01:00
cinap_lenrek 51f4f46ae0 ramfs: fix truncfile() for non multiple of extend size (64k)
The calculation of the last block size is wrong and we can
only shrink the size of the last data block, not extend it.
2021-02-27 15:08:34 +01:00
Sigrid 692919521c vmx: reduce cpu load by eliminating nop-loop
Sacrifice some of the sub-millisecond timer precision in favor of less
cpu load when the timer is about to be kicked a bit early.  Result is
visible *especially* when the guest idling.

Timer proc *still* has to send to the channel (in order to kick PIT
and RTC logic), which takes time, and compensates a bit for possibly
early runs.
2021-02-23 15:54:09 +01:00
Sigrid 007d42e741 html2ms: 0xFFFD → Runeerror 2021-02-23 08:52:59 +01:00
cinap_lenrek 27ad886c95 ip/tftpd: add -n namespace-file flag (thanks sam-d)
tftpd currently unconditionally sets its namespace via /lib/namespace
(newns("none", nil)), which stymied my attempts to pxe boot the
openbsd installer without creating a real /etc dir on 9front, which
would've been gross.

I tried working around this with -h (and -r for good measure), but
again hit issues because the namespace is rebuilt from scratch -- any
binds of /386, /amd64, /cfg/pxe, etc. into the tftp-specific directory
disappeared from tftpd's namespace and rendered my *9front* boxes
unable to boot. I could maintain copies of the needed files in the
tftp-specific directory, but that'd be kind of a drag.

The following patch adds a -n flag to allow the specification of a
namespace file in place of /lib/namespace; similar to ip/ftpd.

I thought about setting up a /lib/namespace.tftp to act as a default
rather than continuing to use /lib/namespace by default (which
security-wise is about the same as allowing 9p mounts by user none,
which I also have disabled), but I had trouble coming up with a sane
default. Maybe someone more experienced would like to try that out.

- sam-d
2021-02-23 01:47:33 +01:00
cinap_lenrek a96cf495fa ip/tftpd: use procsetuser() instead of writing #c/user 2021-02-23 01:41:09 +01:00
cinap_lenrek 5347bb9c96 boot/bcm: download dtb files for rpi-400 and rpi-cm4 2021-02-22 23:44:28 +01:00
cinap_lenrek e77fa31516 libaml: fix IndexField and BankField implementations (thanks Michael Forney)
IndexField is supposed to increment the index value when an
access is done with a bigger size than the data field.
The index value is always a byte offset.

Now that we always calculate the offset for each field unit
access for IndexField, rename the indexv to bank (the bank
value), as it is only used for that. Also, do not compare
it with nil, as it is a integer constant which can be
encoded as nil to mean zero.

For BankField, the banking field was written using store(),
which does nothing when the destination is a Field*.
Use rwfield() to fix it in the new rwfieldunit().

Resolve all the Name*'s when IndexField, BankField and
Field are created. Now, Field.reg points to eigther
Buffer object, Region or Field (data Field of an IndexField).

PS: initial bug report by Michael Forney follows below:

In /dev/kmesg on my T14, I saw a message

	amlmapio: [0xffffff18-0x100000018] overlaps usable memory
	amlmapio: mapping \_SB.FRTP failed

Here is the relevant snippet from my DSDT:

    Scope (_SB)
    {
        ...

        OperationRegion (ECMC, SystemIO, 0x72, 0x02)
        Field (ECMC, AnyAcc, NoLock, Preserve)
        {
            ECMI,   8,
            ECMD,   8
        }

        IndexField (ECMI, ECMD, ByteAcc, NoLock, Preserve)
        {
            Offset (0x08),
            FRTB,   32
        }

        OperationRegion (FRTP, SystemMemory, FRTB, 0x0100)
        Field (FRTP, AnyAcc, NoLock, Preserve)
        {
		...
        }
    }

With some debugging output:

	amlmapio(\_SB.ECMC): Io       72 - 74
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 8
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 18
	amlmapio(\_SB.FRTP): Mem      ffffff18 - 100000018
	amlmapio: [0xffffff18-0x100000018) overlaps usable memory
	amlmapio: mapping \_SB.FRTP failed

It seems that libaml does not handle IndexField correctly and just did
a single read from ECMD after setting ECMI to 8, causing the FRTP
region to be evaluated as 0xffffff18-0x100000018. Instead, it should
be reading 4 bytes [18 c0 22 cc], evaluating it as
0xcc22c018-0xcc22118:

	amlmapio(\_SB.ECMC): Io       72 - 74
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 8
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 18
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- 9
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> c0
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- a
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> 22
	rwreg(\_SB.ECMC): Io       [72+0]/1 <- b
	rwreg(\_SB.ECMC): Io       [72+1]/1 -> cc
	amlmapio(\_SB.FRTP): Mem      cc22c018 - cc22c118

I wrote a patch (attached) to fix this, and it seems to work. Though,
it's not clear to me when things should be dereferenced. Previously,
the data field was dereferenced at evalfield, but the region and index
field were not until rwfield. After the patch, the index field is
also dereferenced in evalfield.

For BankField, the index *is* dereferenced in evalfield. I'm pretty
sure that this means that BankField does not work currently, since
store() just returns nil for 'f' objects. The bank selector will
never get set.

Anyway, I don't know if this solves any real problems; it's just
something I noticed and thought I'd try to fix.
2021-02-22 19:27:49 +01:00
Michael Forney 472958e3e7 games/snes: use 4-point hermite interpolation to resample
This is noticeably better than nearest-neighbor.
2021-02-22 16:12:24 +01:00
Ori Bernstein 6445a14f63 ape/lib9: expose fd2path (thanks phil9)
Fd2path is a useful call for the netsurf plan9 frontend,
so we should expose it.
2021-02-20 21:02:07 -08:00
Ori Bernstein f3a05b16ad upas/send: add \n to error in refuse() (thanks josuah) 2021-02-20 15:25:25 -08:00
Ori Bernstein 2d13ac5d39 marshal: remove debug junk.
Oops.
2021-02-20 13:03:35 -08:00
Ori Bernstein fb88cab9ff upas/marshal: use login instead of user (thanks sirjofri)
User is the upasname, and is unlikely to exist when we save
the message to the outbox. We should use the login name instead.
2021-02-20 13:01:48 -08:00
Ori Bernstein 245264e371 upas/marshal: handle nonexistent save folder correctly (thanks sirjofri)
When the save folder did not exist, and we could not create
it, we would handle up to one Biobuf worth of message, and
then fail, due to a failed tee. The sequence of events leading
up to this was:

	openfolder() -> error
	tee(0, fd, -1) -> wait for read
	write(0, data) ->
		write(fd, data) -> ok
		write(-1, data) -> error, tee terminates
	write(0, attachment) -> error

This change prevents us from writing to a closed fd, and
therefore from erroring out when sending.

We also warn the user.
2021-02-20 12:49:03 -08:00
cinap_lenrek dab168e6bd ether82563: add pci id for i219-LM on thinkcenter (easypeasy, thanks hiro) 2021-02-20 19:06:59 +01:00
cinap_lenrek 8b817fd6c0 pc/devarch: use m->cpumhz instead of recalculatin it 2021-02-20 13:08:59 +01:00
cinap_lenrek 48e795005d 9boot: handle automatic length for 64-bit values in hexfmt() for framebuffer address (thanks Michael Forney) 2021-02-20 12:55:42 +01:00
sl 4bbb3b0b21 /sys/src/cmd/ndb/dns.h:
---

To: 9front@9front.org
Date: Sun, 07 Feb 2021 14:56:39 +0100
From: kvik@a-b.xyz
Subject: Re: [9front] transient dns errors cause smtp failure
Reply-To: 9front@9front.org

I think I found a reason for DNS failing on known good domains.

/sys/src/cmd/ndb/dns.h:156,157
	/* tune; was 60*1000; keep it short */
	Maxreqtm=	8*1000,	/* max. ms to process a request */

So, 8 seconds is how much the resolver will bother with a request it
has been handed, before dropping it on the floor with little
explanation.

It seems quite possible that this is too short a timeout on a machine
during a spam queue run, which predictably stresses the compute and
network resources.

In turn, negative response caching might explain why a particular
unlucky domain would basically stop receiveing any mail for a while.

I'm dying to know if bumping this limit would clear up the queue of
such DNS errors.

---

[narrator: it did.]
2021-02-19 21:29:55 -05:00
sl 29e8ea26f2 sam/{address.c, sam.h}: bump STRSIZE to 512MB (thanks, Ori_B) 2021-02-19 21:15:15 -05:00
kvik bc1cc79225 libstdio: sync bits of vfprintf from APE
* Add the %ll length modifier,
* Convert nil to "<nil>" under %s (not in APE),
* Cast void* to uintptr under %p,
* Use "0x" hex prefix under %p,
* Fix manual page mentions of %P to %p,
* Fix empty result for fp conversions,
* Fix zero padding of left-aligned fp conversions,
* Remove deprecated #pragma ref uses.

Most of these were introduced in APE prior to 9front.

I've omitted the %z conversion specifier since Plan 9 code
rarely uses the usize type. This may need to be added later
for the benefit of native ports of alien code.
2021-02-19 23:04:09 +01:00
Sigrid ca1542a199 audio/flacenc: fix usage 2021-02-18 15:13:25 +01:00
Michael Forney 8aff377698 games/snes: use enum constants KON and ENDX instead of their values 2021-02-17 11:20:13 +01:00
Michael Forney 03eeebb97f games/snes: implement DSP echo 2021-02-17 11:20:05 +01:00
Michael Forney f1d29a9d12 games/snes: implement DSP noise
I'm not sure if this LFSR is the same one used by the hardware or is
arbitrary, but it matches the noise sequence used by all other snes
emulators I looked at.
2021-02-17 11:19:50 +01:00
Michael Forney 52b54097bf games/snes: fix BRR decoding with filters 2 and 3
s1 and s2 should store the last and next to last output, but were set
in the wrong order, causing them both to be the last output. This
breaks filters 2 and 3, which both utilize s2.
2021-02-17 11:19:39 +01:00
Sigrid 79cf39c53a mothra: tune up entry control logic for easier text editing 2021-02-16 22:04:50 +01:00
cinap_lenrek 04bf70d344 9boot: mark efi boot and runtime service regions as reserved
despite the kernel never doing any efi runtime service calls,
overriding the runtime service regions makes some machines
lock up. so consider them reserved.

the boot service regions should also, in theory, be usable
by the os, but linux says otherwise...
2021-02-15 01:49:30 +01:00
cinap_lenrek b5690a5ae7 ndb/dns: implement RFC6844 certificate authority authorization record type 2021-02-14 14:25:41 +01:00
Michael Forney 5fd4fa912e [9front] audio/flacenc: fix error check for fseeko
fseeko returns 0 on success, not the new stream position.

This allows flacenc to update the streaminfo block when it is finished
(for example to set the number of samples and checksum).
2021-02-11 09:37:36 +01:00
cinap_lenrek 2f28aaac65 nusb: don't create rw iso endpoints (by Michael Forney)
There may be two iso endpoints with the same ID if it is asynchronous
or adaptive (one for data, one for feedback), and rw iso endpoints are
unusable (error out with "iso i/o is half-duplex").
2021-02-10 20:08:13 +01:00
cinap_lenrek d7ade692c8 nusb: don't create rw iso endpoints (by Michael Forney)
There may be two iso endpoints with the same ID if it is asynchronous
or adaptive (one for data, one for feedback), and rw iso endpoints are
unusable (error out with "iso i/o is half-duplex").
2021-02-10 19:52:00 +01:00
Ori Bernstein 8606fc8f29 merge 2021-02-10 10:21:06 -08:00
Ori Bernstein 0719ce2aa7 stdio: remove erronous assert in dtoa
The value of `k` in dtoa() is an estimate of
floor(log10(d)), where `d` is the number being
converted. The code was asserting that 'k' was
less than 100, but the full range of a double
goes to 10^308 or so.

This means that the majority of the range of
a double would trigger that assert.
2021-02-09 13:57:38 -08:00
Michael Forney 29fbba7b6d [9front] upas/vf: exclude mime boundary from temporary attachment files
validateattachment has no business with the mime boundary; it is not
part of the attachment itself.

Also, it causes the boundary to be dropped in the message output from
upas/vf, effectively dropping the following attachment (though the
content is still present after the last boundary of the wrapped first
attachment part).

Consider the following sequence of events:
1. upas/vf is run on a message containing two attachments.
2. The first attachment does not have a known extension, so is saved
   to a temporary file *including* the following mime boundary.
3. This file is opened as p->tmpbuf, which is used for subsequent
   reads until switching back to stdin.
4. The attachment fails validateattachment, so upas/vf wraps it in a
   multipart with a warning message.
5. problemchild() calls passbody(p, 0), which copies from p->tmpbuf
   until it hits the outer boundary line, which it excludes, seeks
   back one line, then returns the outer multipart.
6. problemchild() then writes its own boundary, and then copies one
   line from *stdin* to stdout, expecting the outer boundary.
   However, this boundary was already read from stdin in 2, so it ends
   up reading the first line of the subsequent part instead.

To fix this, pass 0 to passbody() in save() to exclude it from the
attachment file and make it available in stdin when expected.
2021-02-08 20:59:01 -08:00
Ori Bernstein 2d8adc7b88 ape/lib9: sync arm getfcr.s implementation
The arm assembler supports movw to handle
getfcr and setfcr now, no need to hack it
with macros; sync from plan9 libc.
2021-02-08 16:07:09 -08:00
Ori Bernstein 491fe25158 Mail: correct rendering of nested multipart messages
Reading nested subparts of messages into the root
message array allows deeply nested multipart trees
of messages to show correctly in the message view.
2021-02-07 20:30:04 -08:00
Michael Forney e20dcb151a [9front] upas/vf: remove debugging print statements
These messages aren't useful and were presumably left over from
someone debugging this code.
2021-02-07 20:17:06 -08:00
Michael Forney 415c110b28 games/gb: fix reversed audio channels
The high bits correspond to the left channel, and the low bits to the
right channel.

Reference: https://gbdev.io/pandocs/#sound-control-registers

Tested with pokemon crystal.
2021-02-08 04:58:49 +01:00
Michael Forney e502abe001 games/gb: various HDMA fixes
H-blank DMA should only transfer 16 bytes per h-blank, rather than
waiting for the first h-blank and then transferring the whole size.

HDMAC should read 0xff when the transfer is finished, and 0 in the
high bit when the transfer is ongoing. Also, if 0 is written in the
high bit, the current transfer should be aborted.

Introduce two flags, DMAREADY and DMAHBLANK rather than special
constants 1 and -1. If dma is non-zero, there is an ongoing DMA. If
DMAREADY is set, the next chunk is ready to transfer.

Reference: https://gbdev.io/pandocs/#ff55-hdma5-cgb-mode-only-new-dma-length-mode-start

Tested with pokemon crystal.

What was happening is that when the game was loading N background tiles
into vram (each 16 bytes, so one per h-blank), it did something like
this:
- start an hdma transfer for N+1 tiles
- after the Nth tile is transferred, it would read HDMA5, clear the
high bit, then write it back to abort the transfer.

games/gb would instead transfer all N+1 tiles at once, overwriting one
extra tile with whatever was 1 past the end of the source array, and
then would interpret the cancel request as the start of a new transfer
of 16 bytes, which would copy an additional tile past the end. The end
result is that every transfer would end up copying N+2 tiles instead
of just N, overwriting certain tiles with whatever was after the end
of the source data.
2021-02-08 04:58:41 +01:00