commit - 7c5aef6eb2cc265bf634fbc9bcfb007874634449
commit + 6b515a6f644d1aebf0f99f296c2a4e6187d8233a
blob - 5c1c81fb5d69f182fc9ed1d8e0e3d4e6ee6241e2
blob + 544829c12a20359e7bbaf24eceee4d8a86927aeb
--- kernel/console/service.c
+++ kernel/console/service.c
* early_console_write() will continue to buffer messages to the ring
* buffer for audit/diagnostics, but won't write to serial.
* PTY master output (console_master_write) becomes the only path to serial. */
- //early_console_disable_serial_write();
+ early_console_disable_serial_write();
#ifdef LENIX_DEBUG
serial_write("[console] early console serial writes disabled\n", 48);
#endif
blob - b009ce14236c9bdfc484f0211a266246c74977b9
blob + aa9cd56c4697c6f50249b6d50f01c3419ae3fc4d
--- kernel/ipc/vfs_service.c
+++ kernel/ipc/vfs_service.c
#endif
if (portal == IPC_PORTAL_INVALID_HANDLE) {
- printk("[vfs] vfs_service_register: invalid portal handle\n");
+ #ifdef LENIX_VFS_DEBUG
+ printk("[vfs] vfs_service_register: invalid portal handle\n");
+ #endif
return -1;
}
current_task = sched_current_task();
portal_owner = ipc_portal_owner(portal);
if (portal_owner != current_task) {
+ #ifdef LENIX_VFS_DEBUG
char buf[160];
size_t idx = 0;
const char hex[] = "0123456789abcdef";
printk(buf);
printk("\n");
printk("[vfs] vfs_service_register: portal not owned by registering task\n");
+ #endif
return -1;
}
blob - 0c567b73060c98a50a6025a63206d5c3a3a74074
blob + c5e90c7c1c075c6db8d87ccf7444c96f3f4610dd
--- kernel/sys/syscall.c
+++ kernel/sys/syscall.c
for (int shift = 28, idx = 0; shift >= 0; shift -= 4, idx++)
buf[idx] = hex[((uint32_t)portal >> shift) & 0xf];
buf[8] = '\0';
+ #ifdef LENIX_VFS_DEBUG
printk("[vfs] register syscall portal=0x");
+ #endif
printk(buf);
printk("\n");
#endif
if (portal == IPC_PORTAL_INVALID_HANDLE && task != NULL)
portal = sched_task_bootstrap_handle(task);
if (portal == IPC_PORTAL_INVALID_HANDLE) {
+ #ifdef LENIX_VFS_DEBUG
printk("[vfs] register: invalid portal handle\n");
+ #endif
return syscall_make_result(-SYSCALL_EINVAL, 0);
}
if (vfs_service_register(portal) != 0) {
+ #ifdef LENIX_VFS_DEBUG
printk("[vfs] register: vfs_service_register failed\n");
+ #endif
return syscall_make_result(-SYSCALL_EINVAL, 0);
}
#ifdef LENIX_DEBUG
- printk("[vfs] register returning 0\n");
+ #ifdef LENIX_VFS_DEBUG
+ printk("[vfs] register returning 0\n");
#endif
+ #endif
return syscall_make_result(0, 0);
}
blob - 5c38d771a413454cf400a92417da45e642ddfd73
blob + c0abe7ee359ef924c65b3cbf54d103ccf3cd6e88
--- servers/fs/vfs/main.c
+++ servers/fs/vfs/main.c
#include "vfs_internal.h"
#undef VFS_DEBUG
-#ifdef LENIX_DEBUG
+#ifdef LENIX_VFS_DEBUG
#define VFS_DEBUG(msg) do { if ((msg) != NULL) puts(msg); } while (0)
#define VFS_LOG_PORTAL(label, h) log_portal(label, h)
+#define VFS_PUTS(msg) puts(msg)
+#define VFS_PRINTF(...) printf(__VA_ARGS__)
+#define VFS_WRITE_STR(...) vfs_write_str(__VA_ARGS__)
#else
#define VFS_DEBUG(msg) do { } while (0)
#define VFS_LOG_PORTAL(label, h) do { (void)(label); (void)(h); } while (0)
+#define VFS_PUTS(msg) do { (void)(msg); } while (0)
+#define VFS_PRINTF(...) do { (void)0; } while (0)
+#define VFS_WRITE_STR(...) do { (void)0; } while (0)
#endif
/* VFS IPC protocol */
/* Update last access time for LRU tracking */
vnode_cache[i].last_access_time = vfs_monotonic_ms();
#ifdef LENIX_DEBUG_VNODE_CACHE
- puts("[vfs] cache: HIT on vnode lookup (device=");
+ VFS_PUTS("[vfs] cache: HIT on vnode lookup (device=");
vfs_write_u64(device);
puts(", inode=");
vfs_write_u64(inode);
}
}
#ifdef LENIX_DEBUG_VNODE_CACHE
- puts("[vfs] cache: MISS on vnode lookup (device=");
+ VFS_PUTS("[vfs] cache: MISS on vnode lookup (device=");
vfs_write_u64(device);
puts(", inode=");
vfs_write_u64(inode);
if (slot == NULL)
return NULL; /* Should not happen if cache has size > 0 */
#ifdef LENIX_DEBUG_VNODE_CACHE
- puts("[vfs] cache: evicting LRU vnode (device=");
+ VFS_PUTS("[vfs] cache: evicting LRU vnode (device=");
vfs_write_u64(slot->device);
puts(", inode=");
vfs_write_u64(slot->inode);
slot->last_access_time = vfs_monotonic_ms();
#ifdef LENIX_DEBUG_VNODE_CACHE
- puts("[vfs] cache: inserted vnode (device=");
+ VFS_PUTS("[vfs] cache: inserted vnode (device=");
vfs_write_u64(device);
puts(", inode=");
vfs_write_u64(inode);
* Path must fit within the inline buffer in the request struct. */
if (path == NULL || path_len == 0 || path_len > IPC_VFS_MAX_PATH ||
path[0] != '/') {
- puts("[vfs] resolve: invalid path");
+ VFS_PUTS("[vfs] resolve: invalid path");
return VFS_EINVAL;
}
/* Reject paths containing ".." to prevent traversal above mount root */
if (vfs_path_contains_parent_ref(path, path_len)) {
- puts("[vfs] resolve: contains ..");
+ VFS_PUTS("[vfs] resolve: contains ..");
return VFS_EINVAL;
}
if (mp_len == 0 || mp_len >= IPC_VFS_MAX_PATH || mp[0] != '/') {
resp.body.mount.status = VFS_EINVAL;
- puts("[vfs] mount: invalid mountpoint");
+ VFS_PUTS("[vfs] mount: invalid mountpoint");
resp.body.mount.device = 0;
vfs_send_response(&resp);
return;
/* Check if already mounted */
if (vfs_mount_find_exact(mp, mp_len) != NULL) {
resp.body.mount.status = VFS_EBUSY;
- puts("[vfs] mount: already mounted");
+ VFS_PUTS("[vfs] mount: already mounted");
resp.body.mount.device = 0;
vfs_send_response(&resp);
return;
mount = vfs_mount_alloc();
if (mount == NULL) {
resp.body.mount.status = VFS_ENOSPC;
- puts("[vfs] mount: no free slots");
+ VFS_PUTS("[vfs] mount: no free slots");
resp.body.mount.device = 0;
vfs_send_response(&resp);
return;
if (mount->fs_portal == IPC_PORTAL_INVALID_HANDLE) {
mount->in_use = false;
resp.body.mount.status = VFS_EINVAL;
- puts("[vfs] mount: fs_portal invalid");
+ VFS_PUTS("[vfs] mount: fs_portal invalid");
resp.body.mount.device = 0;
vfs_send_response(&resp);
return;
vfs_send_response(&resp);
#ifdef LENIX_DEBUG
- puts("[vfs] mounted filesystem");
+ VFS_PUTS("[vfs] mounted filesystem");
#endif
}
vfs_send_response(&resp);
#ifdef LENIX_DEBUG
- puts("[vfs] unmounted filesystem");
+ VFS_PUTS("[vfs] unmounted filesystem");
#endif
}
&resp.body.lookup.vnode);
#ifdef LENIX_DEBUG
- puts("[vfs] sending vnode response to client");
+ VFS_PUTS("[vfs] sending vnode response to client");
#endif
vfs_send_response(&resp);
if (fs_response_buffer.body.open.status != 0) {
resp.body.open.status = fs_response_buffer.body.open.status;
#ifdef LENIX_DEBUG
- puts("[vfs] ERROR: open failed with backend error ");
+ VFS_PUTS("[vfs] ERROR: open failed with backend error ");
vfs_write_u64((uint64_t)fs_response_buffer.body.open.status);
puts(" (path=");
puts(path);
switch (req->opcode) {
case IPC_VFS_REQ_MOUNT:
#ifdef LENIX_DEBUG
- puts("[vfs] handling MOUNT");
+ VFS_PUTS("[vfs] handling MOUNT");
#endif
vfs_respond_mount(req);
break;
case IPC_VFS_REQ_UNMOUNT:
#ifdef LENIX_DEBUG
- puts("[vfs] handling UNMOUNT");
+ VFS_PUTS("[vfs] handling UNMOUNT");
#endif
vfs_respond_unmount(req);
break;
case IPC_VFS_REQ_GETMOUNTS:
#ifdef LENIX_DEBUG
- puts("[vfs] handling GETMOUNTS");
+ VFS_PUTS("[vfs] handling GETMOUNTS");
#endif
vfs_respond_getmounts(req);
break;
case IPC_VFS_REQ_LOOKUP:
#ifdef LENIX_DEBUG
- puts("[vfs] handling LOOKUP");
+ VFS_PUTS("[vfs] handling LOOKUP");
#endif
vfs_respond_lookup(req);
break;
vfs_respond_mkfifo(req);
break;
default:
- puts("[vfs] unknown opcode=");
+ VFS_PUTS("[vfs] unknown opcode=");
vfs_write_u64(req->opcode);
puts(" token=");
vfs_write_u64(req->token);
/* Anchor the tail padding so it survives --gc-sections. */
vfs_touch_bss_tail();
#ifdef LENIX_DEBUG
- puts("[vfs] main() called!");
+ VFS_PUTS("[vfs] main() called!");
#endif
vfs_init();
bootstrap = portal_get_bootstrap();
if (bootstrap == IPC_PORTAL_INVALID_HANDLE) {
- puts("[vfs] bootstrap handle invalid");
+ VFS_PUTS("[vfs] bootstrap handle invalid");
return 1;
}
/* Register VFS service with kernel */
#ifdef LENIX_DEBUG
- puts("[vfs] about to register");
+ VFS_PUTS("[vfs] about to register");
#endif
rc = -1;
uint64_t reg_start = vfs_monotonic_ms();
bootstrap = portal_get_bootstrap();
if (bootstrap == IPC_PORTAL_INVALID_HANDLE) {
if (attempt < 10 || (attempt % 100) == 0)
- puts("[vfs] register: bootstrap invalid; retrying...");
+ VFS_PUTS("[vfs] register: bootstrap invalid; retrying...");
poll(NULL, 0, 1);
continue;
}
rc = vfs_register_service(bootstrap);
if (rc == 0) {
#ifdef LENIX_DEBUG
- puts("[vfs] registered with kernel");
+ VFS_PUTS("[vfs] registered with kernel");
#endif
break;
}
portal_handle_t svc = service_portal(LENIX_SERVICE_VFS);
if (svc != IPC_PORTAL_INVALID_HANDLE) {
#ifdef LENIX_DEBUG
- puts("[vfs] kernel reports VFS service available; continuing (fallback)");
+ VFS_PUTS("[vfs] kernel reports VFS service available; continuing (fallback)");
#endif
/* Warn: registration syscall failed but service portal exists */
- puts("[vfs] WARNING: using fallback VFS portal; check registration path");
+ VFS_PUTS("[vfs] WARNING: using fallback VFS portal; check registration path");
rc = 0;
break;
}
poll(NULL, 0, 1);
}
if (rc != 0) {
- puts("[vfs] FATAL: failed to register with kernel");
+ VFS_PUTS("[vfs] FATAL: failed to register with kernel");
return 1;
}
/* Register with namesvc for client discovery */
#ifdef LENIX_DEBUG
- puts("[vfs] registering with namesvc");
+ VFS_PUTS("[vfs] registering with namesvc");
#endif
vfs_register_with_namesvc(bootstrap);
#ifdef LENIX_DEBUG
- puts("[vfs] initialization complete");
+ VFS_PUTS("[vfs] initialization complete");
#endif
/* Main request processing loop with batch processing */
if (rc == 0) {
/* Registration succeeded */
#ifdef LENIX_DEBUG
- puts("[vfs] registered with namesvc");
+ VFS_PUTS("[vfs] registered with namesvc");
#endif
return;
}
vfs_log_rc("[vfs] namesvc_register rc=", rc);
}
if ((attempt % 100) == 0 && namesvc == IPC_PORTAL_INVALID_HANDLE)
- puts("[vfs] waiting for namesvc...");
+ VFS_PUTS("[vfs] waiting for namesvc...");
poll(NULL, 0, 1);
}
- puts("[vfs] WARNING: namesvc registration failed after 5000 attempts");
+ VFS_PUTS("[vfs] WARNING: namesvc registration failed after 5000 attempts");
}
static void
vfs_respond_close(const struct ipc_vfs_request *req)