Commit de3d1683 authored by jan.koester's avatar jan.koester
Browse files

test

parent 35a64344
Loading
Loading
Loading
Loading
+39 −2
Changes for build-chroot.sh: 39 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@
#   7. chroot        systempp + clang/lld/lldb + fresh + tools assembled into a rootfs
#   8. packages      FenrirOS specs (../scripts/files/rpm) built with rpmbuild in the chroot
#   8b. repo         the package repository of those RPMs (createrepo_c), for dnf5 on FenrirOS
#   fenstore         FenStore's RPMs on the side, only when named: they go to
#                    /build/extra-rpms, not into RPMS, so repo, iso and docker
#                    don't take them along
#   9. iso           live ISOs of the RPM-built system (Limine BIOS+UEFI; CD, USB stick,
#                    Ventoy compatible): <ISO_NAME>-server (no compilers, build tools,
#                    headers or -dev/-devel packages) and <ISO_NAME>-devel (every
@@ -39,6 +42,7 @@
#   ADCONNECT_SRC adconnect checkout         (default: ../adconnect if it exists, else a clone of ADCONNECT_REPO)
#   STORAGED_SRC  storaged checkout          (default: ../storaged if it exists, else a clone of STORAGED_REPO)
#   CONTAINERD_SRC containerd checkout       (default: ../containerd if it exists, else a clone of CONTAINERD_REPO)
#   FENSTORE_SRC  FenStore checkout          (default: ../FenStore if it exists, else a clone of FENSTORE_REPO)
#   ISCSID_SRC    iscsid checkout            (default: ../iscsid if it exists, else a clone of ISCSID_REPO)
#   UPSD_SRC      upsd checkout              (default: ../upsd if it exists, else a clone of UPSD_REPO)
#   FIREWALLD_SRC firewalld checkout         (default: ../firewalld if it exists, else a clone of FIREWALLD_REPO)
@@ -90,6 +94,9 @@ fi
if [[ -z ${CONTAINERD_SRC:-} && -f $SYSTEMPP_SRC/../containerd/CMakeLists.txt ]]; then
    CONTAINERD_SRC="$(realpath "$SYSTEMPP_SRC/../containerd")"
fi
if [[ -z ${FENSTORE_SRC:-} && -f $SYSTEMPP_SRC/../FenStore/CMakeLists.txt ]]; then
    FENSTORE_SRC="$(realpath "$SYSTEMPP_SRC/../FenStore")"
fi
if [[ -z ${ISCSID_SRC:-} && -f $SYSTEMPP_SRC/../iscsid/CMakeLists.txt ]]; then
    ISCSID_SRC="$(realpath "$SYSTEMPP_SRC/../iscsid")"
fi
@@ -120,6 +127,7 @@ SHAREDD_REPO="${SHAREDD_REPO:-git@git.tuxist.de:tuxist/sharedd.git}"
ADCONNECT_REPO="${ADCONNECT_REPO:-git@git.tuxist.de:tuxist/adconnect.git}"
STORAGED_REPO="${STORAGED_REPO:-git@git.tuxist.de:tuxist/storaged.git}"
CONTAINERD_REPO="${CONTAINERD_REPO:-git@git.tuxist.de:tuxist/containerd.git}"
FENSTORE_REPO="${FENSTORE_REPO:-git@git.tuxist.de:tuxist/fenstore.git}"
ISCSID_REPO="${ISCSID_REPO:-git@tuxist.de:tuxist/iscsid.git}"
UPSD_REPO="${UPSD_REPO:-git@git.tuxist.de:tuxist/upsd.git}"
FIREWALLD_REPO="${FIREWALLD_REPO:-git@git.tuxist.de:tuxist/firewalld.git}"
@@ -143,6 +151,7 @@ declare -A GIT_SOURCES=(
    [libparitypp]="$TUXIST_GIT/tuxist/libparitypp.git"
    [libauthdb-client]="$TUXIST_GIT/tuxist/authdb.git"
    [libmediadb-client]="$TUXIST_GIT/tuxist/mediadb.git"
    [libdbpp]="$TUXIST_GIT/jan.koester/libdbpp.git"
    [libsmtppp]="$TUXIST_GIT/tuxist/libsmtppp.git"
    [libbpf]="https://github.com/libbpf/libbpf.git v1.4.0"
    [bpftool]="https://github.com/libbpf/bpftool.git v7.4.0"
@@ -1289,6 +1298,13 @@ stage_sources() {
                              fetch_git "$WORK/src/containerd" "$CONTAINERD_REPO"
                              tar_tree "$WORK/src/containerd" "$srcdir/$f" "$name-$version"
                          fi; continue ;;
                postgresql) fetch_url "$f" "https://ftp.postgresql.org/pub/source/v$version/postgresql-$version.tar.gz"; continue ;;
                fenstore) if [[ -n ${FENSTORE_SRC:-} ]]; then
                              tar_tree "$FENSTORE_SRC" "$srcdir/$f" "$name-$version"
                          else
                              fetch_git "$WORK/src/fenstore" "$FENSTORE_REPO"
                              tar_tree "$WORK/src/fenstore" "$srcdir/$f" "$name-$version"
                          fi; continue ;;
                # the spec installs Limine's prebuilt images: the binary branch
                limine)   fetch_git "$WORK/src/limine" https://github.com/limine-bootloader/limine.git "$LIMINE_REF"
                          tar_tree "$WORK/src/limine" "$srcdir/$f" "$name-$version"; continue ;;
