<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=GB2312" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
块如何组织是文件系统的数据结构决定的, 不一定支持这种操作(否则就破坏数据结构). 即使实现了, 也得修改文件系统驱动,
但别的程序根本不会用这个接口, 不具有通用性.<br>
<br>
Zu 写道:
<blockquote
 cite="mid:ae5455470806130021p6756e008u65480505bd8176c3@mail.gmail.com"
 type="cite">
  <meta http-equiv="Context-Type" content="text/html; charset=GB2312">
没错<br>
  <br>
  <div>2008/6/13 石康志 &lt;<a moz-do-not-send="true"
 href="mailto:shikangzhi@gmail.com">shikangzhi@gmail.com</a>&gt;:<br>
  <blockquote>虽然块是顺序存储的,但是如果一个文件由3个块组成,并不要求这三个块要放到一起,所以如果文件A有4k,B有8k+
1byte,在这里并不需要移动任何一方,需要做的只是更改文件A的地址信息加上地址B,并删掉B的文件地址信息(和rm做的一样,rm也只删掉地址信
息,所以可以找回数据)。
    <div>
    <div><br>
    <br>
    <div>2008/6/13 Zu &lt;<a moz-do-not-send="true"
 href="mailto:zzh@rashost.com">zzh@rashost.com</a>&gt;:<br>
    <blockquote>Ok,考虑当一个块没有被占满的情况呢?看看我前面举的例子?
      <div>
      <div><br>
      <br>
      <div>2008/6/13 石康志 &lt;<a moz-do-not-send="true"
 href="mailto:shikangzhi@gmail.com">shikangzhi@gmail.com</a>&gt;:<br>
      <blockquote>的确在块内是排序的,不过整个文件根本不需要移动,所有从哪儿来的问题呢?
        <div>
        <div><br>
        <br>
        <div>2008/6/13 Zu &lt;<a moz-do-not-send="true"
 href="mailto:zzh@rashost.com">zzh@rashost.com</a>&gt;:<br>
        <blockquote>没有人说是按顺序排列的。按不按顺序排列是不一定的,说不定哪天谁开发出一个完全按顺序排列的,不考虑效率的文
件系统也不是没有可能。<br>
          <br>
ext3在块内是按顺序的。建议先了解一下ext3的分块的基本概念再讨论。<br>
          <br>
          <div>
          <div>2008/6/13 石康志 &lt;<a moz-do-not-send="true"
 href="mailto:shikangzhi@gmail.com">shikangzhi@gmail.com</a>&gt;:<br>
          </div>
          <blockquote>完全不对!在文件系统中,文件并不是顺序排列的,也许一个1G的文件有100MB在'0,
0'-&gt;100mb地址,后面可以在'10000000,
10000000'-&gt;900mb,并不要求这一个G的东西全部按顺序放到一起,控制这一切的,仅仅是一个文件的地址信息(你可以把它想象成指
针),所以可以通过改变地址信息控制文件。
            <div>
            <div><br>
            <br>
            <div>
            <div>2008/6/13 Zu &lt;<a moz-do-not-send="true"
 href="mailto:zzh@rashost.com">zzh@rashost.com</a>&gt;:<br>
            </div>
            <blockquote>可能是我没有把问题说清楚,我的原话是:
              <div>
              <div>
              <div><br>
              <br>
              <b><i>有2个文件,file1和file2,大小都是4G,如果想合并file1和file2,可以 cat<br>
file2&gt;&gt;file1来实现,这样要花几分钟时间。有没有一种办法,能把file2 "剪切"<br>
到file1中?也就是说把file2在文件系统中占用的数据块分配给file1?使用的是ext3文件系统。</i></b><br>
              <br>
              </div>
mv
的作用是把一个文件改一个名字,该文件除了文件名以外其他信息都不变,所以mv的速度特别快。mv不能把一个文件的内容移动到另一个文件的末尾去。我觉着
下面shell909090说的比较有道理:<br>
              <br>
              <b><i>有点困难,因为根据我的理解,任何文件在磁盘中都是"块</i></b>
              <div><b><i>"的集合存储的。如果头<br>
