diff options
Diffstat (limited to 'guts')
-rw-r--r-- | guts/__fxstat64.c | 2 | ||||
-rw-r--r-- | guts/__fxstatat64.c | 2 | ||||
-rw-r--r-- | guts/__xmknodat.c | 5 | ||||
-rw-r--r-- | guts/chdir.c | 10 | ||||
-rw-r--r-- | guts/close.c | 2 | ||||
-rw-r--r-- | guts/dup.c | 2 | ||||
-rw-r--r-- | guts/dup2.c | 4 | ||||
-rw-r--r-- | guts/fchdir.c | 2 | ||||
-rw-r--r-- | guts/fchmod.c | 2 | ||||
-rw-r--r-- | guts/fchmodat.c | 4 | ||||
-rw-r--r-- | guts/fchown.c | 4 | ||||
-rw-r--r-- | guts/fchownat.c | 4 | ||||
-rw-r--r-- | guts/fclose.c | 2 | ||||
-rw-r--r-- | guts/fcntl.c | 2 | ||||
-rw-r--r-- | guts/fopen.c | 6 | ||||
-rw-r--r-- | guts/fopen64.c | 7 | ||||
-rw-r--r-- | guts/freopen.c | 6 | ||||
-rw-r--r-- | guts/get_current_dir_name.c | 15 | ||||
-rw-r--r-- | guts/getcwd.c | 40 | ||||
-rw-r--r-- | guts/getwd.c | 18 | ||||
-rw-r--r-- | guts/lchown.c | 11 | ||||
-rw-r--r-- | guts/link.c | 4 | ||||
-rw-r--r-- | guts/mkdirat.c | 2 | ||||
-rw-r--r-- | guts/mkstemp.c | 27 | ||||
-rw-r--r-- | guts/openat.c | 6 | ||||
-rw-r--r-- | guts/rename.c | 10 | ||||
-rw-r--r-- | guts/rmdir.c | 2 | ||||
-rw-r--r-- | guts/symlink.c | 4 | ||||
-rw-r--r-- | guts/symlinkat.c | 13 | ||||
-rw-r--r-- | guts/unlinkat.c | 11 |
30 files changed, 168 insertions, 61 deletions
diff --git a/guts/__fxstat64.c b/guts/__fxstat64.c index 59f8a59..2e7919c 100644 --- a/guts/__fxstat64.c +++ b/guts/__fxstat64.c @@ -16,7 +16,7 @@ errno = save_errno; return rc; } - msg = pseudo_client_op(OP_FSTAT, 0, fd, -1, 0, buf); + msg = pseudo_client_op(OP_FSTAT, fd, -1, 0, buf); if (msg) { if (msg->result == RESULT_SUCCEED) pseudo_stat_msg(buf, msg); diff --git a/guts/__fxstatat64.c b/guts/__fxstatat64.c index 3edd8c7..b8054f2 100644 --- a/guts/__fxstatat64.c +++ b/guts/__fxstatat64.c @@ -56,7 +56,7 @@ * note that symlink canonicalizing is now automatic, so we * don't need to check for a symlink on this end */ - msg = pseudo_client_op(OP_STAT, flags, -1, dirfd, path, buf); + msg = pseudo_client_op(OP_STAT, -1, dirfd, path, buf); if (msg) { pseudo_stat_msg(buf, msg); if (save_mode) { diff --git a/guts/__xmknodat.c b/guts/__xmknodat.c index a86d6aa..6bd0761 100644 --- a/guts/__xmknodat.c +++ b/guts/__xmknodat.c @@ -30,8 +30,9 @@ rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL, PSEUDO_FS_MODE(mode)); #endif - if (rc == -1) + if (rc == -1) { return -1; + } real___fxstat64(_STAT_VER, rc, &buf); /* mknod does not really open the file. We don't have * to use wrap_close because we've never exposed this file @@ -43,7 +44,7 @@ buf.st_mode = (PSEUDO_DB_MODE(buf.st_mode, mode) & 07777) | (mode & ~07777); buf.st_rdev = *dev; - msg = pseudo_client_op(OP_MKNOD, AT_SYMLINK_NOFOLLOW, -1, dirfd, path, &buf); + msg = pseudo_client_op(OP_MKNOD, -1, dirfd, path, &buf); if (!msg) { errno = ENOSYS; rc = -1; diff --git a/guts/chdir.c b/guts/chdir.c index b910060..ca48738 100644 --- a/guts/chdir.c +++ b/guts/chdir.c @@ -3,11 +3,17 @@ * wrap_chdir(const char *path) { * int rc = -1; */ - pseudo_debug(3, "chdir: %s\n", path ? path : "<nil>"); + pseudo_debug(2, "chdir: '%s'\n", + path ? path : "<nil>"); + + if (!path) { + errno = EFAULT; + return -1; + } rc = real_chdir(path); if (rc != -1) { - pseudo_client_op(OP_CHDIR, 0, -1, -1, path, 0); + pseudo_client_op(OP_CHDIR, -1, -1, path, 0); } /* return rc; diff --git a/guts/close.c b/guts/close.c index 8edbee9..34b279e 100644 --- a/guts/close.c +++ b/guts/close.c @@ -6,7 +6,7 @@ /* this cleans up an internal table, and shouldn't even * make it to the server. */ - pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0); + pseudo_client_op(OP_CLOSE, fd, -1, 0, 0); rc = real_close(fd); /* return rc; @@ -8,7 +8,7 @@ rc = real_dup(fd); save_errno = errno; pseudo_debug(2, "dup: %d->%d\n", fd, rc); - pseudo_client_op(OP_DUP, 0, fd, rc, 0, 0); + pseudo_client_op(OP_DUP, fd, rc, 0, 0); errno = save_errno; /* return rc; diff --git a/guts/dup2.c b/guts/dup2.c index 360c3ad..59d5293 100644 --- a/guts/dup2.c +++ b/guts/dup2.c @@ -8,10 +8,10 @@ /* close existing one first - this also causes the socket to the * server to get moved around if someone tries to overwrite it. */ pseudo_debug(2, "dup2: %d->%d\n", oldfd, newfd); - pseudo_client_op(OP_CLOSE, 0, newfd, -1, 0, 0); + pseudo_client_op(OP_CLOSE, newfd, -1, 0, 0); rc = real_dup2(oldfd, newfd); save_errno = errno; - pseudo_client_op(OP_DUP, 0, oldfd, newfd, 0, 0); + pseudo_client_op(OP_DUP, oldfd, newfd, 0, 0); errno = save_errno; /* return rc; diff --git a/guts/fchdir.c b/guts/fchdir.c index 5289f4c..b255511 100644 --- a/guts/fchdir.c +++ b/guts/fchdir.c @@ -7,7 +7,7 @@ rc = real_fchdir(dirfd); if (rc != -1) { - pseudo_client_op(OP_CHDIR, 0, -1, dirfd, 0, 0); + pseudo_client_op(OP_CHDIR, -1, dirfd, 0, 0); } /* return rc; diff --git a/guts/fchmod.c b/guts/fchmod.c index df2f9e9..663a026 100644 --- a/guts/fchmod.c +++ b/guts/fchmod.c @@ -12,7 +12,7 @@ return -1; } buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_FCHMOD, 0, fd, -1, 0, &buf); + msg = pseudo_client_op(OP_FCHMOD, fd, -1, 0, &buf); real_fchmod(fd, PSEUDO_FS_MODE(mode)); if (!msg) { errno = ENOSYS; diff --git a/guts/fchmodat.c b/guts/fchmodat.c index 36bd4d1..9804711 100644 --- a/guts/fchmodat.c +++ b/guts/fchmodat.c @@ -33,7 +33,7 @@ /* purely for debugging purposes: check whether file * is already in database. */ - msg = pseudo_client_op(OP_STAT, flags, -1, -1, path, &buf); + msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf); if (!msg || msg->result != RESULT_SUCCEED) { pseudo_debug(2, "chmodat to 0%o on %d/%s, ino %llu, new file.\n", mode, dirfd, path, (unsigned long long) buf.st_ino); @@ -54,7 +54,7 @@ */ buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_CHMOD, flags, -1, dirfd, path, &buf); + msg = pseudo_client_op(OP_CHMOD, -1, dirfd, path, &buf); if (!msg) { errno = ENOSYS; rc = -1; diff --git a/guts/fchown.c b/guts/fchown.c index 4d420c8..53a34de 100644 --- a/guts/fchown.c +++ b/guts/fchown.c @@ -15,7 +15,7 @@ return -1; } if (owner == -1 || group == -1) { - msg = pseudo_client_op(OP_STAT, 0, fd, -1, NULL, &buf); + msg = pseudo_client_op(OP_STAT, fd, -1, NULL, &buf); /* copy in any existing values... */ if (msg) { if (msg->result == RESULT_SUCCEED) { @@ -38,7 +38,7 @@ } pseudo_debug(2, "fchown, fd %d: %d:%d -> %d:%d\n", fd, owner, group, buf.st_uid, buf.st_gid); - msg = pseudo_client_op(OP_FCHOWN, 0, fd, -1, 0, &buf); + msg = pseudo_client_op(OP_FCHOWN, fd, -1, 0, &buf); if (!msg) { errno = ENOSYS; rc = -1; diff --git a/guts/fchownat.c b/guts/fchownat.c index 8d24d3e..181fa6d 100644 --- a/guts/fchownat.c +++ b/guts/fchownat.c @@ -30,7 +30,7 @@ } save_errno = errno; - msg = pseudo_client_op(OP_STAT, flags, -1, -1, path, &buf); + msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf); /* copy in any existing values... */ if (msg) { if (msg->result == RESULT_SUCCEED) { @@ -48,7 +48,7 @@ if (group != -1) { buf.st_gid = group; } - msg = pseudo_client_op(OP_CHOWN, flags, -1, dirfd, path, &buf); + msg = pseudo_client_op(OP_CHOWN, -1, dirfd, path, &buf); if (!msg) { errno = ENOSYS; rc = -1; diff --git a/guts/fclose.c b/guts/fclose.c index e0c5681..bcf4ace 100644 --- a/guts/fclose.c +++ b/guts/fclose.c @@ -9,7 +9,7 @@ return -1; } int fd = fileno(fp); - pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0); + pseudo_client_op(OP_CLOSE, fd, -1, 0, 0); rc = real_fclose(fp); /* return rc; diff --git a/guts/fcntl.c b/guts/fcntl.c index d03d40c..ec7277d 100644 --- a/guts/fcntl.c +++ b/guts/fcntl.c @@ -22,7 +22,7 @@ save_errno = errno; if (rc != -1) { pseudo_debug(2, "fcntl_dup: %d->%d\n", fd, rc); - pseudo_client_op(OP_DUP, 0, fd, rc, 0, 0); + pseudo_client_op(OP_DUP, fd, rc, 0, 0); } errno = save_errno; break; diff --git a/guts/fopen.c b/guts/fopen.c index 2aae54c..6495d69 100644 --- a/guts/fopen.c +++ b/guts/fopen.c @@ -16,13 +16,13 @@ pseudo_debug(2, "fopen '%s': fd %d\n", path, fd); if (real___fxstat64(_STAT_VER, fd, &buf) != -1) { if (!existed) { - pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); + pseudo_client_op(OP_CREAT, -1, -1, path, &buf); } - pseudo_client_op(OP_OPEN, 0, fd, -1, path, &buf); + pseudo_client_op(OP_OPEN, fd, -1, path, &buf); } else { pseudo_debug(1, "fopen (fd %d) succeeded, but fstat failed (%s).\n", fd, strerror(errno)); - pseudo_client_op(OP_OPEN, 0, fd, -1, path, 0); + pseudo_client_op(OP_OPEN, fd, -1, path, 0); } errno = save_errno; } diff --git a/guts/fopen64.c b/guts/fopen64.c index 0b0ab58..c6de09c 100644 --- a/guts/fopen64.c +++ b/guts/fopen64.c @@ -5,6 +5,7 @@ */ struct stat64 buf; int save_errno; + int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); rc = real_fopen64(path, mode); @@ -16,13 +17,13 @@ pseudo_debug(2, "fopen64 '%s': fd %d\n", path, fd); if (real___fxstat64(_STAT_VER, fd, &buf) != -1) { if (!existed) { - pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); + pseudo_client_op(OP_CREAT, -1, -1, path, &buf); } - pseudo_client_op(OP_OPEN, 0, fd, -1, path, &buf); + pseudo_client_op(OP_OPEN, fd, -1, path, &buf); } else { pseudo_debug(1, "fopen64 (fd %d) succeeded, but fstat failed (%s).\n", fd, strerror(errno)); - pseudo_client_op(OP_OPEN, 0, fd, -1, path, 0); + pseudo_client_op(OP_OPEN, fd, -1, path, 0); } errno = save_errno; } diff --git a/guts/freopen.c b/guts/freopen.c index 312bc0a..92c9d87 100644 --- a/guts/freopen.c +++ b/guts/freopen.c @@ -16,13 +16,13 @@ pseudo_debug(2, "freopen '%s': fd %d\n", path, fd); if (real___fxstat64(_STAT_VER, fd, &buf) != -1) { if (!existed) { - pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); + pseudo_client_op(OP_CREAT, -1, -1, path, &buf); } - pseudo_client_op(OP_OPEN, 0, fd, -1, path, &buf); + pseudo_client_op(OP_OPEN, fd, -1, path, &buf); } else { pseudo_debug(1, "fopen (fd %d) succeeded, but stat failed (%s).\n", fd, strerror(errno)); - pseudo_client_op(OP_OPEN, 0, fd, -1, path, 0); + pseudo_client_op(OP_OPEN, fd, -1, path, 0); } errno = save_errno; } diff --git a/guts/get_current_dir_name.c b/guts/get_current_dir_name.c new file mode 100644 index 0000000..671c5dc --- /dev/null +++ b/guts/get_current_dir_name.c @@ -0,0 +1,15 @@ +/* + * static char * + * wrap_get_current_dir_name(void) { + * char * rc = NULL; + */ + + pseudo_debug(3, "get_current_dir_name (getcwd)\n"); + /* this relies on a Linux extension, but we dutifully + * emulated that extension. + */ + rc = wrap_getcwd(NULL, 0); + +/* return rc; + * } + */ diff --git a/guts/getcwd.c b/guts/getcwd.c new file mode 100644 index 0000000..d8f4d36 --- /dev/null +++ b/guts/getcwd.c @@ -0,0 +1,40 @@ +/* + * static char * + * wrap_getcwd(char *buf, size_t size) { + * char * rc = NULL; + */ + pseudo_debug(2, "wrap_getcwd: %p, %lu\n", + (void *) buf, (unsigned long) size); + if (!pseudo_cwd) { + pseudo_diag("Asked for CWD, but don't have it!\n"); + errno = EACCES; + return NULL; + } + /* emulate Linux semantics in case of non-Linux systems. */ + if (!buf) { + /* if we don't have one, something's very wrong... */ + if (!size) { + size = pseudo_cwd_len; + } + if (size) { + buf = malloc(size); + } else { + pseudo_diag("can't figure out CWD: length %ld\n", + (unsigned long) pseudo_cwd_len); + } + if (!buf) { + pseudo_diag("couldn't allocate requested CWD buffer - need %ld byes\n", + (unsigned long) size); + errno = ENOMEM; + return NULL; + } + } + rc = buf; + memcpy(buf, pseudo_cwd, pseudo_cwd_len + 1); + if (!*buf) { + strcpy(buf, "/"); + } + +/* return rc; + * } + */ diff --git a/guts/getwd.c b/guts/getwd.c new file mode 100644 index 0000000..2bac467 --- /dev/null +++ b/guts/getwd.c @@ -0,0 +1,18 @@ +/* + * static char * + * wrap_getwd(char *buf) { + * char * rc = NULL; + */ + + pseudo_debug(3, "getwd (getcwd)\n"); + rc = wrap_getcwd(buf, pseudo_path_max()); + /* because it would violate everything we have ever known about + * UNIX for these functions to have the same errno semantics, + * that's why. + */ + if (rc == NULL && errno == ERANGE ) + errno = ENAMETOOLONG; + +/* return rc; + * } + */ diff --git a/guts/lchown.c b/guts/lchown.c index 6f7e53a..2d0aff2 100644 --- a/guts/lchown.c +++ b/guts/lchown.c @@ -4,14 +4,17 @@ */ pseudo_msg_t *msg; struct stat64 buf; - + if (!path) { + errno = EFAULT; + return -1; + } pseudo_debug(2, "lchown(%s, %d, %d)\n", - path ? path : "<null>", owner, group); + path ? path : "<nil>", owner, group); if (real___lxstat64(_STAT_VER, path, &buf) == -1) { return -1; } if (owner == -1 || group == -1) { - msg = pseudo_client_op(OP_STAT, AT_SYMLINK_NOFOLLOW, -1, -1, path, &buf); + msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf); /* copy in any existing values... */ if (msg) { if (msg->result == RESULT_SUCCEED) { @@ -32,7 +35,7 @@ if (group != -1) { buf.st_gid = group; } - msg = pseudo_client_op(OP_CHOWN, AT_SYMLINK_NOFOLLOW, -1, -1, path, &buf); + msg = pseudo_client_op(OP_CHOWN, -1, -1, path, &buf); if (!msg) { errno = ENOSYS; rc = -1; diff --git a/guts/link.c b/guts/link.c index 278edd7..a68a1c1 100644 --- a/guts/link.c +++ b/guts/link.c @@ -17,11 +17,11 @@ * there is one. OP_LINK is also used to insert unseen * files, though, so it can't be implicit. */ - msg = pseudo_client_op(OP_STAT, 0, -1, -1, oldpath, &buf); + msg = pseudo_client_op(OP_STAT, -1, -1, oldpath, &buf); if (msg) { pseudo_stat_msg(&buf, msg); } - pseudo_client_op(OP_LINK, 0, -1, -1, newpath, &buf); + pseudo_client_op(OP_LINK, -1, -1, newpath, &buf); } /* return rc; diff --git a/guts/mkdirat.c b/guts/mkdirat.c index a5ae5d8..188e66b 100644 --- a/guts/mkdirat.c +++ b/guts/mkdirat.c @@ -22,7 +22,7 @@ stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, AT_SYMLINK_NOFOLLOW); #endif if (stat_rc != -1) { - pseudo_client_op(OP_MKDIR, AT_SYMLINK_NOFOLLOW, -1, dirfd, path, &buf); + pseudo_client_op(OP_MKDIR, -1, dirfd, path, &buf); } else { pseudo_debug(1, "mkdir of %s succeeded, but stat failed: %s\n", path, strerror(errno)); diff --git a/guts/mkstemp.c b/guts/mkstemp.c index b339b5c..a8f5915 100644 --- a/guts/mkstemp.c +++ b/guts/mkstemp.c @@ -5,21 +5,40 @@ */ struct stat64 buf; int save_errno; + size_t len; + char *tmp_template; - rc = real_mkstemp(template); + if (!template) { + errno = EFAULT; + return 0; + } + + len = strlen(template); + tmp_template = PSEUDO_ROOT_PATH(AT_FDCWD, template, AT_SYMLINK_NOFOLLOW); + + if (!tmp_template) { + errno = ENOENT; + return -1; + } + + rc = real_mkstemp(tmp_template); if (rc != -1) { save_errno = errno; + if (real___fxstat64(_STAT_VER, rc, &buf) != -1) { - pseudo_client_op(OP_CREAT, 0, -1, -1, template, &buf); - pseudo_client_op(OP_OPEN, 0, rc, -1, template, &buf); + pseudo_client_op(OP_CREAT, -1, -1, tmp_template, &buf); + pseudo_client_op(OP_OPEN, rc, -1, tmp_template, &buf); } else { pseudo_debug(1, "mkstemp (fd %d) succeeded, but fstat failed (%s).\n", rc, strerror(errno)); - pseudo_client_op(OP_OPEN, 0, rc, -1, template, 0); + pseudo_client_op(OP_OPEN, rc, -1, tmp_template, 0); } errno = save_errno; } + /* mkstemp only changes the XXXXXX at the end. */ + memcpy(template + len - 6, tmp_template + strlen(tmp_template) - 6, 6); + free(tmp_template); /* return rc; * } */ diff --git a/guts/openat.c b/guts/openat.c index 9475aeb..801f1e3 100644 --- a/guts/openat.c +++ b/guts/openat.c @@ -48,13 +48,13 @@ if (stat_rc != -1) { buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode); if (!existed) { - pseudo_client_op(OP_CREAT, 0, -1, dirfd, path, &buf); + pseudo_client_op(OP_CREAT, -1, dirfd, path, &buf); } - pseudo_client_op(OP_OPEN, 0, rc, dirfd, path, &buf); + pseudo_client_op(OP_OPEN, rc, dirfd, path, &buf); } else { pseudo_debug(1, "openat (fd %d, path %d/%s, flags %d) succeeded, but stat failed (%s).\n", rc, dirfd, path, flags, strerror(errno)); - pseudo_client_op(OP_OPEN, 0, rc, dirfd, path, 0); + pseudo_client_op(OP_OPEN, rc, dirfd, path, 0); } errno = save_errno; } diff --git a/guts/rename.c b/guts/rename.c index 9dd6d99..117eb78 100644 --- a/guts/rename.c +++ b/guts/rename.c @@ -8,7 +8,7 @@ int oldrc, newrc; int save_errno; - pseudo_debug(1, "rename: %s->%s\n", + pseudo_debug(2, "rename: %s->%s\n", oldpath ? oldpath : "<nil>", newpath ? newpath : "<nil>"); @@ -53,10 +53,10 @@ */ /* newpath must be removed. */ - pseudo_client_op(OP_UNLINK, AT_SYMLINK_NOFOLLOW, -1, -1, newpath, &newbuf); + pseudo_client_op(OP_UNLINK, -1, -1, newpath, &newbuf); /* fill in "correct" details from server */ - msg = pseudo_client_op(OP_STAT, AT_SYMLINK_NOFOLLOW, -1, -1, oldpath, &oldbuf); + msg = pseudo_client_op(OP_STAT, -1, -1, oldpath, &oldbuf); if (msg && msg->result == RESULT_SUCCEED) { pseudo_stat_msg(&oldbuf, msg); pseudo_debug(1, "renaming %s, got old mode of 0%o\n", oldpath, (int) msg->mode); @@ -67,9 +67,9 @@ */ pseudo_debug(1, "renaming new '%s' [%llu]\n", oldpath, (unsigned long long) oldbuf.st_ino); - pseudo_client_op(OP_LINK, AT_SYMLINK_NOFOLLOW, -1, -1, oldpath, &oldbuf); + pseudo_client_op(OP_LINK, -1, -1, oldpath, &oldbuf); } - pseudo_client_op(OP_RENAME, AT_SYMLINK_NOFOLLOW, -1, -1, newpath, &oldbuf, oldpath); + pseudo_client_op(OP_RENAME, -1, -1, newpath, &oldbuf, oldpath); errno = save_errno; /* return rc; diff --git a/guts/rmdir.c b/guts/rmdir.c index 029e5a2..94de46a 100644 --- a/guts/rmdir.c +++ b/guts/rmdir.c @@ -13,7 +13,7 @@ rc = real_rmdir(path); save_errno = errno; if (rc != -1) { - pseudo_client_op(OP_UNLINK, AT_SYMLINK_NOFOLLOW, -1, -1, path, &buf); + pseudo_client_op(OP_UNLINK, -1, -1, path, &buf); } errno = save_errno; diff --git a/guts/symlink.c b/guts/symlink.c index bc1c4be..324fef7 100644 --- a/guts/symlink.c +++ b/guts/symlink.c @@ -1,10 +1,10 @@ /* * static int - * wrap_symlink(const char *oldpath, const char *newpath) { + * wrap_symlink(const char *oldname, const char *newpath) { * int rc = -1; */ - rc = wrap_symlinkat(oldpath, AT_FDCWD, newpath); + rc = wrap_symlinkat(oldname, AT_FDCWD, newpath); /* return rc; * } diff --git a/guts/symlinkat.c b/guts/symlinkat.c index 5f1cc59..df1df06 100644 --- a/guts/symlinkat.c +++ b/guts/symlinkat.c @@ -1,21 +1,23 @@ /* * static int - * wrap_symlinkat(const char *oldpath, int dirfd, const char *newpath) { + * wrap_symlinkat(const char *oldname, int dirfd, const char *newpath) { * int rc = -1; */ struct stat64 buf; + char *roldname = 0; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (dirfd != AT_FDCWD) { errno = ENOSYS; return -1; } - rc = real_symlink(oldpath, newpath); + rc = real_symlink(roldname ? roldname : oldname, newpath); #else - rc = real_symlinkat(oldpath, dirfd, newpath); + rc = real_symlinkat(roldname ? roldname : oldname, dirfd, newpath); #endif if (rc == -1) { + free(roldname); return rc; } #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS @@ -28,10 +30,13 @@ pseudo_diag("symlinkat: couldn't stat '%s' even though symlink creation succeeded (%s).\n", newpath, strerror(errno)); errno = save_errno; + free(roldname); return rc; } /* just record the entry */ - pseudo_client_op(OP_SYMLINK, AT_SYMLINK_NOFOLLOW, -1, dirfd, newpath, &buf); + pseudo_client_op(OP_SYMLINK, -1, dirfd, newpath, &buf); + + free(roldname); /* return rc; * } diff --git a/guts/unlinkat.c b/guts/unlinkat.c index cfa71e7..1c2868a 100644 --- a/guts/unlinkat.c +++ b/guts/unlinkat.c @@ -1,6 +1,6 @@ /* * static int - * wrap_unlinkat(int dirfd, const char *path, int flags) { + * wrap_unlinkat(int dirfd, const char *path, int rflags) { * int rc = -1; */ #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS @@ -8,18 +8,17 @@ errno = ENOSYS; return -1; } - if (flags) { + if (rflags) { /* the only supported flag is AT_REMOVEDIR. We'd never call * with that flag unless the real AT functions exist, so * something must have gone horribly wrong.... */ pseudo_diag("wrap_unlinkat called with flags (0x%x), path '%s'\n", - flags, path ? path : "<nil>"); + rflags, path ? path : "<nil>"); errno = ENOSYS; return -1; } #endif - struct stat64 buf; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS @@ -33,10 +32,10 @@ #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS rc = real_unlink(path); #else - rc = real_unlinkat(dirfd, path, flags); + rc = real_unlinkat(dirfd, path, rflags); #endif if (rc != -1) { - pseudo_client_op(OP_UNLINK, AT_SYMLINK_NOFOLLOW, -1, dirfd, path, &buf); + pseudo_client_op(OP_UNLINK, -1, dirfd, path, &buf); } /* return rc; |