Commit Graph

49 Commits

Author SHA1 Message Date
Giacomo Tesio 001069aa7b libposix: deep refactor; add sys/posixly command
With these changes, libposix (and newlib) can run MirBSD Korn Shell.
2017-12-18 23:02:36 +01:00
Giacomo Tesio f3b882ba4a qa: add setsid test to newlib 2017-09-08 00:15:12 +02:00
Giacomo Tesio a97830e493 newlib: add qa test for setjmp/longjmp 2017-09-03 17:41:55 +02:00
Giacomo Tesio e888e52502 qa: newlib: fix 102-files so that it works with disk based roots (runDisk.sh) 2017-08-30 00:15:50 +02:00
Giacomo Tesio 713eb8843f libc: simplify access; libposix: let access lie
There are a few issues with Plan 9's `access`:

- it has side effects: to test the actual access (that the file
  servers can allow or deny according to complex custom rules)
  it opens and then closes the file, allocating (and disposing) the fd
- it does not work on directories, since
  - they cannot be opened for writing, despite the fact that to
    create a file in a directory you must be granted write access on
    that directory
  - they cannot be opened for execution, despite the fact that to
    access a file in a directory you must be granted execution access
    on that directory

Despite the fact that `access` (even on UNIX) is a violation of the
"tell, don't ask" principle (the access could be forbidden just after
its successful return, making subsequent `open` fail anyway), this
fact smells of a little design error in the file interface.

So, right now we choose to let the libposix's `access` lie on directories:
it will always return 0 on AWRITE and AEXEC for them, accepting that
a successive create/mkdir may fail.

However, a cleaner file API and protocol should allow a simpler `access`
to be implemented for directories too.
2017-08-29 00:17:51 +02:00
Giacomo Tesio fe173086f7 qa: improved newlib/103-files.c (testing access, mkdir, chdir and getcwd) 2017-08-28 23:04:31 +02:00
Giacomo Tesio 9bdbd9b09d qa: improve newlib/040-gettimeofday.c 2017-08-28 23:04:31 +02:00
Giacomo Tesio b78613615d libposix: add access 2017-08-28 23:04:12 +02:00
Giacomo Tesio 44fa703f84 qa: fix test newlib/040-gettimeofday.c 2017-08-25 23:33:10 +02:00
Giacomo Tesio bd149a18f1 libposix: implement gettimeofday 2017-08-25 00:53:10 +02:00
Giacomo Tesio 2409419ba2 qa: fix 199-files-CLEAR.runner 2017-08-24 00:14:02 +02:00
Giacomo Tesio 6158d0e166 qa: newlib test for chdir and mkdir 2017-08-23 04:25:30 +02:00
Giacomo Tesio 511bbd36af qa: newlib: better messages in 100-files 2017-08-22 02:45:49 +02:00
Giacomo Tesio 97c4c2bccb qa: add test for opendir/readdir/closedir in newlib 2017-08-22 01:41:15 +02:00
Giacomo Tesio 6dd00801dc libposix: introduce pause() (still to be integrated in newlib) 2017-08-18 00:50:07 +02:00
Giacomo Tesio ef6aa99b74 qa: libc: slow note handlers cant't break sleep 2017-08-16 00:37:39 +02:00
Giacomo Tesio df8bc2ce43 qa: increase rlockt1 timeout 2017-08-14 18:46:23 +02:00
Giacomo Tesio 1b4b6d1574 qa: reenable newlib's tests 2017-08-13 12:33:18 +02:00
Giacomo Tesio d573d0a39c qa: disable newlib's test 202-signals 2017-08-13 00:06:04 +02:00
Giacomo Tesio 99124f1578 qa: disable newlib's test 201-signals
For some reason it hangs on travis-ci.
2017-08-12 23:55:39 +02:00
Giacomo Tesio e57ff30b63 qa: release cpu on newlib/201-signals and newlib/202-signals 2017-08-12 23:33:38 +02:00
Giacomo Tesio 1c4a04cd30 qa: various fix to tests 2017-08-11 03:18:32 +02:00
Giacomo Tesio 4f97f4a80b qa: disable broken tests 2017-06-05 22:11:36 +02:00
Giacomo Tesio a8d42cecc9 newlib: use SIGINT to avoid abort 2017-05-29 23:45:00 +02:00
Giacomo Tesio 9dc9001469 newlib: test ignored signals (broken) 2017-05-29 01:53:37 +02:00
Giacomo Tesio 559e5429ed newlib: tests for sigchld 2017-05-29 01:42:08 +02:00
Giacomo Tesio fe168aa55d newlib: introduce tests for SIGCHLD 2017-05-26 02:12:42 +02:00
Giacomo Tesio 5ca0ef085c newlib: fix test for SIGSTOP/SIGCONT 2017-05-26 00:39:47 +02:00
Giacomo Tesio 439326fa1f newlib: enabled more tests for signals (still broken) 2017-05-25 22:43:38 +02:00
Giacomo Tesio 48ea61ab9c newlib: more tests for signals 2017-05-08 00:36:04 +02:00
Giacomo Tesio bd8ced55f1 qa: fix CID 168327 and CID 168326 2017-05-04 00:22:50 +02:00
Giacomo Tesio ec8d3427b7 qa: fix newlib test (CID 168329 and CID 168328) 2017-05-04 00:17:19 +02:00
Giacomo Tesio 47573e2122 newlib: add 201-signals (broken as no default action occurs in newlib) 2017-05-02 01:15:10 +02:00
Giacomo Tesio be7c067507 newlib: fix qa_exit_translator in qa tests 2017-05-02 00:18:52 +02:00
Giacomo Tesio 690a89d3ce newlib: add test for waitpid (to implement) 2017-05-01 12:03:49 +02:00
Giacomo Tesio bd22e5154c qa: wait for child in newlib/200-signals 2017-04-30 16:55:13 +02:00
Giacomo Tesio d0b9ae9cac newlib: first test for signals 2017-04-29 00:33:54 +02:00
Giacomo Tesio 28539041d0 newlib: one more test (fread) 2017-04-28 23:15:03 +02:00
Giacomo Tesio 2481b01515 qa: introduce runners and more tests for newlib
For each test, if a script exists with the same name of the test
plus the .runner suffix, the runner is run instead of the test.

