| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We now create a per-command socket pair in the command handler and use the
permanent server-afs socket to pass one end of the pair from the command
handler to the afs process.
With this approach only the command handlers can possibly talk to the
afs process, so we don't need to worry about malicious or bogus connections
arriving at the local socket.
Consequently, we may remove the socket cookie and employ blocking I/O for the
shared memory identifiers that are transferred through the per-command socket.
Connections are now dispatched in one go, obviating the need to keep track
of connected clients. So remove struct afs_client and the client list.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Switch to SPDX licence identifiers
A single patch which replaces the first comment line of most .c and .h files
containing the copyright notice by standardized SPDX (Software/System Package
Data Exchange) nomenclature.
* t/spdx:
Switch to SPDX identifiers.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Generated with
sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h
followed by manually tweaking the result a bit. No license change intended.
|
| |\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Provide --init as a replacement for com_init()
This change does not need a deprecation period because initialization is
only necessary for new instances.
* t/init:
afs: Simplify table open functions.
server: Replace the init subcommand by --init.
|
| | |/
| |
| |
| |
| |
| | |
With the init subcommand gone, it's now a fatal error if at least one table
cannot be opened. So remove the silly "table does not exist, but continue
so that the user can create it" dance we currently do.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This iterates over all audio files to check if the attribute to be removed
is still set in the on-disk afs_info structure of the audio file. If at
least one such audio file is detected, the rmatt subcommand aborts.
With this new behaviour, the existing loop in aft_event_handler() which
clears the corresponding bit from each on-disk afs_info can be removed. This
was the only event handler that looked at the bit number passed, so we may
as well pass NULL instead.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
To obtain an unused bit in the attribute table we currently look up each
value in the range 0-63 in this table until we encounter an unused bit. It
is more efficient to fetch the attribute bitmask once, then compute the
first zero without calling into the osl library.
Also inefficient is that the addatt subcommand generates one ATTRIBUTE_ADD
event for each argument. This can be expensive because the event causes a
mood reload. Change that to generate only one event.
|
| | |
| |
| |
| |
| |
| | |
Return the bit number directly, avoiding the result pointer argument for
the bit number. Remove the pointless "one" variable in one of the callers,
the touch callback, while at it.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The public get_attribute_bitmap() is defined in attribute.c and called from
the ls callback to print an attribute string such as xx--x, indicating which
attribute bits are set/unset. This function should instead be part of aft.c
where the ls subcommand is implemented, so move it there and make it static.
The ls command needs to know the highest used attribute number to limit the
output width of the attribute string. This number is currently maintained in
a global variable of attribute.c. Provide the public attr_get_max_bitnum()
helper to make it available to aft.c.
It is easier to compute the value when it is needed than to maintain the value
in a global variable. This is not performance critical anyway, since the ls
command calls the function only once (rather than once per audio file listed).
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Rather than looking up each bit number in the attribute table, we now loop
over all existing attributes and check whether the corresponding bit is on
in the given attribute bitmask. This should be more efficient.
Switch to para buffers and drop the delimiter argument since the only user,
the callback of the ls subcommand, passes a constant value.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently both the audio file table and the attribute table implement a
check function. The latter first computes the bitmask which corresponds
to the defined attributes, then passes the resulting 64-bit integer to
aft_check_attributes(), which loops over all rows. The loop callback
de-serializes the afs_info structure of the row and checks the attributes
of the row against the bitmask.
This patch removes the check function of the attribute table as
well as aft_check_attributes(). The replacement is the new public
attr_get_defined_mask() in attribute.c.
To make this work, the check function of the audio file table is modified
to call the new function, then iterate over all rows as before, passing the
mask to the existing loop callback. The loop callback is extended to perform
the same check that aft_check_attributes() did before.
This simplifies the code, and should perform better because we now de-serialize
the afs_info struct only once per audio file rather than twice.
As a result, the --attributes option of the check command has become unused.
So we deprecate this option.
|
| | |
| |
| |
| |
| |
| |
| | |
We perform arithmetical operations and use its value as the right hand side
of the shift operator, so uint8_t seems to be more natural than unsigned
char. Rename char_compare() to u8_compare() and simplify it a bit by
dereferencing the two pointers right away.
|
| | |
| |
| |
| |
| | |
It contains only an 8 bit integer, so we may as well just pass a pointer to
uint8_t instead.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
Only the event handler of the audio file table uses the para_buffer to send
the "clearing bit" message on ATTRIBUTE_REMOVE events. It does so without
NULL-checking the para_buffer pointer first, which is dubious but not a bug
because the only source of ATTRIBUTE_REMOVE is the callback of the rmatt
command, which passes non-NULL. We can simply omit the message, and remove
the para_buffer argument from afs_event() and from all event handlers.
|
| | |
| |
| |
| | |
The new message states more precisely what went wrong.
|
| |/
|
|
|
|
|
|
| |
We rejected these due to the weird syntax of the former setatt server
subcommand. With setatt gone, this is no longer relevant, so patch the addatt
callback to be more lenient.
Fixes: ddc0ff368f85f44479132213c920df95c72e45c5
|
| |
|
|
|
| |
The users outside of error.h may as well call osl(), which leaves only
a single caller in error.h. Open-code the macro there and remove it.
|
| |
|
|
|
|
|
|
| |
The aft event handler needs to know the bit number of the attribute which is
being removed in order to clear the bit in the afs info structure of each row
of the audio file table. The handler does not need to know the attribute's
name, though, and remove_attribute() already prints it, so remove this field
from the event data structure.
|
| |
|
|
| |
Every .c file includes it anyway.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The callbacks of some afs commands employ the normal ->pbpout para
buffer to send an error message to the client on failure. These
messages are therefore tagged with the OUTPUT sideband designator
just as regular command output.
The receiving client writes such messages to stdout, so applications
which call para_client have no other way than parsing the output to
guess whether it is normal command output or an error message.
This commit improves on this by providing a public helper in afs.c
to format and send an error message that is tagged with the ERROR
sideband designator and thus gets written to stderr on the client
side. All afs callbacks which currently use ->pbout for error messages
are converted to call the new helper.
|
| |
|
|
|
|
| |
This is simpler, avoids the run-time initialization, and allows us
to mark the instances of the operations structures constant. Improve
the documentation a bit while at it.
|
| |
|
|
|
|
|
|
| |
It is passed to afs_event() to tell the table event handlers the
name and bit number of the newly added attribute. However, the only
table which does not ignore attribute add events is the mood table,
and this just reloads the current mood without even looking at the
information passed.
|
| |
|
|
|
|
| |
Because static functions don't need doxygen comments. The existing
comments for attribute_close() and attribute_open() did not contain
useful information, so remove these,
|
| |
|
|
| |
We miss to free the lopsub parse result on exit. Found by valgrind.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The GPLv2 line does not add any additional information, so drop
it. This leaves a single line of legalese text for most files, which
is about the amount of screen real estate it deserves.
This patch was created with the following script (plus some manual
fixups):
awk '{
if (NR <= 5) {
gs = gensub(/.*Copyright.* ([0-9]+).*Andre Noll.*/, "\\1", "g")
if (gs != $0)
year = gs
next
}
if (NR == 6 && year != "")
printf("/* Copyright (C) %s Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */\n", year)
print
}'
|
| |
|
|
|
| |
This way doxygen issues a warning if the file/function/structure no
longer exists and a stale reference remains.
|
| |
|
|
|
|
|
| |
Another simple command without options which is easy to convert. The
only thing worth noting is that we now fail the command early if more
than 64 arguments are given when previously we only checked that at
least one argument is given.
|
| |
|
|
| |
No change to the action handler, remove_attribute(), necessary.
|
| |
|
|
|
|
| |
We need to cast the obj->data pointer to a non-constant type because
the osl library functions expect void *, which results in a warning
without the cast.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the first afs subcommand which needs to pass a pattern list
to its callback. The new send_lls_callback_request() provides this
functionality. It serializes the parse result into a buffer and passes
this buffer to the callback.
Since there are non-lopsub commands which also pass a pattern list,
action_if_pattern_matches() is patched to receive the pattern
list either from the serialized parse result or in the old way via
pmd->data. To achieve this, a parse result pointer is added to struct
pattern_match_data. If this pointer is not NULL, we are dealing with
a subcommand that has been converted.
Since the ls subcommand has not been converted yet, lopsub will
regard "ls" as a uniqe abbreviation of the lsatt command, which
breaks t0004. To work around this, we deactivate prefix matching by
only accepting exact matches in run_command(). This workaround can
be removed after com_ls() has been converted.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently the server commands are divided into two group: those
commands which are handled by the server process and those which
communicate with the afs process. This commit converts the commands of
the former group and the corresponding completers for para_client to
the lopsub suite format while the afs commands will be converted in
subsequent commits. After this change para_server needs to be linked
with -llopsub.
To this aim the options and help texts of of the server commands are
transferred from server.cmd to the new server_cmd.suite.m4, enabling
long-style options in the progress. Moreover, an introduction is added
at the beginning of the list of server commands which describes how
server commands are executed.
Command permissions are now handled by making use of the aux_info
feature of lopsub. To keep those commands working which do not
have any permission bit set, we need to add a new identifier
NO_PERMISSION_REQUIRED to enum server_command_permissions of
user_list.h. The value of this identifier is zero of course.
Naturally the bulk of the change takes place in command.c where all
server commands are implemented. The command handlers are modified
to take a pointer to a struct lls_parse result as an additional
argument. A new helper, send_errctx(), is introduced to avoid code
duplication.
Since command.h now refers to a lopsub parse result, all files which
include command.h, including those which implement only afs commands,
need to include the system header lopsub.h.
To keep afs commands working, some compatibility code in run_command()
is added. This will go away after all commands have been converted.
A couple of macros in command.h ease the handling of the long symbolic
constants exposed by the generated lopsub header file.
Although only the non-afs commands are converted, the change allows
for a couple of cleanups:
* The E_BAD_COMMAND error code is no longer needed and has been
removed.
* cmd_perms_itohuman() has become unused and is removed.
* The server_cmds[] array is empty and can be removed, along
with the loop in send_list_of_commands() which iterated over
the array.
The patch also adjusts tests t0004 and t0005 since the help output
format changed slightly, breaking the expectations of these tests.
|
| |
|
|
|
|
|
|
|
|
| |
att_logical_or() is called from com_check() to set up a bitmask where
a bit is set if and only if it corresponds to an existing attribute.
Doing "1 << i" is wrong in this context because the constant "1" is a
(signed) 32 bit quantity and we need to be able to shift by more than
31 bits for the attribute mask.
Fix this by using an uint64_t variable instead.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Cooking for about two months.
* refs/heads/t/command_handler_cleanups: (39 commits)
com_addatt(): Return negative on errors
com_rm(): In force mode, don't complain if no paths matched.
aft: Unify handling of hash and path duplicates.
afs: Provide pbout para_buffer for each callback.
afs: Make afs callbacks more flexible.
afs: Rename callback_function to afs_callback.
com_check(): Add attribute checking.
Let afs_event() return int.
playlist_check_callback(): Return negative on errors
mood_check_callback(): Return negative on errors
com_mvblob(): Return negative on errors
com_addblob(): Return negative on errors
com_rmblob(): Return negative on errors, cleanup
com_catblob(): Return negative on errors
com_lsblob(): Return negative on errors
rmatt: Cleanup callback.
com_rmatt(): Return negative on errors
com_mvatt(): Return negative on errors
com_lsatt(): Return negative on errors
com_init(): Return negative on errors
...
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Most afs callbacks define a para_buffer to pass output from the
callback to the command handler. Hence the code which defines and
initializes the para_buffer is duplicated many times.
This commit gets rid of the duplication by moving the initialization
to the common call_callback(). The para_buffer becomes part of
struct afs_callback_arg, a pointer to which is passed to every
callback. The buffer is also flushed and freed in call_callback()
so that the callbacks don't need to care about it any more. This also
allows to make flush_and_free_pb() static since only a single caller
in afs.c remains.
This change simplifies the callbacks considerably. The callbacks of the
rm, setatt, lsatt, lsblob and touch commands don't even need their own
"action_data" structure any more since it was only necessary to pass
the para_buffer to the ->action method.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently we pass the information for callbacks (an int and a pointer
to an osl_object) as separate arguments. If additional information
must be passed to some callbacks, every callback must be modified to
match the new prototype, even those which won't use the new argument.
This commit introduces struct afs_callback_arg which contains the two
callback arguments and changes all callbacks to receive a pointer
to such a structure. This is an equivalent transformation with no
visible change in semantics.
With this commit in place it is easy to provide additional information
by simply extending struct afs_callback as appropriate.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The afs info stored in the audio file table contains the attribute
bit mask of each audio file. If there is a bit set which does
not correspond to an attribute defined in the attribute table, we
have an inconsistency. This commit adds a check that reports such
inconsistencies.
com_check(), which is part of afs.c, calls the attribute check
callback of attribute.c via the callback mechanism. The callback
computes the logical or of all defined bits and passes this bit mask
to aft_check_attributes() of aft.c to check each audio file against
the mask. Hence two new public functions are required.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It is usually a critical error if an afs event handler returns an
error. Currently we only print a log message an continue in this
case. The callers of afs_event() which trigger the event have no way
to tell that something went wrong, since this function returns void.
By returning int instead of void the callers can abort in the error
case. Most of the callers are afs callbacks. These can propagate the
error code to the command handler process, which will translate the
error code into a string and send it to the client. All callbacks
are changed in this way.
|
| | |
| |
| |
| |
| |
| |
| | |
Get rid of struct remove_attribute_action_data, since only the para
buffer is necessary. This changes the code to pass a pointer to the
para buffer itself as the data pointer for ->action() of the pattern
matching loop.
|
| | | |
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It was a design mistake that callbacks have no way to tell whether
they were successful. This commit changes the callback_function
typedef so that callbacks return int instead of void.
Naturally, every callback must be adjusted accordingly. Doing so would
make the patch a bit large, so as a first step we make all callbacks
(except path_brother_callback() and hash_sister_callback() which
are special) return zero. The return value is ignored at the moment,
so the changes of this commit have no effect yet.
|
| | |
| |
| |
| | |
This kills some code which is duplicated in all command handlers.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This function rarely fails, and if it does, we don't care too much. On
the other hand, checking the return value of each call to para_printf()
clutters the code considerably, especially in the error paths where
there is already an error code we have to keep.
This commit simply removes all error checking for para_printf(),
resulting in code which is easier to follow and less error-prone.
|
| | |
| |
| |
| | |
ret is known to be negative at this point.
|
| |\ \
| |/
|/|
| |
| |
| | |
* maint:
lsatt: Fix sort order.
server: Avoid segfault in com_sender().
|
| | |
| |
| |
| |
| |
| |
| | |
The -i option had the opposite effect of what the documentation
says. That is, lsatt -i sorted the attribute list by name while the
default was to sort by id. This patch reverts the logic in com_lsatt()
to let the implementation match the documentation.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Done with
files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll')
sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files
In previous years we ran a similar script to set the second year in
the range to the current year. This is kind of silly, so let's get
rid of this useless information.
This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in
all file headers, i.e. only the first year (A) is left in. Accurate
information including time stamps for each change can be obtained
from the git history.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The mail server on systemlinux.org was down for more than a week
lately, so let's use an alternative official address. This commit
changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de.
Most .c and .h files contain the email address in the copyright header,
so they must all be patched. Three other files contain the address
for a different reason:
* README lists email and git, gitweb and home page URLs
* configure.ac needs it for configure -h
* version.c contains it for the -V option of all commands
|