2014-06-08 10:51:01 +04:00
|
|
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
2014-06-08 10:58:31 +04:00
|
|
|
* This file is part of ToaruOS and is released under the terms
|
2014-06-08 10:13:29 +04:00
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
|
|
|
* Copyright (C) 2014 Kevin Lange
|
|
|
|
*/
|
2014-03-19 09:57:07 +04:00
|
|
|
#include <system.h>
|
|
|
|
#include <module.h>
|
|
|
|
#include <fs.h>
|
2014-04-06 03:36:17 +04:00
|
|
|
#include <printf.h>
|
2014-03-19 09:57:07 +04:00
|
|
|
#include <mod/shell.h>
|
|
|
|
|
|
|
|
DEFINE_SHELL_FUNCTION(testwrite, "Test write") {
|
|
|
|
|
|
|
|
fs_node_t * f = NULL;
|
|
|
|
char * file = "/dev/hdb";
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
file = argv[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
f = kopen(file, 0);
|
|
|
|
|
|
|
|
if (!f) {
|
2014-04-06 03:12:09 +04:00
|
|
|
fprintf(tty, "No device: %s\n", file);
|
2014-03-19 09:57:07 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * s = malloc(1024);
|
|
|
|
|
|
|
|
sprintf(s, "Hello World!");
|
|
|
|
|
|
|
|
write_fs(f, 0, strlen(s), (uint8_t *)s);
|
|
|
|
write_fs(f, 2, strlen(s), (uint8_t *)s);
|
|
|
|
write_fs(f, 523, strlen(s), (uint8_t *)s);
|
|
|
|
|
|
|
|
write_fs(f, 1024*12, 1024, (uint8_t *)s);
|
|
|
|
|
|
|
|
free(s);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int init(void) {
|
|
|
|
BIND_SHELL_FUNCTION(testwrite);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fini(void) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_DEF(testwrite, init, fini);
|
|
|
|
MODULE_DEPENDS(debugshell);
|