def prepare(self): try: dev = self.hdd.disk_path.split('/')[-1] os.unlink('/dev/nomount.%s' % dev) except Exception as e: print("[Harddisk] ERROR: Failed to remove /dev/nomount file:", e) # try mounting through fstab first if self.hdd.mount_device is None: dev = self.hdd.partitionPath("1") else: # if previously mounted, use the same spot dev = self.hdd.mount_device fstab = open("/etc/fstab") lines = fstab.readlines() fstab.close() for line in lines: parts = line.strip().split(" ") fspath = os.path.realpath(parts[0]) if os.path.realpath(fspath) == dev: self.setCmdline("mount -t auto " + fspath) self.postconditions.append(Task.ReturncodePostcondition()) return # device is not in fstab if SystemInfo["Udev"]: # we can let udev do the job, re-read the partition table # Sorry for the sleep 2 hack... self.setCmdline('sleep 2; hdparm -z ' + self.hdd.disk_path) self.postconditions.append(Task.ReturncodePostcondition())
def prepare(self): try: dev = self.hdd.disk_path.split(sep)[-1] unlink("/dev/nomount.%s" % dev) except (IOError, OSError) as err: print( "[Harddisk] Error %d: MountTask failed to remove '/dev/nomount' file! (%s)" % (err.errno, err.strerror)) if self.hdd.mount_device is None: dev = self.hdd.partitionPath( "1") # Try mounting through fstab first. else: dev = self.hdd.mount_device # If previously mounted, use the same spot. lines = fileReadLines("/etc/fstab", []) for line in lines: parts = line.strip().split(" ") fspath = realpath(parts[0]) if realpath(fspath) == dev: self.setCmdline("mount -t auto " + fspath) self.postconditions.append(Task.ReturncodePostcondition()) return # device is not in fstab if BoxInfo.getItem("Udev"): # we can let udev do the job, re-read the partition table # Sorry for the sleep 2 hack... self.setCmdline("sleep 2; hdparm -z " + self.hdd.disk_path) self.postconditions.append(Task.ReturncodePostcondition())
def prepare(self): try: dev = self.hdd.disk_path.split('/')[-1] open('/dev/nomount.%s' % dev, "wb").close() except Exception as e: print("[Harddisk] ERROR: Failed to create /dev/nomount file:", e) self.setTool('umount') self.args.append('-f') for dev in self.hdd.enumMountDevices(): self.args.append(dev) self.postconditions.append(Task.ReturncodePostcondition()) self.mountpoints.append(dev) if not self.mountpoints: print("[Harddisk] UnmountTask: No mountpoints found?") self.cmd = 'true' self.args = [self.cmd]
def prepare(self): try: dev = self.hdd.disk_path.split(sep)[-1] open("/dev/nomount.%s" % dev, "wb").close() except (IOError, OSError) as err: print( "[Harddisk] Error %d: UnmountTask failed to create '/dev/nomount' file! (%s)" % (err.errno, err.strerror)) self.setTool("umount") self.args.append("-f") for dev in self.hdd.enumMountDevices(): self.args.append(dev) self.postconditions.append(Task.ReturncodePostcondition()) self.mountpoints.append(dev) if not self.mountpoints: print("[Harddisk] UnmountTask: No mountpoints found?") self.cmd = "true" self.args = [self.cmd]