- diff --git a/ptxdist/local_src/eag_usbmount/root/etc/usbmount/usbmount.conf b/ptxdist/local_src/eag_usbmount/root/etc/usbmount/usbmount.conf
- index 20e9cf5..bb70433 100644
- --- a/ptxdist/local_src/eag_usbmount/root/etc/usbmount/usbmount.conf
- +++ b/ptxdist/local_src/eag_usbmount/root/etc/usbmount/usbmount.conf
- @@ -25,9 +25,11 @@ FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus"
- # experience data loss. #
- #############################################################################
- # Mount options: Options passed to the mount command with the -o flag.
- -# See the warning above regarding removing "sync" from the options, as
- -# it may lead to data loss.
- -MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime"
- +
- +# JNCG/Quantron: Mount USB-Stick read-only by default, use
- +# /sbin/eag_usbstick to make it writeable, write stuff, and then
- +# make it read-only again to prevent stick data corruption
- +MOUNTOPTIONS="ro,async,noexec,nodev,noatime,nodiratime"
- # Filesystem type specific mount options: This variable contains a space
- # separated list of strings, each which the form "-fstype=TYPE,OPTIONS".
- diff --git a/ptxdist/local_src/eag_usbmount/root/sbin/eag_usbstick b/ptxdist/local_src/eag_usbmount/root/sbin/eag_usbstick
- new file mode 100755
- index 0000000..9eb1213
- --- /dev/null
- +++ b/ptxdist/local_src/eag_usbmount/root/sbin/eag_usbstick
- @@ -0,0 +1,38 @@
- +#!/bin/bash
- +
- +#
- +# EAG USBStick - Manage USB Stick status for JNCG and Quantron
- +#
- +
- +export PATH='/sbin:/bin'
- +
- +typeset -r usbfsmountpoint='/media/usb0'
- +typeset -r cmd="$1"
- +
- +# use POSIX shell tracing to log trace to journalctl
- +# (observe with $ journalctl -f -a #)
- +set -o xtrace
- +
- +case "${cmd}" in
- + 'mount_writeable')
- + mount -o rw,remount "${usbfsmountpoint}"
- + exit $?
- + ;;
- + 'mount_readonly')
- + # remounting as read-only implicitly writes all
- + # pending write buffers to the media before making
- + # the mount point as read-only
- + mount -o ro,remount "${usbfsmountpoint}"
- + exit $?
- + ;;
- + 'is_stick_mounted_writeable')
- + grep -q -E \
- + '[[:space:]]+'"${usbfsmountpoint}"'[[:space:]]+(fat|vfat)[[:space:]]+rw,' \
- + '/proc/self/mounts'
- + exit $?
- + ;;
- + *)
- + exit 1
- + ;;
- +esac
- +# EOF.
- diff --git a/ptxdist/local_src/ecu01-codesys/QAX/QAX.c b/ptxdist/local_src/ecu01-codesys/QAX/QAX.c
- index 79b1495..b77e090 100755
- --- a/ptxdist/local_src/ecu01-codesys/QAX/QAX.c
- +++ b/ptxdist/local_src/ecu01-codesys/QAX/QAX.c
- @@ -524,83 +524,44 @@ void CDECL CDECL_EXT usbstick_getmountpath(usbstick_getmountpath_struct *p)
- /*****************************************************/
- void CDECL CDECL_EXT usbstick_mount(usbstick_mount_struct *p)
- {
- - /* mount -o bind /mnt/test /mnt/usbstick
- - * Beide Ordner müssen existieren.
- - * ändert man nun was in /mnt/usbstick ändert man auch in /mnt/test.
- - * umount /mnt/usbstick
- - * /mnt/usbstick ist leer, /mnt/test ist verändert. */
- -
- - int iRet;
- -
- - /*********************************************/
- - /* Mount fuer Usbstick auf Media ausfuehren */
- - /*********************************************/
- - iRet = mount( "", acSettgUSBStickMountOrgPoint, "", MS_REMOUNT, "" );
- - if ( iRet != 0 )
- - {
- - p->USBStick_Mount = -1;
- - //No USB-Mount cancel,
- - return;
- - }
- -
- - iRet = mount( acSettgUSBStickMountOrgPoint, acSettgUSBStickMountPoint, "", MS_BIND, "" );
- - if ( iRet == 0 ) {
- -
- - /* Mountvorgang war erfolgleich */
- - //Log_Warning(COMPONENT_ID,"USB-Stick Device(%i) %s gemoutet\n", i, acSettgUSBStickDevice[i]);
- - p->USBStick_Mount = 0;
- - return;
- - }
- -
- -
- - /* Mountvorgang war nicht erfolgleich */
- - //Log_Warning(COMPONENT_ID,"Mountvorgang fehlgeschlagen\n");
- - p->USBStick_Mount = -1;
- + int ret;
- + ret = system("/sbin/eag_usbstick mount_writeable");
- + if (ret == -1)
- + {
- + perror("/sbin/eag_usbstick mount_writeable failed.");
- + p->USBStick_Mount = -1;
- + return;
- + }
- + p->USBStick_Mount = (ret == 0)?0:-1;
- } /* eofn: usbstick_mount */
- void CDECL CDECL_EXT usbstick_umount(usbstick_umount_struct *p)
- {
- + int ret;
- + ret = system("/sbin/eag_usbstick mount_readonly");
- + if (ret == -1)
- + {
- + perror("/sbin/eag_usbstick mount_readonly failed.");
- + p->USBStick_Umount = -1;
- + return;
- + }
- - int iRet;
- -
- - //Log_Warning(COMPONENT_ID,"usbstick_umount\n");
- - /************************************/
- - /* Unmount fuer Usbstick ausfuehren */
- - /************************************/
- - iRet = umount2( acSettgUSBStickMountPoint, MNT_DETACH );
- - if ( iRet != 0 ) {
- -
- - /* Fehler beim Unmount */
- - p->USBStick_Umount = -1;
- - return;
- - }
- -
- - /* Umount erfolgreich */
- - p->USBStick_Umount = 0;
- -
- -
- + p->USBStick_Umount = (ret == 0)?0:-1;
- } /* eofn: usbstick_umount */
- void CDECL CDECL_EXT usbstick_status(usbstick_status_struct *p)
- {
- + int ret;
- + ret = system("/sbin/eag_usbstick is_stick_mounted_writeable");
- + if (ret == -1)
- + {
- + perror("/sbin/eag_usbstick is_stick_mounted_writeable failed.");
- + p->USBStick_Status = -1;
- + return;
- + }
- - int iRet;
- -
- - /*******************************************************************************/
- - /* Remout mit gleichen Parameter auf Moutpoint ausfuehren um Status abzufragen */
- - /*******************************************************************************/
- - iRet = mount( "", acSettgUSBStickMountPoint, "", MS_REMOUNT | MS_BIND, "" );
- - if ( iRet != 0 ) {
- -
- - /* Usbstick ist nicht gemountet */
- - p->USBStick_Status = -1;
- - return;
- - }
- -
- - /* Usbstick ist bereits gemountet */
- - p->USBStick_Status = 0;
- -
- + p->USBStick_Status = (ret == 0)?0:-1;
- } /* eofn: usbstick_status */
- /*****************************************/
- diff --git a/ptxdist/rules/usbmount.make b/ptxdist/rules/usbmount.make
- index c7383b7..dce2d7a 100644
- --- a/ptxdist/rules/usbmount.make
- +++ b/ptxdist/rules/usbmount.make
- @@ -125,6 +125,7 @@ endif
- #/sbin
- @$(call install_copy, usbmount, 0, 0, 0755, $(USBMOUNT_DIR)/root/sbin/udev-trigger-massstorage.sh, /sbin/udev-trigger-massstorage.sh)
- + @$(call install_copy, usbmount, 0, 0, 0755, $(USBMOUNT_DIR)/root/sbin/eag_usbstick, /sbin/eag_usbstick)
- #/systemd unitfiles
- ifdef PTXCONF_USBMOUNT_SYSTEMD_UNIT
Quantron+JNCG: Mount usb stick read-only by default, and only rw on demand
Posted by Anonymous on Tue 27th Aug 2019 13:50
raw | new post
modification of post by Anonymous (view diff)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.