test: bail out early if control node can't be accessed

No need to run all the tests if the control node is absent.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: kdbus_cmd_msg_recv() unlock the conn lock on error paths

If kdbus_cmd_msg_recv() fails make sure to unlock the mutex and avoid
unsafe scenarios.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: factor out core of test_run()

Split the fork logic into test_run_forked(), and use that when running
all tests. For single tests in one-shot, use the non-forking variant,
which is nicer for debugging with gdb.

Signed-off-by: Daniel Mack <daniel@zonque.org>
kdbus.txt: document KDBUS_NAME_ALLOW_REPLACEMENT flag of kdbus_name_info struct

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: use ASSERT_RETURN() in kdbus_test_hello()

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: remove unused variable

Signed-off-by: Daniel Mack <daniel@zonque.org>
main: use KBUILD_MODENAME as directory name in /sys/fs/

Avoid hard-coding "kdbus" as directory name. Otherwise, we cannot compile
multiple kdbus modules at the same time.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
fs: rename kdbusfs to kdbus$(EXT)fs

This makes sure that the fs-type is always named according to the module.
If we compile kdbus twice (one for system-boot, one for testing), we want
the second kdbus module (eg, 'kdbus2') to register a new file-system. Use
KBUILD_MODNAME as prefix and "fs" as suffix to guarantee that.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
build-sys: fix tt/stt ordering

Make prerequisites are not ordered, by default. Enforce proper ordering so
the tests even work if you run it with -j8.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
build-sys: remove bogus sync; umount

This was needed in early days as btrfs workaround. It's no longer needed,
so drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Makefile: new location

Less confusion with upstream patch set.

Signed-off-by: Daniel Mack <daniel@zonque.org>
node: simplify global init/exit

Instead of providing two hooks, we now drop IDR caches when the IDR runs
empty. This way, we no longer need the global kdbus_nodes_init/exit()
helpers.

Note that we also re-initialize the IDR immediately (which does _not_
populate the cache). This way, we can safely continue even after all nodes
were dropped.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
node: drop KDBUS_NODE_IDR_MAX

We no longer use IDR entries as char-dev minors. Drop this macro and use
the implicit maximum number of IDRs (INT_MAX). We use those numbers only
as inode-IDs, so we could support up to UINT_MAX.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
node: set callbacks directly

Instead of passing callbacks to kdbus_node_init(), set them directly from
the caller. There's no reason to pass them through kdbus_node_init() so
let the caller have full control over it. They already set other fields
directly, so be consistent.

This also slightly re-orders bus_new and ep_new to move node
initialization closed to kdbus_node_init().

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
fs: update kernel-doc for global init/exit

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
fs: drop unused fs_super_compare()

We no longer allow mounting a single kdbusfs instance multiple times.
Instead, we require people to use mount-points instead. So drop
fs_super_compare() and use the default NULL, which has the same effect.

Also simply the sget() caller. The returned mount is always a new mount so
we can turn the cleanup into a WARN_ON().

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
fs: no need for node-refs in root dentry

The root-inode does not have any dentry ops set and is bound to the
mount lifetime. Therefore, we can rely on the super-block reference to the
domain.

Note that after ->kill_sb() is called, no-one (not even people holding
root dentry references) can ever call into the inode lookup/iterate
callbacks.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
fs: inline "struct kdbus_fs_super"

The per-superblock context is a single kdbus_domain. No need to keep a
structure with one member. Directly set sb->s_fs_info to the domain and
drop "struct kdbus_fs_super" and its helpers.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
domain: drop "name" argument to kdbus_domain_new()

Domains are no longer managed in hierarchical structures, so drop the
"name" argument. Each domain is a root domain now.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
node: move child-search from fs.c to node.c

Move the child-search from fs_dir_iop_lookup() into node.c to keep rb-tree
handling local to node.c.

This also hardens the lookup code to return a reference to an _acquired_
child node. This guarantees that any parallel deactivation will stall
until the dentry is fully materialized.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>