Current File : //proc/thread-self/root/usr/share/doc/python3-llfuse/html/gotchas.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Common Gotchas — Python-LLFUSE 1.3.6 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="author" title="About these documents" href="about.html" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="Python-LLFUSE 1.3.6 documentation" href="index.html" />
<link rel="next" title="Example File Systems" href="example.html" />
<link rel="prev" title="Utility Functions" href="util.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="example.html" title="Example File Systems"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="util.html" title="Utility Functions"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Python-LLFUSE 1.3.6 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="common-gotchas">
<h1>Common Gotchas<a class="headerlink" href="#common-gotchas" title="Permalink to this headline">¶</a></h1>
<p>This chapter lists some common gotchas that should be avoided.</p>
<div class="section" id="removing-inodes-in-unlink-handler">
<h2>Removing inodes in unlink handler<a class="headerlink" href="#removing-inodes-in-unlink-handler" title="Permalink to this headline">¶</a></h2>
<p>If your file system is mounted at <code class="file docutils literal"><span class="pre">mnt</span></code>, the following code
should complete without errors:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">'mnt/file_one'</span><span class="p">,</span> <span class="s1">'w+'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fh1</span><span class="p">:</span>
<span class="n">fh1</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">)</span>
<span class="n">fh1</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">'mnt/file_one'</span><span class="p">,</span> <span class="s1">'a'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fh2</span><span class="p">:</span>
<span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="s1">'mnt/file_one'</span><span class="p">)</span>
<span class="k">assert</span> <span class="s1">'file_one'</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="s1">'mnt'</span><span class="p">)</span>
<span class="n">fh2</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">'bar'</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">close</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">dup</span><span class="p">(</span><span class="n">fh1</span><span class="o">.</span><span class="n">fileno</span><span class="p">()))</span>
<span class="n">fh1</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="k">assert</span> <span class="n">fh1</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> <span class="o">==</span> <span class="s1">'foobar'</span>
</pre></div>
</div>
<p>If you’re getting an error, then you probably did a mistake when
implementing the <a class="reference internal" href="operations.html#llfuse.Operations.unlink" title="llfuse.Operations.unlink"><code class="xref py py-obj docutils literal"><span class="pre">unlink</span></code></a> handler and are removing the
file contents when you should be deferring removal to the
<a class="reference internal" href="operations.html#llfuse.Operations.forget" title="llfuse.Operations.forget"><code class="xref py py-obj docutils literal"><span class="pre">forget</span></code></a> handler.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper"><h3><a href="index.html">Table Of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="about.html">About</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html">General Information</a></li>
<li class="toctree-l1"><a class="reference internal" href="fuse_api.html">FUSE API Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="data.html">Data Structures</a></li>
<li class="toctree-l1"><a class="reference internal" href="lock.html">The global lock</a></li>
<li class="toctree-l1"><a class="reference internal" href="operations.html">Request Handlers</a></li>
<li class="toctree-l1"><a class="reference internal" href="util.html">Utility Functions</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Common Gotchas</a></li>
<li class="toctree-l1"><a class="reference internal" href="example.html">Example File Systems</a></li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Changelog</a></li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="util.html"
title="previous chapter">Utility Functions</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="example.html"
title="next chapter">Example File Systems</a></p>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="example.html" title="Example File Systems"
>next</a> |</li>
<li class="right" >
<a href="util.html" title="Utility Functions"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Python-LLFUSE 1.3.6 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2010-2015, Nikolaus Rath.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.9.
</div>
</body>
</html>