From: BlaisorBlade <bla...@ya...> - 2003-10-15 19:14:34
|
I posted this patch some time ago, but it was hidden inside an unrelated thread, then it seemed not to be noticed. So I'll repost it forever, like if this were the main LKML. This patch applies to .22-[345]um **Description** On the i386 arch(and I think others, too) the translation from return value(of calls like open(), fork()...) to errno setting is done in include/asm-i386/unistd.h. Instead, UML doesn't do it. I'm posting a patch to correct this in include/asm-um/unistd.h for mainline, but I think that parts of the rest of Uml will have to be changed, probably, to conform to the new(and correct) semantic. However, I've checked the code and it seems that already it wants the "new" behaviour(the other archs already have this). Note I'm aware of the difference between errno and kernel_errno(understood the Makefile stuff concerning it). The patch I'm posting corrects only 1 use of errno, but it's about the user space errno. **Why it IS needed** Code inside the kernel relies on this behaviour. It's a things archs must do. So, it will have to end up in. **Tested** Yes, it's straightforward and also works. Stability seems ok. **Applies cleanly** Yes, fine, to all the 3 versions I spoke upon. Use -p1 for patch. **Could need changes?** Some(not all) archs, in include/asm/unistd.h(they all have a errno handling path like the one this patch adds) also check that return value is >=-125. Quoting from the i386 one: /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */ #define __syscall_return(type, res) \ do { \ if ((unsigned long)(res) >= (unsigned long)(-125)) { \ //Note the check! errno = -(res); \ res = -1; \ } \ return (type) (res); \ } while (0) This is done somewhere, and somewhere not. Additionally, there could be some doubts about casts and overflows of errno. Bye -- cat <<EOSIGN Paolo Giarrusso, aka Blaisorblade Linux Kernel 2.4.21/2.6.0-test on an i686; Linux registered user n. 292729 EOSIGN |