⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 049_fs_namei_c.html

📁 重读linux 2.4.2o所写的笔记
💻 HTML
📖 第 1 页 / 共 5 页
字号:
          <font color=#3d85c6 id=hz53 size=-0><font id=wy7b size=2>&nbsp;&nbsp;&nbsp;<font color=#ff00ff id=pzwe>&nbsp;</font><font color=#ff00ff id=iv99 style=BACKGROUND-COLOR:#ffffff>&nbsp;&nbsp;/*
          remove trailing slashes? */</font><br id=tn3c>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!c)<br id=hpu9>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto
          <font color=#38761d id=k4t3><b id=q0ka>last_component</b></font>;<br id=ip2w>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (*++name == '/');<br id=jefb>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (!*name)<br id=r-xs>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto
          <font color=#38761d id=ich0><b id=h0es>last_with_slashes</b></font>;</font></font>
        </p>
        <p align=justify dir=ltr id=titc style="FONT-FAMILY:Courier New; MARGIN-LEFT:40px">
          <font color=#3d85c6 id=nphf size=-0><font id=q0f4 size=2>&nbsp;&nbsp;&nbsp;&nbsp;
          <font color=#ff00ff id=gve1>/*开始处理当前name:
          this的各种情况*/</font><br id=odr4>
          </font></font>
        </p>
        <div id=iz38 style=MARGIN-LEFT:40px>
          <font color=#3d85c6 id=urr6 size=-0><font id=xgjd size=2>&nbsp; &nbsp;
          &nbsp;<span id=b3wk style="FONT-FAMILY:Courier New"> &nbsp;
          /*</span></font></font><font color=#3d85c6 id=jgh0><br id=gc9x style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=l5ut size=-0 style="FONT-FAMILY:Courier New"><font id=x7o1 size=2>&nbsp;
          &nbsp; &nbsp; * "." and ".." are special - ".." especially so because
          it
          has</font></font><font color=#3d85c6 id=z5lv><br id=h8km style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=g-rw size=-0 style="FONT-FAMILY:Courier New"><font id=mgx8 size=2>&nbsp;
          &nbsp; &nbsp; * to be able to know about the current root directory
          and</font></font><font color=#3d85c6 id=wauf><br id=o7gk style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=bbve size=-0 style="FONT-FAMILY:Courier New"><font id=hl3v size=2>&nbsp;
          &nbsp; &nbsp; * parent
          relationships.</font></font><font color=#3d85c6 id=blfd><br id=sru9 style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=ujfi size=-0 style="FONT-FAMILY:Courier New"><font id=vo-0 size=2>&nbsp;&nbsp;&nbsp;
          &nbsp;
          */</font></font><font color=#3d85c6 id=l9f0><br id=zrsm style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=e6nq size=-0 style="FONT-FAMILY:Courier New"><font id=qyrz size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (this.name[0] == '.') switch (this.len)
          {</font></font><font color=#3d85c6 id=vhz6><br id=fzmy style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=x_2y size=-0 style="FONT-FAMILY:Courier New"><font id=njro size=2>&nbsp;&nbsp;&nbsp;
          &nbsp; &nbsp;&nbsp;
          default:</font></font><font color=#3d85c6 id=z3t4><br id=pkuu style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=b0ti size=-0 style="FONT-FAMILY:Courier New"><font id=emu- size=2>&nbsp;&nbsp;&nbsp;
          &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
          break;</font></font><font color=#3d85c6 id=vnpr><br id=pnuq style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=cu:: size=-0 style="FONT-FAMILY:Courier New"><font id=sp:x size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          case
          2:&nbsp;</font></font><font color=#3d85c6 id=rymm><br id=nnd: style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=eqfd size=-0 style="FONT-FAMILY:Courier New"><font id=zp1t size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp; if (this.name[1] !=
          '.')</font></font><font color=#3d85c6 id=oc51><br id=lf_m style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=fbz: size=-0 style="FONT-FAMILY:Courier New"><font id=c678 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp; &nbsp;&nbsp;&nbsp;
          break;</font></font><font color=#3d85c6 id=f2ek><br id=e9.2 style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=nbwq size=-0 style="FONT-FAMILY:Courier New"><font id=dx_9 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          follow_dotdot(nd); <font color=#ff00ff id=j85b>/*
          向上走一级,因为上一级可能是本文将系统的root,需要通过mnt向上稍后讨论*/</font></font></font><font color=#3d85c6 id=l-8t><br id=z38x style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=gw_n size=-0 style="FONT-FAMILY:Courier New"><font id=q6w_ size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          inode =
          nd-&gt;dentry-&gt;d_inode;</font></font><font color=#3d85c6 id=gcqj><br id=v5m2 style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=ixhj size=-0 style="FONT-FAMILY:Courier New"><font id=n0ph size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          /* fallthrough
          */</font></font><font color=#3d85c6 id=g.4j><br id=vlsm style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=p9mz size=-0 style="FONT-FAMILY:Courier New"><font id=dk4m size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          case
          1:</font></font><font color=#3d85c6 id=fgup><br id=ct8z style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=cc67 size=-0 style="FONT-FAMILY:Courier New"><font id=eb8c size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          continue;</font></font><font color=#3d85c6 id=s.:v><br id=wk7q style="FONT-FAMILY:Courier New">
          </font><font color=#3d85c6 id=mcah size=-0 style="FONT-FAMILY:Courier New"><font id=nwuc size=2>&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;}</font></font><font color=#3d85c6 id=b6x0><br id=nx_0>
          </font>
        </div>
        <p align=justify dir=ltr id=d3cu style="FONT-FAMILY:Courier New">
          <font color=#3d85c6 id=sgva size=-0><font id=z9yp size=2>&nbsp; &nbsp;
          &nbsp; &nbsp;&nbsp; /*<font color=#ff00ff id=oc76>
          看看是不是文件系统需要自己的hash</font><br id=nd28>
          &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; * See if the low-level
          filesystem might want to use its own hash..<br id=x9j1>
          &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; */<br id=rd2e>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
          (nd-&gt;dentry-&gt;d_op &amp;&amp; nd-&gt;dentry-&gt;d_op-&gt;d_hash)
          {<br id=e-t9>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err =
          nd-&gt;dentry-&gt;d_op-&gt;d_hash(nd-&gt;dentry, &amp;this);<br id=c1v0>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          if (err &lt; 0)<br id=t5_j>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br id=wa85>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br id=zit.>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=#ff00ff id=c995>
          /* 开始在nd-&gt;dentry下查找this,现在cache中找,没有的话从文件系统读入 */</font><br id=jwyy>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dentry =
          cached_lookup(nd-&gt;dentry, &amp;this, LOOKUP_CONTINUE);
          /*见dcache分析*/<br id=m0sr>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!dentry) {<br id=hv6c>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dentry
          = real_lookup(nd-&gt;dentry, &amp;this,
          LOOKUP_CONTINUE);<font color=#ff00ff id=k:v4>/* 例如ext2_lookup
          */</font><br id=okfq>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err
          = PTR_ERR(dentry);<br id=q10y>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (IS_ERR(dentry))<br id=gei7>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br id=ltkp>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</font></font>
        </p>
        <p align=justify dir=ltr id=bec5 style="FONT-FAMILY:Courier New">
          <font color=#3d85c6 id=ceiw size=-0><font id=qisk size=2>&nbsp;<font color=#ff00ff id=z775>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          /*在当前的dentry(nd-&gt;dentry)下找到了this.name*/<br id=ku8l>
          </font></font></font>
        </p>
        <p align=justify dir=ltr id=zvc9 style="FONT-FAMILY:Courier New">
          <font color=#3d85c6 id=t1nk size=-0><font id=uayc size=2><font color=#ff00ff id=micb>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          /* Check mountpoints..
          ,看看找到的是不是安装点,是的话要下潜到被安装文件系统的根目录*/</font><br id=gtko>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while
          (d_mountpoint(dentry) &amp;&amp; __follow_down(&amp;nd-&gt;mnt,
          &amp;dentry))<br id=n:sr>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;</font></font>
        </p>
        <p align=justify dir=ltr id=vuyq style="FONT-FAMILY:Courier New">
          <font color=#3d85c6 id=oq.g size=-0><font id=yra2 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err
          = -ENOENT;<br id=u0t9>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inode =
          dentry-&gt;d_inode;<br id=etoa>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (!inode)<br id=cfjr>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto
          out_dput;<font color=#ff00ff id=civk>/*无inode,已经删除*/</font><br id=pgcv>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err =
          -ENOTDIR;<br id=acjm>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (!inode-&gt;i_op)
          <font color=#ff0000 id=f_px>/*不应该有这种inode吧?*/</font><br id=yggd>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto
          out_dput;</font></font>
        </p>
        <p align=justify dir=ltr id=o.-g style="FONT-FAMILY:Courier New">
          <font color=#0b5394 id=mq5h size=-0><font id=b-zz size=2><font color=#3d85c6 id=zrcp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (inode-&gt;i_op-&gt;follow_link)
          <span id=v-ta style=BACKGROUND-COLOR:#ffffff>{<font color=#ff00ff id=z75q>
          /*此节点是否为link*/</font></span><br id=nede>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err
          =
          <font color=#38761d id=np11><b id=khg1>do_follow_link</b></font>(dentry,
          nd);
          <font color=#0000ff id=f0ck>/*inode存储了一个路径,会递归到path_walk*/</font><br id=z43b>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dput(dentry);<br id=o:ns>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (err)<br id=u8_->
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto
          return_err;<br id=l2j2>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          err = -ENOENT;<br id=r53s>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inode
          = nd-&gt;dentry-&gt;d_inode;<br id=xtrz>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (!inode)<br id=n:tx>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; break;<br id=o3cx>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;err
          = -ENOTDIR;<br id=qvqm>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if
          (!inode-&gt;i_op)<br id=aywj>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br id=sj9c>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -