diff --git a/Dockerfile.agnos b/Dockerfile.agnos index 663de98..25f70ca 100644 --- a/Dockerfile.agnos +++ b/Dockerfile.agnos @@ -106,7 +106,8 @@ RUN chown -R $USERNAME: /home/$USERNAME/.config RUN rm -rf /root/.config && ln -s /home/$USERNAME/.config /root/.config RUN chmod 644 /etc/logrotate.conf -RUN touch -r /lib/systemd/systemd /etc/fstab +RUN touch -r /lib/systemd/systemd +RUN rm -f /etc/fstab # Install kernel headers COPY ./output/linux-headers/include/ /usr/include/ diff --git a/userspace/root/etc/fstab b/userspace/root/etc/fstab deleted file mode 100644 index 0dd7db5..0000000 --- a/userspace/root/etc/fstab +++ /dev/null @@ -1,8 +0,0 @@ -/dev/disk/by-label/dsp /dsp auto ro -/dev/disk/by-partlabel/modem_a /firmware auto ro -/dev/disk/by-partlabel/persist /persist auto ro,discard,nosuid,nodev,noexec -/dev/disk/by-partlabel/userdata /data auto discard,noatime,nodiratime,nosuid,nodev,nofail 0 0 -/dev/disk/by-partlabel/cache /cache ext4 relatime,data=ordered,noauto_da_alloc,discard,noexec,nodev,nosuid,x-systemd.makefs 0 0 -tmpfs /var tmpfs rw,nosuid,nodev,size=128M,mode=755 0 0 -tmpfs /tmp tmpfs rw,nosuid,nodev,size=150M,mode=1777 0 0 -tmpfs /rwtmp tmpfs rw,nosuid,nodev,size=100M,mode=1777 0 0 diff --git a/userspace/root/etc/systemd/system/local-fs.target.requires/systemrw.mount b/userspace/root/etc/systemd/system/local-fs.target.requires/systemrw.mount deleted file mode 120000 index a3b5919..0000000 --- a/userspace/root/etc/systemd/system/local-fs.target.requires/systemrw.mount +++ /dev/null @@ -1 +0,0 @@ -../systemrw.mount \ No newline at end of file diff --git a/userspace/root/etc/systemd/system/systemd-random-seed.service.d/override.conf b/userspace/root/etc/systemd/system/systemd-random-seed.service.d/override.conf new file mode 100644 index 0000000..b36d511 --- /dev/null +++ b/userspace/root/etc/systemd/system/systemd-random-seed.service.d/override.conf @@ -0,0 +1,2 @@ +[Unit] +After=fs_setup.service diff --git a/userspace/root/etc/systemd/system/systemrw.mount b/userspace/root/etc/systemd/system/systemrw.mount deleted file mode 100644 index 771954c..0000000 --- a/userspace/root/etc/systemd/system/systemrw.mount +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2017, The Linux Foundation. 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 Linux Foundation 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 "AS IS" AND ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -# 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 - -[Unit] -Before=local-fs.target - -[Mount] -What=/dev/disk/by-partlabel/systemrw -Where=/systemrw -Options=relatime,data=ordered,noauto_da_alloc,discard,noexec,nodev diff --git a/userspace/root/lib/systemd/system/fs_setup.service b/userspace/root/lib/systemd/system/fs_setup.service index 224ee76..9b68650 100644 --- a/userspace/root/lib/systemd/system/fs_setup.service +++ b/userspace/root/lib/systemd/system/fs_setup.service @@ -1,6 +1,5 @@ [Unit] Description=Setup rootfs -After=data.mount tmp.mount rwtmp.mount var.mount Before=local-fs.target DefaultDependencies=no diff --git a/userspace/root/usr/comma/fs_setup.sh b/userspace/root/usr/comma/fs_setup.sh index 5a033a1..d912b10 100755 --- a/userspace/root/usr/comma/fs_setup.sh +++ b/userspace/root/usr/comma/fs_setup.sh @@ -1,5 +1,61 @@ #!/bin/bash +PATH=/usr/sbin:/usr/bin:/sbin:/bin + +log() { + echo "fs_setup[$$]: $(cut -d' ' -f1 /proc/uptime) $*" > /dev/kmsg +} + +wait_for_block() { + local device="$1" + local i + + for ((i = 0; i < 150; i++)); do + if [[ -b "$device" ]]; then + return 0 + fi + sleep 0.02 + done + + log "timed out waiting for $device" + return 1 +} + +mount_fs() { + local what="$1" + local where="$2" + local type="$3" + local options="$4" + + if [[ "$what" == /dev/* ]] && ! wait_for_block "$what"; then + failed=1 + return 1 + fi + + log "mounting $where" + if mount --mkdir -t "$type" -o "$options" "$what" "$where"; then + log "mounted $where" + return 0 + fi + + log "failed mounting $where" + failed=1 + return 1 +} + +log "start" + +failed=0 +mount_fs /dev/sde9 /dsp ext4 ro +mount_fs /dev/sde4 /firmware vfat ro +mount_fs /dev/sda2 /persist squashfs ro,nosuid,nodev,noexec +mount_fs /dev/sda10 /systemrw ext4 relatime,data=ordered,noauto_da_alloc,discard,noexec,nodev +mount_fs /dev/sda12 /data ext4 discard,noatime,nodiratime,nosuid,nodev +mount_fs /dev/sda11 /cache ext4 relatime,data=ordered,noauto_da_alloc,discard,noexec,nodev,nosuid +mount_fs tmpfs /var tmpfs rw,nosuid,nodev,size=128M,mode=755 +mount_fs tmpfs /tmp tmpfs rw,nosuid,nodev,size=150M,mode=1777 +mount_fs tmpfs /rwtmp tmpfs rw,nosuid,nodev,size=100M,mode=1777 + # Ensure the symlinks in the read only rootfs are # backed by real files and directories on userdata. @@ -39,3 +95,10 @@ mkdir -p /data/tmp/ if [[ ! -d /data/persist ]]; then sudo cp -r /system/persist /data fi + +if [[ "$failed" -ne 0 ]]; then + log "mounts failed" + exit 1 +fi + +log "done" diff --git a/userspace/root/usr/comma/magic.py b/userspace/root/usr/comma/magic.py index 9a2830f..9c905f2 100755 --- a/userspace/root/usr/comma/magic.py +++ b/userspace/root/usr/comma/magic.py @@ -10,6 +10,7 @@ WESTON_SOCK_PATH = os.path.join(WESTON_RUNTIME_DIR, "wayland-0") SOCK_PATH = "/tmp/drmfd.sock" DRM_DEVICE = "/dev/dri/card0" +BACKLIGHT_POWER = "/sys/class/backlight/panel0-backlight/bl_power" BACKGROUND = "/usr/comma/bg.jpg" # This is needed to keep the old updater working. Updater used to be stored in @@ -93,6 +94,9 @@ def main(): time.sleep(0.1) os.environ['DRM_FD'] = str(drm_master) + while not os.access(BACKLIGHT_POWER, os.W_OK): + time.sleep(0.1) + rl.init_window(0, 0, "not weston") img = rl.load_image(BACKGROUND) rl.image_resize(img, rl.get_screen_width(), rl.get_screen_width()//2)