If BUF is null, return the size of buffer required.
authorroland <roland>
Fri, 29 Jul 1994 05:50:34 +0000 (05:50 +0000)
committerroland <roland>
Fri, 29 Jul 1994 05:50:34 +0000 (05:50 +0000)
sysdeps/mach/hurd/readlink.c

index bf7c518..5ce4a26 100644 (file)
@@ -57,7 +57,12 @@ DEFUN(__readlink, (path, buf, len),
       if (transp[translen - 1] == '\0')
        /* Remove the null terminator.  */
        --len;
-      memcpy (buf, transp + sizeof (_HURD_SYMLINK), len);
+      if (buf == NULL)
+       /* This call is just to find out how large a buffer is required.  */
+       len = translen - sizeof (_HURD_SYMLINK) - 1;
+      else
+       /* Copy into the user's buffer.  */
+       memcpy (buf, transp + sizeof (_HURD_SYMLINK), len);
     }
 
   if (transp != mybuf)