chown(2) vs lchown(2) and application breakage

Anders Hammarquist (iko@netg.se)
Tue, 26 May 1998 02:05:32 +0200


A few patch levels ago we were blessed with a lchown() syscall and chown()
started following symlinks (until that time chown() had really been an
lchown()). On the x86 and m68k (at least) lchown() eventually received the
same syscall number (16) as the old chown() and the new chown() got a new
syscall number. On the alpha, chown() is still 16 and lchown() is "new" (I
suspect this has to do with wanting to remain compatible with Digital
Unix).

For the past few days we've been having a discussion of what's right and
how to fix it on Debian's alpha port list (start reading at
http://www.debian.org/Lists-Archives/debian-alpha-9805/msg00060.html if
you are interested).

>From what I can see, the semantics change only affects programs that
expect chown() to act as lchown() (very few, but unfortunately the Debian
package tool dpkg is one of them). The syscall number change that has been
used on i386 and m68k only fix it for a libc that does not know about the
new lchown(), binaries that break with unchanged syscall numbers as on the
alpha will break on i386 and m68k when libc is recompiled with the new
syscall numbers.

This needs fixing (though exactly how may not be immediately obvious). To
me, any application that expects lchown() behaviour should call lchown().
Unfortunately this alone is not enough, since lchown() will fail with
ENOSYS on some architectures for kernels < 2.1.8x, so libc (or the
applications) need to call chown() iff lchown() fail with ENOSYS (I not
sure where would be cleanest, but I leaning towards libc).

On a related note, chown() will fail with ENOSYS with a libc compiled for >
2.1.8x on a kernel < 2.1.8x for those architectures that changed syscall
numbers unless it is handled in libc. Perhaps I should advocate that the
numbers be changed back? :-)

Regards,
/Anders

-- 
 -- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist   |       Mud at Kingdoms        | iko@netg.se
NetGuide Scandinavia |   telnet kingdoms.se 1812    | Fax: +46 31 50 79 39
http://www.netg.se   |                              | Tel: +46 31 50 79 40

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu