Task:
Write a small module that creates a proc entry that can be read or written. Text written is rot13 scrambled and can be read back with the same proc entry.
- Processing shall not be done within the proc write function, but delayed with a workqueue
- Take care of race conditions!
- No buffering etc. required; only the last written text can be read back.
Tips:
static void rot_buf(char *buf, int rotate)
{
int x;
for (x=0; buf[x] != '\0'; x++) {
if (islower (buf[x]))
buf[x] = ((buf[x] + rotate - 'a') % 26) + 'a';
else if (isupper (buf[x]))
buf[x] = ((buf[x] + rotate - 'A') % 26) + 'A';
else if (isdigit (buf[x]))
buf[x] = ((buf[x] + rotate - '0') % 10) + '0';
}
}
- c library functions:
include/linux/ctype.h