Posted Jan 20, 2013 14:08 UTC (Sun) by justincormack (subscriber, #70439)
Parent article: Making EPERM friendlier
I don't see why we can't just add more error codes. There are only about 132 error codes at the moment, and return values are 32 bit.
A high bit mask with more detailed information would suffice, so you get the traditional error code in the low 8 bits, then information about the error location in the kernel in other bits. The kernel could export a map of more detailed information, so you could match up (and document) the reasons.
Obviously this is a breaking change, so your binary might have to set some flag to get the extended bits from the kernel.
Posted Jan 20, 2013 15:44 UTC (Sun) by andreasb (subscriber, #80258)
[Link]
Setting a flag wouldn't work, I think. The main application might set the flag, but some library it has linked in might also make a syscall and get confused by the errno values.
Making EPERM friendlier
Posted Jan 20, 2013 18:59 UTC (Sun) by akeane (subscriber, #85436)
[Link]
It would if the flag was a #define directive the C lib header files picked up and you had a set of parallel syscalls in the kernel, behold:
_open is the normal one
__open_ret_32 is the OMG MORE ERROR CODEZ!!!
So, you need a set of extra syscalls in the kernel to add more info to the ret value, (luckily this will add even more lines of code and complexity to the kernel, what could go wrong? yay!)
and a switch in the C lib:
cc -o my_earthly_soul p_audio.cs -DOMGMOREERRNOSSUCKA
But this is assuming that anybody actually goes around checking error codes in this modern era; no one really bothers anyway; if it's a real problem and not just the kernel nagging at you then something else will break properly later on and you get a nice SEGV which you can blame on a third party device driver.
It also becomes increasing difficult to add additional lines of error checking code when you reach a certain age, and your monocle has seen better days (also you waste valuable bytes on your winchester disk)
I stand by my assertion that only two ERR codes are necessary in your typical unix warez:
fd = open("~/Music/a-dreadful-din.mp1");
#ifdef YOUNG_PERSON
if(fd == E:-) )
return cool;
if(fd == E:-( ))
return opens_gonna_hate;
#endif
#ifdef MOI
if(fd == EAKEANE) /* Clearly a measure of success */
{
/* Remove rubbish modern so-called "music" */
unlink("~/Music");
/* Check for errors from unlink? nah... */
return heh!;
}
if(fd == EGETOFFMYLAWN)
unlink("~"); /* There's probably some bad music there somewhere */
#endif
Making EPERM friendlier
Posted Jan 20, 2013 19:03 UTC (Sun) by jreiser (subscriber, #11027)
[Link]
The current scheme used by the linux kernel for error return codes from a syscall allows only 4095 error codes (0xFFF...F001 through 0xFFF...FFFF) because any other bit pattern could be a legitimate non-error return value.
Making EPERM friendlier
Posted Jan 20, 2013 20:02 UTC (Sun) by justincormack (subscriber, #70439)
[Link]
Good point. Thats probably still enough to distinguish all the error points for a particular syscall, but it is more of a squeeze.