[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH] When discovering dirtiness of filesystems, mount the /mnt/sysimage read only Resolves: rhbz#601862



I was considering merging this to mount code, but I decided to abstract the options=r?,remount from the high level logic. I would have to add remount= argument to the mount call as we pass the remount option to isys in this form.

This code also behaves more like unmount call (checking for mounted and existing filesystem first). On the other hand there is a significant part common with the mount call too, especially the SElinux handling.

--
Martin Sivák
msivak redhat com
Red Hat Czech
Anaconda team / Brno, CZ

----- Original Message -----
> > diff --git a/storage/formats/fs.py b/storage/formats/fs.py
> > index 646194c..77a459c 100644
> > --- a/storage/formats/fs.py
> > +++ b/storage/formats/fs.py
> > @@ -632,6 +632,44 @@ class FS(DeviceFormat):
> >
> >          self._mountpoint = chrootedMountpoint
> >
> > + 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, "")
> > +
> > +
> >      def unmount(self):
> >          """ Unmount this filesystem. """
> >          if not self.exists:
> 
> The idea looks sound, but it'd be nice if the remount() method could
> either be a wrapper around mount() or removed and mount() called
> directly. Perhaps this could be as simple as adding ",remount" to the
> options= parameter? Or is there something else hiding in mount that
> prevents this?
> 
> - Chris
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list redhat com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]