For example, i want to create a file named "example.txt" and write "Hello world!" into it. In theory, I can write something like that:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/systm.h>
#include <mach/mach_types.h>
kern_return_t examplekext_start(kmod_info_t * ki, void *d);
kern_return_t examplekext_stop(kmod_info_t *ki, void *d);
kern_return_t examplekext_start(kmod_info_t * ki, void *d)
{
char const *hw = "Hello world!";
FILE *xmpl = fopen("/example.txt", "w");
int *s = fwrite(hw, strlen(hw), 1, xmpl);
if (s == 1) return KERN_SUCCESS;
else return KERN_FAILURE;
}
kern_return_t examplekext_stop(kmod_info_t *ki, void *d)
{
return KERN_SUCCESS;
}
But, if I will try to build & run something like that, I will get an error: "stdio.h file not found". So, the question is how can I do that? Is there an another lib for working with file system or something like that? Or that is impossible to do from a kernel extension?