一个文件正好放满N块还好说,如果正好差一点,那么后面的数据按</i></b><b><i>照规则必须先<br>
填充前面的块。这样会造成后一个文件全面的内容位移</i></b><b><i>,其读写数据量没有比直接<br>
附加低多少。</i></b></div>
              <br>
举例:<br>
file1的文件长度是1个字节,在块大小是4k的ext3文件系统下,这个文件要占用4k的空间,也就是一个块的空间。<br>
file2的文件长度是8K+1个字节,在块大小是4k的ext3文件系统下,这个文件要占用8K+4k的空间,也就是3个块的空间。<br>
如果要把file2剪切到file1的末尾,要做到比"cat file2&gt;&gt;file1"更快,不修改内核中的文件系统能做到吗?<br>
              <br>
2008/6/13 马利 &lt;<a moz-do-not-send="true"
 href="mailto:richard.ma.19850509@gmail.com">richard.ma.19850509@gmail.com</a>&gt;:
              <div><br>
&gt; 看看mv的源代码就差不多了吧,适当复用,没看出来和内核有什么关系<br>
&gt;<br>
&gt; --<br>
&gt; 马利<br>
&gt; <a moz-do-not-send="true" href="http://richard.ma">richard.ma</a><br>
              </div>
              <div>
              <div>&gt; --<br>
&gt; ubuntu-zh mailing list<br>
&gt; <a moz-do-not-send="true" href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
&gt; <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
&gt;<br>
&gt;<br>
              <br>
              <br>
              <br>
-- <br>
瑞豪开源VPS - 基于Linux/Xen - 最低58元/月 - 免费试用<br>
              <a moz-do-not-send="true" href="http://www.RasHost.com">http://www.RasHost.com</a><br>
              </div>
              </div>
              <br>
--<br>
ubuntu-zh mailing list<br>
              <a moz-do-not-send="true"
 href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
              <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
              <br>
              </div>
              </div>
            </blockquote>
            </div>
            <br>
            <br>
--<br>
ubuntu-zh mailing list<br>
            <a moz-do-not-send="true"
 href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
            <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
            <br>
            </div>
            </div>
          </blockquote>
          </div>
          <div>
          <div><br>
          <br>
          <br>
-- <br>
瑞豪开源VPS - 基于Linux/Xen - 最低58元/月 - 免费试用<br>
          <a moz-do-not-send="true" href="http://www.RasHost.com">http://www.RasHost.com</a>
          </div>
          </div>
          <br>
--<br>
ubuntu-zh mailing list<br>
          <a moz-do-not-send="true"
 href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
          <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
          <br>
        </blockquote>
        </div>
        <br>
        </div>
        </div>
        <br>
--<br>
ubuntu-zh mailing list<br>
        <a moz-do-not-send="true"
 href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
        <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
        <br>
      </blockquote>
      </div>
      <br>
      <br>
      <br>
-- <br>
瑞豪开源VPS - 基于Linux/Xen - 最低58元/月 - 免费试用<br>
      <a moz-do-not-send="true" href="http://www.RasHost.com">http://www.RasHost.com</a>
      </div>
      </div>
      <br>
--<br>
ubuntu-zh mailing list<br>
      <a moz-do-not-send="true" href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
      <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
      <br>
    </blockquote>
    </div>
    <br>
    </div>
    </div>
    <br>
--<br>
ubuntu-zh mailing list<br>
    <a moz-do-not-send="true" href="mailto:ubuntu-zh@lists.ubuntu.com">ubuntu-zh@lists.ubuntu.com</a><br>
    <a moz-do-not-send="true"
 href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh">https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh</a><br>
    <br>
  </blockquote>
  </div>
  <br>
  <br>
  <br>
-- <br>
瑞豪开源VPS - 基于Linux/Xen - 最低58元/月 - 免费试用<br>
  <a moz-do-not-send="true" href="http://www.RasHost.com">http://www.RasHost.com</a>
</blockquote>
</body>
</html>