Ticket #8770: commit-562e46b-1143406443.diff

File commit-562e46b-1143406443.diff, 1.3 KB (added by przemub, 11 years ago)
  • src/system/libroot/posix/unistd/link.c

    commit 562e46b50217c99fcfa8ef0b2af71a5cead66803
    Author: Przemysław Buczkowski <przemub@yahoo.pl>
    Date:   Fri Jan 11 21:48:20 2013 +0100
    
        Correct errno return in link() function
    
    diff --git a/src/system/libroot/posix/unistd/link.c b/src/system/libroot/posix/unistd/link.c
    index 491e275..e7f977b 100644
    a b  
    11/*
    2  * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
     2 * Copyright 2002-2013, Axel Dörfler, axeld@pinc-software.de.
    33 * Distributed under the terms of the MIT License.
    44 */
    55
    unlinkat(int fd, const char *path, int flag)  
    7676int
    7777link(const char *toPath, const char *linkPath)
    7878{
    79     RETURN_AND_SET_ERRNO(_kern_create_link(-1, linkPath, -1, toPath, true));
     79    int status = _kern_create_link(-1, linkPath, -1, toPath, true);
     80    // Haiku -> POSIX error mapping
     81    switch (status) {
     82        case B_UNSUPPORTED:
     83            status = EPERM;
     84            break;
     85        case B_NO_MEMORY:
     86            status = ENOSPC;
     87            break;
     88        case B_READ_ONLY_DEVICE:
     89            status = EROFS;
     90            break;
     91        case B_CROSS_DEVICE_LINK:
     92            status = EXDEV;
     93            break;
     94        case B_ENTRY_NOT_FOUND:
     95            status = ENOENT;
     96            break;
     97        case B_NAME_TOO_LONG:
     98            status = ENAMETOOLONG;
     99            break;
     100    }
     101
     102    RETURN_AND_SET_ERRNO(status);
    80103}
    81104
    82105