UML之分區掛載之三

概述

上節說的“PARTNAME=super”和"PARTNAME=vbmeta"在哪裏賦值。

2. 調用流程

register_disk(struct device *parent, struct gendisk *disk)
    ------->int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)

2. 代碼

2.1 efi_partition

692 int efi_partition(struct parsed_partitions *state)                              
693 {                                                                               
694         gpt_header *gpt = NULL;                                                                                                                                                                         
695         gpt_entry *ptes = NULL;                                                 
696         u32 i;                                                                  
697         unsigned ssz = bdev_logical_block_size(state->bdev) / 512;              
698                                                                                 
699         if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {             
700                 kfree(gpt);                                                     
701                 kfree(ptes);                                                    
702                 return 0;                                                       
703         }                                                                       
704                                                                                 
705         pr_debug("GUID Partition Table is valid!  Yea!\n");                     
706                                                                                 
707         for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) {
708                 struct partition_meta_info *info;                               
709                 unsigned label_count = 0;                                       
710                 unsigned label_max;                                             
711                 u64 start = le64_to_cpu(ptes[i].starting_lba);                  
712                 u64 size = le64_to_cpu(ptes[i].ending_lba) -                    
713                            le64_to_cpu(ptes[i].starting_lba) + 1ULL;            
714                                                                                 
715                 if (!is_pte_valid(&ptes[i], last_lba(state->bdev)))             
716                         continue;                                               
717                                                                                 
718                 put_partition(state, i+1, start * ssz, size * ssz);             
719                                                                                 
720                 /* If this is a RAID volume, tell md */                         
721                 if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID))
722                         state->parts[i + 1].flags = ADDPART_FLAG_RAID;          
723                                                                                 
724                 info = &state->parts[i + 1].info;                               
725                 efi_guid_to_str(&ptes[i].unique_partition_guid, info->uuid);    
726                                                                                 
727                 /* Naively convert UTF16-LE to 7 bits. */                       
728                 label_max = min(ARRAY_SIZE(info->volname) - 1,                  
729                                 ARRAY_SIZE(ptes[i].partition_name));            
730                 info->volname[label_max] = 0;                                   
731                 while (label_count < label_max) {                               
732                         u8 c = ptes[i].partition_name[label_count] & 0xff;      
733                         if (c && !isprint(c))                                   
734                                 c = '!';                                        
735                         info->volname[label_count] = c;                         
736                         label_count++;                                          
737                 }                                                               
738                 state->parts[i + 1].has_info = true;
739                                                                                 
740                 printk(KERN_ERR "tom F=%s L=%d volname=%s",__FUNCTION__,__LINE__,info->volname);
741         }                                                                       
742         printk(KERN_ERR "tom F=%s L=%d ",__FUNCTION__,__LINE__);                
743         kfree(ptes);                                                            
744         kfree(gpt);                                                             
745         strlcat(state->pp_buf, "\n", PAGE_SIZE);                                
746         return 1;                                                               
747 }  

說明:在735行,可以看出info->volnam的賦值。

調試信息:

[    1.204013] tom F=efi_partition L=740 volname=vbmeta
[    1.204424] tom F=efi_partition L=740 volname=super

分區信息:
在block/partition-generic.c中,read_dev_sector函數:

658 unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)                                                                                                                        
659 {                                                                               
660         struct address_space *mapping = bdev->bd_inode->i_mapping;              
661         struct page *page;                                                      
662                                                                                 
663         page = read_mapping_page(mapping, (pgoff_t)(n >> (PAGE_SHIFT-9)), NULL);
664         if (!IS_ERR(page)) {                                                    
665                 if (PageError(page))                                            
666                         goto fail;                                              
667                 p->v = page;                                                    
668                 return (unsigned char *)page_address(page) +  ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << 9);
669 fail:                                                                           
670                 put_page(page);                                                 
671         }                                                                       
672         p->v = NULL;                                                            
673         return NULL;                                                            
674 }  

GPT信息是從bdev->bd_inode->i_mapping中撈數據的。

2.3 問題:

下一步繼續探討賦值問題。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章