Kerneltimerc

asmlinkage long sys_getuid(void) {

/* Only we change this so SMP safe */ return current->uid;

current is a pointer to the current instance of task_struct and is set automatically by the kernel. The above code returns the uid element (current user ID) of task_struct. It couldn't be simpler!

Of course, there are much more complicated system calls, some of which were discussed in preceding chapters. Implementation of the handler function itself is always short and compact. It is usual to transfer control to a more general kernel auxiliary function as soon as possible, as, for example, in the case of read.

Continue reading here: Fsreadwritec

Was this article helpful?

0 0