self.mounted = True
+class F2fsDiskMount(DiskMount):
+ """A DiskMount object that is able to format/resize f2fs filesystems."""
+ def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None, fsuuid=None):
+ DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
+ self.blocksize = blocksize
+ self.fslabel = fslabel.replace("/", "")
+ self.uuid = fsuuid or str(uuid.uuid4())
+ self.skipformat = skipformat
+ self.fsopts = fsopts
+ self.__extopts = None
+ self.dumpe2fs = find_binary_path("dump." + self.fstype)
+ self.fsckcmd = find_binary_path("fsck." + self.fstype)
+ self.resizecmd = find_binary_path("resize." + self.fstype)
+
+ def __parse_field(self, output, field):
+ return
+
+ def __format_filesystem(self):
+ if self.skipformat:
+ msger.debug("Skip filesystem format.")
+ return
+
+ msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
+ rc = runner.show([self.mkfscmd, "-l", self.fslabel, self.disk.device])
+ if rc != 0:
+ raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device))
+
+ def __resize_filesystem(self, size = None):
+ msger.info("Resizing filesystem ...")
+ current_size = os.stat(self.disk.lofile)[stat.ST_SIZE]
+
+ if size is None:
+ size = self.disk.size
+
+ if size == current_size:
+ return
+
+ if size > current_size:
+ self.disk.expand(size=size)
+
+ self.__fsck()
+
+ return size
+
+ def __create(self):
+ resize = False
+ if not self.disk.fixed() and self.disk.exists():
+ resize = True
+
+ self.disk.create()
+
+ if resize:
+ self.__resize_filesystem()
+ else:
+ self.__format_filesystem()
+
+ def mount(self, options = None, init_expand = False):
+ self.__create()
+ if init_expand:
+ expand_size = long(self.disk.size * 1.5)
+ msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size))
+ self.__resize_filesystem(expand_size)
+ self.disk.reread_size()
+ DiskMount.mount(self, options)
+
+ def __fsck(self):
+ msger.info("Checking filesystem %s" % self.disk.lofile)
+ runner.quiet([self.fsckcmd, self.disk.lofile])
+
+ def __get_size_from_filesystem(self):
+ return self.disk.size
+
+ def __resize_to_minimal(self):
+ msger.info("Resizing filesystem to minimal ...")
+ self.__fsck()
+
+ return self.__get_size_from_filesystem()
+
+ def resparse(self, size = None):
+ self.cleanup()
+ if size == 0:
+ minsize = 0
+ else:
+ minsize = self.__resize_to_minimal()
+ self.disk.truncate(minsize)
+ self.__resize_filesystem(size)
+ return minsize
+
class ExtDiskMount(DiskMount):
"""A DiskMount object that is able to format/resize ext[23] filesystems."""
def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True, skipformat = False, fsopts = None, fsuuid=None):
# not recognize properly.
# TODO: Can we make better assumption?
fstype = "btrfs"
- elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs" ]:
+ elif partition_info[5] in [ "ext2", "ext3", "ext4", "btrfs", "f2fs" ]:
fstype = partition_info[5]
elif partition_info[5] in [ "fat16", "fat32" ]:
fstype = "vfat"
if rootpart and rootpart == line[0]:
mountpoint = '/'
- elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs" ]:
+ elif not root_mounted and fstype in [ "ext2", "ext3", "ext4", "btrfs", "f2fs" ]:
# TODO: Check that this is actually the valid root partition from /etc/fstab
mountpoint = "/"
root_mounted = True