Sebastian Stark [Wed, 4 Feb 2009 10:16:01 +0000 (11:16 +0100)]
new option database-root
If database-root is given, the database dir is computed by
appending the base dir to it. Obviously this works only if
base dir is given, even for select mode.
The needed directory structure is created below database-root
by the new function mkpath(), which recursively creates any
directory needed to copy the structure of base dir. This
has the side-effect that the database dir is always created
for the user (if permissions allow) which wasn't the case
before.
database_dir is now a global variable just like conf and should
be used whenever conf.database_dir_arg was used before.
Andre Noll [Tue, 23 Dec 2008 16:26:52 +0000 (17:26 +0100)]
Make it compile on FreeBSD and NetBSD.
off_t on BSD is 64 bit even on 32bit machines, so there are no
special tricks needed to get large file support. In fact, getconf
has no options for large file support and struct stat64 and lstat64()
do not exist on BSD systems. This caused the compilation to fail on
those systems.
Fix this problem by checking for BSD via uname -s in the Makefile. If
uname indicates we're on BSD, then do not use getconf and #define
stat64 and lstat64() to stat and lstat() respectively.
Andre Noll [Wed, 17 Dec 2008 22:32:21 +0000 (23:32 +0100)]
Fix a design bug concerning struct user_info.
It was a bad idea to include the accounting data (#files, #dirs,
information about the user only.
So move the accounting data to user_summary_info. This allows
to get rid of the ugly uid_hash_table_sort_idx construct and of
sort_hash_table(). These were only needed because of the broken
design. We now never sort the hash table but allocate an array of
user_summary_info structures on each query and sort that array instead.
This patch not only simplifies code but also fixes a real bug noted by
Sebastian Stark: If the user_summary was requested more than once in
interactive mode, the old code computed incorrect values because the
above mentioned accounting fields were only initialized once. The new
code gets this right automatically because a fresh array is created
on each query.
Andre Noll [Sun, 9 Nov 2008 19:37:09 +0000 (20:37 +0100)]
Make the header line configurable.
This replaces the --no-header flag by --header string option. The
argument is the header of the summary/list.
This was not a straight-forward task because the headers for the
user lists contain the uid and the user name. So introduce another
set of format string directives to still allow this.
Andre Noll [Sun, 9 Nov 2008 14:33:16 +0000 (15:33 +0100)]
Fix sorting of the uid hash table.
We must not blindy sort the whole table because in interactive mode
this table may be modified by later commands and lookup_uid() gets
confused if the entries have been permuted. So introduce
uid_hash_table_sort_idx, an array of indices that describes the current
sorting of the hash table. The order of the entries in the table itsself
never gets changed any more with this patch.
Also, simplify the uid comparators by introducing a wrapper that does
the casts which were previously contained in each comparator.
Andre Noll [Sun, 9 Nov 2008 00:45:42 +0000 (01:45 +0100)]
Do not close tables on each query.
This speeds up interactive mode where many queries may be executed
in a row. User tables are opened on demand (if the uid is admissible)
and only closed on exit. Also the dir table is opened only once per
session rather than on each query.
Andre Noll [Sat, 8 Nov 2008 22:05:54 +0000 (23:05 +0100)]
User handling improvments.
- move global variable num_uids to user.c.
- logging improvements.
- replace search_uid() by create_user_table(). search_uid() had a
horrible interface.
- in user.c, use FOR_EACH_USER() to loop over all users rather than
for_each_admissible_user().
Andre Noll [Wed, 5 Nov 2008 17:30:28 +0000 (18:30 +0100)]
Fix return codes for loop functions.
The four different loop functions must set the return value in
their private struct because these functions are called from
within the osl library which will replace any negative return value
by -E_OSL_LOOP.
Andre Noll [Sat, 1 Nov 2008 22:45:47 +0000 (23:45 +0100)]
Improve interactive feeling, kill dump command.
It's no good to spam the user with syntax errors on empty lines.
In popular shells, the set command prints the current environment
if called without arguments. So do the same and kill the dump command.
Andre Noll [Sat, 1 Nov 2008 21:06:16 +0000 (22:06 +0100)]
Make it easier to print the help for select options.
It was always a bit awkward to print the help for the select options
because one had to specify a valid mode (-C -S or -I) and the required
-d option just to make gengetopt not bail out early.
Fix this flaw by not using gengetopt's internal help.
Andre Noll [Sat, 1 Nov 2008 19:21:18 +0000 (20:21 +0100)]
Add format string doku, simplify format string handling.
As adu now only prints one list/summary at a time, there's only need
for one format string. So replace the four format-string related
option by a single --format option and add a detailed description
on how adu format strings may be used.
Andre Noll [Sat, 1 Nov 2008 13:30:28 +0000 (14:30 +0100)]
Introduce select-mode and use pretty formating for the global lists.
This patch introduces the new --select-mode option which is used
to specify which of the four possible output formats should be used.
Only this table is being printed.
The other change to select.c is that the global list also uses the
functions from format.c to pretty-print the output. The new
--global-list-format option may be used to customize the output.
Andre Noll [Sun, 26 Oct 2008 13:13:01 +0000 (14:13 +0100)]
Add create_argv() to string.c.
A problem with gengetopt's string parser is that it can not handle
whitespace within parameters. It's therefore necessary to roll our
own line splitting code.