[EMAIL PROTECTED] wrote:
> Note, though, that much of the *at functions can be implemented as
> follows:
>
> int
> fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag)
> {
> char *buf;
> size_t len = snprintf(buf, 0, "/proc/self/fd/%d/%s", fd, path);
> buf = alloca(len + 1);
> (void) snprintf(buf, len + 1, "/proc/self/fd/%d/%s", fd, path);
>
> if (flag == SYMLNK) {
> return (lchown(buf, owner, group));
> else {
> return (chown(buf, owner, group));
> }
> }
The problem with this function is that it does not give you what you expect:
access to long path names.
"/proc/self/fd/%d" is a symlink and for this reason, the whole path resolution
is still done as if you did call open(2) with the complete long path.
Note: for portable software, you cannot asume that "/proc/self/fd/%d" works at
all. For this reason, you need to have a fallback solution in a portable source
anyway. I see no advantage in your code.
Jörg
--
EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
[EMAIL PROTECTED] (uni)
[EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code