[PATCH 4 of 5 V2] util: add a getfstype method

Yuya Nishihara yuya at tcha.org
Sun Mar 12 11:08:55 EDT 2017


On Sat, 11 Mar 2017 23:28:25 -0800, Jun Wu wrote:
> Excerpts from Yuya Nishihara's message of 2017-03-11 16:48:54 -0800:
> > On Thu, 2 Mar 2017 22:13:30 -0800, Jun Wu wrote:
> > > # HG changeset patch
> > > # User Jun Wu <quark at fb.com>
> > > # Date 1488521308 28800
> > > #      Thu Mar 02 22:08:28 2017 -0800
> > > # Node ID d79c818940ff7e29c76ff5e985b920885aa4e7c1
> > > # Parent  1cf153ec3faaef92c9ad3515372a6d8591195d6e
> > > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > > #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r d79c818940ff
> > > util: add a getfstype method
> > 
> > Can you update debugfsinfo to include this information?
> > 
> > > +if pycompat.sysplatform.startswith('linux'):
> > > +    # for Linux, reading /etc/mtab (symlink to /proc/self/mounts) is a sane way
> > > +    # to get the current filesystem mount information
> > > +    def _getfstypetable():
> > > +        result = {}
> > > +        try:
> > > +            with open('/etc/mtab', 'r') as f:
> > > +                for line in f.read().splitlines():
> > > +                    name, path, fs, ops, freq, passno = line.split(' ', 5)
> > > +                    result[path] = fs
> > > +        except OSError:
> > 
> > For reminder, it should be IOError.
> > 
> > Shouldn't we take care of mtab corruption as well? IIRC, it was a plain file
> > on old Linux.
> > 
> > > +# cache _getfstypetable() to avoid repetitive expensive queries, it assumes
> > > +# mount table does not change during the lifetime of the process, which is
> > > +# reasonable for short-lived process
> > > +_fstypetable = None
> > 
> > This can be problem on chg or hgweb. Short-lived cache in vfs would help.
> 
> The problem is, "util.copyfile" is not in vfs.

That shouldn't matter as the transaction knows vfs objects. copyfile() can be
proxied through vfs.


More information about the Mercurial-devel mailing list