Esempio n. 1
0
    def umount_tgt_device(self):
        self.mounted_devs.reverse()
        for dev in self.mounted_devs:
            if type(dev) is MiDevice:
                if not dev.do_umount():
                    logger.w('Umount device %s Failed, but we continue')
            else:
                umount_dev(dev)
        res = run_bash('mount')
        logger.d(''''UMount target system partition finished, check the mount output please:)
%s
%s
        ''' % ('\n'.join(res['out']), '\n'.join(res['err'])))
Esempio n. 2
0
def win_probe(mia, operid, hdpartlist):
    mia.set_step(operid, 0, -1)
    result = []
    all_drives = hdpartlist
    for (device, fstype, new_device) in all_drives:
        dolog('Search %s for Windows files\n' % device)
        if fstype not in CF.D.FSTYPE_MAP or \
               CF.D.FSTYPE_MAP[fstype][0] not in ('vfat', 'ntfs', 'ntfs-3g'):
            continue
        ret, mntdir = mount_dev(CF.D.FSTYPE_MAP[fstype][0], device)
        if ret:
            if os.path.exists(os.path.join(mntdir, 'bootmgr')):
                result.append((new_device, 'vista/7'))
            elif os.path.exists(os.path.join(mntdir, 'ntldr')):
                result.append((new_device, 'winnt'))
            elif os.path.exists(os.path.join(mntdir, 'io.sys')):
                result.append((new_device, 'win98'))
            else:
                 result.append((new_device, 'win'))
            umount_dev(mntdir)
    return result
Esempio n. 3
0
 def do_umount(self):
     if not self.has_mounted:
         return True
     ret, errmsg = umount_dev(self.mntdir)
     if not ret:
         logger.e("MiDevice.do_umount UMount(%s) failed: %s" % (self.mntdir, str(errmsg)))
         return False
     else:
         self.has_mounted = False
         if not self.mntdir_fixed:
             self.mntdir = ""
         return True
Esempio n. 4
0
 def do_umount(self):
     if not self.has_mounted: return True
     for t in range(3): # try 3 time, because some udisk program will hold on disk, when disk mount. umount action can not so quickly.
         ret, errmsg = umount_dev(self.mntdir)
         if ret:
             break
         else:
             time.sleep(1)
     if not ret:
         logger.e("MiDevice.do_umount UMount(%s) failed: %s" % (self.mntdir, str(errmsg))); return False
     else:
         self.has_mounted = False
         if not self.mntdir_fixed: self.mntdir = ''
         return True
Esempio n. 5
0
def logger_copy_logfiles(mia, operid, param):
    def start_operate(title):
        time.sleep(0.2)
        print title

    usb_dev_path, usb_fs_type, logfiles = param
    usb_mount_dir = ""
    steps = 4
    step = 0
    mia.set_step(operid, step, steps)
    # mount the usb device.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Mount...')
    ret, msg = mount_dev(usb_fs_type, usb_dev_path)
    if not ret:
        return str(msg)
    else:
        usb_mount_dir = msg

    # Copy logfiles to usb.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Copy logfiles...')
    ret, msg = copy_logfiles(logfiles,
                             os.path.join(usb_mount_dir, "magiclogger"))
    if ret:
        return str(msg)

    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Sync files...')
    run_bash('/bin/sync')

    # umount the usb device.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Umount...')
    ret, msg = umount_dev(usb_mount_dir)
    if not ret:
        return str(msg)

    return 0
Esempio n. 6
0
def logger_copy_logfiles(mia, operid, param):
    def start_operate(title):
        time.sleep(0.2)
        print title

    usb_dev_path, usb_fs_type, logfiles = param
    usb_mount_dir = ""
    steps = 4
    step = 0
    mia.set_step(operid, step, steps)
    # mount the usb device.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Mount...')
    ret, msg = mount_dev(usb_fs_type, usb_dev_path)
    if not ret:
        return str(msg)
    else:
        usb_mount_dir = msg

    # Copy logfiles to usb.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Copy logfiles...')
    ret, msg = copy_logfiles(logfiles, os.path.join(usb_mount_dir, "magiclogger"))
    if ret:
        return str(msg)
    
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Sync files...')
    run_bash('/bin/sync')

    # umount the usb device.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Umount...')
    ret, msg = umount_dev(usb_mount_dir)
    if not ret:
        return str(msg)

    return 0
Esempio n. 7
0
        boot_ini = open(os.path.join(win_mntdir, 'boot.ini'), 'r+')
        found = False
        for line in boot_ini.readlines():
            dolog('%s' % line)
            if 'grldr' in line.lower():
                found = True
                break
        if not found:
            dolog('APPEND')
            boot_ini.seek(0, 2)
            boot_ini.write('\nc:\\grldr="Grub"\n')
        boot_ini.close()

        os.system('cp -a %s %s/' % ('/usr/share/grldr',
                                   win_mntdir))
        umount_dev(win_mntdir)
        return 0, ''

    else:
        if os.path.exists('/tmpfs/debug/nobootloader'):
            dolog('TURN ON: nobootloader\n')
            return 0, ''
        # Get the command arguments for grub.
        #floppy = kudzu.probe(kudzu.CLASS_FLOPPY,
        #                     kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
        #                     kudzu.PROBE_ALL)
        floppy = getdev.probe(getdev.CLASS_FLOPPY)

        # Because --batch will cause a bus error, we don not use this
        # option.
        #grubopt = '--batch'
Esempio n. 8
0
              os.path.join(win_mntdir, 'boot.ini'))
        boot_ini = open(os.path.join(win_mntdir, 'boot.ini'), 'r+')
        found = False
        for line in boot_ini.readlines():
            dolog('%s' % line)
            if 'grldr' in line.lower():
                found = True
                break
        if not found:
            dolog('APPEND')
            boot_ini.seek(0, 2)
            boot_ini.write('\nc:\\grldr="Grub"\n')
        boot_ini.close()

        os.system('cp -a %s %s/' % ('/usr/share/grldr', win_mntdir))
        umount_dev(win_mntdir)
        return 0, ''

    else:
        if os.path.exists('/tmpfs/debug/nobootloader'):
            dolog('TURN ON: nobootloader\n')
            return 0, ''
        # Get the command arguments for grub.
        #floppy = kudzu.probe(kudzu.CLASS_FLOPPY,
        #                     kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
        #                     kudzu.PROBE_ALL)
        floppy = getdev.probe(getdev.CLASS_FLOPPY)

        # Because --batch will cause a bus error, we don not use this
        # option.
        #grubopt = '--batch'