@@ -11,19 +11,7 @@
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 */
@@ -11,27 +11,13 @@
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;
}
@@ -23,15 +23,7 @@
/* 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;
@@ -41,13 +33,8 @@
errno = EINVAL;
return -1;
}
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- rc = real_open(path, O_CREAT | O_WRONLY | O_EXCL,
- PSEUDO_FS_MODE(mode, 0));
-#else
rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL,
PSEUDO_FS_MODE(mode, 0));
-#endif
if (rc == -1) {
return -1;
}
@@ -73,11 +60,7 @@
}
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;
}
@@ -17,13 +17,6 @@
/* mask out mode bits appropriately */
mode = mode & ~pseudo_umask;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
-#endif
-
#ifdef PSEUDO_FORCE_ASYNC
/* Yes, I'm aware that every Linux system I've seen has
* DSYNC and RSYNC being the same value as SYNC.
@@ -54,15 +47,7 @@
/* note "else" in #ifdef O_TMPFILE above */
if (flags & O_CREAT) {
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (flags & O_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 & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
-#endif
existed = (rc != -1);
if (!existed)
pseudo_debug(PDBGF_FILE, "openat_creat: %s -> 0%o\n", path, mode);
@@ -75,15 +60,7 @@
*/
if (!(flags & O_NONBLOCK) && ((flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_RDWR)) {
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (flags & O_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 & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
-#endif
if (rc != -1 && S_ISFIFO(buf.st_mode)) {
overly_magic_nonblocking = 1;
}
@@ -99,11 +76,7 @@
* is if a file is going to be created, in which case it's
* not a directory.
*/
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- rc = real_open(path, flags, PSEUDO_FS_MODE(mode, 0));
-#else
rc = real_openat(dirfd, path, flags, PSEUDO_FS_MODE(mode, 0));
-#endif
if (overly_magic_nonblocking) {
save_errno = errno;
sigprocmask(SIG_SETMASK, &local_saved_sigmask, NULL);
@@ -132,15 +105,7 @@
return rc;
}
#endif
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (flags & O_NOFOLLOW) {
- stat_rc = real___lxstat64(_STAT_VER, path, &buf);
- } else {
- stat_rc = real___xstat64(_STAT_VER, path, &buf);
- }
-#else
stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
-#endif
pseudo_debug(PDBGF_FILE, "openat(path %s), flags %o, stat rc %d, stat mode %o\n",
path, flags, stat_rc, buf.st_mode);
@@ -44,7 +44,7 @@
/* mask out mode bits appropriately */
my_how.mode = my_how.mode & ~pseudo_umask;
-#if defined(PSEUDO_NO_REAL_AT_FUNCTIONS) || ! defined(SYS_openat2)
+#ifndef SYS_openat2
if (dirfd != AT_FDCWD) {
errno = ENOSYS;
return -1;
@@ -81,15 +81,7 @@
/* note "else" in #ifdef O_TMPFILE above */
if (my_how.flags & O_CREAT) {
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (my_how.flags & O_NOFOLLOW) {
- rc = real___lxstat64(_STAT_VER, pseudo_path, &buf);
- } else {
- rc = real___xstat64(_STAT_VER, pseudo_path, &buf);
- }
-#else
rc = real___fxstatat64(_STAT_VER, dirfd, pseudo_path, &buf, (my_how.flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
-#endif
existed = (rc != -1);
if (!existed)
pseudo_debug(PDBGF_FILE, "openat2_creat: %s -> 0%lld\n", pseudo_path, my_how.mode);
@@ -102,15 +94,7 @@
*/
if (!(my_how.flags & O_NONBLOCK) && ((my_how.flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_RDWR)) {
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (my_how.flags & O_NOFOLLOW) {
- rc = real___lxstat64(_STAT_VER, pseudo_path, &buf);
- } else {
- rc = real___xstat64(_STAT_VER, pseudo_path, &buf);
- }
-#else
rc = real___fxstatat64(_STAT_VER, dirfd, pseudo_path, &buf, (my_how.flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
-#endif
if (rc != -1 && S_ISFIFO(buf.st_mode)) {
overly_magic_nonblocking = 1;
}
@@ -126,7 +110,7 @@
* is if a file is going to be created, in which case it's
* not a directory.
*/
-#if defined(PSEUDO_NO_REAL_AT_FUNCTIONS) || ! defined(SYS_openat2)
+#ifndef SYS_openat2
pseudo_debug(PDBGF_SYSCALL, "openat2, calling open.\n");
rc = real_open(path, my_how.flags, PSEUDO_FS_MODE(my_how.mode, 0));
#else
@@ -167,15 +151,7 @@
return rc;
}
#endif
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (my_how.flags & O_NOFOLLOW) {
- stat_rc = real___lxstat64(_STAT_VER, pseudo_path, &buf);
- } else {
- stat_rc = real___xstat64(_STAT_VER, pseudo_path, &buf);
- }
-#else
stat_rc = real___fxstatat64(_STAT_VER, dirfd, pseudo_path, &buf, (my_how.flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
-#endif
pseudo_debug(PDBGF_FILE, "openat2(path %s), flags %lld, stat rc %d, stat mode %o\n",
pseudo_path, my_how.flags, stat_rc, buf.st_mode);
@@ -10,19 +10,7 @@
*/
PSEUDO_STATBUF buf;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
- if (flags & AT_SYMLINK_NOFOLLOW) {
- rc = base_lstat(path, &buf);
- } else {
- rc = base_stat(path, &buf);
- }
-#else
rc = base_fstatat(dirfd, path, &buf, flags & AT_SYMLINK_NOFOLLOW);
-#endif
if (rc == -1)
return rc;
@@ -11,19 +11,7 @@
PSEUDO_STATBUF buf;
int save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
- if (flags & AT_SYMLINK_NOFOLLOW) {
- rc = base_lstat(path, &buf);
- } else {
- rc = base_stat(path, &buf);
- }
-#else
rc = base_fstatat(dirfd, path, &buf, flags);
-#endif
if (rc == -1) {
return rc;
}
@@ -50,13 +38,7 @@
#endif
/* user bits added so "root" can always access files. */
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- /* note: if path was a symlink, and AT_SYMLINK_NOFOLLOW was
- * specified, we already bailed previously. */
- real_chmod(path, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode)));
-#else
rc = real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode)), flags);
-#endif
/* we otherwise ignore failures from underlying fchmod, because pseudo
* may believe you are permitted to change modes that the filesystem
* doesn't. Note that we also don't need to know whether the
@@ -12,19 +12,7 @@
PSEUDO_STATBUF buf;
int save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
- if (flags & AT_SYMLINK_NOFOLLOW) {
- rc = base_lstat(path, &buf);
- } else {
- rc = base_stat(path, &buf);
- }
-#else
rc = base_fstatat(dirfd, path, &buf, flags);
-#endif
if (rc == -1) {
return rc;
}
@@ -27,12 +27,6 @@
rflags = (flags & AT_SYMLINK_FOLLOW) ? 0 : AT_SYMLINK_NOFOLLOW;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (olddirfd != AT_FDCWD || newdirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
-#endif
oldpath = oldname;
if (oldpath && *oldpath && pseudo_chroot_len && !strncmp(oldpath, pseudo_chroot, pseudo_chroot_len) &&
oldpath[pseudo_chroot_len] == '/') {
@@ -54,11 +48,6 @@
*/
#ifdef O_TMPFILE
if (!strncmp(oldpath, "/proc/self/fd/", 14) && (flags & AT_SYMLINK_FOLLOW)) {
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- /* only linkat() lets you do this horrible thing */
- errno = ENOSYS;
- return -1;
-#endif
tmpfile_fd = pseudo_atoi_wrapper(oldpath + 14);
// call actual link
rc = real_linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, AT_SYMLINK_FOLLOW);
@@ -10,34 +10,17 @@
*/
/* mask out mode bits appropriately */
mode = mode & ~pseudo_umask;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
-
- rc = real_mkdir(path, PSEUDO_FS_MODE(mode, 1));
-#else
rc = real_mkdirat(dirfd, path, PSEUDO_FS_MODE(mode, 1));
-#endif
if (rc != -1) {
PSEUDO_STATBUF buf;
int stat_rc;
int save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- stat_rc = base_lstat(path, &buf);
-#else
stat_rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
-#endif
if (stat_rc != -1) {
buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode);
pseudo_client_op(OP_MKDIR, 0, -1, dirfd, path, &buf);
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- real_fchmod(path, PSEUDO_FS_MODE(mode, 1));
-#else
real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, 1), 0);
-#endif
} else {
pseudo_debug(PDBGF_OP, "mkdir of %s succeeded, but stat failed: %s\n",
path, strerror(errno));
@@ -16,29 +16,12 @@
/* mask out mode bits appropriately */
mode = mode & ~pseudo_umask;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
- rc = base_stat(path, &buf);
-#else
rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
-#endif
if (rc != -1) {
/* if we can stat the file, you can't mkfifo it */
errno = EEXIST;
return -1;
}
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- rc = real_mkfifo(path, PSEUDO_FS_MODE(mode, 0));
- if (rc == -1) {
- return -1;
- }
- save_errno = errno;
- rc = base_stat(path, &buf);
- real_chmod(path, PSEUDO_FS_MODE(mode, 0));
-#else
rc = real_mkfifoat(dirfd, path, PSEUDO_FS_MODE(mode, 0));
if (rc == -1) {
return -1;
@@ -46,7 +29,6 @@
save_errno = errno;
rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, 0), 0);
-#endif
/* if the stat failed, we are going to give up and nuke
* any file we may have created, and hope for the best.
*/
@@ -67,11 +49,7 @@
}
if (rc == -1) {
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- real_unlink(path);
-#else
real_unlinkat(dirfd, path, AT_SYMLINK_NOFOLLOW);
-#endif
errno = save_errno;
}
@@ -21,27 +21,14 @@
pseudo_debug(PDBGF_FILE, "mknodat creating '%s', mode 0%o\n",
path ? path : "<no name>", (int) mode);
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (dirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
- rc = base_stat(path, &buf);
-#else
rc = base_fstatat(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;
}
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- rc = real_open(path, O_CREAT | O_WRONLY | O_EXCL,
- PSEUDO_FS_MODE(mode, 0));
-#else
rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL,
PSEUDO_FS_MODE(mode, 0));
-#endif
if (rc == -1) {
return -1;
}
@@ -68,11 +55,7 @@
}
if (rc == -1) {
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- real_unlink(path);
-#else
real_unlinkat(dirfd, path, AT_SYMLINK_NOFOLLOW);
-#endif
errno = save_errno;
}
@@ -8,15 +8,7 @@
* 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);
@@ -20,13 +20,6 @@
olddirfd, oldpath ? oldpath : "<nil>",
newdirfd, newpath ? newpath : "<nil>");
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- if (olddirfd != AT_FDCWD || newdirfd != AT_FDCWD) {
- errno = ENOSYS;
- return -1;
- }
-#endif
-
if (!oldpath || !newpath) {
errno = EFAULT;
return -1;
@@ -34,13 +27,8 @@
save_errno = errno;
-#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
- newrc = base_lstat(newpath, &newbuf);
- oldrc = base_lstat(oldpath, &oldbuf);
-#else
oldrc = base_fstatat(olddirfd, oldpath, &oldbuf, AT_SYMLINK_NOFOLLOW);
newrc = base_fstatat(newdirfd, newpath, &newbuf, AT_SYMLINK_NOFOLLOW);
-#endif
/* nothing to do for a "rename" of a link to itself */
if (newrc != -1 && oldrc != -1 &&
@@ -17,25 +17,13 @@
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 = base_lstat(newpath, &buf);
-#else
rc = base_fstatat(dirfd, newpath, &buf, AT_SYMLINK_NOFOLLOW);
-#endif
if (rc == -1) {
int save_errno = errno;
pseudo_warning("symlinkat: couldn't stat '%s' even though symlink creation succeeded (%s).\n",
@@ -13,39 +13,14 @@
PSEUDO_STATBUF buf;
int old_db_entry = 0;
-#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_info("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 = base_lstat(path, &buf);
-#else
rc = base_fstatat(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;
@@ -135,23 +135,16 @@ extern char *pseudo_version;
#define PSEUDO_SEVERITY_DEFAULT "info,warn,error"
-/* some systems might not have *at(). We like to define operations in
- * terms of each other, and for instance, open(...) is the same as
- * openat(AT_FDCWD, ...). If no AT_FDCWD is provided, any value that can't
- * be a valid file descriptor will do. Using -2 because -1 could be
- * mistaken for a failed syscall return. AT_SYMLINK_NOFOLLOW has to be
- * non-zero; AT_SYMLINK_FOLLOW has to be non-zero and different. Finally,
- * if this happened, we set our own flag we can use to indicate that dummy
- * implementations of the _at functions are needed.
+/* pseudo defines operations in terms of each other; for instance,
+ * open(...) is the same as openat(AT_FDCWD, ...). This requires the *at()
+ * functions and AT_FDCWD, AT_SYMLINK_NOFOLLOW and AT_SYMLINK_FOLLOW from
+ * <fcntl.h>.
*/
#ifndef AT_FDCWD
-#define AT_FDCWD -2
-#define AT_SYMLINK_NOFOLLOW 1
-#define AT_SYMLINK_FOLLOW 2
-#define PSEUDO_NO_REAL_AT_FUNCTIONS
+#error "pseudo requires *at() function support (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_SYMLINK_FOLLOW)"
#endif
-/* Likewise, someone might not have O_LARGEFILE (the flag equivalent to
+/* Someone might not have O_LARGEFILE (the flag equivalent to
* using open64()). Since open64() is the same as O_LARGEFILE in flags,
* we implement it that way... If the system has no O_LARGEFILE, we'll
* just call open() with nothing special.