- 論壇徽章:
- 4
|
20可用積分
本帖最后由 chishanmingshen 于 2013-01-25 09:30 編輯
from 3.6.10
populate_rootfs()->unpack_to_rootfs() 做新的initramfs或者舊的initrd的文件拷貝操作。
1. 可是我不明白的是拷貝到哪里去?不用指定文件名字么?比如initrd方式(非cpio)時(shí),內(nèi)核會(huì)建好文件/initrd.image,然后寫入。
2. 此時(shí)是實(shí)際根文件系統(tǒng)是哪里加載的?因?yàn)楹罄m(xù)才會(huì)加載實(shí)際根文件系統(tǒng).
3. header_buf symlink_buf name_buf : 這幾個(gè)全局變量的作用是?
4. 請(qǐng)指點(diǎn)這個(gè)函數(shù)的具體機(jī)制.
謝謝!
- static char * __init unpack_to_rootfs(char *buf, unsigned len)
- {
- int written, res;
- decompress_fn decompress;
- const char *compress_name;
- static __initdata char msg_buf[64];
- header_buf = kmalloc(110, GFP_KERNEL);
- symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
- name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);
- if (!header_buf || !symlink_buf || !name_buf)
- panic("can't allocate buffers");
- state = Start;
- this_header = 0;
- message = NULL;
- while (!message && len) {
- loff_t saved_offset = this_header;
- if (*buf == '0' && !(this_header & 3)) {
- state = Start;
- written = write_buffer(buf, len);<---(*actions[])將數(shù)據(jù)寫到哪里去了?求詳解。。
- buf += written;
- len -= written;
- continue;
- }
- if (!*buf) {
- buf++;
- len--;
- this_header++;
- continue;
- }
- this_header = 0;
- decompress = decompress_method(buf, len, &compress_name);
- if (decompress) {
- res = decompress(buf, len, NULL, flush_buffer, NULL,
- &my_inptr, error);
- if (res)
- error("decompressor failed");
- } else if (compress_name) {
- if (!message) {
- snprintf(msg_buf, sizeof msg_buf,
- "compression method %s not configured",
- compress_name);
- message = msg_buf;
- }
- } else
- error("junk in compressed archive");
- if (state != Reset)
- error("junk in compressed archive");
- this_header = saved_offset + my_inptr;
- buf += my_inptr;
- len -= my_inptr;
- }
- dir_utime();
- kfree(name_buf);
- kfree(symlink_buf);
- kfree(header_buf);
- return message;
- }
復(fù)制代碼 |
最佳答案
查看完整內(nèi)容
回復(fù) 3# chishanmingshen 就是這個(gè)"unpack_to_rootfs就是將initramfs或者initrd的內(nèi)容釋放到"/"那里", 我搞不明白其中的奧秘...任何文件系統(tǒng)的訪問都要以來于建立在RAM中的文件系統(tǒng)相關(guān)的數(shù)據(jù)結(jié)構(gòu),這些最基本的數(shù)據(jù)結(jié)構(gòu)就是位于RAM中的"/",當(dāng)需要訪問外部的存儲(chǔ)器而不是在RAM中的該如何辦呢?在RAM中的“/”留一個(gè)掛在點(diǎn)去mount,來搭建一條訪問的路徑。unpack_to_rootfs做的就是在RAM的“/”建立ramdisk中事先建立好的一些 ...
|