Skip to content

Commit

Permalink
Replace _mountpoint with systemMountpoint in other modules
Browse files Browse the repository at this point in the history
Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
  • Loading branch information
vojtechtrefny committed Mar 16, 2015
1 parent 856e081 commit 79b5011
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
22 changes: 11 additions & 11 deletions blivet/devices/btrfs.py
Expand Up @@ -108,14 +108,14 @@ def _do_temp_mount(self, orig=False):
fmt.mount(mountpoint=tmpdir)

def _undo_temp_mount(self):
if getattr(self.format, "_mountpoint", None):
if getattr(self.format, "systemMountpoint", None):
fmt = self.format
elif getattr(self.originalFormat, "_mountpoint", None):
elif getattr(self.originalFormat, "systemMountpoint", None):
fmt = self.originalFormat
else:
return

mountpoint = fmt._mountpoint
mountpoint = fmt.systemMountpoint

if os.path.basename(mountpoint).startswith(self._temp_dir_prefix):
fmt.unmount()
Expand Down Expand Up @@ -327,7 +327,7 @@ def listSubVolumes(self, snapshotsOnly=False):
return subvols

try:
subvols = btrfs.list_subvolumes(self.originalFormat._mountpoint,
subvols = btrfs.list_subvolumes(self.originalFormat.systemMountpoint,
snapshots_only=snapshotsOnly)
except errors.BTRFSError as e:
log.debug("failed to list subvolumes: %s", e)
Expand All @@ -354,7 +354,7 @@ def removeSubVolume(self, name):
def _getDefaultSubVolumeID(self):
subvolid = None
try:
subvolid = btrfs.get_default_subvolume(self.originalFormat._mountpoint)
subvolid = btrfs.get_default_subvolume(self.originalFormat.systemMountpoint)
except errors.BTRFSError as e:
log.debug("failed to get default subvolume id: %s", e)

Expand All @@ -366,7 +366,7 @@ def _setDefaultSubVolumeID(self, vol_id):
This writes the change to the filesystem, which must be mounted.
"""
try:
btrfs.set_default_subvolume(self.originalFormat._mountpoint, vol_id)
btrfs.set_default_subvolume(self.originalFormat.systemMountpoint, vol_id)
except errors.BTRFSError as e:
log.error("failed to set new default subvolume id (%s): %s",
vol_id, e)
Expand Down Expand Up @@ -430,7 +430,7 @@ def _remove(self, member):
raise

try:
btrfs.remove(self.originalFormat._mountpoint, member.path)
btrfs.remove(self.originalFormat.systemMountpoint, member.path)
finally:
self._undo_temp_mount()

Expand All @@ -442,7 +442,7 @@ def _add(self, member):
raise

try:
btrfs.add(self.originalFormat._mountpoint, member.path)
btrfs.add(self.originalFormat.systemMountpoint, member.path)
finally:
self._undo_temp_mount()

Expand Down Expand Up @@ -527,7 +527,7 @@ def setupParents(self, orig=False):
def _create(self):
log_method_call(self, self.name, status=self.status)
self.volume._do_temp_mount()
mountpoint = self.volume.format._mountpoint
mountpoint = self.volume.format.systemMountpoint
if not mountpoint:
raise RuntimeError("btrfs subvol create requires mounted volume")

Expand All @@ -547,7 +547,7 @@ def _destroy(self):
# btrfs does not allow removal of the default subvolume
self.volume._setDefaultSubVolumeID(self.volume.vol_id)

mountpoint = self.volume.originalFormat._mountpoint
mountpoint = self.volume.originalFormat.systemMountpoint
if not mountpoint:
raise RuntimeError("btrfs subvol destroy requires mounted volume")
btrfs.delete_subvolume(mountpoint, self.name)
Expand Down Expand Up @@ -623,7 +623,7 @@ def __init__(self, *args, **kwargs):
def _create(self):
log_method_call(self, self.name, status=self.status)
self.volume._do_temp_mount()
mountpoint = self.volume.format._mountpoint
mountpoint = self.volume.format.systemMountpoint
if not mountpoint:
raise RuntimeError("btrfs subvol create requires mounted volume")

Expand Down
2 changes: 1 addition & 1 deletion blivet/devices/file.py
Expand Up @@ -65,7 +65,7 @@ def fstabSpec(self):
@property
def path(self):
try:
root = self.parents[0].format._mountpoint
root = self.parents[0].format.systemMountpoint
mountpoint = self.parents[0].format.mountpoint
except (AttributeError, IndexError):
root = ""
Expand Down
32 changes: 14 additions & 18 deletions blivet/formats/fs.py
Expand Up @@ -671,29 +671,25 @@ def mount(self, options="", chroot="/", mountpoint=None):
if not ret:
log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context)

self._mountpoint = chrootedMountpoint

def unmount(self):
""" Unmount this filesystem. """
if not self.exists:
raise FSError("filesystem has not been created")

if not self._mountpoint:
if not self.systemMountpoint:
# not mounted
return

if not os.path.exists(self._mountpoint):
if not os.path.exists(self.systemMountpoint):
raise FSError("mountpoint does not exist")

udev.settle()
rc = util.umount(self._mountpoint)
rc = util.umount(self.systemMountpoint)
if rc:
# try and catch whatever is causing the umount problem
util.run_program(["lsof", self._mountpoint])
util.run_program(["lsof", self.systemMountpoint])
raise FSError("umount failed")

self._mountpoint = None

def readLabel(self):
"""Read this filesystem's label.
Expand Down Expand Up @@ -906,7 +902,7 @@ def status(self):
# FIXME check /proc/mounts or similar
if not self.exists:
return False
return self._mountpoint is not None
return self.systemMountpoint is not None

def sync(self, root="/"):
pass
Expand Down Expand Up @@ -1285,16 +1281,16 @@ def sync(self, root='/'):
This is a little odd because xfs_freeze will only be
available under the install root.
"""
if not self.status or not self._mountpoint.startswith(root):
if not self.status or not self.systemMountpoint.startswith(root):
return

try:
util.run_program(["xfs_freeze", "-f", self.mountpoint], root=root)
util.run_program(["xfs_freeze", "-f", self.systemMountpoint], root=root)
except OSError as e:
log.error("failed to run xfs_freeze: %s", e)

try:
util.run_program(["xfs_freeze", "-u", self.mountpoint], root=root)
util.run_program(["xfs_freeze", "-u", self.systemMountpoint], root=root)
except OSError as e:
log.error("failed to run xfs_freeze: %s", e)

Expand Down Expand Up @@ -1618,14 +1614,14 @@ def _setOptions(self, options):

@property
def free(self):
if self._mountpoint:
# If self._mountpoint is defined, it means this tmpfs mount
if self.systeMountpoint:
# If self.systeMountpoint is defined, it means this tmpfs mount
# has been mounted and there is a path we can use as a handle to
# look-up the free space on the filesystem.
# When running with changeroot, such as during installation,
# self._mountpoint is set to the full changeroot path once mounted,
# so even with changeroot, statvfs should still work fine.
st = os.statvfs(self._mountpoint)
# self.systeMountpoint is set to the full changeroot path once
# mounted so even with changeroot, statvfs should still work fine.
st = os.statvfs(self.systeMountpoint)
free_space = Size(st.f_bavail*st.f_frsize)
else:
# Free might be called even if the tmpfs mount has not been
Expand Down Expand Up @@ -1659,7 +1655,7 @@ def resizeArgs(self):
# if any mount options are defined, append them
if self._options:
remount_options = "%s,%s" % (remount_options, self._options)
return ['-o', remount_options, self._type, self._mountpoint]
return ['-o', remount_options, self._type, self.systeMountpoint]

def doResize(self):
# we need to override doResize, because the
Expand Down

0 comments on commit 79b5011

Please sign in to comment.