Changed mount function, since libc can't handle loop devices automatically without some how probing partitions?
This commit is contained in:
parent
0dfc0d6195
commit
ff9475ffe4
|
|
@ -53,5 +53,5 @@ class Installer():
|
||||||
## so we'll use the old manual method until we get that sorted out.
|
## so we'll use the old manual method until we get that sorted out.
|
||||||
# UUID = simple_command(f"blkid -s PARTUUID -o value /dev/{os.path.basename(args['drive'])}{args['partitions']['2']}").decode('UTF-8').strip()
|
# UUID = simple_command(f"blkid -s PARTUUID -o value /dev/{os.path.basename(args['drive'])}{args['partitions']['2']}").decode('UTF-8').strip()
|
||||||
# entry.write('options root=PARTUUID={UUID} rw intel_pstate=no_hwp\n'.format(UUID=UUID))
|
# entry.write('options root=PARTUUID={UUID} rw intel_pstate=no_hwp\n'.format(UUID=UUID))
|
||||||
UUID = b''.join(sys_command(f"ls -l /dev/disk/by-uuid/ | grep {os.path.basename(partition['path'])} | awk '{{print $9}}'")).decode('UTF-8').strip()
|
UUID = b''.join(sys_command(f"ls -l /dev/disk/by-uuid/ | grep {os.path.basename(partition.path)} | awk '{{print $9}}'")).decode('UTF-8').strip()
|
||||||
entry.write(f'options cryptdevice=UUID={UUID}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
|
entry.write(f'options cryptdevice=UUID={UUID}:luksdev root=/dev/mapper/luksdev rw intel_pstate=no_hwp\n')
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
import glob, re, os, json
|
import glob, re, os, json
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from helpers.general import sys_command
|
#import ctypes
|
||||||
|
#import ctypes.util
|
||||||
from exceptions import *
|
from exceptions import *
|
||||||
import ctypes
|
from helpers.general import sys_command
|
||||||
import ctypes.util
|
|
||||||
import os
|
|
||||||
|
|
||||||
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
|
ROOT_DIR_PATTERN = re.compile('^.*?/devices')
|
||||||
GPT = 0b00000001
|
GPT = 0b00000001
|
||||||
libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
|
#libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
|
||||||
libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p)
|
#libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p)
|
||||||
|
|
||||||
|
|
||||||
class BlockDevice():
|
class BlockDevice():
|
||||||
def __init__(self, path, info):
|
def __init__(self, path, info):
|
||||||
|
|
@ -109,13 +107,14 @@ class Partition():
|
||||||
if not fs:
|
if not fs:
|
||||||
if not self.filesystem: raise DiskError(f'Need to format (or define) the filesystem on {self} before mounting.')
|
if not self.filesystem: raise DiskError(f'Need to format (or define) the filesystem on {self} before mounting.')
|
||||||
fs = self.filesystem
|
fs = self.filesystem
|
||||||
# TODO: Move this to the BlockDevice or something.
|
## libc has some issues with loop devices, defaulting back to sys calls
|
||||||
ret = libc.mount(self.path.encode(), target.encode(), fs.encode(), 0, options.encode())
|
# ret = libc.mount(self.path.encode(), target.encode(), fs.encode(), 0, options.encode())
|
||||||
if ret < 0:
|
# if ret < 0:
|
||||||
errno = ctypes.get_errno()
|
# errno = ctypes.get_errno()
|
||||||
raise OSError(errno, f"Error mounting {self.path} ({fs}) on {target} with options '{options}': {os.strerror(errno)}")
|
# raise OSError(errno, f"Error mounting {self.path} ({fs}) on {target} with options '{options}': {os.strerror(errno)}")
|
||||||
self.mountpoint = target
|
if sys_command(f'/usr/bin/mount {self.path} {target}').exit_code == 0:
|
||||||
|
self.mountpoint = target
|
||||||
|
return True
|
||||||
|
|
||||||
class luks2():
|
class luks2():
|
||||||
def __init__(self, filesystem):
|
def __init__(self, filesystem):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue