Esempio n. 1
0
    def format(self, partition):
        self.preFormat(partition)

        cmd_path = sysutils.find_executable("mke2fs")
        if not cmd_path:
            cmd_path = sysutils.find_executable("mkfs.ext3")

        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e

        # bug 5616: ~100MB reserved-blocks-percentage
        reserved_percentage = int(math.ceil(100.0 * 100.0 / partition.getMB()))

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -j -m %d %s" %(cmd_path,
                                              reserved_percentage,
                                              partition.getPath())

        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "ext3 format failed: %s" % partition.getPath()

        # for Disabling Lengthy Boot-Time Checks
        self.tune2fs(partition)
Esempio n. 2
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = sysutils.find_executable("dosfslabel")
     cmd = "%s %s %s" % (cmd_path, partition.getPath(), label)
     try:
         p = os.popen(cmd)
         p.close()
     except:
         return False
     return True
Esempio n. 3
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = sysutils.find_executable("xfs_db")
     cmd = "%s -x -c \"label %s\" %s" % (cmd_path, label, partition.getPath())
     try:
         p = os.popen(cmd)
         p.close()
     except:
         return False
     return True
Esempio n. 4
0
    def format(self, partition):
        self.preFormat(partition)
        cmd_path = sysutils.find_executable("mkfs.vfat")
        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e

        cmd = "%s %s" %(cmd_path,partition.getPath())
        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "vfat format failed: %s" % partition.getPath()
Esempio n. 5
0
 def list_edd_signatures(self):
     sigs = {}
     if not os.path.exists(self.edd_dir):
         cmd_path = sysutils.find_executable("modprobe")
         cmd = "%s %s" %(cmd_path,"edd")
         p = os.popen(cmd)
         o = p.readlines()
         if p.close():
             raise YaliException, "Inserting EDD Module failed !"
     for d in os.listdir(self.edd_dir):
         bios_num = d[9:]
         sigs[bios_num] = self.get_edd_sig(bios_num)
     return sigs
Esempio n. 6
0
    def getLabel(self, partition):
        cmd_path = sysutils.find_executable("dosfslabel")
        if not cmd_path:
            e = "Command not found to get label for %s filesystem" %(self.name())
            raise FSError, e 

        cmd = "%s %s" % (cmd_path, partition.getPath())
        p = os.popen(cmd)
        label = p.read()
        p.close()
        if not label == '':
            return label.strip(' \n')
        return False
Esempio n. 7
0
    def tune2fs(self, partition):
        cmd_path = sysutils.find_executable("tune2fs")
        if not cmd_path:
            e = "Command not found to tune the filesystem"
            raise FSError, e

        # Disable mount count and use 6 month interval to fsck'ing disks at boot
        cmd = "%s -c 0 -i 6m %s" % (cmd_path, partition.getPath())

        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "tune2fs tuning failed: %s" % partition.getPath()
Esempio n. 8
0
    def preResize(self, partition):
        cmd_path = sysutils.find_executable("e2fsck")

        if not cmd_path:
            raise FSError, "Command not found to resize %s filesystem" % (self.name())

        res = sysutils.execClear("e2fsck",
                                ["-f", "-p", "-C", "0", partition.getPath()],
                                stdout="/tmp/resize.log",
                                stderr="/tmp/resize.log")
        if res >= 4:
            raise FSError, "FSCheck failed on %s" % (partition.getPath())

        return True
Esempio n. 9
0
    def format(self, partition):
        self.preFormat(partition)

        cmd_path = sysutils.find_executable("mkreiserfs")

        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e

        cmd = "%s  %s" %(cmd_path, partition.getPath())

        p = os.popen(cmd, "w")
        p.write("y\n")
        if p.close():
            raise YaliException, "reiserfs format failed: %s" % partition.getPath()