@@ -1448,6 +1464,27 @@ step_repo() {
    msg "repo ready: $CHROOT/build/repo (serve it as https://repo.tuxist.de/fenriros/)"
}

# ---------------------------------------------------------------------------
# fenstore: FenStore and libdbpp, which it needs to build, as RPMs outside
# RPMS -- repo, iso and docker take everything from there. libdbpp goes into
# the chroot (build dependency), FenStore itself doesn't. FENSTORE_PG=1 adds
# PostgreSQL first, for libdbpp's pgsql backend.
step_fenstore() {
    local pkg log dir=/build/extra-rpms
    mkdir -p "$LOGS/packages" "$CHROOT$dir"
    for pkg in ${FENSTORE_PG:+postgresql} libdbpp fenstore; do
        log="$LOGS/packages/$pkg.log"
        cp "$FENRIR_FILES/rpm/specs/$pkg.spec" "$CHROOT/build/rpmbuild/SPECS/"
        stage_sources "$FENRIR_FILES/rpm/specs/$pkg.spec"
        msg "fenstore: rpmbuild $pkg"
        in_chroot rpmbuild -bb --nodeps --define "_rpmdir $dir" "/build/rpmbuild/SPECS/$pkg.spec" >"$log" 2>&1 ||
            { tail -n 15 "$log" >&2; die "fenstore: $pkg failed (log: $log)"; }
        [[ $pkg == fenstore ]] ||
            in_chroot /bin/sh -c "rpm -Uvh --nodeps --force --replacepkgs $dir/x86_64/$pkg-*.rpm" >>"$log" 2>&1
    done
    msg "fenstore: RPMs in $CHROOT$dir"
}

# ---------------------------------------------------------------------------
# iso: a live ISO of the RPM-based system, booted by Limine

@@ -1801,11 +1838,11 @@ steps=("$@")

for s in "${steps[@]}"; do
    case "$s" in
        systempp|toolchain|host-tblgen|llvm|fresh|tools|rpm|chroot|packages|repo|iso|docker)
        systempp|toolchain|host-tblgen|llvm|fresh|tools|rpm|chroot|packages|repo|iso|docker|fenstore)
            check_deps; mkdir -p "$WORK" "$BUILD"; "step_${s//-/_}" ;;
        enter) step_enter ;;
        clean) step_clean ;;
        -h|--help) sed -n '2,/^$/s/^# \{0,1\}//p' "$0"; exit 0 ;;
        *) die "unknown step '$s' (steps: ${ALL_STEPS[*]} enter clean)" ;;
        *) die "unknown step '$s' (steps: ${ALL_STEPS[*]} fenstore enter clean)" ;;
    esac
done

include/sys/ipc.h

0 → 100644
+73 −0
Changes for include/sys/ipc.h: 73 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
Copyright (c) 2026, Jan Koester jan.koester@gmx.net
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

