Skip to content

Conversation

@Thaodan
Copy link
Contributor

@Thaodan Thaodan commented Aug 6, 2025

Originally based on work by Frajo Haider but completely reworked
to use the existing interface system.

Contains #32, obsoletes #21.

@piggz
Copy link

piggz commented Oct 6, 2025

This appears to fix the issues building qt6, with file permission errors. See https://build.sailfishos.org/project/monitor/home:piggz:qt6sb2?arch_aarch64=1&defaults=0&repo_sailfish_latest_aarch64=1&succeeded=1 i had to fork and make some build fixes, minor printf formatting placeholders.

@vige
Copy link

vige commented Oct 10, 2025

You should rebase the PR on top of current master. It would still be a huge PR but at least a bit more comprehensible.

if (str) {
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: %s='%s'", __func__, s_name, str, fldoffs);
"%s: %s='%s' o=%lu", __func__, s_name, str, fldoffs);
Copy link

@piggz piggz Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u for size_t

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with @mlehtima , %zu is probably better?

} else {
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: No %s", __func__, s_name, fldoffs);
"%s: No %s o=%lu", __func__, s_name, fldoffs);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u

uip = ruletree_get_pointer_to_boolean(offs);
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: @%u = *%p = %d",
"%s: @%u = *%p = %d o=%lu",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u

uip = ruletree_get_pointer_to_uint32(offs);
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: @%u = *%p = %u",
"%s: @%u = *%p = %u o=%lu",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u

eph.exec_policy_offset, r_name);
SB_LOG(SB_LOGLEVEL_NOISE,
"%s: @%u", __func__, offs, fldoffs);
"%s: @%u o=%lu", __func__, offs, fldoffs);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u