As a first example qa/lib/newlib/testsuite/atexit is run by
qa/lib/newlib/testsuite/atexit.runner.

These .runner scripts allow more complex checks of the side effects
generated by the test.
2017-04-28 00:47:12 +02:00
Giacomo Tesio 5c8200b9da qa: simple infrastructure to test output expectations 2017-04-24 00:06:33 +02:00
Giacomo Tesio 7ab8fecd80 newlib: qa checks from RedHat tests suite 2017-04-23 23:50:20 +02:00
Giacomo Tesio c2982db8a2 newlib: run first QA checks 2017-04-22 00:46:55 +02:00
Giacomo Tesio e70feee4a3 libc: introduce "jehanne_" namespace
With this commit all functions declared in libc.h have been renamed
with the "jehanne_" prefix. This is done for several reason:

- it removes conflicts during symbol resolution when linking
  standard C libraries like newlib or musl
- it allows programs depending on a standard C library to directly
  link to a library depending on our non standard libc (eg libsec).

To ease transiction two files are provided:

- sys/include/lib9.h that can be included instead of <libc.h> to use
  the old names (via a simple set of macros)
- sys/src/lib/c/lib9.c that can be compiled with a program where the
  macro provided by lib9.h are too dumb (see for example rc or grep).

In the kernel port/lib.h has been modified accordingly and some of
the functions it directly provides has been renamed too (eg malloc
in qmalloc.c and print in devcons.c).
2017-04-19 23:48:21 +02:00
Giacomo Tesio 65cdad4317 libc: rewrite putenv and getenv.
These new implementations

- do several validity check on input parameters
- allow a bit larger variable names (127 bytes, aka sizeof(Proc.genbuf)-1)
- preserve nulls in the content (the original version used to replace
  '\0' with ' '). I can't see why they did, actually.
  See also http://marc.info/?l=9fans&m=148475801229908&w=2

Should also fix CID 155718
2017-01-19 00:58:43 +01:00
Giacomo Tesio 01562d4ddb qa: rfork(RFNAMEG) on tests that are going to rfork(RFNOMNT) later 2017-01-06 23:04:04 +01:00
Giacomo Tesio 4676c65a3d kernel: move nsec to libc 2017-01-06 00:56:22 +01:00
Giacomo Tesio b862596737 kernel&all: create() syscall only sends Tcreate
In Plan9 the create syscall fallback on a open(OTRUNC) if the
path provided already exists. This is actually a common requirement
as most programs (editors, cat...) simply requires that a file is
there and is empty, and doesn't care overwriting existing contents
(note that this is particularily sensible with something like fossil).

In Jehanne the application is responsible of actually handle this
"file exists" error but libc provides ocreate() to mimic the Plan9
behaviour. Note that ocreate introduce a subtle race too: the path
is walked several times if the file exists, thus it could misbehave
on concurrent namespace changes. However I guess this is not going to
happen often enough to care now.

NOTE we will probably address this rare race too, with a more drammatic change
to syscalls: a new walk() syscall that will provide an unopen fd.
2016-12-24 21:25:20 +01:00
Giacomo Tesio 99855d60d6 kernel: move chdir to libc using devself/devproc
Added wdir to devself and devproc:

- read '#0/wdir' to get the working directory of the calling process
  NOTE that a read(fd, nil, -1) will return the negated length
  of the working directory, just in case you want to
  allocate the memory required

- read '/proc/n/wdir' to know the working directory of process n
  (read(fd, nil, -1) still returns the negated length)

- write '#0/wdir' to change the working directory of the calling process
  NOTE: no offset is allowed and the provided string must
  be null terminated

- write '/proc/n/wdir' to change the working directory of process n
  NOTE: no offset is allowed and the provided string must
  be null terminated; moreover if another process change the working
  directory change during the write, the current process will
  receive an error.

In libc updated getwd() and chdir().
Also modified pwd to get advantage of the new file.

To test, run /arch/amd64/qa/kern/wdir.rc or simply try

	% pwd
	/usr/glenda
	% echo -n /tmp > /proc/$pid/wdir
        % pwd
        /tmp
        % cat '#0/wdir' && echo
        /tmp

The expected use cases for wdir in devproc are rio and acme.

Also, note that we could theoretically remove the cd builtin
from rc and simply implement it as a rc function.
We don't do that to preserve rc portability to other OS.
2016-12-15 22:42:01 +01:00
Giacomo Tesio 38aca7a581 first usable version of kernel and commands
After an year of hard work, this is a first "usable" version of Jehanne.
2016-11-26 03:49:29 +01:00