]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Code optimization
authorlongpanda <admin@ventoy.net>
Wed, 4 Jan 2023 07:39:03 +0000 (15:39 +0800)
committerlongpanda <admin@ventoy.net>
Wed, 4 Jan 2023 07:39:03 +0000 (15:39 +0800)
IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh
IMG/cpio/ventoy/hook/rhel7/ventoy-inotifyd-hook.sh
IMG/cpio/ventoy/hook/rhel7/ventoy-make-link.sh
IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
INSTALL/ventoy/vtoyjump32.exe
INSTALL/ventoy/vtoyjump64.exe
vtoyjump/vtoyjump/vtoyjump.c

index 7601687418370b247b30206e4e479289dff4c44d..d1cbdac199b3dd9f3c2da6524b952e70b323c008 100644 (file)
@@ -150,3 +150,19 @@ fi
 if [ -f $VTOY_PATH/autoinstall ]; then
     cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh
 fi
+
+
+#special distro magic
+$BUSYBOX_PATH/mkdir -p $VTOY_PATH/distmagic
+if $GREP -q SCRE /proc/cmdline; then
+    echo 1 > $VTOY_PATH/distmagic/SCRE
+fi
+
+if $GREP -qw 'SA[.]1' /proc/cmdline; then
+if $GREP -qw 'SA[.]2' /proc/cmdline; then
+if $GREP -qw 'rw'     /proc/cmdline; then
+    echo 1 > $VTOY_PATH/distmagic/DELL_PER
+fi
+fi
+fi
+
index 609dc4cad355945eedd6da5ca3040ab874b3ec97..0ab59475e090145c504b750936f3459c1597efbe 100644 (file)
@@ -50,18 +50,9 @@ if is_inotify_ventoy_part $3; then
         vtScript=$($GREP -m1 'RUN.=' $vtGenRulFile | $AWK -F'RUN.=' '{print $2}' | $SED 's/"\(.*\)".*/\1/')
         vtlog "vtScript=$vtScript"
         
-        DELL_PER=''
-        if [ -f /etc/services ]; then
-            if grep -qiw DTK /etc/services; then
-                if grep -qiw Dell /etc/services; then
-                    DELL_PER='YES'
-                fi
-            fi
-        fi
-        
-        if $GREP -q SCRE /proc/cmdline; then
+        if [ -f $VTOY_PATH/distmagic/SCRE ]; then
             /sbin/dmsquash-live-root /dev/ventoy
-        elif [ "$DELL_PER" = "YES" ]; then
+        elif [ -f $VTOY_PATH/distmagic/DELL_PER ]; then
             sed 's/liverw=[^ ]*/liverw=ro/g' -i /sbin/dmsquash-live-root
             sed 's/writable_fsimg=[^ ]*/writable_fsimg=""/g' -i /sbin/dmsquash-live-root
             /sbin/dmsquash-live-root /dev/ventoy
index a69233610c143538e365ee292f7e2bcb25bb6fb6..100815a87df4a0ae648e9ff83e52cc61dff85dd0 100644 (file)
@@ -26,7 +26,9 @@ fi
 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 ! [ -e /dev/mapper/ventoy ]; then
+if [ -e /dev/mapper/ventoy ]; then
+    vtlog "/dev/mapper/ventoy already exist"
+else
     vtlog "link /dev/$vtDM to /dev/mapper/ventoy"
     ln -s /dev/$vtDM /dev/mapper/ventoy
 fi
@@ -35,7 +37,13 @@ VTLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
 vtlog "VTLABEL=$VTLABEL"
 
 if [ -n "$VTLABEL" ]; then
-    if ! [ -e "/dev/disk/by-label/$VTLABEL" ]; then
+    if ! [ -d /dev/disk/by-label ]; then
+        mkdir -p /dev/disk/by-label
+    fi
+
+    if [ -e "/dev/disk/by-label/$VTLABEL" ]; then
+        vtlog "/dev/disk/by-label/$VTLABEL already exist"
+    else
         vtlog "link /dev/$vtDM to /dev/disk/by-label/$VTLABEL"
         ln -s /dev/$vtDM "/dev/disk/by-label/$VTLABEL"
     fi
index f6d9cb0fb128ae12f7bee267cf845f64403e1892..b367895b2dd000e37412136fbc1077fc390fcd21 100644 (file)
@@ -892,3 +892,17 @@ ventoy_check_umount() {
         fi
     done
 }
+
+ventoy_wait_dir() {
+    vtdir=$1
+    vtsec=0
+    
+    while [ $vtsec -lt $2 ]; do
+        if [ -d "$vtdir" ]; then
+            break
+        else
+            $SLEEP 1
+            vtsec=$(expr $vtsec + 1)
+        fi
+    done
+}
index d6af4ac7552f4c24163536907aa54fceb8433a82..15f3fc17793138e8823db13774a25cdcba7091e0 100644 (file)
Binary files a/INSTALL/ventoy/vtoyjump32.exe and b/INSTALL/ventoy/vtoyjump32.exe differ
index 544212007aaeff7d3b1de5028fe645c15b39068e..d1e63c6f05cbe0e25e5678f5401ac54c4129cc1c 100644 (file)
Binary files a/INSTALL/ventoy/vtoyjump64.exe and b/INSTALL/ventoy/vtoyjump64.exe differ
index e72754dc1e1402274800225687dfaf5d1ce8c1db..178e4354e4a3d8427931e5a852479ae2a6763346 100644 (file)
@@ -1073,24 +1073,24 @@ End:
     return rc;\r
 }\r
 \r
-static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe, const char *ExOpt)\r
+static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe, const char *opt)\r
 {\r
     CHAR Letter;\r
     CHAR Cmdline[512];\r
     WCHAR CmdlineW[512];\r
     PROCESS_INFORMATION Pi;\r
 \r
-    Log("VentoyRunImdisk <%s> <%s>", IsoPath, imdiskexe);\r
+    Log("VentoyRunImdisk <%s> <%s> <%s>", IsoPath, imdiskexe, opt);\r
 \r
     Letter = GetIMDiskMountLogicalDrive();\r
 \r
-    if (ExOpt)\r
+    if (opt)\r
     {\r
-        sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o ro,%s -f \"%s\" -m %C:", imdiskexe, ExOpt, IsoPath, Letter);\r
+        sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o %s -f \"%s\" -m %C:", imdiskexe, opt, IsoPath, Letter);\r
     }\r
     else\r
     {\r
-        sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o ro -f \"%s\" -m %C:", imdiskexe, IsoPath, Letter);\r
+        sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -f \"%s\" -m %C:", imdiskexe, IsoPath, Letter);\r
     }\r
     \r
     Log("mount iso to %C: use imdisk cmd <%s>", Letter, Cmdline);\r
@@ -1135,7 +1135,7 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
 \r
     if (0 == VentoyCopyImdisk(PhyDrive, ImPath))\r
     {\r
-        VentoyRunImdisk(IsoPath, ImPath, NULL);\r
+        VentoyRunImdisk(IsoPath, ImPath, "ro");\r
         rc = 0;\r
     }\r
 \r