Esempio n. 10
0
    def minResizeMB(self, partition):
        cmd_path = sysutils.find_executable("dumpe2fs")

        if not cmd_path:
            e = "Command not found to get information about %s" %(partition)
            raise FSError, e 

        lines = os.popen("%s -h %s" % (cmd_path, partition.getPath())).readlines()

        try:
            total_blocks = long(filter(lambda line: line.startswith('Block count'), lines)[0].split(':')[1].strip('\n').strip(' '))
            free_blocks  = long(filter(lambda line: line.startswith('Free blocks'), lines)[0].split(':')[1].strip('\n').strip(' '))
            block_size   = long(filter(lambda line: line.startswith('Block size'), lines)[0].split(':')[1].strip('\n').strip(' '))
            return (((total_blocks - free_blocks) * block_size) / parteddata.MEGABYTE) + 150
        except:
            return 0
Esempio n. 11
0
    def resize(self, size_mb, partition):
        if size_mb < self.minResizeMB(partition):
            return False

        cmd_path = sysutils.find_executable("resize2fs")

        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e 

        res = sysutils.execClear("resize2fs",
                                ["-f", partition.getPath(), "%sM" %(size_mb)],
                                stdout="/tmp/resize.log",
                                stderr="/tmp/resize.log")
        if res:
            raise FSError, "Resize failed on %s" % (partition.getPath())

        return True
Esempio n. 12
0
def setOrderedDiskList():
    devices = detectAll()
    devices.sort()

    import yali4.gui.context as ctx

    # Check EDD Module
    if not os.path.exists("/sys/firmware/edd"):
        cmd_path = sysutils.find_executable("modprobe")
        cmd = "%s %s" % (cmd_path, "edd")
        res = sysutils.run(cmd)
        if not res:
            ctx.installData.orderedDiskList = devices
            ctx.debugger.log("ERROR : Inserting EDD Module failed !")
            return

    edd = EDD()
    sortedList = []
    edd_list = edd.list_edd_signatures()
    mbr_list = edd.list_mbr_signatures()
    edd_keys = edd_list.keys()
    edd_keys.sort()
    for bios_num in edd_keys:
        edd_sig = edd_list[bios_num]
        if mbr_list.has_key(edd_sig):
            sortedList.append(mbr_list[edd_sig])

    if len(devices) > 1:
        a = ctx.installData.orderedDiskList = sortedList
        b = devices
        # check consistency of diskList
        if not len(filter(None, map(lambda x: x in a, b))) == len(b):
            ctx.installData.orderedDiskList = devices
            ctx.isEddFailed = True
    else:
        ctx.installData.orderedDiskList = devices
Esempio n. 13
0
def setOrderedDiskList():
    devices = detectAll()
    devices.sort()

    import yali4.gui.context as ctx

    # Check EDD Module
    if not os.path.exists("/sys/firmware/edd"):
        cmd_path = sysutils.find_executable("modprobe")
        cmd = "%s %s" % (cmd_path, "edd")
        res = sysutils.run(cmd)
        if not res:
            ctx.installData.orderedDiskList = devices
            ctx.debugger.log("ERROR : Inserting EDD Module failed !")
            return

    edd = EDD()
    sortedList = []
    edd_list = edd.list_edd_signatures()
    mbr_list = edd.list_mbr_signatures()
    edd_keys = edd_list.keys()
    edd_keys.sort()
    for bios_num in edd_keys:
        edd_sig = edd_list[bios_num]
        if mbr_list.has_key(edd_sig):
            sortedList.append(mbr_list[edd_sig])

    if len(devices) > 1:
        a = ctx.installData.orderedDiskList = sortedList
        b = devices
        # check consistency of diskList
        if not len(filter(None, map(lambda x: x in a,b))) == len(b):
            ctx.installData.orderedDiskList = devices
            ctx.isEddFailed = True
    else:
        ctx.installData.orderedDiskList = devices
Esempio n. 14
0
def requires(command):
    cmd_path = sysutils.find_executable(command)
    if not cmd_path:
        raise FSError, "Command not found: %s " % command
    return cmd_path
Esempio n. 15
0
def requires(command):
    cmd_path = sysutils.find_executable(command)
    if not cmd_path:
        raise FSError, "Command not found: %s " % command
    return cmd_path