I'm trying to add a new system call to linux kernel:
asmlinkage long sys_set_status(int status) { if ((status != 0) && (status != 1)) return -EINVAL; //-22 current->status = status; return 0;}in syscall_64.tbl it is declared:
334 common set_status sys_set_statusin syscalls.h it is declared:
asmlinkage long sys_set_status(int status);but when i test the return value:
int set_status(int status) { long r = syscall(334, status); return (int)r;}int main() { int res = set_status(-1); //illegal status, should return -EINVAL whish is -22 cout << "return value is: " << res << endl; return 0;}i get:
return value is: -1