Index Home About Blog
Date: 	Sat, 8 Dec 2001 10:00:00 -0800 (PST)
From: Linus Torvalds <torvalds@transmeta.com>
Subject: Re: [PATCH] fix for idiocy in mount_root cleanups.
Newsgroups: fa.linux.kernel

On Sat, 8 Dec 2001, Alexander Viro wrote:
>
> 	Change in question was s/do_mount/mount/.  Which is almost
> the same thing, except for one little detail:  mount(2) in case of
> error returns -1 and stores the error in errno.  do_mount(9), OTOH...

Don't use errno in the kernel. EVER. This is a bug, we should get rid of
it.

Please fix "mount()" instead.

"errno" is one of those few _really_ bad stupidities in UNIX. Linux has
fixed it, and doesn't use it internally, and never shall. Too bad that
user space has to fix up the _correct_ error code returning that the
kernel does, and turn it into the "errno" stupidity for backwards
compatibility.

(If you care why "errno" is stupid, just think about threading and
performance)

		Linus




Newsgroups: fa.linux.kernel
From: Linus Torvalds <torvalds@osdl.org>
Subject: Re: errno
Original-Message-ID: <Pine.LNX.4.58.0405032111450.1636@ppc970.osdl.org>
Date: Tue, 4 May 2004 04:17:10 GMT
Message-ID: <fa.gue1tu6.82oqpi@ifi.uio.no>

On Mon, 3 May 2004, Albert Cahalan wrote:
>
> The obvious fix would be to stuff errno into the
> task_struct, hmmm?

No. "errno" is one of those fundamentally broken things that should not
exist. It was wrong in original UNIX, it's wrong now.

The kernel usage comes not from the kernel wanting to use it per se (the
kernel has always used the "negative error" approach), but from some
misguided kernel modules using the user-space interfaces.

The Linux way of returning negative error numbers is much nicer. It's
inherently thread-safe, and it has no performance downsides. Of course, it
does depend on having enough of a result domain that you can always
separate error returns from good returns, but that's true in practice for
all system calls.

Too bad we can't fix broken calling conventions.

		Linus

Index Home About Blog