免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3420 | 回复: 4
打印 上一主题 下一主题

initramfs unpack 到内存那里去了? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-23 16:38 |只看该作者 |倒序浏览
各位兄弟,
在看 initramfs unpack 过程 ,有点疑惑,
  1. static int __init populate_rootfs(void)
  2. {
  3.         char *err = unpack_to_rootfs(__initramfs_start,
  4.                          __initramfs_end - __initramfs_start, 0);
  5.         if (err)
  6.                 panic(err);
  7.         if (initrd_start) {
  8. #ifdef CONFIG_BLK_DEV_RAM
  9.                 int fd;
  10.                 printk(KERN_INFO "checking if image is initramfs...");   
  11.                 err = unpack_to_rootfs((char *)initrd_start,
  12.                         initrd_end - initrd_start, 1);                              /* 1 => check only */
  13.                 if (!err) {
  14.                         printk(" it is\n");
  15.                         unpack_to_rootfs((char *)initrd_start,
  16.                                 initrd_end - initrd_start, 0);                       /* 释放到那里??? */
  17.                         free_initrd();
  18.                         return 0;
  19.                 }
复制代码
跟了下
unpack_to_rootfs((char *)initrd_start,  initrd_end - initrd_start, 0);
看起来 其中gzip 的buf 就是 initrd_start ,那么unpack 后的initramfs 应该也在 initrd_start
但这样理解的话 接下来的free_initrd();  又释放了这部分内存

如果后面有内存分配 initramfs unpack 后的页不是没了?

难道是unpack 到别的地方去了?
懂的兄弟帮忙 分析下

论坛徽章:
0
2 [报告]
发表于 2011-03-23 17:00 |只看该作者
/* inbuf   - input buffer
*len     - len of pre-read data in inbuf
*fill    - function to fill inbuf when empty
*flush   - function to write out outbuf
*outbuf  - output buffer
*posp    - if non-null, input position (number of bytes read) will be
*          returned here
*
*If len != 0, inbuf should contain all the necessary input data, and fill
*should be NULL
*If len = 0, inbuf can be NULL, in which case the decompressor will allocate
*the input buffer.  If inbuf != NULL it must be at least XXX_IOBUF_SIZE bytes.
*fill will be called (repeatedly...) to read data, at most XXX_IOBUF_SIZE
*bytes should be read per call.  Replace XXX with the appropriate decompressor
*name, i.e. LZMA_IOBUF_SIZE.
*
*If flush = NULL, outbuf must be large enough to buffer all the expected
*output.  If flush != NULL, the output buffer will be allocated by the
*decompressor (outbuf = NULL), and the flush function will be called to
*flush the output buffer at the appropriate time (decompressor and stream
*dependent).
*/

论坛徽章:
0
3 [报告]
发表于 2011-03-23 18:43 |只看该作者
兄弟,谢谢你的回答,我是2.6.29 我没找到你贴的这段注释
能否讲具体点,谢了

论坛徽章:
0
4 [报告]
发表于 2011-03-23 19:02 |只看该作者
不过我根据你的提示,我又看了下代码:
gzip => flush_window (initramfs.c) =>  flush_buffer => write_buffer =>actions[state]() =>
static __initdata int (*actions[])(void) = {
        [Start]                = do_start,
        [Collect]        = do_collect,
        [GotHeader]        = do_header,
        [SkipIt]        = do_skip,
        [GotName]        = do_name,
        [CopyFile]        = do_copy,
        [GotSymlink]        = do_symlink,
        [Reset]                = do_reset,
};

wfd = sys_open(collected, openflags, mode)

好象最后被弄到文件系统去了,但是还有个问题,这部分的内存地址就没办法获得了,是吗?

论坛徽章:
4
酉鸡
日期:2014-03-21 23:19:50狮子座
日期:2014-08-01 22:11:40酉鸡
日期:2015-01-10 21:31:442015年辞旧岁徽章
日期:2015-03-03 16:54:15
5 [报告]
发表于 2013-01-24 19:08 |只看该作者
哪里去了???
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP