Ken Van Hoeylandt 79d3dd4fdb
Improvements for apps, filesystems, terminal and shell (#659)
app-module

- Apps now have support for:
  - environment variables (inherit from parent app)
  - current workdir
  - window size (when running in terminal)
- Add type aliases like `AppId` and `PackageId`
- Remove data duplication between ledger and app instance records: create `AppManifestSet`
- `AppManifest` usage safety improved: pass by value where needed, or use `AppId` instead of a manifest.

Terminal and shell

- Moved shell commands into coreutils-module as proper apps.
- Refine stack size for terminal and shell because apps now run with their own task and stack (including in-memory apps)

Platform

- Fix for listing root dir on ESP32: wrap posix directory functions and wire in file systems.
- Moved all platform-specific file system init code to platform subprojects

Other

- Fix for screenshot capture (issue with paths)
- Fixes for coreutils app correctness
- Memory optimizations (use more PSRAM where possible) in various locations such as app-module, shell and terminal.
- `ls` and `help` commands now use terminal width and show columns of data by default
- Created fs helpers at `TactilityKernel/include/tactility/filesystem/fs.h` (partially ported from `ShellFs`)
2026-09-25 08:29:27 +02:00

58 lines
1.8 KiB
C

// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <app/file.h>
#include <stddef.h>
#include <sys/types.h>
#include <tactility/error.h>
#ifdef __cplusplus
extern "C" {
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/** Fixed size of an app instance's fd table. FD allocation uses the lowest unused index >= 3. */
#define APP_MAX_FDS 16
/**
* FD-table dispatch for read()/write()/close(). Falls through to the real syscall for a fd not
* bound by the calling task's own app instance.
*/
ssize_t app_io_read(int fd, void* buffer, size_t size);
ssize_t app_io_write(int fd, const void* buffer, size_t size);
int app_io_close(int fd);
/**
* FD-table dispatch for AppFileOps::await(): blocks until @a fd is ready or @a timeout elapses.
* @retval ERROR_NOT_FOUND @a fd isn't bound in the calling task's own app instance fd table
* @retval ERROR_TIMEOUT @a timeout elapsed
* @retval ERROR_NONE the condition is true
*/
error_t app_io_await(int fd, AppFileWait wait, TickType_t timeout);
/**
* FD-table dispatch for AppFileOps::ioctl().
* @retval ERROR_NOT_FOUND @a fd isn't bound in the calling task's own app instance fd table
* @retval ERROR_NOT_SUPPORTED the object bound at @a fd has no ioctl() implementation
*/
error_t app_io_ioctl(int fd, AppIoctlRequest request, void* arg);
/**
* Installs a custom AppFileOps at @a fd in the calling task's own app instance fd table.
* Unlike AppStreamBinding, writes are never teed to the real underlying fd.
* @warning Must be called from the app instance's own task.
* @retval ERROR_NOT_FOUND the calling task isn't a running app instance
* @retval ERROR_OUT_OF_RANGE @a fd is outside [0, APP_MAX_FDS)
* @retval ERROR_NONE on success
*/
error_t app_io_bind_self(int fd, const struct AppFileOps* ops, void* object);
#ifdef __cplusplus
}
#endif