Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6502

Linux kernel function returns 1 instead of EINVAL

$
0
0

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_status

in 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


Viewing all articles
Browse latest Browse all 6502

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>