]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
1.0.08beta1 v1.0.08beta1
authorlongpanda <admin@ventoy.net>
Sun, 26 Apr 2020 14:37:36 +0000 (22:37 +0800)
committerlongpanda <admin@ventoy.net>
Sun, 26 Apr 2020 14:37:38 +0000 (22:37 +0800)
17 files changed:
IMG/cpio/ventoy/hook/debian/default-hook.sh
IMG/cpio/ventoy/hook/debian/disk_mount_hook.sh [moved from IMG/cpio/ventoy/hook/rhel7/ventoy-disk.sh with 89% similarity]
IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh
IMG/cpio/ventoy/hook/debian/ventoy-hook.sh
IMG/cpio/ventoy/hook/debian/ventoy-inotifyd-hook.sh [moved from IMG/cpio/ventoy/hook/debian/deepin-disk.sh with 73% similarity]
IMG/cpio/ventoy/hook/default/ventoy-inotifyd-start.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/manjaro/ventoy-hook.sh
IMG/cpio/ventoy/hook/manjaro/ventoy-inotifyd-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh
IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-hook.sh [moved from IMG/cpio/ventoy/hook/debian/deepin-hook.sh with 55% similarity]
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
IMG/cpio/ventoy/hook/ventoy-os-lib.sh
INSTALL/Ventoy2Disk.exe
INSTALL/grub/grub.cfg
INSTALL/ventoy/ventoy.cpio
Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc
VtoyTool/vtoydump.c

index a8fd7ec67a55b21e863325045481cc783051b2c2..d7d0eac4a6acadbecb772f913651af7ec0d190e8 100644 (file)
 # 
 #************************************************************************************
 
-ventoy_systemd_udevd_work_around
-ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
+if [ -e /init ] && $GREP -q '^mountroot$' /init; then
+    echo "Here before mountroot ..." >> $VTLOG
+    
+    $SED  "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh"  -i /init
+    $SED  "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy"  -i /init
+    $SED  "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy"  -i /init    
+    
+elif [ -e /init ] && $GREP -q '/start-udev$' /init; then
+    echo "Here use notify ..." >> $VTLOG
+    
+    ventoy_set_inotify_script  debian/ventoy-inotifyd-hook.sh
+    $SED  "/start-udev$/i\\mount -n -o mode=0755 -t devtmpfs devtmpfs /dev"  -i /init
+    $SED  "/start-udev$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh"  -i /init
+else
+    echo "Here use udev hook ..." >> $VTLOG
+    ventoy_systemd_udevd_work_around
+    ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
+fi
similarity index 89%
rename from IMG/cpio/ventoy/hook/rhel7/ventoy-disk.sh
rename to IMG/cpio/ventoy/hook/debian/disk_mount_hook.sh
index ab1d497554c6de555d0c7fe02a2fb77729c399e2..28943562aba272f560ef9c36d95de80354a0e6e0 100644 (file)
 
 . /ventoy/hook/ventoy-hook-lib.sh
 
-if is_ventoy_hook_finished; then
-    exit 0
-fi
-
 vtlog "####### $0 $* ########"
 
 VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
@@ -36,9 +32,4 @@ if [ "$vtdiskname" = "unknown" ]; then
     exit 0
 fi
 
-ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
-
-PATH=$VTPATH_OLD
-
-set_ventoy_hook_finish
-
+$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/udev_disk_hook.sh "${vtdiskname#/dev/}2"
index 7edcbe73de0e8e932c34c61f937bcb40b870d7aa..6bc7077d998a3cfb430b3dbc7209a0e8940d1067 100644 (file)
@@ -86,6 +86,10 @@ if [ -z "$dmsetup_path" ]; then
     ventoy_os_install_dmsetup "/dev/${1:0:-1}"
 fi
 
+if ! $GREP -q 'device-mapper' /proc/devices; then
+    ventoy_os_install_dmsetup "/dev/${1:0:-1}"
+fi
+
 ventoy_udev_disk_common_hook $*
 
 #
