diff options
Diffstat (limited to 'guts')
138 files changed, 0 insertions, 3468 deletions
diff --git a/guts/__fxstat.c b/guts/__fxstat.c deleted file mode 100644 index db9716b..0000000 --- a/guts/__fxstat.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int - * wrap___fxstat(int ver, int fd, struct stat *buf) { - * int rc = -1; - */ - - struct stat64 buf64; - /* populate buffer with complete data */ - real___fxstat(ver, fd, buf); - /* obtain fake data */ - rc = wrap___fxstat64(ver, fd, &buf64); - /* overwrite */ - pseudo_stat32_from64(buf, &buf64); - -/* return rc; - * } - */ diff --git a/guts/__fxstat64.c b/guts/__fxstat64.c deleted file mode 100644 index 615926e..0000000 --- a/guts/__fxstat64.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int - * wrap___fxstat64(int ver, int fd, struct stat64 *buf) { - * int rc = -1; - */ - pseudo_msg_t *msg; - int save_errno; - - rc = real___fxstat64(ver, fd, buf); - save_errno = errno; - if (rc == -1) { - return rc; - } - if (ver != _STAT_VER) { - pseudo_debug(1, "version mismatch: got stat version %d, only supporting %d\n", ver, _STAT_VER); - errno = save_errno; - return rc; - } - msg = pseudo_client_op(OP_FSTAT, 0, fd, -1, 0, buf); - if (msg) { - if (msg->result == RESULT_SUCCEED) - pseudo_stat_msg(buf, msg); - } - - errno = save_errno; -/* return rc; - * } - */ diff --git a/guts/__fxstatat.c b/guts/__fxstatat.c deleted file mode 100644 index 94c5ff6..0000000 --- a/guts/__fxstatat.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___fxstatat(int ver, int dirfd, const char *path, struct stat *buf, int flags) { - * int rc = -1; - */ - - struct stat64 buf64; - /* populate buffer with complete data */ -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - if (flags & AT_SYMLINK_NOFOLLOW) { - rc = real___lxstat(ver, path, buf); - } else { - rc = real___xstat(ver, path, buf); - } -#else - real___fxstatat(ver, dirfd, path, buf, flags); -#endif - /* obtain fake data */ - rc = wrap___fxstatat64(ver, dirfd, path, &buf64, flags); - /* overwrite */ - pseudo_stat32_from64(buf, &buf64); - -/* return rc; - * } - */ diff --git a/guts/__fxstatat64.c b/guts/__fxstatat64.c deleted file mode 100644 index f8a9298..0000000 --- a/guts/__fxstatat64.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___fxstatat64(int ver, int dirfd, const char *path, struct stat64 *buf, int flags) { - * int rc = -1; - */ - pseudo_msg_t *msg; - int save_errno; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } -#endif - if (flags & AT_SYMLINK_NOFOLLOW) { -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___lxstat64(ver, path, buf); -#else - rc = real___fxstatat64(ver, dirfd, path, buf, flags); -#endif - if (rc == -1) { - return rc; - } - } else { -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___xstat64(ver, path, buf); -#else - rc = real___fxstatat64(ver, dirfd, path, buf, flags); -#endif - if (rc == -1) { - return rc; - } - } - save_errno = errno; - - if (ver != _STAT_VER) { - pseudo_debug(1, "version mismatch: got stat version %d, only supporting %d\n", ver, _STAT_VER); - errno = save_errno; - return rc; - } - - /* query database - * 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, 0, -1, dirfd, path, buf); - if (msg) { - pseudo_stat_msg(buf, msg); - } - - errno = save_errno; - -/* return rc; - * } - */ diff --git a/guts/__lxstat.c b/guts/__lxstat.c deleted file mode 100644 index 32b0301..0000000 --- a/guts/__lxstat.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___lxstat(int ver, const char *path, struct stat *buf) { - * int rc = -1; - */ - - rc = wrap___fxstatat(ver, AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); - -/* - * } - */ diff --git a/guts/__lxstat64.c b/guts/__lxstat64.c deleted file mode 100644 index ac1f782..0000000 --- a/guts/__lxstat64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___lxstat64(int ver, const char *path, struct stat64 *buf) { - * int rc = -1; - */ - - rc = wrap___fxstatat64(ver, AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); - -/* - * } - */ diff --git a/guts/__openat64_2.c b/guts/__openat64_2.c deleted file mode 100644 index 8772115..0000000 --- a/guts/__openat64_2.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___openat64_2(int dirfd, const char *path, int flags) { - * int rc = -1; - */ - - rc = wrap_openat(dirfd, path, flags, O_LARGEFILE); - -/* return rc; - * } - */ diff --git a/guts/__openat_2.c b/guts/__openat_2.c deleted file mode 100644 index 33ed620..0000000 --- a/guts/__openat_2.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___openat_2(int dirfd, const char *path, int flags) { - * int rc = -1; - */ - - rc = wrap_openat(dirfd, path, flags, 0); - -/* return rc; - * } - */ diff --git a/guts/__xmknod.c b/guts/__xmknod.c deleted file mode 100644 index fa31b66..0000000 --- a/guts/__xmknod.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___xmknod(int ver, const char *path, mode_t mode, dev_t *dev) { - * int rc = -1; - */ - - rc = wrap___xmknodat(ver, AT_FDCWD, path, mode, dev); - -/* return rc; - * } - */ diff --git a/guts/__xmknodat.c b/guts/__xmknodat.c deleted file mode 100644 index 7b4fc4b..0000000 --- a/guts/__xmknodat.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___xmknodat(int ver, int dirfd, const char *path, mode_t mode, dev_t *dev) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - - /* we don't use underlying call, so _ver is irrelevant to us */ - (void) ver; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - rc = real___xstat64(_STAT_VER, path, &buf); -#else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, AT_SYMLINK_NOFOLLOW); -#endif - if (rc != -1) { - /* if we can stat the file, you can't mknod it */ - errno = EEXIST; - return -1; - } - if (!dev) { - errno = EINVAL; - return -1; - } -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real_open(path, O_CREAT | O_WRONLY | O_EXCL, PSEUDO_FS_MODE(mode)); -#else - rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL, - PSEUDO_FS_MODE(mode)); -#endif - 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 - * descriptor to the client code. - */ - real_close(rc); - - /* mask in the mode type bits again */ - buf.st_mode = (PSEUDO_DB_MODE(buf.st_mode, mode) & 07777) | - (mode & ~07777); - buf.st_rdev = *dev; - msg = pseudo_client_op(OP_MKNOD, 0, -1, dirfd, path, &buf); - if (!msg) { - errno = ENOSYS; - rc = -1; - } else if (msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - rc = 0; - } - if (rc == -1) { - int save_errno = errno; -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - real_unlink(path); -#else - real_unlinkat(dirfd, path, AT_SYMLINK_NOFOLLOW); -#endif - errno = save_errno; - } - -/* return rc; - * } - */ diff --git a/guts/__xstat.c b/guts/__xstat.c deleted file mode 100644 index ec10abb..0000000 --- a/guts/__xstat.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___xstat(int ver, const char *path, struct stat *buf) { - * int rc = -1; - */ - - rc = wrap___fxstatat(ver, AT_FDCWD, path, buf, 0); - -/* return rc; - * } - */ diff --git a/guts/__xstat64.c b/guts/__xstat64.c deleted file mode 100644 index ed62e7e..0000000 --- a/guts/__xstat64.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap___xstat64(int ver, const char *path, struct stat64 *buf) { - * int rc = -1; - */ - rc = wrap___fxstatat64(ver, AT_FDCWD, path, buf, 0); - -/* return rc; - * } - */ diff --git a/guts/access.c b/guts/access.c deleted file mode 100644 index c250c2e..0000000 --- a/guts/access.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_access(const char *path, int mode) { - * int rc = -1; - */ - struct stat64 buf; - - /* note: no attempt to handle the case where user isn't - * root. - */ - rc = wrap___fxstatat64(_STAT_VER, AT_FDCWD, path, &buf, 0); - if (rc == -1) - return rc; - - if (mode & X_OK) { - if (buf.st_mode & 0111) { - return 0; - } else { - errno = EPERM; - return -1; - } - } else { - return 0; - } - -/* return rc; - * } - */ diff --git a/guts/acct.c b/guts/acct.c deleted file mode 100644 index b8dca5d..0000000 --- a/guts/acct.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_acct(const char *path) { - * int rc = -1; - */ - - rc = real_acct(path); - -/* return rc; - * } - */ diff --git a/guts/canonicalize_file_name.c b/guts/canonicalize_file_name.c deleted file mode 100644 index 9a04f33..0000000 --- a/guts/canonicalize_file_name.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_canonicalize_file_name(const char *filename) { - * char * rc = NULL; - */ - - rc = wrap_realpath(filename, NULL); - -/* return rc; - * } - */ diff --git a/guts/chdir.c b/guts/chdir.c deleted file mode 100644 index 59a262f..0000000 --- a/guts/chdir.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_chdir(const char *path) { - * int rc = -1; - */ - 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); - } - -/* return rc; - * } - */ diff --git a/guts/chmod.c b/guts/chmod.c deleted file mode 100644 index a157335..0000000 --- a/guts/chmod.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_chmod(const char *path, mode_t mode) { - * int rc = -1; - */ - - rc = wrap_fchmodat(AT_FDCWD, path, mode, 0); - -/* return rc; - * } - */ diff --git a/guts/chown.c b/guts/chown.c deleted file mode 100644 index 4fcbdda..0000000 --- a/guts/chown.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_chown(const char *path, uid_t owner, gid_t group) { - * int rc = -1; - */ - - rc = wrap_fchownat(AT_FDCWD, path, owner, group, 0); - -/* return rc; - * } - */ diff --git a/guts/chroot.c b/guts/chroot.c deleted file mode 100644 index c5b6f2f..0000000 --- a/guts/chroot.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_chroot(const char *path) { - * int rc = -1; - */ - pseudo_debug(2, "chroot: %s\n", path); - if (!pseudo_client_op(OP_CHROOT, 0, -1, -1, path, 0)) { - pseudo_debug(1, "chroot failed: %s\n", strerror(errno)); - rc = -1; - } else { - rc = 0; - } - -/* return rc; - * } - */ diff --git a/guts/clone.c b/guts/clone.c deleted file mode 100644 index b3400c7..0000000 --- a/guts/clone.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * clone(...) { - * .... - */ - /* because clone() doesn't actually continue in this function, we - * can't check the return and fix up environment variables in the - * child. Instead, we have to temporarily do any fixup, then possibly - * undo it later. UGH! - */ - pseudo_debug(1, "client resetting for clone(2) call\n"); - if (!pseudo_get_value("PSEUDO_RELOADED")) { - pseudo_setupenv(); - pseudo_reinit_libpseudo(); - } else { - pseudo_setupenv(); - pseudo_dropenv(); - } - /* call the real syscall */ - rc = (*real_clone)(fn, child_stack, flags, arg, pid, tls, ctid); -/* ... - * return rc; - * } - */ diff --git a/guts/close.c b/guts/close.c deleted file mode 100644 index 09c73e6..0000000 --- a/guts/close.c +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_close(int fd) { - * int rc = -1; - */ - /* 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); - rc = real_close(fd); - -/* return rc; - * } - */ diff --git a/guts/creat.c b/guts/creat.c deleted file mode 100644 index d46e4d5..0000000 --- a/guts/creat.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_creat(const char *path, mode_t mode) { - * int rc = -1; - */ - - rc = wrap_openat(AT_FDCWD, path, O_CREAT|O_WRONLY|O_TRUNC, mode); - -/* return rc; - * } - */ diff --git a/guts/creat64.c b/guts/creat64.c deleted file mode 100644 index 2d2fc27..0000000 --- a/guts/creat64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_creat64(const char *path, ...mode_t mode) { - * int rc = -1; - */ - - rc = wrap_openat(AT_FDCWD, path, O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE, mode); - -/* return rc; - * } - */ diff --git a/guts/dup.c b/guts/dup.c deleted file mode 100644 index 13612b1..0000000 --- a/guts/dup.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_dup(int fd) { - * int rc = -1; - */ - int save_errno; - - 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); - - errno = save_errno; -/* return rc; - * } - */ diff --git a/guts/dup2.c b/guts/dup2.c deleted file mode 100644 index 04666d1..0000000 --- a/guts/dup2.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_dup2(int oldfd, int newfd) { - * int rc = -1; - */ - int save_errno; - - /* 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); - rc = real_dup2(oldfd, newfd); - save_errno = errno; - pseudo_client_op(OP_DUP, 0, oldfd, newfd, 0, 0); - errno = save_errno; - -/* return rc; - * } - */ diff --git a/guts/eaccess.c b/guts/eaccess.c deleted file mode 100644 index e2119cc..0000000 --- a/guts/eaccess.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_eaccess(const char *path, int mode) { - * int rc = -1; - */ - - rc = wrap_access(path, mode); - -/* return rc; - * } - */ diff --git a/guts/endgrent.c b/guts/endgrent.c deleted file mode 100644 index 843cad0..0000000 --- a/guts/endgrent.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static void - * wrap_endgrent(void) { - * - */ - - pseudo_grp_close(); - -/* return; - * } - */ diff --git a/guts/endpwent.c b/guts/endpwent.c deleted file mode 100644 index f76cf10..0000000 --- a/guts/endpwent.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static void - * wrap_endpwent(void) { - * - */ - - pseudo_pwd_close(); - -/* return; - * } - */ diff --git a/guts/euidaccess.c b/guts/euidaccess.c deleted file mode 100644 index 85433a8..0000000 --- a/guts/euidaccess.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_euidaccess(const char *path, int mode) { - * int rc = -1; - */ - - rc = wrap_access(path, mode); - -/* return rc; - * } - */ diff --git a/guts/execv.c b/guts/execv.c deleted file mode 100644 index 15ad51e..0000000 --- a/guts/execv.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_execv(const char *file, char *const *argv) { - * int rc = -1; - */ - /* note: we don't canonicalize this, because we are intentionally - * NOT redirecting execs into the chroot environment. If you try - * to execute /bin/sh, you get the actual /bin/sh, not - * <CHROOT>/bin/sh. This allows use of basic utilities. This - * design will likely be revisited. - */ - if (antimagic == 0) { - char *path_guess = pseudo_exec_path(file, 0); - pseudo_client_op(OP_EXEC, PSA_EXEC, -1, -1, path_guess, 0); - free(path_guess); - } - - if (!pseudo_get_value("PSEUDO_RELOADED")) - pseudo_setupenv(); - else { - pseudo_setupenv(); - pseudo_dropenv(); - } - - /* if exec() fails, we may end up taking signals unexpectedly... - * not much we can do about that. - */ - sigprocmask(SIG_SETMASK, &pseudo_saved_sigmask, NULL); - rc = real_execv(file, argv); - -/* return rc; - * } - */ diff --git a/guts/execve.c b/guts/execve.c deleted file mode 100644 index a47b9a7..0000000 --- a/guts/execve.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_execve(const char *file, char *const *argv, char *const *envp) { - * int rc = -1; - */ - char * const *new_environ; - /* note: we don't canonicalize this, because we are intentionally - * NOT redirecting execs into the chroot environment. If you try - * to execute /bin/sh, you get the actual /bin/sh, not - * <CHROOT>/bin/sh. This allows use of basic utilities. This - * design will likely be revisited. - */ - if (antimagic == 0) { - char *path_guess = pseudo_exec_path(file, 0); - pseudo_client_op(OP_EXEC, PSA_EXEC, -1, -1, path_guess, 0); - free(path_guess); - } - - if (!pseudo_get_value("PSEUDO_RELOADED")) - new_environ = pseudo_setupenvp(envp); - else { - new_environ = pseudo_setupenvp(envp); - new_environ = pseudo_dropenvp(new_environ); - } - - /* if exec() fails, we may end up taking signals unexpectedly... - * not much we can do about that. - */ - sigprocmask(SIG_SETMASK, &pseudo_saved_sigmask, NULL); - rc = real_execve(file, argv, new_environ); - -/* return rc; - * } - */ diff --git a/guts/execvp.c b/guts/execvp.c deleted file mode 100644 index 419f41b..0000000 --- a/guts/execvp.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_execvp(const char *file, char *const *argv) { - * int rc = -1; - */ - - /* note: we don't canonicalize this, because we are intentionally - * NOT redirecting execs into the chroot environment. If you try - * to execute /bin/sh, you get the actual /bin/sh, not - * <CHROOT>/bin/sh. This allows use of basic utilities. This - * design will likely be revisited. - */ - if (antimagic == 0) { - char *path_guess = pseudo_exec_path(file, 1); - pseudo_client_op(OP_EXEC, PSA_EXEC, -1, -1, path_guess, 0); - free(path_guess); - } - - if (!pseudo_get_value("PSEUDO_RELOADED")) - pseudo_setupenv(); - else { - pseudo_setupenv(); - pseudo_dropenv(); - } - - /* if exec() fails, we may end up taking signals unexpectedly... - * not much we can do about that. - */ - sigprocmask(SIG_SETMASK, &pseudo_saved_sigmask, NULL); - rc = real_execvp(file, argv); - -/* return rc; - * } - */ diff --git a/guts/fchdir.c b/guts/fchdir.c deleted file mode 100644 index ba77ebf..0000000 --- a/guts/fchdir.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fchdir(int dirfd) { - * int rc = -1; - */ - - rc = real_fchdir(dirfd); - - if (rc != -1) { - pseudo_client_op(OP_CHDIR, 0, -1, dirfd, 0, 0); - } - -/* return rc; - * } - */ diff --git a/guts/fchmod.c b/guts/fchmod.c deleted file mode 100644 index c06f677..0000000 --- a/guts/fchmod.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fchmod(int fd, mode_t mode) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - int save_errno = errno; - - if (real___fxstat64(_STAT_VER, fd, &buf) == -1) { - /* can't stat it, can't chmod it */ - return -1; - } - buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_FCHMOD, 0, fd, -1, 0, &buf); - real_fchmod(fd, PSEUDO_FS_MODE(mode)); - if (!msg) { - errno = ENOSYS; - rc = -1; - } else if (msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - errno = save_errno; - rc = 0; - } - -/* return rc; - * } - */ diff --git a/guts/fchmodat.c b/guts/fchmodat.c deleted file mode 100644 index f58f55a..0000000 --- a/guts/fchmodat.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fchmodat(int dirfd, const char *path, mode_t mode, int flags) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - int save_errno; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - if (flags & AT_SYMLINK_NOFOLLOW) { - rc = real___lxstat64(_STAT_VER, path, &buf); - } else { - rc = real___xstat64(_STAT_VER, path, &buf); - } -#else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, flags); -#endif - if (rc == -1) { - return rc; - } - if (S_ISLNK(buf.st_mode)) { - /* we don't really support chmod of a symlink */ - errno = ENOSYS; - return -1; - } - save_errno = errno; - - /* purely for debugging purposes: check whether file - * is already in database. - */ - msg = pseudo_client_op(OP_STAT, 0, -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); - - } - - /* user bits added so "root" can always access files. */ -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - /* note: if path was a symlink, and AT_NOFOLLOW_SYMLINKS was - * specified, we already bailed previously. */ - real_chmod(path, PSEUDO_FS_MODE(mode)); -#else - real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode), flags); -#endif - /* we ignore a failure from underlying fchmod, because pseudo - * may believe you are permitted to change modes that the filesystem - * doesn't. - */ - - buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_CHMOD, 0, -1, dirfd, path, &buf); - if (!msg) { - errno = ENOSYS; - rc = -1; - } else if (msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - rc = 0; - } - -/* return rc; - * } - */ diff --git a/guts/fchown.c b/guts/fchown.c deleted file mode 100644 index 7d0da85..0000000 --- a/guts/fchown.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fchown(int fd, uid_t owner, gid_t group) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - int save_errno; - - if (real___fxstat64(_STAT_VER, fd, &buf) == -1) { - save_errno = errno; - pseudo_debug(2, "fchown failing because fxstat failed: %s\n", - strerror(errno)); - errno = save_errno; - return -1; - } - if (owner == (uid_t) -1 || group == (gid_t) -1) { - msg = pseudo_client_op(OP_STAT, 0, fd, -1, NULL, &buf); - /* copy in any existing values... */ - if (msg) { - if (msg->result == RESULT_SUCCEED) { - pseudo_stat_msg(&buf, msg); - } else { - pseudo_debug(2, "fchown fd %d, ino %llu, unknown file.\n", - fd, (unsigned long long) buf.st_ino); - } - } else { - pseudo_diag("stat within chown of fd %d [%llu] failed.\n", - fd, (unsigned long long) buf.st_ino); - } - } - /* now override with arguments */ - if (owner != (uid_t) -1) { - buf.st_uid = owner; - } - if (group != (gid_t) -1) { - buf.st_gid = group; - } - 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); - if (!msg) { - errno = ENOSYS; - rc = -1; - } else if (msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - rc = 0; - } - -/* return rc; - * } - */ diff --git a/guts/fchownat.c b/guts/fchownat.c deleted file mode 100644 index f006efe..0000000 --- a/guts/fchownat.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - int save_errno; - int doing_link = 0; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - if (flags & AT_SYMLINK_NOFOLLOW) { - rc = real___lxstat64(_STAT_VER, path, &buf); - } else { - rc = real___xstat64(_STAT_VER, path, &buf); - } -#else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, flags); -#endif - if (rc == -1) { - return rc; - } - /* pseudo won't track the ownership, here */ - if (S_ISLNK(buf.st_mode)) { - doing_link = 1; - } - save_errno = errno; - - if (owner == (uid_t) -1 || group == (gid_t) -1) { - msg = pseudo_client_op(OP_STAT, 0, -1, -1, path, &buf); - /* copy in any existing values... */ - if (msg) { - if (msg->result == RESULT_SUCCEED) { - pseudo_stat_msg(&buf, msg); - } else { - pseudo_debug(2, "chownat to %d:%d on %d/%s, ino %llu, new file.\n", - owner, group, dirfd, path, - (unsigned long long) buf.st_ino); - } - } - } - /* now override with arguments */ - if (owner != (uid_t) -1) { - buf.st_uid = owner; - } - if (group != (gid_t) -1) { - buf.st_gid = group; - } - msg = pseudo_client_op(OP_CHOWN, 0, -1, dirfd, path, &buf); - if (!msg) { - errno = ENOSYS; - rc = -1; - } else if (msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - rc = 0; - } - -/* return rc; - * } - */ diff --git a/guts/fclose.c b/guts/fclose.c deleted file mode 100644 index 4469f5b..0000000 --- a/guts/fclose.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fclose(FILE *fp) { - * int rc = -1; - */ - - if (!fp) { - errno = EFAULT; - return -1; - } - int fd = fileno(fp); - pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0); - rc = real_fclose(fp); - -/* return rc; - * } - */ diff --git a/guts/fcntl.c b/guts/fcntl.c deleted file mode 100644 index 2e3e96d..0000000 --- a/guts/fcntl.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fcntl(int fd, int cmd, ...struct flock *lock) { - * int rc = -1; - */ - long arg; - int save_errno; - - /* we don't know whether we need lock or arg; grab both, which - * should be safe enough on Linuxy systems. */ - va_start(ap, cmd); - arg = va_arg(ap, long); - va_end(ap); - - switch (cmd) { - case F_DUPFD: -#ifdef F_DUPFD_CLOEXEC - case F_DUPFD_CLOEXEC: -#endif - /* actually do something */ - rc = real_fcntl(fd, cmd, arg); - 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); - } - errno = save_errno; - break; - /* no argument: */ - case F_GETFD: - case F_GETFL: - case F_GETOWN: - case F_GETSIG: - case F_GETLEASE: - rc = real_fcntl(fd, cmd); - break; - /* long argument */ - case F_SETFD: - case F_SETFL: - case F_SETOWN: - case F_SETSIG: - case F_SETLEASE: - case F_NOTIFY: - rc = real_fcntl(fd, cmd, arg); - break; - /* struct flock * argument */ - case F_GETLK: - case F_SETLK: - case F_SETLKW: - rc = real_fcntl(fd, cmd, lock); - break; -#if defined(F_GETLK64) && (F_GETLK64 != F_GETLK) - /* the cast is safe, all struct pointers must smell the same */ - case F_GETLK64: - case F_SETLK64: - case F_SETLKW64: - rc = real_fcntl(fd, cmd, (struct flock64 *) lock); - break; -#endif - default: - pseudo_diag("unknown fcntl argument %d, assuming long argument.\n", - cmd); - rc = real_fcntl(fd, cmd, arg); - break; - } -/* return rc; - * } - */ diff --git a/guts/fgetxattr.c b/guts/fgetxattr.c deleted file mode 100644 index a9bd8b0..0000000 --- a/guts/fgetxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size) - * ssize_t rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/flistxattr.c b/guts/flistxattr.c deleted file mode 100644 index 62b4173..0000000 --- a/guts/flistxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * ssize_t flistxattr(int filedes, char *list, size_t size) - * ssize_t rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/fopen.c b/guts/fopen.c deleted file mode 100644 index c8a3f98..0000000 --- a/guts/fopen.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static FILE * - * wrap_fopen(const char *path, const char *mode) { - * FILE * rc = 0; - */ - struct stat64 buf; - int save_errno; - int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); - - rc = real_fopen(path, mode); - save_errno = errno; - - if (rc) { - int fd = fileno(rc); - - pseudo_debug(2, "fopen '%s': fd %d <FILE %p>\n", path, fd, (void *) rc); - if (real___fxstat64(_STAT_VER, fd, &buf) != -1) { - if (!existed) { - pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); - } - pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), 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, pseudo_access_fopen(mode), fd, -1, path, 0); - } - errno = save_errno; - } - -/* return rc; - * } - */ diff --git a/guts/fopen64.c b/guts/fopen64.c deleted file mode 100644 index b2724de..0000000 --- a/guts/fopen64.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static FILE * - * wrap_fopen64(const char *path, const char *mode) { - * FILE * rc = 0; - */ - struct stat64 buf; - int save_errno; - - int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); - - rc = real_fopen64(path, mode); - save_errno = errno; - - if (rc) { - int fd = fileno(rc); - - pseudo_debug(2, "fopen64 '%s': fd %d <FILE %p>\n", path, fd, (void *) rc); - if (real___fxstat64(_STAT_VER, fd, &buf) != -1) { - if (!existed) { - pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); - } - pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), 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, pseudo_access_fopen(mode), fd, -1, path, 0); - } - errno = save_errno; - } - -/* return rc; - * } - */ diff --git a/guts/fork.c b/guts/fork.c deleted file mode 100644 index 76cac6f..0000000 --- a/guts/fork.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_fork(void) { - * int rc = -1; - */ - rc = real_fork(); - /* special case: we may want to enable or disable - * pseudo in the child process - */ - if (rc == 0) { - if (!pseudo_get_value("PSEUDO_RELOADED")) { - pseudo_setupenv(); - pseudo_reinit_libpseudo(); - } else { - pseudo_setupenv(); - pseudo_dropenv(); - } - } -/* return rc; - * } - */ diff --git a/guts/fremovexattr.c b/guts/fremovexattr.c deleted file mode 100644 index fe3681e..0000000 --- a/guts/fremovexattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int fremovexattr(int filedes, const char *name) - * int rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/freopen.c b/guts/freopen.c deleted file mode 100644 index bd50b29..0000000 --- a/guts/freopen.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static FILE * - * wrap_freopen(const char *path, const char *mode, FILE *stream) { - * FILE * rc = NULL; - */ - struct stat64 buf; - int save_errno; - int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); - - rc = real_freopen(path, mode, stream); - save_errno = errno; - - if (rc) { - int fd = fileno(rc); - - 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_OPEN, pseudo_access_fopen(mode), 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, pseudo_access_fopen(mode), fd, -1, path, 0); - } - errno = save_errno; - } - -/* return rc; - * } - */ diff --git a/guts/freopen64.c b/guts/freopen64.c deleted file mode 100644 index b8e576b..0000000 --- a/guts/freopen64.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static FILE * - * wrap_freopen64(const char *path, const char *mode, FILE *stream) { - * FILE * rc = NULL; - */ - struct stat64 buf; - int save_errno; - int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); - - rc = real_freopen64(path, mode, stream); - save_errno = errno; - - if (rc) { - int fd = fileno(rc); - - pseudo_debug(2, "freopen64 '%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_OPEN, pseudo_access_fopen(mode), 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, pseudo_access_fopen(mode), fd, -1, path, 0); - } - errno = save_errno; - } - -/* return rc; - * } - */ diff --git a/guts/fsetxattr.c b/guts/fsetxattr.c deleted file mode 100644 index a891ffb..0000000 --- a/guts/fsetxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags) - * int rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/fts_open.c b/guts/fts_open.c deleted file mode 100644 index 8b3ce19..0000000 --- a/guts/fts_open.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static FTS * - * wrap_fts_open(char * const *path_argv, int options, int (*compar)(const FTSENT **, const FTSENT **)) { - * FTS * rc = NULL; - */ - char **rpath_argv; - int args = 0; - int errored = 0; - int i; - - if (!path_argv) { - errno = EFAULT; - return NULL; - } - /* count args */ - for (i = 0; path_argv[i]; ++i) { - ++args; - } - rpath_argv = malloc((args + 1) * sizeof(*rpath_argv)); - if (!rpath_argv) { - errno = ENOMEM; - return NULL; - } - - for (i = 0; i < args; ++i) { - rpath_argv[i] = PSEUDO_ROOT_PATH(AT_FDCWD, path_argv[i], AT_SYMLINK_NOFOLLOW); - if (!rpath_argv[i]) - errored = 1; - } - - if (errored) { - errno = ENOMEM; - rc = NULL; - } else { - rc = real_fts_open(path_argv, options, compar); - } - for (i = 0; i < args; ++i) - free(rpath_argv[i]); - free(rpath_argv); - -/* return rc; - * } - */ diff --git a/guts/ftw.c b/guts/ftw.c deleted file mode 100644 index 0861194..0000000 --- a/guts/ftw.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int nopenfd) { - * int rc = -1; - */ - - rc = real_ftw(path, fn, nopenfd); - -/* return rc; - * } - */ diff --git a/guts/ftw64.c b/guts/ftw64.c deleted file mode 100644 index a375fbf..0000000 --- a/guts/ftw64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_ftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int), int nopenfd) { - * int rc = -1; - */ - - rc = real_ftw64(path, fn, nopenfd); - -/* return rc; - * } - */ diff --git a/guts/get_current_dir_name.c b/guts/get_current_dir_name.c deleted file mode 100644 index e07a6ee..0000000 --- a/guts/get_current_dir_name.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * 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 deleted file mode 100644 index b3f552c..0000000 --- a/guts/getcwd.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_getcwd(char *buf, size_t size) { - * char * rc = NULL; - */ - pseudo_debug(3, "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 a cwd, something's very wrong... */ - if (!size) { - size = pseudo_cwd_len + 1; - if (pseudo_chroot_len && size >= pseudo_chroot_len && - !memcmp(pseudo_cwd, pseudo_chroot, pseudo_chroot_len)) { - size -= pseudo_chroot_len; - /* if cwd is precisely the same as chroot, we - * actually want a /, not an empty string - */ - if (size < 2) - size = 2; - } - } - if (size) { - buf = malloc(size); - } else { - pseudo_diag("can't figure out CWD: length %ld + 1 - %ld => %ld\n", - (unsigned long) pseudo_cwd_len, - (unsigned long) pseudo_chroot_len, - (unsigned long) size); - } - if (!buf) { - pseudo_diag("couldn't allocate requested CWD buffer - need %ld byes\n", - (unsigned long) size); - errno = ENOMEM; - return NULL; - } - } - if (pseudo_cwd_len - (pseudo_cwd_rel - pseudo_cwd) >= size) { - pseudo_debug(1, "only %ld bytes available, need %ld (%ld + 1 - %ld)\n", - (unsigned long) size, - (unsigned long) pseudo_cwd_len + 1 - pseudo_chroot_len, - (unsigned long) pseudo_cwd_len, - (unsigned long) pseudo_chroot_len); - errno = ERANGE; - return NULL; - } - rc = buf; - pseudo_debug(3, "getcwd: copying %d (%d + 1 - %d) characters from <%s>.\n", - (int) ((pseudo_cwd_len + 1) - pseudo_chroot_len), - (int) pseudo_cwd_len, (int) pseudo_chroot_len, - pseudo_cwd_rel); - memcpy(buf, pseudo_cwd_rel, (pseudo_cwd_len + 1) - (pseudo_cwd_rel - pseudo_cwd)); - if (!*buf) { - strcpy(buf, "/"); - } - -/* return rc; - * } - */ diff --git a/guts/getegid.c b/guts/getegid.c deleted file mode 100644 index 7c14f48..0000000 --- a/guts/getegid.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static gid_t - * wrap_getegid(void) { - * gid_t rc = 0; - */ - - rc = pseudo_egid; - -/* return rc; - * } - */ diff --git a/guts/geteuid.c b/guts/geteuid.c deleted file mode 100644 index 1745e13..0000000 --- a/guts/geteuid.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static uid_t - * wrap_geteuid(void) { - * uid_t rc = 0; - */ - - rc = pseudo_euid; - -/* return rc; - * } - */ diff --git a/guts/getgid.c b/guts/getgid.c deleted file mode 100644 index ca8bad3..0000000 --- a/guts/getgid.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static gid_t - * wrap_getgid(void) { - * gid_t rc = 0; - */ - - rc = pseudo_rgid; - -/* return rc; - * } - */ diff --git a/guts/getgrent.c b/guts/getgrent.c deleted file mode 100644 index e8e07f5..0000000 --- a/guts/getgrent.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static struct group * - * wrap_getgrent(void) { - * struct group * rc = NULL; - */ - static struct group grp; - static char grbuf[PSEUDO_PWD_MAX]; - int r_rc; - - r_rc = wrap_getgrent_r(&grp, grbuf, PSEUDO_PWD_MAX, &rc); - /* different error return conventions */ - if (r_rc != 0) { - errno = r_rc; - } - -/* return rc; - * } - */ diff --git a/guts/getgrent_r.c b/guts/getgrent_r.c deleted file mode 100644 index b02466a..0000000 --- a/guts/getgrent_r.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getgrent_r(struct group *gbuf, char *buf, size_t buflen, struct group **gbufp) { - * int rc = -1; - */ - - /* note that we don't wrap fgetgrent_r, since there's no path - * references in it. - */ - if (!pseudo_grp) { - errno = ENOENT; - return -1; - } - rc = fgetgrent_r(pseudo_grp, gbuf, buf, buflen, gbufp); - if (rc == 0 && *gbufp) { - if (*gbufp == gbuf) { - pseudo_debug(3, "found group: %d/%s\n", gbuf->gr_gid, gbuf->gr_name); - } else { - pseudo_debug(1, "found group (%d), but it's wrong?", gbuf->gr_gid); - } - } - -/* return rc; - * } - */ diff --git a/guts/getgrgid.c b/guts/getgrgid.c deleted file mode 100644 index c1824e7..0000000 --- a/guts/getgrgid.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static struct group * - * wrap_getgrgid(gid_t gid) { - * struct group * rc = NULL; - */ - static struct group grp; - static char grbuf[PSEUDO_PWD_MAX]; - int r_rc; - - r_rc = wrap_getgrgid_r(gid, &grp, grbuf, PSEUDO_PWD_MAX, &rc); - /* different error return conventions */ - if (r_rc != 0) { - errno = r_rc; - } - -/* return rc; - * } - */ diff --git a/guts/getgrgid_r.c b/guts/getgrgid_r.c deleted file mode 100644 index 06a91c9..0000000 --- a/guts/getgrgid_r.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getgrgid_r(gid_t gid, struct group *gbuf, char *buf, size_t buflen, struct group **gbufp) { - * int rc = -1; - */ - - setgrent(); - while ((rc = wrap_getgrent_r(gbuf, buf, buflen, gbufp)) == 0) { - /* 0 means no error occurred, and *gbufp == gbuf */ - if (gbuf->gr_gid == gid) { - pseudo_debug(1, "found group gid %d, name %s\n", - gbuf->gr_gid, gbuf->gr_name); - endgrent(); - return rc; - } - } - endgrent(); - /* we never found a match; rc is 0 if there was no error, or - * non-zero if an error occurred. Either way, set the - * pwbufp pointer to NULL to indicate that we didn't find - * something, and leave rc alone. - */ - *gbufp = NULL; - -/* return rc; - * } - */ diff --git a/guts/getgrnam.c b/guts/getgrnam.c deleted file mode 100644 index 0e26444..0000000 --- a/guts/getgrnam.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static struct group * - * wrap_getgrnam(const char *name) { - * struct group * rc = NULL; - */ - - static struct group grp; - static char grbuf[PSEUDO_PWD_MAX]; - int r_rc; - - r_rc = wrap_getgrnam_r(name, &grp, grbuf, PSEUDO_PWD_MAX, &rc); - /* different error return conventions */ - if (r_rc != 0) { - errno = r_rc; - } - - -/* return rc; - * } - */ diff --git a/guts/getgrnam_r.c b/guts/getgrnam_r.c deleted file mode 100644 index 39de641..0000000 --- a/guts/getgrnam_r.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getgrnam_r(const char *name, struct group *gbuf, char *buf, size_t buflen, struct group **gbufp) { - * int rc = -1; - */ - - setgrent(); - while ((rc = wrap_getgrent_r(gbuf, buf, buflen, gbufp)) == 0) { - /* 0 means no error occurred, and *gbufp == gbuf */ - if (gbuf->gr_name && !strcmp(gbuf->gr_name, name)) { - endgrent(); - return rc; - } - } - endgrent(); - /* we never found a match; rc is 0 if there was no error, or - * non-zero if an error occurred. Either way, set the - * pwbufp pointer to NULL to indicate that we didn't find - * something, and leave rc alone. - */ - *gbufp = NULL; - - -/* return rc; - * } - */ diff --git a/guts/getgrouplist.c b/guts/getgrouplist.c deleted file mode 100644 index 3489ec9..0000000 --- a/guts/getgrouplist.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups) { - * int rc = -1; - */ - - int found = 0; - int found_group = 0; - char buf[PSEUDO_PWD_MAX]; - struct group grp, *gbuf = &grp; - - setgrent(); - while ((rc = wrap_getgrent_r(gbuf, buf, PSEUDO_PWD_MAX, &gbuf)) == 0) { - int i = 0; - for (i = 0; gbuf->gr_mem[i]; ++i) { - if (!strcmp(gbuf->gr_mem[i], user)) { - if (found < *ngroups) - groups[found] = gbuf->gr_gid; - ++found; - if (gbuf->gr_gid == group) - found_group = 1; - } - } - } - endgrent(); - if (!found_group) { - if (found < *ngroups) - groups[found] = group; - ++found; - } - if (found >= *ngroups) - rc = -1; - else - rc = found; - *ngroups = found; - -/* return rc; - * } - */ diff --git a/guts/getgroups.c b/guts/getgroups.c deleted file mode 100644 index afb9662..0000000 --- a/guts/getgroups.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getgroups(int size, gid_t *list) { - * int rc = -1; - */ - struct passwd *p = wrap_getpwuid(wrap_getuid()); - int oldsize = size; - - if (p) { - rc = wrap_getgrouplist(p->pw_name, wrap_getgid(), list, &size); - if (oldsize == 0 || size <= oldsize) - rc = size; - } else { - errno = ENOENT; - } - -/* return rc; - * } - */ diff --git a/guts/getpw.c b/guts/getpw.c deleted file mode 100644 index 62b44da..0000000 --- a/guts/getpw.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getpw(uid_t uid, char *buf) { - * int rc = -1; - */ - static struct passwd pwd; - static char pwbuf[PSEUDO_PWD_MAX]; - struct passwd *pwp; - - pseudo_diag("warning: unsafe getpw() called. hoping buf has at least %d chars.\n", - PSEUDO_PWD_MAX); - rc = wrap_getpwuid_r(uid, &pwd, pwbuf, PSEUDO_PWD_MAX, &pwp); - /* different error return conventions */ - if (rc != 0) { - errno = rc; - rc = -1; - } else { - snprintf(buf, PSEUDO_PWD_MAX, "%s:%s:%d:%d:%s:%s:%s", - pwd.pw_name, - pwd.pw_passwd, - pwd.pw_uid, - pwd.pw_gid, - pwd.pw_gecos, - pwd.pw_dir, - pwd.pw_shell); - } - -/* return rc; - * } - */ diff --git a/guts/getpwent.c b/guts/getpwent.c deleted file mode 100644 index 3b1f837..0000000 --- a/guts/getpwent.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static struct passwd * - * wrap_getpwent(void) { - * struct passwd * rc = NULL; - */ - static struct passwd pwd; - static char pwbuf[PSEUDO_PWD_MAX]; - int r_rc; - - r_rc = wrap_getpwent_r(&pwd, pwbuf, PSEUDO_PWD_MAX, &rc); - /* different error return conventions */ - if (r_rc != 0) { - errno = r_rc; - } - -/* return rc; - * } - */ diff --git a/guts/getpwent_r.c b/guts/getpwent_r.c deleted file mode 100644 index d55763e..0000000 --- a/guts/getpwent_r.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp) { - * int rc = -1; - */ - - /* note that we don't wrap fgetpwent_r, since there's no path - * references in it. - */ - if (!pseudo_pwd) { - errno = ENOENT; - return -1; - } - return fgetpwent_r(pseudo_pwd, pwbuf, buf, buflen, pwbufp); - -/* return rc; - * } - */ diff --git a/guts/getpwnam.c b/guts/getpwnam.c deleted file mode 100644 index 024b3d8..0000000 --- a/guts/getpwnam.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static struct passwd * - * wrap_getpwnam(const char *name) { - * struct passwd * rc = NULL; - */ - static struct passwd pwd; - static char pwbuf[PSEUDO_PWD_MAX]; - int r_rc; - - r_rc = wrap_getpwnam_r(name, &pwd, pwbuf, PSEUDO_PWD_MAX, &rc); - /* different error return conventions */ - if (r_rc != 0) { - errno = r_rc; - } - -/* return rc; - * } - */ diff --git a/guts/getpwnam_r.c b/guts/getpwnam_r.c deleted file mode 100644 index 5d7a4ea..0000000 --- a/guts/getpwnam_r.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getpwnam_r(const char *name, struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp) { - * int rc = -1; - */ - - setpwent(); - while ((rc = wrap_getpwent_r(pwbuf, buf, buflen, pwbufp)) == 0) { - /* 0 means no error occurred, and *pwbufp == pwbuf */ - if (pwbuf->pw_name && !strcmp(pwbuf->pw_name, name)) { - endpwent(); - return rc; - } - } - endpwent(); - /* we never found a match; rc is 0 if there was no error, or - * non-zero if an error occurred. Either way, set the - * pwbufp pointer to NULL to indicate that we didn't find - * something, and leave rc alone. - */ - *pwbufp = NULL; - -/* return rc; - * } - */ diff --git a/guts/getpwuid.c b/guts/getpwuid.c deleted file mode 100644 index 11142de..0000000 --- a/guts/getpwuid.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static struct passwd * - * wrap_getpwuid(uid_t uid) { - * struct passwd * rc = NULL; - */ - static struct passwd pwd; - static char pwbuf[PSEUDO_PWD_MAX]; - int r_rc; - - r_rc = wrap_getpwuid_r(uid, &pwd, pwbuf, PSEUDO_PWD_MAX, &rc); - /* different error return conventions */ - if (r_rc != 0) { - errno = r_rc; - } - -/* return rc; - * } - */ diff --git a/guts/getpwuid_r.c b/guts/getpwuid_r.c deleted file mode 100644 index 06b920e..0000000 --- a/guts/getpwuid_r.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getpwuid_r(uid_t uid, struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp) { - * int rc = -1; - */ - - setpwent(); - while ((rc = wrap_getpwent_r(pwbuf, buf, buflen, pwbufp)) == 0) { - /* 0 means no error occurred, and *pwbufp == pwbuf */ - if (pwbuf->pw_uid == uid) { - endpwent(); - return rc; - } - } - endpwent(); - /* we never found a match; rc is 0 if there was no error, or - * non-zero if an error occurred. Either way, set the - * pwbufp pointer to NULL to indicate that we didn't find - * something, and leave rc alone. - */ - *pwbufp = NULL; - -/* return rc; - * } - */ diff --git a/guts/getresgid.c b/guts/getresgid.c deleted file mode 100644 index 13551a4..0000000 --- a/guts/getresgid.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) { - * int rc = -1; - */ - if (rgid) - *rgid = pseudo_rgid; - if (egid) - *egid = pseudo_egid; - if (sgid) - *sgid = pseudo_sgid; - if (rgid && egid && sgid) { - rc = 0; - } else { - rc = -1; - errno = EFAULT; - } -/* return rc; - * } - */ diff --git a/guts/getresuid.c b/guts/getresuid.c deleted file mode 100644 index 2e47520..0000000 --- a/guts/getresuid.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) { - * int rc = -1; - */ - if (ruid) - *ruid = pseudo_ruid; - if (euid) - *euid = pseudo_euid; - if (suid) - *suid = pseudo_suid; - if (ruid && euid && suid) { - rc = 0; - } else { - rc = -1; - errno = EFAULT; - } -/* return rc; - * } - */ diff --git a/guts/getuid.c b/guts/getuid.c deleted file mode 100644 index e783cc8..0000000 --- a/guts/getuid.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static uid_t - * wrap_getuid(void) { - * uid_t rc = 0; - */ - - rc = pseudo_ruid; - -/* return rc; - * } - */ diff --git a/guts/getwd.c b/guts/getwd.c deleted file mode 100644 index 836301e..0000000 --- a/guts/getwd.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * 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/getxattr.c b/guts/getxattr.c deleted file mode 100644 index 71cfd56..0000000 --- a/guts/getxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * ssize_t getxattr(const char *pathname, const char *name, void *value, size_t size) - * ssize_t rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/glob.c b/guts/glob.c deleted file mode 100644 index 0012179..0000000 --- a/guts/glob.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob) { - * int rc = -1; - */ - char *rpattern = NULL; - int alloced = 0; - - /* note: no canonicalization */ - if (pattern && (*pattern == '/') && pseudo_chroot_len) { - size_t len = strlen(pattern) + pseudo_chroot_len + 2; - rpattern = malloc(len); - if (!rpattern) { - errno = ENOMEM; - return GLOB_NOSPACE; - } - snprintf(rpattern, len, "%s/%s", pseudo_chroot, pattern); - alloced = 1; - } - - rc = real_glob(alloced ? rpattern : pattern, flags, errfunc, pglob); - - free(rpattern); - - if (rc == 0) { - unsigned int i; - for (i = 0; i < pglob->gl_pathc; ++i) { - pseudo_dechroot(pglob->gl_pathv[i], (size_t) -1); - } - } -/* return rc; - * } - */ diff --git a/guts/glob64.c b/guts/glob64.c deleted file mode 100644 index ccac6e4..0000000 --- a/guts/glob64.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_glob64(const char *pattern, int flags, int (*errfunc)(const char *, int), glob64_t *pglob) { - * int rc = -1; - */ - char *rpattern = NULL; - int alloced = 0; - - /* note: no canonicalization */ - if (pattern && (*pattern == '/') && pseudo_chroot_len) { - size_t len = strlen(pattern) + pseudo_chroot_len + 2; - rpattern = malloc(len); - if (!rpattern) { - errno = ENOMEM; - return GLOB_NOSPACE; - } - snprintf(rpattern, len, "%s/%s", pseudo_chroot, pattern); - alloced = 1; - } - - rc = real_glob64(alloced ? rpattern : pattern, flags, errfunc, pglob); - - free(rpattern); - - if (rc == 0) { - unsigned int i; - for (i = 0; i < pglob->gl_pathc; ++i) { - pseudo_dechroot(pglob->gl_pathv[i], (size_t) -1); - } - } -/* return rc; - * } - */ diff --git a/guts/lchown.c b/guts/lchown.c deleted file mode 100644 index 4eb1202..0000000 --- a/guts/lchown.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_lchown(const char *path, uid_t owner, gid_t group) { - */ - - rc = wrap_fchownat(AT_FDCWD, path, owner, group, AT_SYMLINK_NOFOLLOW); - -/* return rc; - * } - */ diff --git a/guts/lckpwdf.c b/guts/lckpwdf.c deleted file mode 100644 index b452ec0..0000000 --- a/guts/lckpwdf.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_lckpwdf(void) { - * int rc = -1; - */ - rc = pseudo_pwd_lck_open(); - if (rc != -1) { - struct flock lck = { - .l_type = F_RDLCK, - .l_whence = SEEK_SET, - .l_start = 0, - .l_len = 1 - }; - /* I don't really care whether this works. */ - fcntl(rc, F_SETFD, FD_CLOEXEC); - /* Now lock it. */ - alarm(15); /* magic number from man page */ - rc = fcntl(rc, F_SETLKW, &lck); - alarm(0); - if (rc == -1) { - int save_errno = errno; - pseudo_pwd_lck_close(); - errno = save_errno; - } - } - -/* return rc; - * } - */ diff --git a/guts/lgetxattr.c b/guts/lgetxattr.c deleted file mode 100644 index 84fe020..0000000 --- a/guts/lgetxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * ssize_t lgetxattr(const char *pathname, const char *name, void *value, size_t size) - * ssize_t rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/link.c b/guts/link.c deleted file mode 100644 index e528d53..0000000 --- a/guts/link.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_link(const char *oldpath, const char *newpath) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - - rc = real_link(oldpath, newpath); - if (rc == 0) { - /* link(2) will not overwrite; if it succeeded, we know - * that there was no previous file with this name, so we - * shove it into the database. - */ - /* On linux, link(2) links to symlinks, not to the - * files they link to. This is contraPOSIX, but - * it's apparently useful. - */ - real___lxstat64(_STAT_VER, oldpath, &buf); - /* a link should copy the existing database entry, if - * 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); - if (msg) { - pseudo_stat_msg(&buf, msg); - } - pseudo_client_op(OP_LINK, 0, -1, -1, newpath, &buf); - } - -/* return rc; - * } - */ diff --git a/guts/listxattr.c b/guts/listxattr.c deleted file mode 100644 index cef53fc..0000000 --- a/guts/listxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * ssize_t listxattr(const char *pathname, char *list, size_t size) - * ssize_t rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/llistxattr.c b/guts/llistxattr.c deleted file mode 100644 index 92870b5..0000000 --- a/guts/llistxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * ssize_t llistxattr(const char *pathname, char *list, size_t size) - * ssize_t rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/lremovexattr.c b/guts/lremovexattr.c deleted file mode 100644 index 2ad8a82..0000000 --- a/guts/lremovexattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int lremovexattr(const char *pathname, const char *name) - * int rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/lsetxattr.c b/guts/lsetxattr.c deleted file mode 100644 index e5b4cd6..0000000 --- a/guts/lsetxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int lsetxattr(const char *pathname, const char *name, const void *value, size_t size, int flags) - * int rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/lutimes.c b/guts/lutimes.c deleted file mode 100644 index cdadbbd..0000000 --- a/guts/lutimes.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_lutimes(const char *path, const struct timeval *tv) { - * int rc = -1; - */ - - rc = real_lutimes(path, tv); - -/* return rc; - * } - */ diff --git a/guts/mkdir.c b/guts/mkdir.c deleted file mode 100644 index 9f116e2..0000000 --- a/guts/mkdir.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_mkdir(const char *path, mode_t mode) { - * int rc = -1; - */ - - rc = wrap_mkdirat(AT_FDCWD, path, mode); - -/* return rc; - * } - */ diff --git a/guts/mkdirat.c b/guts/mkdirat.c deleted file mode 100644 index 988e3f4..0000000 --- a/guts/mkdirat.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_mkdirat(int dirfd, const char *path, mode_t mode) { - * int rc = -1; - */ -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - rc = real_mkdir(path, PSEUDO_FS_MODE(mode)); -#else - rc = real_mkdirat(dirfd, path, PSEUDO_FS_MODE(mode)); -#endif - if (rc != -1) { - struct stat64 buf; - int stat_rc; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - stat_rc = real___lxstat64(_STAT_VER, path, &buf); -#else - stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, AT_SYMLINK_NOFOLLOW); -#endif - if (stat_rc != -1) { - pseudo_client_op(OP_MKDIR, 0, -1, dirfd, path, &buf); - } else { - pseudo_debug(1, "mkdir of %s succeeded, but stat failed: %s\n", - path, strerror(errno)); - } - } - -/* return rc; - * } - */ diff --git a/guts/mkdtemp.c b/guts/mkdtemp.c deleted file mode 100644 index fb23bc3..0000000 --- a/guts/mkdtemp.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_mkdtemp(char *template) { - * char * rc = NULL; - */ - struct stat64 buf; - int save_errno; - size_t len; - char *tmp_template; - - if (!template) { - errno = EFAULT; - return NULL; - } - - len = strlen(template); - tmp_template = PSEUDO_ROOT_PATH(AT_FDCWD, template, AT_SYMLINK_NOFOLLOW); - - if (!tmp_template) { - errno = ENOENT; - return NULL; - } - - rc = real_mkdtemp(tmp_template); - - if (rc != NULL) { - save_errno = errno; - - if (real___xstat64(_STAT_VER, rc, &buf) != -1) { - pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, &buf); - } else { - pseudo_debug(1, "mkdtemp (path %s) succeeded, but fstat failed (%s).\n", - rc, strerror(errno)); - } - errno = save_errno; - } - /* mkdtemp only changes the XXXXXX at the end. */ - memcpy(template + len - 6, tmp_template + strlen(tmp_template) - 6, 6); - rc = template; - free(tmp_template); -/* return rc; - * } - */ diff --git a/guts/mkfifo.c b/guts/mkfifo.c deleted file mode 100644 index 32f79fb..0000000 --- a/guts/mkfifo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_mkfifo(const char *path, mode_t mode) { - * int rc = -1; - */ - - rc = wrap_mkfifoat(AT_FDCWD, path, mode); - -/* return rc; - * } - */ diff --git a/guts/mkfifoat.c b/guts/mkfifoat.c deleted file mode 100644 index 26fcba3..0000000 --- a/guts/mkfifoat.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_mkfifoat(int dirfd, const char *path, mode_t mode) { - * int rc = -1; - */ - dev_t unused = 0; - - rc = wrap___xmknodat(_STAT_VER, dirfd, path, (mode & 07777) | S_IFIFO, &unused); - -/* return rc; - * } - */ diff --git a/guts/mkstemp.c b/guts/mkstemp.c deleted file mode 100644 index 83f7bfe..0000000 --- a/guts/mkstemp.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_mkstemp(char *template) { - * int rc = -1; - */ - struct stat64 buf; - int save_errno; - size_t len; - char *tmp_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, tmp_template, &buf); - pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, 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, PSA_READ | PSA_WRITE, 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/mkstemp64.c b/guts/mkstemp64.c deleted file mode 100644 index def4126..0000000 --- a/guts/mkstemp64.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_mkstemp64(char *template) { - * int rc = -1; - */ - struct stat64 buf; - int save_errno; - size_t len; - char *tmp_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_mkstemp64(tmp_template); - - if (rc != -1) { - save_errno = errno; - - if (real___fxstat64(_STAT_VER, rc, &buf) != -1) { - pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, &buf); - pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, 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, PSA_READ | PSA_WRITE, 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/mktemp.c b/guts/mktemp.c deleted file mode 100644 index 7cf594a..0000000 --- a/guts/mktemp.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_mktemp(char *template) { - * char * rc = NULL; - */ - size_t len; - char *tmp_template; - - if (!template) { - errno = EFAULT; - return NULL; - } - - len = strlen(template); - tmp_template = PSEUDO_ROOT_PATH(AT_FDCWD, template, AT_SYMLINK_NOFOLLOW); - - if (!tmp_template) { - errno = ENOENT; - return NULL; - } - - rc = real_mktemp(tmp_template); - - /* mktemp only changes the XXXXXX at the end, and never created - * a file -- note the race condition implied here. - */ - memcpy(template + len - 6, tmp_template + strlen(tmp_template) - 6, 6); - rc = template; - free(tmp_template); - -/* return rc; - * } - */ diff --git a/guts/nftw.c b/guts/nftw.c deleted file mode 100644 index 73daec8..0000000 --- a/guts/nftw.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_nftw(const char *path, int (*fn)(const char *, const struct stat *, int, struct FTW *), int nopenfd, int flag) { - * int rc = -1; - */ - - rc = real_nftw(path, fn, nopenfd, flag); - -/* return rc; - * } - */ diff --git a/guts/nftw64.c b/guts/nftw64.c deleted file mode 100644 index 82571cd..0000000 --- a/guts/nftw64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_nftw64(const char *path, int (*fn)(const char *, const struct stat64 *, int, struct FTW *), int nopenfd, int flag) { - * int rc = -1; - */ - - rc = real_nftw64(path, fn, nopenfd, flag); - -/* return rc; - * } - */ diff --git a/guts/open.c b/guts/open.c deleted file mode 100644 index 0a0596c..0000000 --- a/guts/open.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_open(const char *path, int flags, ...mode_t mode) { - * int rc = -1; - */ - - return wrap_openat(AT_FDCWD, path, flags, mode); - -/* return rc; - * } - */ diff --git a/guts/open64.c b/guts/open64.c deleted file mode 100644 index adeb885..0000000 --- a/guts/open64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_open64(const char *path, int flags, ...mode_t mode) { - * int rc = -1; - */ - - rc = wrap_openat(AT_FDCWD, path, flags, mode | O_LARGEFILE); - -/* return rc; - * } - */ diff --git a/guts/openat.c b/guts/openat.c deleted file mode 100644 index c245796..0000000 --- a/guts/openat.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_openat(int dirfd, const char *path, int flags, ...mode_t mode) { - * int rc = -1; - */ - struct stat64 buf; - int existed = 1; - int save_errno; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } -#endif - /* if a creation has been requested, check whether file exists */ - if (flags & O_CREAT) { - save_errno = errno; -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___xstat64(_STAT_VER, path, &buf); -#else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); -#endif - existed = (rc != -1); - if (!existed) - pseudo_debug(2, "openat_creat: %s -> 0%o\n", path, mode); - errno = save_errno; - } - - /* because we are not actually root, secretly mask in 0700 to the - * underlying mode - */ -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real_open(path, flags, PSEUDO_FS_MODE(mode)); -#else - rc = real_openat(dirfd, path, flags, PSEUDO_FS_MODE(mode)); -#endif - save_errno = errno; - - if (rc != -1) { - int stat_rc; -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - stat_rc = real___xstat64(_STAT_VER, path, &buf); -#else - stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); -#endif - - 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_OPEN, PSEUDO_ACCESS(flags), 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, PSEUDO_ACCESS(flags), rc, dirfd, path, 0); - } - errno = save_errno; - } - -/* return rc; - * } - */ diff --git a/guts/openat64.c b/guts/openat64.c deleted file mode 100644 index 726ec6d..0000000 --- a/guts/openat64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_openat64(int dirfd, const char *path, int flags, ...mode_t mode) { - * int rc = -1; - */ - - rc = wrap_openat(dirfd, path, flags, mode | O_LARGEFILE); - -/* return rc; - * } - */ diff --git a/guts/opendir.c b/guts/opendir.c deleted file mode 100644 index 8eaa71f..0000000 --- a/guts/opendir.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static DIR * - * wrap_opendir(const char *path) { - * DIR * rc = NULL; - */ - - rc = real_opendir(path); - -/* return rc; - * } - */ diff --git a/guts/pathconf.c b/guts/pathconf.c deleted file mode 100644 index c6caa34..0000000 --- a/guts/pathconf.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static long - * wrap_pathconf(const char *path, int name) { - * long rc = -1; - */ - - rc = real_pathconf(path, name); - -/* return rc; - * } - */ diff --git a/guts/readlink.c b/guts/readlink.c deleted file mode 100644 index 18d9dc7..0000000 --- a/guts/readlink.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static ssize_t - * wrap_readlink(const char *path, char *buf, size_t bufsiz) { - * ssize_t rc = -1; - */ - - rc = wrap_readlinkat(AT_FDCWD, path, buf, bufsiz); - -/* return rc; - * } - */ diff --git a/guts/readlinkat.c b/guts/readlinkat.c deleted file mode 100644 index 5282e2b..0000000 --- a/guts/readlinkat.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static ssize_t - * wrap_readlinkat(int dirfd, const char *path, char *buf, size_t bufsiz) { - * ssize_t rc = -1; - */ -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - rc = real_readlink(path, buf, bufsiz); -#else - rc = real_readlinkat(dirfd, path, buf, bufsiz); -#endif - - if (rc > 0) { - rc = pseudo_dechroot(buf, rc); - } - -/* return rc; - * } - */ diff --git a/guts/realpath.c b/guts/realpath.c deleted file mode 100644 index 8059f5e..0000000 --- a/guts/realpath.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_realpath(const char *name, char *resolved_name) { - * char * rc = NULL; - */ - char *rname = PSEUDO_ROOT_PATH(AT_FDCWD, name, 0); - ssize_t len; - if (!rname) { - errno = ENAMETOOLONG; - return NULL; - } - if ((len = strlen(rname)) >= pseudo_sys_path_max()) { - free(rname); - errno = ENAMETOOLONG; - return NULL; - } - if (resolved_name) { - memcpy(resolved_name, rname, len + 1); - free(rname); - rc = resolved_name; - } else { - rc = rname; - } - -/* return rc; - * } - */ diff --git a/guts/remove.c b/guts/remove.c deleted file mode 100644 index 47f8752..0000000 --- a/guts/remove.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_remove(const char *path) { - * int rc = -1; - */ - struct stat buf; - if (real___lxstat(_STAT_VER, path, &buf) == -1) { - errno = ENOENT; - return -1; - } - if (S_ISDIR(buf.st_mode)) { - rc = wrap_rmdir(path); - } else { - rc = wrap_unlink(path); - } - -/* return rc; - * } - */ diff --git a/guts/removexattr.c b/guts/removexattr.c deleted file mode 100644 index bf844dd..0000000 --- a/guts/removexattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int removexattr(const char *pathname, const char *name) - * int rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/rename.c b/guts/rename.c deleted file mode 100644 index 8d4106b..0000000 --- a/guts/rename.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_rename(const char *oldpath, const char *newpath) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 oldbuf, newbuf; - int oldrc, newrc; - int save_errno; - int old_db_entry = 0; - - pseudo_debug(2, "rename: %s->%s\n", - oldpath ? oldpath : "<nil>", - newpath ? newpath : "<nil>"); - - if (!oldpath || !newpath) { - errno = EFAULT; - return -1; - } - - save_errno = errno; - - newrc = real___lxstat64(_STAT_VER, newpath, &newbuf); - oldrc = real___lxstat64(_STAT_VER, oldpath, &oldbuf); - - errno = save_errno; - - /* newpath must be removed. */ - /* as with unlink, we have to mark that the file may get deleted */ - msg = pseudo_client_op(OP_MAY_UNLINK, 0, -1, -1, newpath, newrc ? NULL : &newbuf); - if (msg && msg->result == RESULT_SUCCEED) - old_db_entry = 1; - rc = real_rename(oldpath, newpath); - save_errno = errno; - if (old_db_entry) { - if (rc == -1) { - /* since we failed, that wasn't really unlinked -- put - * it back. - */ - pseudo_client_op(OP_CANCEL_UNLINK, 0, -1, -1, newpath, &newbuf); - } else { - /* confirm that the file was removed */ - pseudo_client_op(OP_DID_UNLINK, 0, -1, -1, newpath, &newbuf); - } - } - if (rc == -1) { - /* and we're done. */ - errno = save_errno; - return rc; - } - save_errno = errno; - /* nothing to do for a "rename" of a link to itself */ - if (newrc != -1 && oldrc != -1 && - newbuf.st_dev == oldbuf.st_dev && - newbuf.st_ino == oldbuf.st_ino) { - return rc; - } - - /* rename(3) is not mv(1). rename(file, dir) fails; you must provide - * the corrected path yourself. You can rename over a directory only - * if the source is a directory. Symlinks are simply removed. - * - * If we got here, the real rename call succeeded. That means newpath - * has been unlinked and oldpath has been linked to it. - * - * There are a ton of special cases to error check. I don't check - * for any of them, because in every such case, the underlying rename - * failed, and there is nothing to do. - * The only tricky part is that, because we used to ignore symlinks, - * we may have to rename or remove directory trees even though in - * theory rename can never destroy a directory tree. - */ - if (!old_db_entry) { - /* create an entry under the old name, which will then be - * renamed; this way, children would get renamed too, if there - * were any. - */ - if (newrc == 0) { - if (newbuf.st_dev != oldbuf.st_dev) { - oldbuf.st_dev = newbuf.st_dev; - oldbuf.st_ino = newbuf.st_ino; - } - } - pseudo_debug(1, "creating new '%s' [%llu] to rename\n", - oldpath, (unsigned long long) oldbuf.st_ino); - pseudo_client_op(OP_LINK, 0, -1, -1, oldpath, &oldbuf); - } - pseudo_client_op(OP_RENAME, 0, -1, -1, newpath, &oldbuf, oldpath); - - errno = save_errno; -/* return rc; - * } - */ diff --git a/guts/renameat.c b/guts/renameat.c deleted file mode 100644 index c8203b7..0000000 --- a/guts/renameat.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) { - * int rc = -1; - */ - - pseudo_diag("help! unimplemented renameat [%s -> %s].\n", oldpath, newpath); - rc = real_renameat(olddirfd, oldpath, newdirfd, newpath); - -/* return rc; - * } - */ diff --git a/guts/rmdir.c b/guts/rmdir.c deleted file mode 100644 index af7fb7e..0000000 --- a/guts/rmdir.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_rmdir(const char *path) { - * int rc = -1; - */ - pseudo_msg_t *msg; - struct stat64 buf; - int save_errno; - int old_db_entry = 0; - - rc = real___lxstat64(_STAT_VER, path, &buf); - if (rc == -1) { - return rc; - } - msg = pseudo_client_op(OP_MAY_UNLINK, 0, -1, -1, path, &buf); - if (msg && msg->result == RESULT_SUCCEED) - old_db_entry = 1; - rc = real_rmdir(path); - if (old_db_entry) { - if (rc == -1) { - save_errno = errno; - pseudo_client_op(OP_CANCEL_UNLINK, 0, -1, -1, path, &buf); - errno = save_errno; - } else { - pseudo_client_op(OP_DID_UNLINK, 0, -1, -1, path, &buf); - } - } else { - pseudo_debug(1, "rmdir on <%s>, not in database, no effect.\n", path); - } - -/* return rc; - * } - */ diff --git a/guts/scandir.c b/guts/scandir.c deleted file mode 100644 index afcebaf..0000000 --- a/guts/scandir.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_scandir(const char *path, struct dirent ***namelist, int (*filter)(const struct dirent *), int (*compar)(const void *, const void *)) { - * int rc = -1; - */ - - rc = real_scandir(path, namelist, filter, compar); - -/* return rc; - * } - */ diff --git a/guts/scandir64.c b/guts/scandir64.c deleted file mode 100644 index 1317b73..0000000 --- a/guts/scandir64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_scandir64(const char *path, struct dirent64 ***namelist, int (*filter)(const struct dirent64 *), int (*compar)(const void *, const void *)) { - * int rc = -1; - */ - - rc = real_scandir64(path, namelist, filter, compar); - -/* return rc; - * } - */ diff --git a/guts/setegid.c b/guts/setegid.c deleted file mode 100644 index ff777a0..0000000 --- a/guts/setegid.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setegid(gid_t egid) { - * int rc = -1; - */ - if (pseudo_euid == 0 || egid == pseudo_egid || egid == pseudo_rgid || egid == pseudo_sgid) { - pseudo_egid = egid; - pseudo_fgid = egid; - pseudo_client_touchgid(); - rc = 0; - } else { - rc = -1; - errno = EPERM; - } -/* return rc; - * } - */ diff --git a/guts/seteuid.c b/guts/seteuid.c deleted file mode 100644 index 430768f..0000000 --- a/guts/seteuid.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_seteuid(uid_t euid) { - * int rc = -1; - */ - if (pseudo_euid == 0 || euid == pseudo_euid || euid == pseudo_ruid || euid == pseudo_suid) { - pseudo_euid = euid; - pseudo_fuid = euid; - pseudo_client_touchuid(); - rc = 0; - } else { - rc = -1; - errno = EPERM; - } -/* return rc; - * } - */ diff --git a/guts/setfsgid.c b/guts/setfsgid.c deleted file mode 100644 index 0e5a10b..0000000 --- a/guts/setfsgid.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setfsgid(gid_t fsgid) { - * int rc = -1; - */ - if (pseudo_euid == 0 || - pseudo_egid == fsgid || pseudo_rgid == fsgid || pseudo_sgid == fsgid) { - pseudo_fgid = fsgid; - rc = 0; - } else { - rc = -1; - errno = EPERM; - } -/* return rc; - * } - */ diff --git a/guts/setfsuid.c b/guts/setfsuid.c deleted file mode 100644 index e52b65e..0000000 --- a/guts/setfsuid.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setfsuid(uid_t fsuid) { - * int rc = -1; - */ - if (pseudo_euid == 0 || - pseudo_euid == fsuid || pseudo_ruid == fsuid || pseudo_suid == fsuid) { - pseudo_fuid = fsuid; - rc = 0; - } else { - rc = -1; - errno = EPERM; - } -/* return rc; - * } - */ diff --git a/guts/setgid.c b/guts/setgid.c deleted file mode 100644 index b94db1a..0000000 --- a/guts/setgid.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setgid(gid_t gid) { - * int rc = -1; - */ - if (pseudo_euid == 0) { - pseudo_rgid = gid; - pseudo_egid = gid; - pseudo_sgid = gid; - pseudo_fgid = gid; - pseudo_client_touchgid(); - rc = 0; - } else if (pseudo_egid == gid || pseudo_sgid == gid || pseudo_rgid == gid) { - pseudo_egid = gid; - pseudo_fgid = gid; - pseudo_client_touchgid(); - rc = 0; - } else { - rc = -1; - errno = EPERM; - } -/* return rc; - * } - */ diff --git a/guts/setgrent.c b/guts/setgrent.c deleted file mode 100644 index 75aab61..0000000 --- a/guts/setgrent.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static void - * wrap_setgrent(void) { - * - */ - - pseudo_grp_open(); - -/* return; - * } - */ diff --git a/guts/setgroups.c b/guts/setgroups.c deleted file mode 100644 index 31b2b57..0000000 --- a/guts/setgroups.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setgroups(size_t size, const gid_t *list) { - * int rc = -1; - */ - - /* let gcc know we're ignoring these */ - (void) size; - (void) list; - /* you always have all group privileges. we're like magic! */ - rc = 0; - -/* return rc; - * } - */ diff --git a/guts/setpwent.c b/guts/setpwent.c deleted file mode 100644 index fb35e07..0000000 --- a/guts/setpwent.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static void - * wrap_setpwent(void) { - * - */ - - pseudo_pwd_open(); - -/* return; - * } - */ diff --git a/guts/setregid.c b/guts/setregid.c deleted file mode 100644 index 78b2037..0000000 --- a/guts/setregid.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setregid(gid_t rgid, gid_t egid) { - * int rc = -1; - */ - rc = 0; - if (pseudo_euid != 0 && rgid != (gid_t) -1 && - rgid != pseudo_egid && rgid != pseudo_rgid && rgid != pseudo_sgid) { - rc = -1; - errno = EPERM; - } - if (pseudo_euid != 0 && egid != (gid_t) -1 && - egid != pseudo_egid && egid != pseudo_rgid && egid != pseudo_sgid) { - rc = -1; - errno = EPERM; - } - if (rc != -1) { - if (rgid != (gid_t) -1) - pseudo_rgid = rgid; - if (egid != (gid_t) -1) - pseudo_egid = egid; - pseudo_fgid = pseudo_egid; - pseudo_client_touchuid(); - } -/* return rc; - * } - */ diff --git a/guts/setresgid.c b/guts/setresgid.c deleted file mode 100644 index 2a26405..0000000 --- a/guts/setresgid.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setresgid(gid_t rgid, gid_t egid, gid_t sgid) { - * int rc = -1; - */ - rc = 0; - if (pseudo_euid != 0 && rgid != (gid_t) -1 && - rgid != pseudo_egid && rgid != pseudo_rgid && rgid != pseudo_sgid) { - rc = -1; - errno = EPERM; - } - if (pseudo_euid != 0 && egid != (gid_t) -1 && - egid != pseudo_egid && egid != pseudo_rgid && egid != pseudo_sgid) { - rc = -1; - errno = EPERM; - } - if (pseudo_euid != 0 && sgid != (gid_t) -1 && - sgid != pseudo_egid && sgid != pseudo_rgid && sgid != pseudo_sgid) { - rc = -1; - errno = EPERM; - } - if (rc != -1) { - if (rgid != (gid_t) -1) - pseudo_rgid = rgid; - if (egid != (gid_t) -1) - pseudo_egid = egid; - if (sgid != (gid_t) -1) - pseudo_sgid = sgid; - pseudo_fgid = pseudo_egid; - pseudo_client_touchuid(); - } -/* return rc; - * } - */ diff --git a/guts/setresuid.c b/guts/setresuid.c deleted file mode 100644 index a0a367f..0000000 --- a/guts/setresuid.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setresuid(uid_t ruid, uid_t euid, uid_t suid) { - * int rc = -1; - */ - rc = 0; - if (pseudo_euid != 0 && ruid != (uid_t) -1 && - ruid != pseudo_euid && ruid != pseudo_ruid && ruid != pseudo_suid) { - rc = -1; - errno = EPERM; - } - if (pseudo_euid != 0 && euid != (uid_t) -1 && - euid != pseudo_euid && euid != pseudo_ruid && euid != pseudo_suid) { - rc = -1; - errno = EPERM; - } - if (pseudo_euid != 0 && suid != (uid_t) -1 && - suid != pseudo_euid && suid != pseudo_ruid && suid != pseudo_suid) { - rc = -1; - errno = EPERM; - } - if (rc != -1) { - if (ruid != (uid_t) -1) - pseudo_ruid = ruid; - if (euid != (uid_t) -1) - pseudo_euid = euid; - if (suid != (uid_t) -1) - pseudo_suid = suid; - pseudo_fuid = pseudo_euid; - pseudo_client_touchuid(); - } -/* return rc; - * } - */ diff --git a/guts/setreuid.c b/guts/setreuid.c deleted file mode 100644 index 3ff82ab..0000000 --- a/guts/setreuid.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setreuid(uid_t ruid, uid_t euid) { - * int rc = -1; - */ - rc = 0; - if (pseudo_euid != 0 && ruid != (uid_t) -1 && - ruid != pseudo_euid && ruid != pseudo_ruid && ruid != pseudo_suid) { - rc = -1; - errno = EPERM; - } - if (pseudo_euid != 0 && euid != (uid_t) -1 && - euid != pseudo_euid && euid != pseudo_ruid && euid != pseudo_suid) { - rc = -1; - errno = EPERM; - } - if (rc != -1) { - if (ruid != (uid_t) -1) - pseudo_ruid = ruid; - if (euid != (uid_t) -1) - pseudo_euid = euid; - pseudo_fuid = pseudo_euid; - pseudo_client_touchuid(); - } -/* return rc; - * } - */ diff --git a/guts/setuid.c b/guts/setuid.c deleted file mode 100644 index 6bfdf6c..0000000 --- a/guts/setuid.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_setuid(uid_t uid) { - * int rc = -1; - */ - if (pseudo_euid == 0) { - pseudo_ruid = uid; - pseudo_euid = uid; - pseudo_suid = uid; - pseudo_fuid = uid; - pseudo_client_touchuid(); - rc = 0; - } else if (pseudo_euid == uid || pseudo_suid == uid || pseudo_ruid == uid) { - pseudo_euid = uid; - pseudo_fuid = uid; - pseudo_client_touchuid(); - rc = 0; - } else { - rc = -1; - errno = EPERM; - } -/* return rc; - * } - */ diff --git a/guts/setxattr.c b/guts/setxattr.c deleted file mode 100644 index c9a590c..0000000 --- a/guts/setxattr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * int setxattr(const char *pathname, const char *name, const void *value, size_t size, int flags) - * int rc = -1; - */ - - errno = ENOTSUP; - -/* return rc; - * } - */ diff --git a/guts/symlink.c b/guts/symlink.c deleted file mode 100644 index 487c135..0000000 --- a/guts/symlink.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_symlink(const char *oldname, const char *newpath) { - * int rc = -1; - */ - - rc = wrap_symlinkat(oldname, AT_FDCWD, newpath); - -/* return rc; - * } - */ diff --git a/guts/symlinkat.c b/guts/symlinkat.c deleted file mode 100644 index b70d500..0000000 --- a/guts/symlinkat.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_symlinkat(const char *oldname, int dirfd, const char *newpath) { - * int rc = -1; - */ - struct stat64 buf; - char *roldname = 0; - - if (oldname[0] == '/' && pseudo_chroot_len && !pseudo_nosymlinkexp) { - size_t len = pseudo_chroot_len + strlen(oldname) + 1; - roldname = malloc(len); - snprintf(roldname, len, "%s%s", pseudo_chroot, oldname); - } - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - rc = real_symlink(roldname ? roldname : oldname, newpath); -#else - rc = real_symlinkat(roldname ? roldname : oldname, dirfd, newpath); -#endif - - if (rc == -1) { - free(roldname); - return rc; - } -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___lxstat64(_STAT_VER, newpath, &buf); -#else - rc = real___fxstatat64(_STAT_VER, dirfd, newpath, &buf, AT_SYMLINK_NOFOLLOW); -#endif - if (rc == -1) { - int save_errno = errno; - 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, 0, -1, dirfd, newpath, &buf); - - free(roldname); - -/* return rc; - * } - */ diff --git a/guts/tempnam.c b/guts/tempnam.c deleted file mode 100644 index 9b0257f..0000000 --- a/guts/tempnam.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_tempnam(const char *template, const char *pfx) { - * char * rc = NULL; - */ - /* let gcc know we ignored these on purpose */ - (void) template; - (void) pfx; - pseudo_diag("tempnam() is so ludicrously insecure as to defy implementation."); - errno = ENOMEM; - rc = NULL; - -/* return rc; - * } - */ diff --git a/guts/tmpnam.c b/guts/tmpnam.c deleted file mode 100644 index 3fece57..0000000 --- a/guts/tmpnam.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static char * - * wrap_tmpnam(char *s) { - * char * rc = NULL; - */ - - /* let gcc know we're ignoring this */ - (void) s; - pseudo_diag("tmpnam() is so ludicrously insecure as to defy implementation."); - errno = ENOMEM; - rc = NULL; - -/* return rc; - * } - */ diff --git a/guts/truncate.c b/guts/truncate.c deleted file mode 100644 index 6a19a50..0000000 --- a/guts/truncate.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_truncate(const char *path, off_t length) { - * int rc = -1; - */ - - rc = real_truncate(path, length); - -/* return rc; - * } - */ diff --git a/guts/truncate64.c b/guts/truncate64.c deleted file mode 100644 index a798984..0000000 --- a/guts/truncate64.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_truncate64(const char *path, off64_t length) { - * int rc = -1; - */ - - rc = real_truncate64(path, length); - -/* return rc; - * } - */ diff --git a/guts/ulckpwdf.c b/guts/ulckpwdf.c deleted file mode 100644 index bdb6f42..0000000 --- a/guts/ulckpwdf.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_ulckpwdf(void) { - * int rc = -1; - */ - - /* lock is cleared automatically on close */ - pseudo_pwd_lck_close(); - rc = 0; - -/* return rc; - * } - */ diff --git a/guts/unlink.c b/guts/unlink.c deleted file mode 100644 index d8a5d01..0000000 --- a/guts/unlink.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_unlink(const char *path) { - * int rc = -1; - */ - - rc = wrap_unlinkat(AT_FDCWD, path, 0); - -/* return rc; - * } - */ diff --git a/guts/unlinkat.c b/guts/unlinkat.c deleted file mode 100644 index 3bfda81..0000000 --- a/guts/unlinkat.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2008-2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_unlinkat(int dirfd, const char *path, int rflags) { - * int rc = -1; - */ - pseudo_msg_t *msg; - int save_errno; - struct stat64 buf; - int old_db_entry; - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - if (dirfd != AT_FDCWD) { - errno = ENOSYS; - return -1; - } - 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", - rflags, path ? path : "<nil>"); - errno = ENOSYS; - return -1; - } -#endif - -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___lxstat64(_STAT_VER, path, &buf); -#else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, AT_SYMLINK_NOFOLLOW); -#endif - if (rc == -1) { - return rc; - } - msg = pseudo_client_op(OP_MAY_UNLINK, 0, -1, dirfd, path, &buf); - if (msg && msg->result == RESULT_SUCCEED) - old_db_entry = 1; -#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real_unlink(path); -#else - rc = real_unlinkat(dirfd, path, rflags); -#endif - if (old_db_entry) { - if (rc == -1) { - save_errno = errno; - pseudo_client_op(OP_CANCEL_UNLINK, 0, -1, -1, path, &buf); - errno = save_errno; - } else { - pseudo_client_op(OP_DID_UNLINK, 0, -1, -1, path, &buf); - } - } else { - pseudo_debug(1, "unlink on <%s>, not in database, no effect.\n", path); - } - -/* return rc; - * } - */ diff --git a/guts/utime.c b/guts/utime.c deleted file mode 100644 index ff65237..0000000 --- a/guts/utime.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_utime(const char *path, const struct utimbuf *buf) { - * int rc = -1; - */ - rc = real_utime(path, buf); - -/* return rc; - * } - */ diff --git a/guts/utimes.c b/guts/utimes.c deleted file mode 100644 index 69ad949..0000000 --- a/guts/utimes.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2010 Wind River Systems; see - * guts/COPYRIGHT for information. - * - * static int - * wrap_utimes(const char *path, const struct timeval *times) { - * int rc = -1; - */ - rc = real_utimes(path, times); - -/* return rc; - * } - */ |