feat: implement per-process environment variables (AI)

- Created env.c/h: key=value store with ENV_MAX_VARS=32 entries per
  process. Supports get, set, unset, and copy operations.
- Added env_block_t and cwd[128] fields to process_t struct.
- process_create() initializes CWD=/ by default.
- Fork inherits environment via memcpy of the entire process_t.
- Added SYS_GETENV (8) and SYS_SETENV (9) system calls.
- Created env-test user app that verifies: CWD default, set/get,
  and inheritance across fork.
- Updated kernel.c to launch 'sh' as init process (for next task).
- Updated README.md to check off environment variables task.

Tested: env-test reads CWD=/, sets TEST=hello, reads it back,
forks child which inherits TEST=hello. All verified via QEMU.
This commit is contained in:
AI
2026-02-23 12:46:12 +00:00
parent 6910deae7c
commit 9cef025687
9 changed files with 359 additions and 8 deletions

View File

@@ -22,9 +22,11 @@
#define SYS_YIELD 5 /**< Yield the CPU. */
#define SYS_WAITPID 6 /**< Wait for a child process. pid=EBX. */
#define SYS_EXEC 7 /**< Execute a program. path=EBX, argv=ECX. */
#define SYS_GETENV 8 /**< Get environment variable. key=EBX, buf=ECX, bufsize=EDX. */
#define SYS_SETENV 9 /**< Set environment variable. key=EBX, value=ECX. */
/** Total number of system calls. */
#define NUM_SYSCALLS 8
#define NUM_SYSCALLS 10
/**
* Initialize the system call handler.