@@ -103,7 +107,14 @@ else
     else
         vtlog "No boot param, need to mount"
         $BUSYBOX_PATH/mkdir /cdrom
-        $BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH  /cdrom
+        
+        if [ -b $VTOY_DM_PATH ]; then
+            vtlog "mount $VTOY_DM_PATH ..."
+            $BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH  /cdrom
+        else
+            vtlog "mount /dev/$1 ..."
+            $BUSYBOX_PATH/mount -t iso9660 /dev/$1  /cdrom
+        fi
     fi
 fi
 
index 05b9487be65432d8078fc7bc972a74f68b1a2c46..2bc7a8604b3bc2161e2d6d550c7f82449eb2a806 100644 (file)
@@ -52,14 +52,6 @@ ventoy_get_debian_distro() {
         echo 'pve'; return
     fi
     
-    if $GREP -q '[Dd]eepin' /proc/version; then
-        echo 'deepin'; return
-    fi
-    
-    if $GREP -q '[Uu][Oo][Ss] ' /proc/version; then
-        echo 'deepin'; return
-    fi
-    
     if [ -d /porteus ]; then
         echo 'porteus'; return
     fi
similarity index 73%
rename from IMG/cpio/ventoy/hook/debian/deepin-disk.sh
rename to IMG/cpio/ventoy/hook/debian/ventoy-inotifyd-hook.sh
index 926e1a50f2ab2acc9d9cf59f0491b6da267e7cd7..53916c6a42170853a36ff0e936dc04733539f0bb 100644 (file)
 
 . /ventoy/hook/ventoy-hook-lib.sh
 
-vtlog "####### $0 $* ########"
-
-VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
-
-vtmountpoint=$1
-
 if is_ventoy_hook_finished; then
-    PATH=$VTPATH_OLD
     exit 0
 fi
 
-wait_for_usb_disk_ready
+vtlog "##### INOTIFYD: $2/$3 is created ..."
 
-vtdiskname=$(get_ventoy_disk_name)
-if [ "$vtdiskname" = "unknown" ]; then
-    vtlog "ventoy disk not found"
-    PATH=$VTPATH_OLD
-    exit 0
-fi
-
-ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"
+VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
 
-$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH $vtmountpoint
+if is_inotify_ventoy_part $3; then
+    vtlog "find ventoy partition $3 ..."    
+    $BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/udev_disk_hook.sh "$3"
+fi
 
-# OK finish
-set_ventoy_hook_finish
+PATH=$VTPATH_OLD
diff --git a/IMG/cpio/ventoy/hook/default/ventoy-inotifyd-start.sh b/IMG/cpio/ventoy/hook/default/ventoy-inotifyd-start.sh
new file mode 100644 (file)
index 0000000..7981b1e
--- /dev/null
@@ -0,0 +1,25 @@
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2020, longpanda <admin@ventoy.net>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# 
+#************************************************************************************
+
+. /ventoy/hook/ventoy-hook-lib.sh
+
+vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)
+
+vtlog "... start inotifyd listen $vtHook ..."
+$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook  /dev:n  2>&-  & 
index b902f9846a8e6af00591d6588733454b9ad32908..ebd828ece9ec7eef6d601a7bcbe49a6a59716ed7 100644 (file)
@@ -28,6 +28,13 @@ else
     $CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$DISTRO_UDEV_DIR/13-dm-disk.rules"
 fi
 
-ventoy_systemd_udevd_work_around
 
-ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
+if $GREP -q '^mount_setup$' init; then
+    echo "Here use notify ..." >> $VTLOG
+    
+    ventoy_set_inotify_script  manjaro/ventoy-inotifyd-hook.sh
+    $SED  "/^mount_setup$/a\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh"  -i /init
+else
+    ventoy_systemd_udevd_work_around
+    ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
+fi
diff --git a/IMG/cpio/ventoy/hook/manjaro/ventoy-inotifyd-hook.sh b/IMG/cpio/ventoy/hook/manjaro/ventoy-inotifyd-hook.sh
new file mode 100644 (file)
index 0000000..60cff43
--- /dev/null
@@ -0,0 +1,46 @@
+#!/ventoy/busybox/sh
+#************************************************************************************
+# Copyright (c) 2020, longpanda <admin@ventoy.net>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 3 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# 
+#************************************************************************************
+
+. /ventoy/hook/ventoy-hook-lib.sh
+
+if is_ventoy_hook_finished; then
+    exit 0
+fi
+
+vtlog "##### INOTIFYD: $2/$3 is created ..."
+
+VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
+
+if is_inotify_ventoy_part $3; then
+    vtlog "find ventoy partition $3 ..."    
+    $BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh "$3"
+    
+    blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')  
+    vtDM=$(ventoy_find_dm_id ${blkdev_num})
+    vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $AWK '{print $2}' | $SED 's/.*"\(.*\)".*/\1/')
+
+    vtlog "blkdev_num=$blkdev_num  vtDM=$vtDM  label $vtLABEL ..."
+    
+    if ! [ -d /dev/disk/by-label ]; then
+        mkdir -p /dev/disk/by-label
+    fi
+    $BUSYBOX_PATH/cp -a /dev/$vtDM /dev/disk/by-label/$vtLABEL
+fi
+
+PATH=$VTPATH_OLD
index ca3503df8c27a057c875816dd303a5d5c1ec2cf5..aa1f7fc6f08f25a45e3a7fd596367a9581cd2ab3 100644 (file)
 
 . $VTOY_PATH/hook/ventoy-os-lib.sh
 
-ventoy_systemd_udevd_work_around
-ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
+#ventoy_systemd_udevd_work_around
+#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
 
-#$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-disk.sh /lib/dracut/hooks/initqueue/01-ventoy-disk.sh
+$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0#" -i /lib/dracut-lib.sh
+ventoy_set_inotify_script  rhel7/ventoy-inotifyd-hook.sh
+
+$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh
 
 # suppress write protected mount warning
 if [ -e /usr/sbin/anaconda-diskroot ]; then
similarity index 55%
rename from IMG/cpio/ventoy/hook/debian/deepin-hook.sh
rename to IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-hook.sh
index deec6405796099975c5a94712145fa72206eb114..bf81445cd65bf58cb6b7122909e17e3e7113f4e1 100644 (file)
 # 
 #************************************************************************************
 
-drop_initramfs_workaround() {
-    mainfilelist=$($FIND / -name 9990-main.sh)
-    
-    echo "mainfilelist=$mainfilelist" >> $VTLOG
-    
-    if [ -z "$mainfilelist" ]; then 
-        return
-    fi
+. /ventoy/hook/ventoy-hook-lib.sh
 
-    for vtfile in $mainfilelist; do
-        vtcnt=$($GREP -c 'panic.*Unable to find a medium' $vtfile)
-        if [ $vtcnt -ne 1 ]; then
-            return
-        fi
-    done
-    
-    echo "direct_hook insert ..." >> $VTLOG
-    
-    for vtfile in $mainfilelist; do
-        $SED "s#panic.*Unable to find a medium.*#$BUSYBOX_PATH/sh  $VTOY_PATH/hook/debian/deepin-disk.sh \$mountpoint; livefs_root=\$mountpoint#" -i $vtfile
-    done
-}
+if is_ventoy_hook_finished; then
+    exit 0
+fi
 
-ventoy_systemd_udevd_work_around
-ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
+vtlog "##### INOTIFYD: $2/$3 is created ..."
 
-drop_initramfs_workaround
+VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
+
+if is_inotify_ventoy_part $3; then
+    vtlog "find ventoy partition ..."
+    $BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 noreplace
+    
+    blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')  
+    vtDM=$(ventoy_find_dm_id ${blkdev_num})
+
+    if [ "$vtDM" = "dm-0" ]; then
+        vtlog "This is dm-0, OK ..."
+    else
+        vtlog "####### This is $vtDM ####### this is abnormal ..."
+        ventoy_swap_device /dev/dm-0 /dev/$vtDM
+    fi
+    
+    set_ventoy_hook_finish
+fi
 
