diff options
Diffstat (limited to 'src/fs/stdio.c')
-rw-r--r-- | src/fs/stdio.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/fs/stdio.c b/src/fs/stdio.c index 6cea2a3..e15003d 100644 --- a/src/fs/stdio.c +++ b/src/fs/stdio.c @@ -1,12 +1,32 @@ +/** + * @file stdio.c + * Filesystem module for handling stdio (stdout, stdin, stderr) + * + * Copyright (C) 2018 Clyne Sullivan + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + #include "stdio.h" #include <kernel/heap.h> #include <kernel/serial.h> void *stdio_open(const char *path); -int stdio_close(void *info); -uint32_t stdio_read(void *info, uint32_t count, uint8_t *buffer); -uint32_t stdio_write(void *info, uint32_t count, const uint8_t *buffer); +int stdio_close(vfs_file_info *info); +uint32_t stdio_read(vfs_file_info *info, uint32_t count, uint8_t *buffer); +uint32_t stdio_write(vfs_file_info *info, uint32_t count, const uint8_t *buffer); const vfs_volume_funcs stdio_funcs = { stdio_open, @@ -14,6 +34,7 @@ const vfs_volume_funcs stdio_funcs = { stdio_read, stdio_write, 0, // readdir + 0 // seek }; void *stdio_open(const char *path) @@ -30,14 +51,14 @@ void *stdio_open(const char *path) return id; } -int stdio_close(void *info) +int stdio_close(vfs_file_info *info) { // Nothing to do - free(info); + free(info->fsinfo); return 0; } -uint32_t stdio_read(void *info, uint32_t count, uint8_t *buffer) +uint32_t stdio_read(vfs_file_info *info, uint32_t count, uint8_t *buffer) { (void)info; (void)count; @@ -45,11 +66,11 @@ uint32_t stdio_read(void *info, uint32_t count, uint8_t *buffer) return 0; } -uint32_t stdio_write(void *info, uint32_t count, const uint8_t *buffer) +uint32_t stdio_write(vfs_file_info *info, uint32_t count, const uint8_t *buffer) { (void)info; for (uint32_t i = 0; i < count; i++) - serial_put(buffer[count]); + serial_put(buffer[i]); return count; } |