aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2014-01-22some minor tweaks to the performance testPeter Seebach
2013-06-25Change debugging to use flags rather than levelsPeter Seebach
This is a moderately intrusive change. The basic overall effect: Debugging messages are now controlled, not by a numeric "level", but by a series of flags, which are expressed as a string of letters. Each flag has a single-letter form used for string specifications, a name, a description, a numeric value (1 through N), and a flag value (which is 1 << the numeric value). (This does mean that no flag has the value 1, so we only have 31 bits available. Tiny violins play.) The other significant change is that the pseudo_debug calls are now implemented with a do/while macro containing a conditional, so that computationally-expensive arguments are never evaluated if the corresponding debug flags weren't set. The assumption is that in the vast majority of cases (specifically, all of them so far) the debug flags for a given call are a compile-time constant, so the nested conditional will never actually show up in code when compiled with optimization; we'll just see the appropriate conditional test. The VERBOSE flag is magical, in that if the VERBOSE flag is used in a message, the debug flags have to have both VERBOSE and at least one other flag for the call to be made. This should dramatically improve performance for a lot of cases without as much need for PSEUDO_NDEBUG, and improve the ability of users to get coherent debugging output that means something and is relevant to a given case. It's also intended to set the stage for future development work involving improving the clarity and legibility of pseudo's diagnostic messages in general. Old things which used numeric values for PSEUDO_DEBUG will sort of continue to work, though they will almost always be less verbose than they used to. There should probably be a pass through adding "| PDBGF_CONSISTENCY" to a lot of the messages that are specific to some other type.
2013-06-18Fix RHEL 4.7 compilation errorPeter Seebach
No idea how this survived so long, but the clone() syscall prototype on RHEL 4.7 doesn't have the "..." for additional arguments, so we can't pass them. Also had unused variables that would otherwise have been being filled in from va_args and passed. But there's no extra args to pass. Interestingly, this contradicts the clone() man page in RHEL 4.7. If you have problems with clone() there, that's probably why.
2013-02-27documentation updatesPeter Seebach
2013-02-27remove left-over debug messagePeter Seebach
2013-02-26PSEUDO_ALLOW_FSYNC: Allow fsync()pseudo-1.5PSEUDO_1_5Peter Seebach
Some filesystems have buggy semantics where stat(2) will return incorrect sizes for files for a while after some changes, sometimes, unless they've been fsync'd. We still want to disable fsync most of the time, but enabling it for specific programs can be useful. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2013-02-26completely remove pseudo_debugcalls when -DNDEBUGPeter Seebach
2013-02-17Darwin fixes for fsync changes, uninitialized variablePeter Seebach
Darwin's off_t is a 64-bit type, so there's no off64_t. Also, there's an uninitialized variable usage in unlinkat which LLVM catches. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2013-02-16If you don't want the answer, don't ask the question.Peter Seebach
Most pseudo operations don't actually USE the server's response. So why wait for a response? This patch introduces a new message type, PSEUDO_MSG_FASTOP. It also tags pseudo operation types with whether or not they need to give a response. This requires updates to maketables to allow non-string types for additional columns, and the addition of some quotes to the SQL query enums/query_type.in table. A few routines are altered to change their behavior and whether or not they perform a stat operation. The only operations that do wait are OP_FSTAT and OP_STAT, OP_MKNOD, and OP_MAY_UNLINK. Rationale: You can't query the server for replacement information and not wait for it. Makes no sense. There's extra checking in mknod, because we really do want to fail out if we couldn't do that -- that implies that we haven't created a thing that will look like a node. The result from OP_MAY_UNLINK is checked because it's used to determine whether we need to send a DID_UNLINK or CANCEL_UNLINK. It might be cheaper to send two messages without waiting than to send one, wait, and maybe send another, but I don't want to send invalid messages. This is highly experimental.
2013-02-16allow pseudo to force asynchronous behaviorPeter Seebach
The openembedded build, at least with RPM or SMART, is heavily affected by the cost of calling fsync or fdatasync on package databases all the time. Gosh, wouldn't it be nice if we could suppress that without making dozens of highly intrusive and risky changes into RPM, various database packages, and so on? Yes, yes it would. If only there were a program which could intercept system calls and change their behavior! Enter --enable-force-async. There are now wrappers for fsync, fdatasync, and a few related functions. If --enable-force-async is set, these wrappers instantly return 0, even if PSEUDO_DISABLED is set. And with any luck, bitbake will now perform a bit better. Credit for this insight goes to Richard Purdie. I've reimplemented this to add the configure option, and make the fsync suppression work even when PSEUDO_DISABLED is set.
2013-02-16Use in-memory database for filesPeter Seebach
It turns out that file databases don't get very large, and that sqlite3 can be quite fast with an in-memory database. It also turns out that dumping the database to disk on exit (or during idle times) is pretty cheap compared to constant updates. So: We add "--enable-memory-db", which defaults to on if you have sqlite 3.7 or later, and off for 3.6 (because 3.6 has horrible performance with in-memory db on some hosts we tried).
2013-02-13Fix linkat() again.pseudo-1.4.5PSEUDO_1_4_5Peter Seebach
wrap_linkat() was trying to avoid "redundantly" expanding paths before calling real_linkat(). Which is fine when you're not using an absolute path in a chroot environment, but if you are, it ends up calling the real syscall with the absolute path and no chroot prefix. General observation: All the *at() implementations are expanding paths into absolute paths, then dutifully calling real_*at() functions with them anyway. This is silly. Added a note to Futures.txt to fix it some day. In the mean time, linkat() is fixed correctly; it always expands paths, does so exactly once, and then uses the underlying link() call because it doesn't need special processing of directory fds anymore. Also fixed errno stashing to reduce the risk that link() will change errno in a circumstance where it doesn't actually fail.
2013-02-12Fix link() to work when chrootedpseudo-1.4.4PSEUDO_1_4_4Peter Seebach
The automatic path fixups invoked for names which end in the string "path" was still applying to link(), which then called linkat(), which would do the same path fixups; if you were chrooted, this would produce bogus paths. On systems which actually have linkat(), this would produce the even more mysterious behavior that the link would succeed, but the following stat would fail. Solution: Change the wrapfuncs prototypes for link() so it doesn't invoke automatic path name fixups.
2013-01-31Tag: 1.4.3.pseudo-1.4.3PSEUDO_1_4_3Peter Seebach
Fixed up the libdir stuff in a saner way, fixed the @GLIBC_2.7 thing, want to avoid any risk of someone having a stale archive.
2013-01-30Add sqlite-lib setting.pseudo-1.4.2PSEUDO_1_4_2Peter Seebach
There's a few circumstances where sqlite's libdir isn't the same as the directory name we want to use for libpseudo.so, so make it a separate setting. This may obviate the need for --with-static-sqlite. Signed-off-by: seebs <peter.seebach@windriver.com>
2013-01-30Remove a couple of highly non-obvious GLIBC_2.7 dependencies.Peter Seebach
There were a couple of cases where pseudo built against GLIBC_2.7 or newer was ending up with dependencies on symbols which required GLIBC_2.7. With these gone, it appears that a libpseudo.so can be used on an older host in some cases. None were particularly important or intentional: 1. pseudo_util was conditionally calling open() with only two arguments, which can invoke a new __open2() function in some systems. Don't care, and the docs specifically state that the mode argument is "ignored" when O_CREAT is absent, so it's not necessary to omit it. 2. The calls to sscanf/fscanf in pseudo_client.c were getting translated into a special new iso_c99 sscanf/fscanf, and we don't care because we're not using those features; #define _GNU_SOURCE suppresses the extra-compliant behavior. Signed-off-by: seebs <peter.seebach@windriver.com>
2012-12-13tag (and makefile.in) 1.4.2Peter Seebach
2012-12-12bitrot and linkat() fixes for Darwin.SEEBS_TESTINGPeter Seebach
2012-12-12add linkat() implementationPeter Seebach
We never had an implementation for linkat() because no one used it; now someone uses it. link() is now implemented on top of linkat(). Note the abnormal AT_SYMLINK_FOLLOW (as opposed to _NOFOLLOW) flag.
2012-11-02Makefile.in/configure: Use $(LIB), not hardcoded lib, for sqlitePeter Seebach
It turns out that the -L usage mostly doesn't matter (usually something else has requested the right directory, or it's the default), but the explicit path to libsqlite3.a hardcoded "lib", and on some systems it should be something else, such as "lib64". Solution: Use $(LIB) for that directory. Note that this may not resolve things if, say, you're doing MIPS n32 on a target where that lives in /usr/lib32, but I think in that case you'd be specifying $libdir, so it should still work out. Also added --with-static-sqlite=/path as an option in case people need to further outsmart this. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2012-08-09Fix up chroot damage caused by PSEUDO_STATBUF fixpseudo-1.4.1PSEUDO_1_4_1Peter Seebach
The PSEUDO_STATBUF change (allowing operations on files over 2GB even on 32-bit systems) introduced a subtle bug; by calling stat64() rather than real_stat(), pseudo stopped handling chrooted paths well. In most cases, this was fine, but in the specific case of a rename, where the stat buffers for the various parts were actually used, it wasn't. Of particular note, pseudo could end up creating links which had stack garbage for their stat buffs, because it assumed that if the rename operation succeeded, the stat operations must have succeeded. Of course, there is no real_stat64 in the Linux port, because there's no need for it; most code is calling __xstat64 or some relative thereof, and even if you did really call stat64, it'd end up routed there anyway. So we add that so that it can be used for calls and we don't have to encode Linux-specific magic about __xstat into the generic header.
2012-08-02Remove the _plain thing, use PSEUDO_STATBUF everywhere.Peter Seebach
The _plain thing was added because of clashes between Linux ("struct stat64 for 64-bit file sizes") and Darwin ("struct stat is already 64 bits"). But it turns out not to be enough, because stat will *fail* if it cannot represent a file size, so when something like unlinkat() calls a non-64-bit stat in order to determine whether a file exists, it gets the wrong answer if the file is over 2GB in size. Solution: Continue using PSEUDO_STATBUF, and also provide defines for base_stat() which can be either real_stat() or real_stat64(), etcetera. This eliminates any reason to need the _plain functions. It also suggests that the other real___fxstatat() calls should someday go away because that is an ugly, ugly, implementation detail. As part of testing this, fix up some bitrot which affected Darwin (such as the continue outside of a loop, but inside an #ifdef; that was left over from the conversion of init_one_wrapper to a separate function).
2012-07-27Use .tar.bz2 tarballpseudo-1.4PSEUDO_1_4Peter Seebach
Instead of using .tgz, use .tar.bz2 (and change czf to cjf). This makes life easier for Yocto.
2012-07-24CleanupPeter Seebach
Clean up a couple of (harmless, but unsightly) bits of cruft left from a failed attempt at implementing the ARCH_FLAGS support.
2012-07-20tag 1.4Peter Seebach
2012-07-20Don't try to learn all the architecture-specific flagsPeter Seebach
Pseudo should never have been the one picking -m32/-m64. That should be coming from the build system in some way. Deprecate --arch, add --cflags.
2012-06-281.3.1 tagPeter Seebach
Enough changes to justify a tag.
2012-06-28[Yocto #2639] Don't crash with really long chroot directoriesPeter Seebach
The logic for whether to allocate space for the "base" path in pseudo_fix_path recognized that you don't need it when the path you're evaluating starts with a slash. This is great, except: 1. It's not actually true, if rootlen isn't 0. 2. The decision of whether or not to copy over the base path didn't check for this, so it would happen anyway. The net result is, if you had a path in excess of 256 characters as a base (say, a chroot directory), and you tried to evaluate a path starting with a slash (say, /etc/shadow), pseudo would allocate enough space for the path, but not for the base path, and then copy the base path into it anyway. The rounding up to multiples of 256 isn't enough to save us in this case. Solution: 1. Make the logic for the base path copy match the allocation logic. 2. Use (path[0] != '/' || rootlen) as the second part of the test, because if there's a non-zero rootlen, we're in a chroot and MUST preserve at least some of the path. This could maybe be smarter (what if we only allocated space for rootlen in that case?) except that in reality, it's very very often the case that baselen == rootlen, and it's not as though we want MORE complexity.
2012-04-30change official upstreamPeter Seebach
2012-04-10First pass at smarter handling of multilib compile optionsPeter Seebach
Long story short: ARM doesn't use -m32 and -m64, so make those a little more dependent. We'll probably rework this completely "soon" as we mess with more targets and x32 becomes an issue.
2012-04-09Improve RPATH logicPeter Seebach
The existing behavior was to set rpath to whatever was specified explicitly with --with-rpath, or to set a default if the opt_rpath variable was unset and we reached a --with-sqlite. This turns out to be incorrect in the case where a static sqlite is being used. You can force the issue with --without-rpath, but it's probably better to make the inference smarter. This also allows the slight cleanup of setting opt_rpath to '' to begin with, because we're no longer depending on the distinction between empty and unset.
2012-03-28cleanup and fixesPeter Seebach
Spotted a couple of things during the last batch of fixes; fixing these up so things are more consistent or clearer.
2012-03-27call this 1.3pseudo-1.3PSEUDO_1_3Peter Seebach
2012-03-27Allow static sqlitePeter Seebach
Some systems prefer to avoid messing with LD_LIBRARY_PATH as much, and instead link sqlite statically.
2012-03-27Configuration cleanup for OE-core:Peter Seebach
In OE-Core we need to be able to configure for both 32-bit and 64-bit libpseudo libraries. In order to avoid some complex manipulations, we adjust the configure and Makefile to facilitate this. Upstream-Status: Submitted Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2012-03-27add popen() callPeter Seebach
We weren't trapping popen(), so if environment variables were in an inconsistent state when popen() was called, Bad Things Happened. Add a popen() wrapper. Like a couple of other special cases, is applied even when pseudo is theoretically disabled, and that includes the antimagic case. (But we never use popen() so that's fine.)
2012-02-06The O_LARGEFILE value was getting merged into mode (where it wasPeter Seebach
ignored) rather than flags (where it was needed), meaning that the open64 type functions didn't work as intended on 32-bit hosts.
2012-02-06fix spaces/tabs in python againPeter Seebach
2012-02-06Fix *at() function interface holesPeter Seebach
1. Fix *at() where dirfd is obtained through dirfd(DIR *). The dirfd(DIR *) interface allows you to get the fd for a DIR *, meaning you can use it with openat(), meaning you can need its path. This causes a segfault. Also fixed the base_path code not to segfault in that case, but first fix the underlying problem. 2. Implement renameat() After three long years, someone tried to use this. This was impossibly hard back when pseudo was written, because there was only one dirfd provided for. Thing is, now, the canonicalization happens in wrapfuncs, so a small tweak to makewrappers to recognize that oldpath should use olddirfd if it exists is enough to get us fully canonicalized paths when needed.
2011-11-02Name this 1.2pseudo-1.2PSEUDO_1_2Peter Seebach
2011-11-02Initialize memory in pseudo_client to avoid valgrind warningMark Hatle
2011-11-01: * (mhatle) Stop valgrind from reporting use of uninitialized memory from pseudo_client:client_ping() Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2011-11-02Rework the clone wrapper to add an intermediate function to resolve a defect.Mark Hatle
Previously the clone(2) wrapper unconditionallity restored the system environment. It also invokes the checks to see if the user has requested pseudo to be disabled or unloaded. Due to the semantics of clone, this caused both the parent and child processes to be disabled or unloaded. The new code adds an intermediate function, wrap_clone_child, that only runs within the child context. This way we can be sure to only disable/unload pseudo from within the child process. In addition, we avoid mucking with the environment if CLONE_VM is set, since this will affect both parent and child. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2011-11-02Implement PSEUDO_UNLOAD, replacing existing PSEUDO_RELOADED semantics.Mark Hatle
Change from internal PSEUDO_RELOADED to external PSEUDO_UNLOAD environment variable. Enable external programs to have a safe and reliable way to unload pseudo on the next exec*. PSEUDO_UNLOAD also will disable pseudo if we're in a fork/clone situation in the same way PSEUDO_DISABLED=1 would. Rename the PSEUDO_DISABLED tests, and create a similar set for the new PSEUDO_UNLOAD. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2011-07-19Fix uninitalized variable.Peter Seebach
You might be wondering why this wasn't caught. Answer: gcc's too smart. Consider: int x; if (condition) x = 23; return x; This function will just return 23. Since gcc knows that it doesn't matter what happens if x is used uninitialized (it's an indeterminate value, thus a possible trap representation, thus undefined behavior to use it), it simplifies the initial part of this away. Thus there's no use of an uninitialized value. Something similar seems to be at issue with the use of the uninitialized f in pseudo_init_one_wrapper. The variable wasn't initialized in the pre-realpath-fix version either, but in that version, the assignment from dlsym was completely unconditional.
2011-06-09Fix realpath(name, NULL) when PSEUDO_DISABLED=1Peter Seebach
On some Linux systems, dlsym("realpath", RTLD_NEXT) prefers for reasons of its own to give a symbol that is also known as old_realpath, which fails and yields EINVAL when called with a null pointer as the second argument. This can be avoided, on some systems, by using dlvsym() to request the GLIBC_2.3 version of the symbol. The wrapper logic is enhanced to allow for specifying versions, although this currently only works for Linux (Darwin has no dlvsym, apparently?). The test case is a trivial program which calls realpath(name, NULL) run with PSEUDO_DISABLED=1.
2011-06-061.1.1 releasePeter Seebach
2011-06-06Improve system()Peter Seebach
2011-06-02Call this "version 1.1".Peter Seebach
2011-06-02Add system() wrapper to force setup of the pseudo environment. NotePeter Seebach
that we add an extra fork() so we can do the setup in a child process, but still just pass the command string to the standard system() call.
2011-05-31Change logic on file creation/chmod so that we only secretly mask inPeter Seebach
the 0100 bit for directories. The reason is that otherwise we create plain files which are 0700 on disk, which means they're non-zero &0111, which breaks euidaccess(X_OK).