/* Was completely missing -- SysV IPC keys and permissions, for sys/shm.h.
 * Real gap: PostgreSQL's postmaster interlock is a SysV shared memory
 * segment. Field layout is the kernel's struct ipc64_perm on x86_64; the
 * ids stay 32-bit numbers here, whatever uid_t is. */

#include <sys/types.h>

#pragma once

#define IPC_CREAT  01000
#define IPC_EXCL   02000
#define IPC_NOWAIT 04000

#define IPC_RMID 0
#define IPC_SET  1
#define IPC_STAT 2

#define IPC_PRIVATE ((key_t)0)

#ifndef __key_t_defined
#define __key_t_defined
typedef int key_t;
#endif

struct ipc_perm {
    key_t          __key;
    unsigned int   uid;
    unsigned int   gid;
    unsigned int   cuid;
    unsigned int   cgid;
    unsigned int   mode;
    unsigned short __seq;
    unsigned short __pad2;
    unsigned long  __unused1;
    unsigned long  __unused2;
};

#ifdef __cplusplus
extern "C" {
#endif

key_t ftok(const char *path, int id);

#ifdef __cplusplus
}
#endif

include/sys/shm.h

0 → 100644
+74 −0
Changes for include/sys/shm.h: 74 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
Copyright (c) 2026, Jan Koester jan.koester@gmx.net
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

/* Was completely missing -- real shmget(2) & co, thin syscall wrappers
 * (the __NR_shm* numbers already existed). Field layout is the kernel's
 * struct shmid64_ds on x86_64. */

#include <sys/ipc.h>
#include <time.h>

#pragma once

#define SHM_R 0400
#define SHM_W 0200

#define SHM_RDONLY 010000
#define SHM_RND    020000
#define SHM_REMAP  040000
#define SHM_EXEC   0100000

#define SHM_LOCK   11
#define SHM_UNLOCK 12

typedef unsigned long shmatt_t;

struct shmid_ds {
    struct ipc_perm shm_perm;
    size_t          shm_segsz;
    time_t          shm_atime;
    time_t          shm_dtime;
    time_t          shm_ctime;
    int             shm_cpid;
    int             shm_lpid;
    shmatt_t        shm_nattch;
    unsigned long   __unused4;
    unsigned long   __unused5;
};

#ifdef __cplusplus
extern "C" {
#endif

int shmget(key_t key, size_t size, int flags);
void *shmat(int id, const void *addr, int flags);
int shmdt(const void *addr);
int shmctl(int id, int cmd, struct shmid_ds *buf);

#ifdef __cplusplus
}
#endif
+1 −0
Changes for src/CMakeLists.txt: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -201,6 +201,7 @@ list(APPEND osSrcs
    "linux/stdio.cpp"
    "linux/membarrier.cpp"
    "linux/epoll.cpp"
    "linux/sysvipc.cpp"
    "linux/elf.cpp"
    "linux/dlfcn.cpp"
    "linux/global.cpp"

src/linux/sysvipc.cpp

0 → 100644
+60 −0
Changes for src/linux/sysvipc.cpp: 60 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*******************************************************************************
Copyright (c) 2021, Jan Koester jan.koester@gmx.net
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the <organization> nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <bits/syscall.h>
#include <bits/sysbits.h>

#include <sys/shm.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>

extern "C" {
    int shmget(key_t key, size_t size, int flags) {
        return syscall_ret(syscall3(__NR_shmget, key, size, flags));
    };

    void *shmat(int id, const void *addr, int flags) {
        return (void*)syscall_ret(syscall3(__NR_shmat, id, (long)addr, flags));
    };

    int shmdt(const void *addr) {
        return syscall_ret(syscall1(__NR_shmdt, (long)addr));
    };

    int shmctl(int id, int cmd, struct shmid_ds *buf) {
        return syscall_ret(syscall3(__NR_shmctl, id, cmd, (long)buf));
    };

    /* glibc's mix of inode, device and id. */
    key_t ftok(const char *path, int id) {
        struct stat st;
        if (stat(path, &st) < 0)
            return (key_t)-1;
        return (key_t)((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16) | ((id & 0xff) << 24));
    };
};