diff options
author | Jeremy Katz <katzj@redhat.com> | 2007-11-29 17:50:35 -0500 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2007-11-29 17:54:37 -0500 |
commit | 41908853dd254c3b9f860d4f719aa33b3fb0f8a4 (patch) | |
tree | 8bfa0cb0b4dba642494e6394606a553a1c4034bf | |
parent | f66fb97b131e6f4cf100b5bd48716d086eb8b836 (diff) | |
download | anaconda-41908853dd254c3b9f860d4f719aa33b3fb0f8a4.tar.gz anaconda-41908853dd254c3b9f860d4f719aa33b3fb0f8a4.tar.xz anaconda-41908853dd254c3b9f860d4f719aa33b3fb0f8a4.zip |
add support for resizing ntfs
-rw-r--r-- | fsset.py | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -935,6 +935,59 @@ class NTFSFileSystem(FileSystemType): self.formattable = 0 self.checked = 0 self.name = "ntfs" + if len(filter(lambda d: os.path.exists("%s/ntfsresize" %(d,)), + os.environ["PATH"].split(":"))) > 0: + self.resizable = True + + def resize(self, entry, size, progress, chroot='/'): + devicePath = entry.device.setupDevice(chroot) + log.info("resizing %s to %sM" %(devicePath, size)) + w = None + if progress: + w = progress(_("Resizing"), + _("Resizing filesystem on %s...") %(devicePath), + 100, pulse = True) + + p = os.pipe() + os.write(p[1], "y\n") + os.close(p[1]) + + rc = iutil.execWithPulseProgress("ntfsresize", ["-v", + "-s", "%sM" %(size,), + devicePath], + stdin = p[0], stdout = "/dev/tty5", + stderr = "/dev/tty5", progress = w) + if progress: + w.pop() + if rc: + raise RuntimeError, "Resize of %s failed" %(devicePath,) + + def getMinimumSize(self, device): + """Return the minimum filesystem size in megabytes""" + devicePath = "/dev/%s" % (device,) + if not os.path.exists(devicePath): + isys.makeDevInode(device, devicePath) + + buf = iutil.execWithCapture("ntfsresize", ["--info", devicePath], + stderr = "/dev/tty5") + for l in buf.split("\n"): + if not l.startswith("Space in use"): + continue + try: + usedamt = l.split(":")[1].strip() + (num, unit, pct) = usedamt.split(" ", 2) + used = int(num) + if unit == "GB": + used *= 1024 + except Exception, e: + log.error("unable to parse used space for %s: %s" %(device, e)) + log.debug(l) + # FIXME: arbitrary fudge factor for ntfs resizing + return used + 250 + + log.warning("Unable to discover minimum size of filesystem on %s" %(device,)) + return 1 + fileSystemTypeRegister(NTFSFileSystem()) |