+PATH=$VTPATH_OLD
index 62e413b9d2c5daf3363d5743666902b96b6aea05..f70d55743f8cd8432a1f7d0a823dbe03bf562c59 100644 (file)
@@ -421,4 +421,37 @@ ventoy_udev_disk_common_hook() {
     fi
 }
 
+is_inotify_ventoy_part() {
+    if echo $1 | grep -q "2$"; then
+        if ! [ -e /sys/block/$1 ]; then
+            if [ -e /sys/class/block/$1 ]; then
+                if [ -e /dev/${1:0:-1} ]; then
+                    $VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c ${1:0:-1}
+                    return
+                fi
+            fi
+        fi
+    fi
+    
+    [ "1" = "0" ]
+}
+
+ventoy_find_dm_id() {
+    for vt in $($BUSYBOX_PATH/ls /sys/block/); do
+        if [ "${vt:0:3}" = "dm-" ]; then
+            vtMajorMinor=$($CAT /sys/block/$vt/dev)
+            if [ "$vtMajorMinor" = "$1" ]; then
+                echo ${vt}
+                return
+            fi
+        fi
+    done
+    echo 'xx'
+}
+
+ventoy_swap_device() {
+    mv $1 $VTOY_PATH/swap_tmp_dev
+    mv $2 $1
+    mv $VTOY_PATH/swap_tmp_dev $2
+}
 
index b5ea3bf7d8e49d34a20e0a4a12bb5c7bdadc7946..05533347e45082ed14863ccd83532e5420b15e7e 100644 (file)
@@ -101,3 +101,7 @@ ventoy_print_yum_repo() {
     echo "gpgcheck=0"
     echo "priority=0"
 }
+
+ventoy_set_inotify_script() {
+    echo $VTOY_PATH/hook/$1 > $VTOY_PATH/inotifyd-hook-script.txt
+}
index 693a9b5f141dcf0edecc00bcbf11e789ca58b76b..228eb99082c3b2a7c883f7c67ec0b6b03ba78227 100644 (file)
Binary files a/INSTALL/Ventoy2Disk.exe and b/INSTALL/Ventoy2Disk.exe differ
index d9a59fab39b0ce831b3430d71200962189fe2597..3bf13d138762879f4c8555ff4c38f4c21f6cb6fa 100644 (file)
@@ -395,7 +395,7 @@ function legacy_iso_memdisk {
 #############################################################
 #############################################################
 
-set VENTOY_VERSION="1.0.07"
+set VENTOY_VERSION="1.0.08b1"
 
 #disable timeout
 unset timeout
index da7f43ef05fee418358f3fa54ddc0a1d28070bea..30c34e766cf060d5a7c58d43785ffc6dab11fcf3 100644 (file)
Binary files a/INSTALL/ventoy/ventoy.cpio and b/INSTALL/ventoy/ventoy.cpio differ
index d38afb0fe4c9b0788df4bf2b46d1b191af617cad..990dcfe3b10675c2af95777c4cd6f5e6e376f49e 100644 (file)
Binary files a/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc and b/Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc differ
index ef11ce8067a8679740a484021a66dc3dafd2eac0..fd557cf96e57b77ac4a447612ba5250e7ee5b6a4 100644 (file)
@@ -448,7 +448,7 @@ static int vtoy_check_device(ventoy_os_param *param, const char *device)
     debug("param->vtoy_disk_size=%llu size=%llu\n", 
         (unsigned long long)param->vtoy_disk_size, (unsigned long long)size);
 
-    if (param->vtoy_disk_size == size && 
+    if ((param->vtoy_disk_size == size || param->vtoy_disk_size == size + 512) && 
         memcmp(vtguid, param->vtoy_disk_guid, 16) == 0)
     {
         debug("<%s> is right ventoy disk\n", device);