mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-01-25 21:53:19 -05:00
Code optimization
This commit is contained in:
parent
1de7489c6d
commit
a18aa36c01
@ -150,3 +150,19 @@ fi
|
|||||||
if [ -f $VTOY_PATH/autoinstall ]; then
|
if [ -f $VTOY_PATH/autoinstall ]; then
|
||||||
cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh
|
cp -a $VTOY_PATH/hook/rhel7/ventoy-autoexp.sh /lib/dracut/hooks/pre-mount/99-ventoy-autoexp.sh
|
||||||
fi
|
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
|
||||||
|
|
||||||
|
@ -50,18 +50,9 @@ if is_inotify_ventoy_part $3; then
|
|||||||
vtScript=$($GREP -m1 'RUN.=' $vtGenRulFile | $AWK -F'RUN.=' '{print $2}' | $SED 's/"\(.*\)".*/\1/')
|
vtScript=$($GREP -m1 'RUN.=' $vtGenRulFile | $AWK -F'RUN.=' '{print $2}' | $SED 's/"\(.*\)".*/\1/')
|
||||||
vtlog "vtScript=$vtScript"
|
vtlog "vtScript=$vtScript"
|
||||||
|
|
||||||
DELL_PER=''
|
if [ -f $VTOY_PATH/distmagic/SCRE ]; then
|
||||||
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
|
|
||||||
/sbin/dmsquash-live-root /dev/ventoy
|
/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/liverw=[^ ]*/liverw=ro/g' -i /sbin/dmsquash-live-root
|
||||||
sed 's/writable_fsimg=[^ ]*/writable_fsimg=""/g' -i /sbin/dmsquash-live-root
|
sed 's/writable_fsimg=[^ ]*/writable_fsimg=""/g' -i /sbin/dmsquash-live-root
|
||||||
/sbin/dmsquash-live-root /dev/ventoy
|
/sbin/dmsquash-live-root /dev/ventoy
|
||||||
|
@ -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/')
|
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})
|
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"
|
vtlog "link /dev/$vtDM to /dev/mapper/ventoy"
|
||||||
ln -s /dev/$vtDM /dev/mapper/ventoy
|
ln -s /dev/$vtDM /dev/mapper/ventoy
|
||||||
fi
|
fi
|
||||||
@ -35,7 +37,13 @@ VTLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
|
|||||||
vtlog "VTLABEL=$VTLABEL"
|
vtlog "VTLABEL=$VTLABEL"
|
||||||
|
|
||||||
if [ -n "$VTLABEL" ]; then
|
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"
|
vtlog "link /dev/$vtDM to /dev/disk/by-label/$VTLABEL"
|
||||||
ln -s /dev/$vtDM "/dev/disk/by-label/$VTLABEL"
|
ln -s /dev/$vtDM "/dev/disk/by-label/$VTLABEL"
|
||||||
fi
|
fi
|
||||||
|
@ -892,3 +892,17 @@ ventoy_check_umount() {
|
|||||||
fi
|
fi
|
||||||
done
|
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
|
||||||
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1073,24 +1073,24 @@ End:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe, const char *ExOpt)
|
static int VentoyRunImdisk(const char *IsoPath, const char *imdiskexe, const char *opt)
|
||||||
{
|
{
|
||||||
CHAR Letter;
|
CHAR Letter;
|
||||||
CHAR Cmdline[512];
|
CHAR Cmdline[512];
|
||||||
WCHAR CmdlineW[512];
|
WCHAR CmdlineW[512];
|
||||||
PROCESS_INFORMATION Pi;
|
PROCESS_INFORMATION Pi;
|
||||||
|
|
||||||
Log("VentoyRunImdisk <%s> <%s>", IsoPath, imdiskexe);
|
Log("VentoyRunImdisk <%s> <%s> <%s>", IsoPath, imdiskexe, opt);
|
||||||
|
|
||||||
Letter = GetIMDiskMountLogicalDrive();
|
Letter = GetIMDiskMountLogicalDrive();
|
||||||
|
|
||||||
if (ExOpt)
|
if (opt)
|
||||||
{
|
{
|
||||||
sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o ro,%s -f \"%s\" -m %C:", imdiskexe, ExOpt, IsoPath, Letter);
|
sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o %s -f \"%s\" -m %C:", imdiskexe, opt, IsoPath, Letter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -o ro -f \"%s\" -m %C:", imdiskexe, IsoPath, Letter);
|
sprintf_s(Cmdline, sizeof(Cmdline), "%s -a -f \"%s\" -m %C:", imdiskexe, IsoPath, Letter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log("mount iso to %C: use imdisk cmd <%s>", Letter, Cmdline);
|
Log("mount iso to %C: use imdisk cmd <%s>", Letter, Cmdline);
|
||||||
@ -1135,7 +1135,7 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
|
|||||||
|
|
||||||
if (0 == VentoyCopyImdisk(PhyDrive, ImPath))
|
if (0 == VentoyCopyImdisk(PhyDrive, ImPath))
|
||||||
{
|
{
|
||||||
VentoyRunImdisk(IsoPath, ImPath, NULL);
|
VentoyRunImdisk(IsoPath, ImPath, "ro");
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user