Beispiel #1
0
    def remount(self, *args, **kwargs):
        """ Remount the filesystem with new options """
        options = kwargs.get("options", "")
        log.info("remounting %s on %s", self.device, self._mountpoint)

        if not self.exists:
            raise FSError("filesystem has not been created")

        if not self._mountpoint:
            # not mounted
            return

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

        # passed in options override default options
        if not options or not isinstance(options, str):
            options = self.options

        try:
            rc = isys.mount(self.device,
                            self._mountpoint,
                            fstype=self.mountType,
                            options=options,
                            remount=True,
                            bindMount=isinstance(self, BindFS))
        except Exception as e:
            raise FSError("mount failed: %s" % e)

        if rc:
            raise FSError("mount failed: %s" % rc)

        if flags.selinux:
            ret = isys.resetFileContext(self._mountpoint, "")
            log.info("set SELinux context for newly mounted filesystem "
                     "root at %s to %s" % (self._mountpoint, ret))
            isys.setFileContext("%s/lost+found" % self._mountpoint,
                                lost_and_found_context, "")
Beispiel #2
0
    def remount(self, *args, **kwargs):
        """ Remount the filesystem with new options """
        options = kwargs.get("options", "")
        log.info("remounting %s on %s", self.device, self._mountpoint)

        if not self.exists:
            raise FSError("filesystem has not been created")

        if not self._mountpoint:
            # not mounted
            return

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

        # passed in options override default options
        if not options or not isinstance(options, str):
            options = self.options

        try: 
            rc = isys.mount(self.device, self._mountpoint, 
                            fstype=self.mountType,
                            options=options, remount=True,
                            bindMount=isinstance(self, BindFS))
        except Exception as e:
            raise FSError("mount failed: %s" % e)

        if rc:
            raise FSError("mount failed: %s" % rc)

        if flags.selinux:
            ret = isys.resetFileContext(self._mountpoint, "")
            log.info("set SELinux context for newly mounted filesystem "
                     "root at %s to %s" %(self._mountpoint, ret))
            isys.setFileContext("%s/lost+found" % self._mountpoint,
                                lost_and_found_context, "")
Beispiel #3
0
    def mount(self, *args, **kwargs):
        """ Mount this filesystem.

            Arguments:

                None

            Keyword Arguments:

                options -- mount options (overrides all other option strings)
                chroot -- prefix to apply to mountpoint
                mountpoint -- mountpoint (overrides self.mountpoint)
        """
        options = kwargs.get("options", "")
        chroot = kwargs.get("chroot", "/")
        mountpoint = kwargs.get("mountpoint")

        if not self.exists:
            raise FSError("filesystem has not been created")

        if not mountpoint:
            mountpoint = self.mountpoint

        if not mountpoint:
            raise FSError("no mountpoint given")

        if self.status:
            return

        if not isinstance(self, NoDevFS) and not os.path.exists(self.device):
            raise FSError("device %s does not exist" % self.device)

        # XXX os.path.join is FUBAR:
        #
        #         os.path.join("/mnt/foo", "/") -> "/"
        #
        #mountpoint = os.path.join(chroot, mountpoint)
        chrootedMountpoint = os.path.normpath("%s/%s" % (chroot, mountpoint))
        iutil.mkdirChain(chrootedMountpoint)
        if flags.selinux:
            ret = isys.resetFileContext(mountpoint, chroot)
            log.info("set SELinux context for mountpoint %s to %s" \
                     % (mountpoint, ret))

        # passed in options override default options
        if not options or not isinstance(options, str):
            options = self.options

        try:
            rc = isys.mount(self.device,
                            chrootedMountpoint,
                            fstype=self.mountType,
                            options=options,
                            bindMount=isinstance(self, BindFS))
        except Exception as e:
            raise FSError("mount failed: %s" % e)

        if rc:
            raise FSError("mount failed: %s" % rc)

        if flags.selinux and "ro" not in options.split(","):
            ret = isys.resetFileContext(mountpoint, chroot)
            log.info("set SELinux context for newly mounted filesystem "
                     "root at %s to %s" % (mountpoint, ret))
            isys.setFileContext("%s/lost+found" % mountpoint,
                                lost_and_found_context, chroot)

        self._mountpoint = chrootedMountpoint
Beispiel #4
0
    def mount(self, *args, **kwargs):
        """ Mount this filesystem.

            Arguments:

                None

            Keyword Arguments:

                options -- mount options (overrides all other option strings)
                chroot -- prefix to apply to mountpoint
                mountpoint -- mountpoint (overrides self.mountpoint)
        """
        options = kwargs.get("options", "")
        chroot = kwargs.get("chroot", "/")
        mountpoint = kwargs.get("mountpoint")

        if not self.exists:
            raise FSError("filesystem has not been created")

        if not mountpoint:
            mountpoint = self.mountpoint

        if not mountpoint:
            raise FSError("no mountpoint given")

        if self.status:
            return

        if not isinstance(self, NoDevFS) and not os.path.exists(self.device):
            raise FSError("device %s does not exist" % self.device)

        # XXX os.path.join is FUBAR:
        #
        #         os.path.join("/mnt/foo", "/") -> "/"
        #
        #mountpoint = os.path.join(chroot, mountpoint)
        chrootedMountpoint = os.path.normpath("%s/%s" % (chroot, mountpoint))
        iutil.mkdirChain(chrootedMountpoint)
        if flags.selinux:
            ret = isys.resetFileContext(mountpoint, chroot)
            log.info("set SELinux context for mountpoint %s to %s" \
                     % (mountpoint, ret))

        # passed in options override default options
        if not options or not isinstance(options, str):
            options = self.options

        try: 
            rc = isys.mount(self.device, chrootedMountpoint, 
                            fstype=self.mountType,
                            options=options,
                            bindMount=isinstance(self, BindFS))
        except Exception as e:
            raise FSError("mount failed: %s" % e)

        if rc:
            raise FSError("mount failed: %s" % rc)

        if flags.selinux:
            ret = isys.resetFileContext(mountpoint, chroot)
            log.info("set SELinux context for newly mounted filesystem "
                     "root at %s to %s" %(mountpoint, ret))
            isys.setFileContext("%s/lost+found" % mountpoint,
                                lost_and_found_context, chroot)

        self._mountpoint = chrootedMountpoint