| 1 | /* $Id: symlink.c 1505 2004-09-12 19:40:29Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | *
|
|---|
| 4 | * symlink()
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright (c) 2004 knut st. osmundsen <[email protected]>
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of InnoTek LIBC.
|
|---|
| 10 | *
|
|---|
| 11 | * InnoTek LIBC is free software; you can redistribute it and/or modify
|
|---|
| 12 | * it under the terms of the GNU General Public License as published by
|
|---|
| 13 | * the Free Software Foundation; either version 2 of the License, or
|
|---|
| 14 | * (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * InnoTek LIBC is distributed in the hope that it will be useful,
|
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | * GNU General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU General Public License
|
|---|
| 22 | * along with InnoTek LIBC; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 | /*******************************************************************************
|
|---|
| 30 | * Header Files *
|
|---|
| 31 | *******************************************************************************/
|
|---|
| 32 | #include "libc-alias.h"
|
|---|
| 33 | #include <errno.h>
|
|---|
| 34 | #include <string.h>
|
|---|
| 35 | #include <unistd.h>
|
|---|
| 36 | #include <sys/stat.h>
|
|---|
| 37 | #include <sys/syslimits.h>
|
|---|
| 38 | #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_IO
|
|---|
| 39 | #include <InnoTekLIBC/logstrict.h>
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | /**
|
|---|
| 44 | * Softlinks a file.
|
|---|
| 45 | *
|
|---|
| 46 | * This is stub. It always fails.
|
|---|
| 47 | *
|
|---|
| 48 | * @returns 0 on success.
|
|---|
| 49 | * @returns -1 and errno on failure.
|
|---|
| 50 | * @param oldpath Path to the old (or current if you prefere) file.
|
|---|
| 51 | * @param newpath Path to the new file.
|
|---|
| 52 | */
|
|---|
| 53 | int _STD(symlink)(const char *oldpath, const char *newpath)
|
|---|
| 54 | {
|
|---|
| 55 | LIBCLOG_ENTER("oldpath=%p:{%s} newpath=%p:{%s}\n", (void *)oldpath, oldpath, (void *)newpath, newpath);
|
|---|
| 56 |
|
|---|
| 57 | /*
|
|---|
| 58 | * Validate input.
|
|---|
| 59 | */
|
|---|
| 60 | struct stat st;
|
|---|
| 61 | int rc = stat(oldpath, &st);
|
|---|
| 62 | if (rc)
|
|---|
| 63 | LIBCLOG_RETURN_INT(rc);
|
|---|
| 64 |
|
|---|
| 65 | rc = stat(newpath, &st);
|
|---|
| 66 | if (!rc)
|
|---|
| 67 | {
|
|---|
| 68 | errno = EEXIST;
|
|---|
| 69 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 70 | }
|
|---|
| 71 | if (errno != ENOENT)
|
|---|
| 72 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 73 |
|
|---|
| 74 | if (strlen(newpath) >= PATH_MAX)
|
|---|
| 75 | {
|
|---|
| 76 | errno = ENAMETOOLONG;
|
|---|
| 77 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | errno = ENOSYS;
|
|---|
| 81 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|