Age | Commit message (Collapse) | Author |
|
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-01:
* (mhatle) Stop valgrind from reporting use of uninitialized
memory from pseudo_client:client_ping()
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
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>
|
|
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>
|
|
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.
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
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).
|
|
|
|
Build improvements (better compatibility with how other people do things)
|
|
This is what GNU configure does, for valid reasons. My build wrapper
unconditionally passes --enable-maintainer-mode.
|
|
The way multilib works on at least Fedora is that --libdir=$prefix/lib64
is passed to configure. The source build system should not attempt to
guess at architecture or take other configure flags (like --bits); instead
it should default to whatever the given $(CC) does.
This patch preserves the ability to specify --bits however.
|
|
|
|
|
|
|
|
|
|
|
|
debugger messages from going to the wrong place. No longer fclose(stderr)
after grabbing log file, because stderr is likely still using fd 2.
|
|
|
|
This is a spiffied-up rebase of a bunch of intermediate changes, presented
as a whole because it is, surprisingly, less confusing that way. The basic
idea is to separate the guts code into categories ranging from generic
stuff that can be the same everywhere and specific variants. The big scary
one is the Darwin support, which actually seems to run okay on 64-bit OS X
10.6. (No other variants were tested.) The other example given is support
for the old clone() syscall on RHEL 4, which affects some wrlinux use cases.
There's a few minor cleanup bits here, such as a function with inconsistent
calling conventions, but nothing really exciting.
|
|
|
|
directly rather than via an on-demand spawn from the client, the
directory is never created.
|
|
|
|
This is fussy, because we have to actually do the path search ourselves
as best we can to handle unqualified paths. The result, though, is
more meaningful logs.
Along the way, fix some bitrot in the comments in pseudo_fix_path and
friends.
|
|
|
|
|
|
|
|
|
|
This reverts commit 49d4d35918d457b0e9206679ecad3b9c84f11e66.
|
|
The cached data values were being collected when an OP_EXEC call was made.
This is incorrect as the values are only for logging purposes. It's believed
this caused an occasional crash in certain instances.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
It'd be handy for the WR build system if new state directories could
be created as needed. It is made so. And to answer the first
question everyone, including me, has on reading this: You can't
do system("mkdir -p ...") because the invoked shell would need to
run under pseudo, so it'd have to check for a server, and...
|
|
|
|
The problem is that path_by_ino could end up being the same pointer
as cache_path, after which, if cache_path were freed (or kept around
for later), there would be malloc arena problems.
Also, fix the calculation for pathlen to increase cache hits. The
IPC messages use length of path *plus one* as the length, because
the buffer is defined to include its terminating null byte.
|
|
The pathlen that is cached could be wrong in certain operations (RENAME).
Fix this by resetting it to the proper path length.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
When pseudo is disabled, we skip a bunch of the prefix, localstate, etc
processing. This allows pseudo to run with a directory that does not yet
exist.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
before pseudo_tables.h existed. Fixed.
|
|
|
|
Changing the file journal to OFF, this makes things a bit more susceptible
to failure in cases where pseudo crashes or the system crashes.. however, this
is believed to be unlikely.
Timing:
Before:
real 6m42.093s
user 0m34.321s
sys 2m46.086s
(with journal set to MEMORY)
real 6m33.037s
user 0m33.133s
sys 2m48.668s
After (journal set to OFF)
real 6m17.313s
user 0m32.757s
sys 2m47.654s
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
We change the index from simply "path" to "path, dev, ino". This allows for
slightly faster searches for the exact file information, and does not cause
any penalty for a simple "path" based search.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
Add a cache of the last object found in pseudo_op. Profiling has indiciated
that many operations come in clusters. So instead of doing select, operation
for each item in the cluster, we check to see if we already know the item and
perform the op..
Performance improvement when processing 500k or so files:
Previous:
real 7m11.778s
user 0m35.929s
sys 2m46.723s
This commit:
real 6m42.093s
user 0m34.321s
sys 2m46.086s
Also validation of the component can be added by compiling with NVALIDATE.
This verifies the result of the cache is the same as what would have come
from the database. Differences are logged to the standard pseudo.log.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
We restructure the pseudo_op file identification, which involves a fairly
significant performance increase.
The old method would do:
if pdb_find_file_path:
found_path = 1;
if found_path && pdb_find_file_exact:
found_ino = 1;
else if pdb_find_file_dev:
found_ino = 1;
This resulted in at least two select calls for each file. One for "path"
and one for exact or dev.
The new method instead does:
if pdb_find_file_exact:
found_path = 1;
found_ino = 1;
else
if pdb_find_file_path:
found_path = 1;
if pdb_find_file_dev:
found_ino = 1;
This shrinks the number of selects to either one or three. Potentially cutting
the number of selects in half -- or increasing the number to three on an empty
set... (Profiling has shown this is a net win)
Timing numbers when manipulating a large number (500k) of files in a ramdisk:
real 7m48.354s
user 0m32.895s
sys 2m50.274s
After this change:
real 7m11.778s
user 0m35.929s
sys 2m46.723s
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
Add sqlite call profiling, this allows us to see the sqlite calls
that are being made as the system runs, via the pseudo log.
It was noted that by this profiling that a small change to pseudo.c,
when a file was found, reduced the sqlite SELECT calls by about 1/3.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
Restructure wrapfuncs.c in an attempt to improve PSEUDO_DISABLED=1
performance.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
2010-12-09:
* (mhatle) Add doc/program_flow to attempt to explain startup/running
* (mhatle) guts/* minor cleanup
* (mhatle) Reorganize into a new constructor for libpseudo ONLY
pseudo main() now manually calls the util init
new / revised init for client, wrappers and utils
* (mhatle) Add central "reinit" function
* (mhatle) Add manul execv* functions
* (mhatle) rename pseudo_populate_wrappers to pseudo_check_wrappers
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
* (mhatle) Add guts/clone.c to cleanup the clone support
* (mhatle) guts/clone.c only run setupenv and reinit when NOT PSEUDO_RELOADED
* (mhatle) guts/execve.c whitespace fixe
* (mhatle) guts/fork.c similar to guts/clone.c change
* (mhatle) pseudo_client.c add reinit function
* (mhatle) pseudo_client.c revise client reset, include code from pseudo_wrappers.c
* (mhatle) pseudo_server.c move the pid writing to the parent
* (mhatle) pseudo_wrappers.c clone cleanup and populate cleanup
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
be out of sync in a very inconvenient way.
Changes include:
* Some whitespace fixes, also move the pseudo_variables definition
into pseudo_util.c since it's not used anywhere else.
* Further improvements in the fork() support:
We now recognize both positive and negative forms of PSEUDO_DISABLED,
so we can distinguish between "it was removed from the environment
by env -i" (restore the old value) and "it was intentionally turned
off" (the new value wins).
* clone(2) support. This is a little primitive, and programs might still
fail horribly due to clone's semantics, but at least it's there and
passes easy test cases.
Plus a big patch from Mark Hatle:
Cleanup fork/clone and PSEUDO_DISABLED
guts/fork.c:
* cleanup function and make it more robust
* be sure to call pseudo_setupenv prior to pseudo_client_reset
to match exec behavior
pseudo_wrappers.c:
* fix mismatched type in execl_to_v call via typecast
* Simplify fork call via single call to wrap_fork()
* be sure to save pseudo_disabled
* be sure to call pseudo_setupenv prior to pseudo_client_reset
to match exec behavior
tests:
* Add a test of whether pseudo can be disabled/enabled on a fork.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|