File: gotchas.html

package info (click to toggle)
pyfuse3 3.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,776 kB
  • sloc: javascript: 16,150; python: 2,822; ansic: 363; sh: 27; makefile: 15
file content (146 lines) | stat: -rw-r--r-- 8,989 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

    <title>Common Gotchas &#8212; pyfuse3 3.4.0 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/classic.css" />
    
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <script src="_static/sphinx_highlight.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="next" title="Example File Systems" href="example.html" />
    <link rel="prev" title="Utility Functions" href="util.html" /> 
  </head><body>
    <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="py-modindex.html" title="Python Module Index"
             >modules</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">pyfuse3 3.4.0 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Common Gotchas</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="common-gotchas">
<h1>Common Gotchas<a class="headerlink" href="#common-gotchas" title="Permalink to this heading">¶</a></h1>
<p>This chapter lists some common gotchas that should be avoided.</p>
<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 heading">¶</a></h2>
<p>If your file system is mounted at <code class="file docutils literal notranslate"><span class="pre">mnt</span></code>, the following code
should complete without errors:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;mnt/file_one&#39;</span><span class="p">,</span> <span class="s1">&#39;w+&#39;</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">&#39;foo&#39;</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">&#39;mnt/file_one&#39;</span><span class="p">,</span> <span class="s1">&#39;a&#39;</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">&#39;mnt/file_one&#39;</span><span class="p">)</span>
        <span class="k">assert</span> <span class="s1">&#39;file_one&#39;</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">&#39;mnt&#39;</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">&#39;bar&#39;</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">&#39;foobar&#39;</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#pyfuse3.Operations.unlink" title="pyfuse3.Operations.unlink"><code class="xref py py-obj docutils literal notranslate"><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#pyfuse3.Operations.forget" title="pyfuse3.Operations.forget"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forget</span></code></a> handler.</p>
</section>
</section>


            <div class="clearer"></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="asyncio.html">asyncio Support</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="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>

  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="util.html"
                          title="previous chapter">Utility Functions</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="example.html"
                          title="next chapter">Example File Systems</a></p>
  </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</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="py-modindex.html" title="Python Module Index"
             >modules</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">pyfuse3 3.4.0 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Common Gotchas</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2010-2024, Nikolaus Rath.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.3.0.
    </div>
  </body>
</html>