I am trying to write a file in user space from keyboard interrupt module I am using vfs_write to write to file.
static char *key_names_caps[] = {
"-", "<ESC>",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=",
"<Backspace>", "<Tab>",
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
"[", "]", "<Enter>", "<LCtrl>",
"A", "S", "D", "F", "G", "H", "J", "K", "L", ";",
"'", "`", "<LShift>",
"\\", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/",
"<RShift>",
"<KP*>",
"<LAlt>", " ", "<CapsLock>",
"<F1>", "<F2>", "<F3>", "<F4>", "<F5>", "<F6>", "<F7>", "<F8>", "<F9>", "<F10>",
"<NumLock>", "<ScrollLock>",
"<KP7>", "<KP8>", "<KP9>",
"<KP->",
"<KP4>", "<KP5>", "<KP6>",
"<KP+>",
"<KP1>", "<KP2>", "<KP3>", "<KP0>",
"<KP.>",
"-", "-", "-",
"<F11>", "<F12>",
"-", "-", "-", "-", "-", "-", "-",
"<KPEnter>", "<RCtrl>", "<KP/>", "<SysRq>", "<RAlt>", "-",
"<Home>", "<Up>", "<PageUp>", "<Left>", "<Right>", "<End>", "<Down>",
"<PageDown>", "<Insert>", "<Delete>"
};
int file_write(struct file *file, unsigned long long offset, const char *data, unsigned int size)
{
mm_segment_t oldfs;
int ret;
oldfs = get_fs();
set_fs(get_ds());
ret = vfs_write(file, data, size, &offset);
set_fs(oldfs);
return ret;
}
static void write_byte_by_byte(char *pos[]) {
unsigned int count = 0;
while (*pos != '\0') {
count += 1;
pos++;
//printf("%c\n", *(pos++));
}
file_write(fp,0, (const char *)&pos, count);
}
But I am not able to read the file that is output by this vfs_write function. The file output is giving me garbage value. Also, can you tell me how I can write strings in the given array into the file written by vfs_write
I need to able to write <DELETE>
9
as characters into the file.