SB_LOG(SB_LOGLEVEL_NOISE,
"%s: '%s' (%u), '%s' (%u) => %d (%s)",
"%s: '%s' (%lu), '%s' (%u) => %d (%s)",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u


SB_LOG(SB_LOGLEVEL_NOISE,
"ruletree_test_path_match '%s' (%u), '%s' (%u) => %d (%s)",
"ruletree_test_path_match '%s' (%lu), '%s' (%u) => %d (%s)",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u

if (write(ruletree_ctx.rtree_ruletree_fd, ptr, size) < (int)size) {
SB_LOG(SB_LOGLEVEL_ERROR,
"Failed to append a struct (%d bytes) to the rule tree", size);
"Failed to append a struct (%lu bytes) to the rule tree", size);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u

if ((wr_result == -1) || ((size_t)wr_result < list_size_in_bytes)) {
SB_LOG(SB_LOGLEVEL_ERROR,
"Failed to append a list (%d items, %d bytes) to the rule tree",
"Failed to append a list (%d items, %lu bytes) to the rule tree",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %u


SB_LOG(SB_LOGLEVEL_NOISE,
"ruletree_find_inodestat (dev=%lld,ino=%lld,key=%llX)",
"ruletree_find_inodestat (dev=%lld,ino=%lld,key=%lu)",
Copy link

@piggz piggz Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %llu

{
SB_LOG(SB_LOGLEVEL_NOISE,
"ruletree_set_inodestat (dev=%lld,ino=%lld,key=%llX))",
"ruletree_set_inodestat (dev=%lld,ino=%lld,key=%lu))",
Copy link

@piggz piggz Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be %llu

ldexportlist was removed earlier for export.map. Replace with
export.map where not done already. Remove obsolete references such as
the target in preload/Makefile.

Fixes: 20180ac
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Previously in some instance the assumption was $(SRCDIR) = $(OBJDIR).
If $(OBJDIR) isn't equal to $(SRCDIR) these files were not found anymore.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Resolves error when using a compiler with stricter settings such as
when using LTO.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
…JB#61866

Both open and openat load their last argument 'mode' lazily, using
va_arg() only if O_CREAT is found in oflag. This is wrong, mode is also
necessary if O_TMPFILE is in oflag.

Adapt __OPEN_NEEDS_MODE(oflag) present since glibc 2.22 to solve the
issue.

Read more down below:
https://sourceware.org/git/?p=glibc.git;a=commit;h=65f6f938cd562a614a68e15d0581a34b177ec29d

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Once in autogen.sh and once in %make

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Previously preload/exported.h depended on preload/wrappers.c even thou
both where generated from interface.master by gen-interface.pl.

Refactor so that all generated preloader files depend on the interface
and the gen-interface script.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
The builtin multilib support as unused. It's cleaner to built
libsb2 for 32bit targets in a 32bit worker.
The side effect of these changes is that make file pickup
the correct directories passed to configure in %configure.

Also now we can use regular build macros.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
By detecting if configure.ac has changed and thus configure will change
in the following step we can run autogen.sh and config.status to rerun
configure with the previously set built options.

The change removes the need for .configure file, correctly detects
if configures sources changed and doesn't run configure again without
all the previously passed options.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
In case the root Makefile isn't in PWD assume that the Makefiles
directory is the source directory.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Remove obsolete and unused things.
Own all directories correctly (this will be an error in later RPM versions).

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Remove useless checks like:
```
command
if [ $# -eq 0 ] ; then
    error
fi
```

Or replace obsolescent -a and -o with `[ ] && [ ] ` and `[ ] || [ ]`.

https://github.com/koalaman/shellcheck/wiki/SC2166
https://github.com/koalaman/shellcheck/wiki/SC2181
Doing so exits with a clearer error message then errors about sb2d
failing to start later such as these:

Runtime-Error loading /tmp/sb2-bidar-20240329-145433.AwoNRb/lua_scripts/init.lua (...dar-20240329-145433.AwoNRb/lua_scripts/argvenvp_misc.lua:28: bad argument #1 to 'files' (/tmp/sb2-bidar-20240329-145433.AwoNRb/wrappers.sdk-build: No such file or directory))
sb2: Error: startup of sb2d failed.

Tested-by: Björn Bidar <bjorn.bidar@jolla.com>
To make it easier to detect where Scratchbox2 helper scripts
and binaries are found on the host and partially on the
tooling/target.
This is especially important for helper binaries such as sb2dctl.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Thaodan and others added 9 commits December 10, 2025 13:39
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
The version used in the Makefile and version header was extracted
using git with a phony target which resulted in unintended rebuilds.

Using the autoconf script avoids these as now the version only updates
when the autoconf script changes.

Further the version originally set in the autoconf was also out of
date. This change fixes both of these issues.
The script in build-aux was taken from Gnulib.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Previously config.status was also clean as part of the clean making
rebuilds impossible without calling configure again.
Clean isn't supposed to clean the generated build- or
distribution-system files.

Further somefiles that should be clean where not cleaned at all.
This change also aligns the name of the clean target which removes
the distribution to the one configure mentions when it fails.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
When configure.ac or config.mak.in change but not their output their
will be repeated rebuilds as the timestamp their output files such as
config.mak stay older than their dependency.

The timestamp file's timestamp will always update after the targets
dependency changed.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Co-authored-by: Matti Viljanen <matti.viljanen@jolla.com>
Co-authored-by: Björn Bidar <bjorn.bidar@jolla.com>
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
In case not available.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Sets basic indentation across editors and reviews on Github.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
The char arrays in sblog_vprintf_line_to_logfile where not initialized
which can cause the the call to vsnprintf can fail.
See for example the backtrace below:

   from ~/dev/vms/jolla/targets/SailfishOS-devel-i486/lib/libc.so.6
    level=9, format=0xf7f6c488 "%s gate: calling mapped syscall(%s) to %s",
    ap=0xffcd9f10 "\304\035\367\367\005")
    at ~/dev/sailfish/jolla/pkgs/pj_oss/scratchbox2/sblib/sb_log.c:318
    level=9, format=0xf7f6c488 "%s gate: calling mapped syscall(%s) to %s")
    at ~/dev/sailfish/jolla/pkgs/pj_oss/scratchbox2/sblib/sb_log.c:423
    realfnname=0xf7f71988 <__func__.292> "syscall", number=5, ap=0xffcd9fc4 "\034\240\004\b")
    at preload/syscallgate.c:91
@Thaodan Thaodan force-pushed the syscall_forwarding_refactored_jb59837 branch from e4a0ced to 8c36b9c Compare December 10, 2025 11:41
Also remove some extra white space at end or in empty lines.
Originally based on work by Frajo Haider but completely reworked
to use the existing interface system.

Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
Signed-off-by: Björn Bidar <bjorn.bidar@jolla.com>
@Thaodan Thaodan force-pushed the syscall_forwarding_refactored_jb59837 branch from 8c36b9c to f96ddc0 Compare December 15, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants