[PATCH][RFC] global errno considered harmful

Lennert Buytenhek
2001-12-30T16:06:53Z

Hi,

Is there any particular reason we need a global errno in the kernel
at all? (which, by the way, doesn't seem to be subject to any kind of
locking) It makes life for User Mode Linux somewhat more complicated than
it could be, and it generally just seems a bad idea. Half a dozen places
in the kernel call syscalls from kernel space (the asm/unistd.h
__KERNEL_SYSCALLS__ stubs), but it sounds way better to change that limited
number to check the syscall return code instead of errno.

It appears that only one syscall stub caller checks syscall return value
anyway (exec_usermodehelper in kernel/kmod.c), so removing errno is quite
painless. Referenced patch deletes all mention of a global errno from the
kernel, and fixes up callers where necessary. I had to change definition
of _syscallX in various asm/unistd.h's not to use errno which might break
some userland, but userland shouldn't be touching these anyway.

Only tested on i386. Feedback appreciated, particularly experiences on
non-i386.

http://www.math.leidenuniv.nl/~buytenh/errno_ectomy-1.diff (33kb)

cheers,
Lennert