The data in the directory entry structure is meant to be used in opening
a file. It should not change during the program.
For the virtual directory, the pointer to constant data must be wrapped
because the data for the open file is not constant.
There is extra debug logging in the code which can be activated by
`meson configure build -Dc_args=-DHEXAGONRPC_VERBOSE`. This may be
difficult to trigger, since it requires -D twice in the same argument.
Add the hexagonrpcd_verbose option to make it easier to configure the
extra logging.
This can be activated with `-Dhexagonrpcd_verbose=true` and deactivated
with `-Dhexagonrpcd_verbose=false`.
Most subdirectories in this project have all, pedantic, and some extra
warnings enabled. Set this for tests as well, as there is no real
justification otherwise.
Signed character arrays can overflow when specifying values greater than
127. The actual data is not affected, but this can cause compiler
warnings. Use unsigned character arrays so the compiler does not
complain about overflows.
This file seems to implicitly return 0 when everything is successful,
but this is unclear when reading it. Explicitly return zero when all
tests are successful.
This variable represents the subdirectory in the dsp/ directory where
libraries should be searched. This is the argument to the optional `-d`
and is used when creating the filesystem. Initialize it to an empty
string so HexagonFS searches in /usr/share/qcom/dsp/ by default.
The FastRPC implementation is loosely related to the sensor shell. It is
useful to provide interfaces over FastRPC for sensor DSP firmware, and
enables the sensor shell to provide most physical sensors. However, the
FastRPC implementation has no meaningful connection with the sensor
shell in terms of code. Move the FastRPC implementation to the project
root to make it more intuitive to install and use and to separate it
from a distinct project.
The CHRE client is not part of the core functionality of the daemon. The
client is only meant to run on sensorspd, and should not always run,
such as on non-Android or on rootpd. It should not be stuck in the file
with the program's entry point, as it needs to do more than simply
starting CHRE, like starting any useful nanoapps. Move it into a new
directory as a client that can use the same session as the daemon that
listens for remote method calls to the Application Processor, so the
session can make calls back to fetch files.
Also modify the calling conventions for starting the reverse tunnel,
since the calling conventions are not limited to a single pointer.
The HexagonRPCD daemon has support for sharing sessions with other
programs by executing them with the HEXAGONRPC_FD environment variable
set. Add a library function to obtain the file descriptor used in this
session for FastRPC communication.
The Linux kernel FastRPC driver creates a unique session for every
process that opens a file descriptor. Session sharing allows the sharing
of a reverse tunnel across clients that need it. Add support for
managing the session for clients.
The argument to -p is a path to any executable file, such as /bin/sh.
The file descriptor to the FastRPC device node is in the HEXAGONRPC_FD
environment variable.
Remove the brackets around the -f option which imply that it is
optional. The default value is a NULL pointer.
FastRPC is not specialized to serving files to the DSPs and can do other
things such as logging and profiling, pending discovery. Change the
description of the program accordingly.
Referring to a "FastRPC node" is a bit vague and misses the detail that
the program is expecting a path to a file (a device node). Refer to the
file as a FastRPC device node so the user can intuitively look for what
the program wants.
The letter in the -R option was seemingly chosen arbitrarily. Add the
word which it originated from ("root") to make it memorable.
The INIT_ATTACH and INIT_ATTACH_SNS terms have no meaning in the usage
text. They are terms of jargon originating in the userspace API for the
Linux kernel driver, as abbreviations of FASTRPC_IOCTL_INIT_ATTACH and
FASTRPC_IOCTL_INIT_ATTACH_SNS. It is unclear what the difference is
between the two, and SNS is ambiguous with no clear connection to
sensors (did Qualcomm design some DSP communication protocol around a
Social Networking Service?). Instead of deriving terms used to inform
the driver how to interact with the DSP, use the name of the
PD ("sensorspd") and describe the effective interaction with the DSP.
If the file name for the FastRPC device node is a NULL pointer, then the
error message always prints out a NULL pointer, made redundant by the
word "invalid". An unspecified device node is an error made by the user,
and the usage text should be given to the user instead of an internal
diagnosis of invalid usage.
This is useful for most programs using FastRPC, so it does not make
sense to copy the interface every time. Move it to libhexagonrpc, even
though it may not be strictly necessary to communicate over FastRPC,
since it is common.
Warnings on unused variables or functions can be fixed by removing the
unnecessary variable or function. Unused parameters are a regular
occurrence, and cannot be removed. Warnings about these may be useful
for new internal APIs with long development histories, but clutter any
build logs with meaningless warnings about unused parameters when
defining functions to be used with existing APIs, such as the reverse
tunnel API. Suppress these warnings to bring any more meaningful issues
to attention.
Despite the modularity of the FastRPC implementation, there are no unit
tests. This makes it unpredictable when the implementation encounters an
unlikely scenario, such as when reading uninitialized memory that is
non-zero, or when allocating zero bytes of memory. Add a unit test for
the I/O buffer encoder and decoder so there can be more confidence in
its expected operation.
This does not test edge cases in the malloc() function, such as
allocating zero bytes or failures.
When a pathname navigates to the parent directory via the special "../"
name, the current directory may be assigned a numeric file descriptor.
With a numeric file descriptor, the current directory can still be
referenced, and should not be closed. Only close the directory if it is
not assigned.
The file descriptor for the root directory is required for file
operations. Without the root directory open, opening or getting stats of
a file always fails. Currently, the apps_std methods check if the root
directory is open every time they are called. Fail to initialize if the
root directory cannot be opened to allow the simplification of remote
methods accepting a path name.
The path name is already NULL-terminated by the caller and does not need
to be copied to a larger buffer to add more NULL termination. Allocating
an extra buffer can cause an unnecessary crash or failure when out of
memory. Do not copy the path name. Instead, check that the path name is
NULL-terminated by the caller.
Normally, the CHRE performs a full configuration on streaming sensors
with a stream type of zero. This made it seem like a simple enable would
not properly activate sensors with this stream type, but it is possible
to use the watch command on streaming sensors. Remove this statement
which may be misleading.