Changeset b7fd2a0 in mainline for uspace/lib/label
- Timestamp:
- 2018-01-13T03:10:29Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- Location:
- uspace/lib/label
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/label/include/label/empty.h
r36f0738 rb7fd2a0 41 41 #include <types/liblabel.h> 42 42 43 extern int label_bd_is_empty(label_bd_t *, bool *);44 extern int label_bd_empty(label_bd_t *);45 extern int label_part_empty(label_part_t *);43 extern errno_t label_bd_is_empty(label_bd_t *, bool *); 44 extern errno_t label_bd_empty(label_bd_t *); 45 extern errno_t label_part_empty(label_part_t *); 46 46 47 47 #endif -
uspace/lib/label/include/label/label.h
r36f0738 rb7fd2a0 40 40 #include <types/liblabel.h> 41 41 42 extern int label_open(label_bd_t *, label_t **);43 extern int label_create(label_bd_t *, label_type_t, label_t **);42 extern errno_t label_open(label_bd_t *, label_t **); 43 extern errno_t label_create(label_bd_t *, label_type_t, label_t **); 44 44 extern void label_close(label_t *); 45 extern int label_destroy(label_t *);46 extern int label_get_info(label_t *, label_info_t *);45 extern errno_t label_destroy(label_t *); 46 extern errno_t label_get_info(label_t *, label_info_t *); 47 47 48 48 extern label_part_t *label_part_first(label_t *); … … 50 50 extern void label_part_get_info(label_part_t *, label_part_info_t *); 51 51 52 extern int label_part_create(label_t *, label_part_spec_t *,52 extern errno_t label_part_create(label_t *, label_part_spec_t *, 53 53 label_part_t **); 54 extern int label_part_destroy(label_part_t *);54 extern errno_t label_part_destroy(label_part_t *); 55 55 extern void label_pspec_init(label_part_spec_t *); 56 extern int label_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *);56 extern errno_t label_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *); 57 57 58 58 #endif -
uspace/lib/label/include/types/liblabel.h
r36f0738 rb7fd2a0 54 54 /** Ops for individual label type */ 55 55 typedef struct { 56 int (*open)(label_bd_t *, label_t **);57 int (*create)(label_bd_t *, label_t **);56 errno_t (*open)(label_bd_t *, label_t **); 57 errno_t (*create)(label_bd_t *, label_t **); 58 58 void (*close)(label_t *); 59 int (*destroy)(label_t *);60 int (*get_info)(label_t *, label_info_t *);59 errno_t (*destroy)(label_t *); 60 errno_t (*get_info)(label_t *, label_info_t *); 61 61 label_part_t *(*part_first)(label_t *); 62 62 label_part_t *(*part_next)(label_part_t *); 63 63 void (*part_get_info)(label_part_t *, label_part_info_t *); 64 int (*part_create)(label_t *, label_part_spec_t *, label_part_t **);65 int (*part_destroy)(label_part_t *);66 int (*suggest_ptype)(label_t *, label_pcnt_t, label_ptype_t *);64 errno_t (*part_create)(label_t *, label_part_spec_t *, label_part_t **); 65 errno_t (*part_destroy)(label_part_t *); 66 errno_t (*suggest_ptype)(label_t *, label_pcnt_t, label_ptype_t *); 67 67 } label_ops_t; 68 68 … … 144 144 struct label_bd_ops { 145 145 /** Get block size */ 146 int (*get_bsize)(void *, size_t *);146 errno_t (*get_bsize)(void *, size_t *); 147 147 /** Get number of blocks */ 148 int (*get_nblocks)(void *, aoff64_t *);148 errno_t (*get_nblocks)(void *, aoff64_t *); 149 149 /** Read blocks */ 150 int (*read)(void *, aoff64_t, size_t, void *);150 errno_t (*read)(void *, aoff64_t, size_t, void *); 151 151 /** Write blocks */ 152 int (*write)(void *, aoff64_t, size_t, const void *);152 errno_t (*write)(void *, aoff64_t, size_t, const void *); 153 153 }; 154 154 -
uspace/lib/label/src/dummy.c
r36f0738 rb7fd2a0 40 40 #include "dummy.h" 41 41 42 static int dummy_open(label_bd_t *, label_t **);43 static int dummy_create(label_bd_t *, label_t **);42 static errno_t dummy_open(label_bd_t *, label_t **); 43 static errno_t dummy_create(label_bd_t *, label_t **); 44 44 static void dummy_close(label_t *); 45 static int dummy_destroy(label_t *);46 static int dummy_get_info(label_t *, label_info_t *);45 static errno_t dummy_destroy(label_t *); 46 static errno_t dummy_get_info(label_t *, label_info_t *); 47 47 static label_part_t *dummy_part_first(label_t *); 48 48 static label_part_t *dummy_part_next(label_part_t *); 49 49 static void dummy_part_get_info(label_part_t *, label_part_info_t *); 50 static int dummy_part_create(label_t *, label_part_spec_t *, label_part_t **);51 static int dummy_part_destroy(label_part_t *);52 static int dummy_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *);50 static errno_t dummy_part_create(label_t *, label_part_spec_t *, label_part_t **); 51 static errno_t dummy_part_destroy(label_part_t *); 52 static errno_t dummy_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *); 53 53 54 54 label_ops_t dummy_label_ops = { … … 66 66 }; 67 67 68 static int dummy_open(label_bd_t *bd, label_t **rlabel)68 static errno_t dummy_open(label_bd_t *bd, label_t **rlabel) 69 69 { 70 70 label_t *label = NULL; … … 73 73 aoff64_t nblocks; 74 74 uint64_t ba_min, ba_max; 75 int rc;75 errno_t rc; 76 76 77 77 rc = bd->ops->get_bsize(bd->arg, &bsize); … … 128 128 } 129 129 130 static int dummy_create(label_bd_t *bd, label_t **rlabel)130 static errno_t dummy_create(label_bd_t *bd, label_t **rlabel) 131 131 { 132 132 return ENOTSUP; … … 148 148 } 149 149 150 static int dummy_destroy(label_t *label)151 { 152 return ENOTSUP; 153 } 154 155 static int dummy_get_info(label_t *label, label_info_t *linfo)150 static errno_t dummy_destroy(label_t *label) 151 { 152 return ENOTSUP; 153 } 154 155 static errno_t dummy_get_info(label_t *label, label_info_t *linfo) 156 156 { 157 157 memset(linfo, 0, sizeof(label_info_t)); … … 193 193 } 194 194 195 static int dummy_part_create(label_t *label, label_part_spec_t *pspec,195 static errno_t dummy_part_create(label_t *label, label_part_spec_t *pspec, 196 196 label_part_t **rpart) 197 197 { … … 199 199 } 200 200 201 static int dummy_part_destroy(label_part_t *part)202 { 203 return ENOTSUP; 204 } 205 206 static int dummy_suggest_ptype(label_t *label, label_pcnt_t pcnt,201 static errno_t dummy_part_destroy(label_part_t *part) 202 { 203 return ENOTSUP; 204 } 205 206 static errno_t dummy_suggest_ptype(label_t *label, label_pcnt_t pcnt, 207 207 label_ptype_t *ptype) 208 208 { -
uspace/lib/label/src/empty.c
r36f0738 rb7fd2a0 97 97 } 98 98 99 int label_bd_is_empty(label_bd_t *bd, bool *rempty)100 { 101 int rc;99 errno_t label_bd_is_empty(label_bd_t *bd, bool *rempty) 100 { 101 errno_t rc; 102 102 void *buf = NULL; 103 103 aoff64_t nblocks; … … 174 174 } 175 175 176 int label_bd_empty(label_bd_t *bd)177 { 178 int rc;176 errno_t label_bd_empty(label_bd_t *bd) 177 { 178 errno_t rc; 179 179 void *buf = NULL; 180 180 aoff64_t nblocks; … … 236 236 } 237 237 238 int label_part_empty(label_part_t *part)239 { 240 int rc;238 errno_t label_part_empty(label_part_t *part) 239 { 240 errno_t rc; 241 241 void *buf = NULL; 242 242 aoff64_t block0; -
uspace/lib/label/src/gpt.c
r36f0738 rb7fd2a0 46 46 #include "gpt.h" 47 47 48 static int gpt_open(label_bd_t *, label_t **);49 static int gpt_create(label_bd_t *, label_t **);48 static errno_t gpt_open(label_bd_t *, label_t **); 49 static errno_t gpt_create(label_bd_t *, label_t **); 50 50 static void gpt_close(label_t *); 51 static int gpt_destroy(label_t *);52 static int gpt_get_info(label_t *, label_info_t *);51 static errno_t gpt_destroy(label_t *); 52 static errno_t gpt_get_info(label_t *, label_info_t *); 53 53 static label_part_t *gpt_part_first(label_t *); 54 54 static label_part_t *gpt_part_next(label_part_t *); 55 55 static void gpt_part_get_info(label_part_t *, label_part_info_t *); 56 static int gpt_part_create(label_t *, label_part_spec_t *, label_part_t **);57 static int gpt_part_destroy(label_part_t *);58 static int gpt_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *);59 60 static int gpt_check_free_idx(label_t *, int);61 static int gpt_check_free_range(label_t *, uint64_t, uint64_t);56 static errno_t gpt_part_create(label_t *, label_part_spec_t *, label_part_t **); 57 static errno_t gpt_part_destroy(label_part_t *); 58 static errno_t gpt_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *); 59 60 static errno_t gpt_check_free_idx(label_t *, int); 61 static errno_t gpt_check_free_range(label_t *, uint64_t, uint64_t); 62 62 63 63 static void gpt_unused_pte(gpt_entry_t *); 64 static int gpt_part_to_pte(label_part_t *, gpt_entry_t *);65 static int gpt_pte_to_part(label_t *, gpt_entry_t *, int);66 static int gpt_pte_update(label_t *, gpt_entry_t *, int);67 68 static int gpt_update_pt_crc(label_t *, uint32_t);64 static errno_t gpt_part_to_pte(label_part_t *, gpt_entry_t *); 65 static errno_t gpt_pte_to_part(label_t *, gpt_entry_t *, int); 66 static errno_t gpt_pte_update(label_t *, gpt_entry_t *, int); 67 68 static errno_t gpt_update_pt_crc(label_t *, uint32_t); 69 69 static void gpt_hdr_compute_crc(gpt_header_t *, size_t); 70 static int gpt_hdr_get_crc(gpt_header_t *, size_t, uint32_t *);71 72 static int gpt_pmbr_create(label_bd_t *, size_t, uint64_t);73 static int gpt_pmbr_destroy(label_bd_t *, size_t);70 static errno_t gpt_hdr_get_crc(gpt_header_t *, size_t, uint32_t *); 71 72 static errno_t gpt_pmbr_create(label_bd_t *, size_t, uint64_t); 73 static errno_t gpt_pmbr_destroy(label_bd_t *, size_t); 74 74 75 75 const uint8_t efi_signature[8] = { … … 92 92 }; 93 93 94 static int gpt_open(label_bd_t *bd, label_t **rlabel)94 static errno_t gpt_open(label_bd_t *bd, label_t **rlabel) 95 95 { 96 96 label_t *label = NULL; … … 111 111 uint32_t hdr_crc; 112 112 int i, j; 113 int rc;113 errno_t rc; 114 114 115 115 gpt_hdr[0] = NULL; … … 345 345 } 346 346 347 static int gpt_create(label_bd_t *bd, label_t **rlabel)347 static errno_t gpt_create(label_bd_t *bd, label_t **rlabel) 348 348 { 349 349 label_t *label = NULL; … … 362 362 uuid_t disk_uuid; 363 363 int i, j; 364 int rc;364 errno_t rc; 365 365 366 366 rc = bd->ops->get_bsize(bd->arg, &bsize); … … 510 510 } 511 511 512 static int gpt_destroy(label_t *label)512 static errno_t gpt_destroy(label_t *label) 513 513 { 514 514 gpt_header_t *gpt_hdr = NULL; … … 516 516 label_part_t *part; 517 517 int i; 518 int rc;518 errno_t rc; 519 519 520 520 part = gpt_part_first(label); … … 580 580 } 581 581 582 static int gpt_get_info(label_t *label, label_info_t *linfo)582 static errno_t gpt_get_info(label_t *label, label_info_t *linfo) 583 583 { 584 584 memset(linfo, 0, sizeof(label_info_t)); … … 624 624 } 625 625 626 static int gpt_part_create(label_t *label, label_part_spec_t *pspec,626 static errno_t gpt_part_create(label_t *label, label_part_spec_t *pspec, 627 627 label_part_t **rpart) 628 628 { 629 629 label_part_t *part; 630 630 gpt_entry_t pte; 631 int rc;631 errno_t rc; 632 632 633 633 part = calloc(1, sizeof(label_part_t)); … … 696 696 } 697 697 698 static int gpt_part_destroy(label_part_t *part)698 static errno_t gpt_part_destroy(label_part_t *part) 699 699 { 700 700 gpt_entry_t pte; 701 int rc;701 errno_t rc; 702 702 703 703 /* Prepare unused partition table entry */ … … 715 715 } 716 716 717 static int gpt_suggest_ptype(label_t *label, label_pcnt_t pcnt,717 static errno_t gpt_suggest_ptype(label_t *label, label_pcnt_t pcnt, 718 718 label_ptype_t *ptype) 719 719 { 720 720 const char *ptid; 721 int rc;721 errno_t rc; 722 722 723 723 ptid = NULL; … … 748 748 749 749 /** Verify that the specified index is valid and free. */ 750 static int gpt_check_free_idx(label_t *label, int index)750 static errno_t gpt_check_free_idx(label_t *label, int index) 751 751 { 752 752 label_part_t *part; … … 771 771 } 772 772 773 static int gpt_check_free_range(label_t *label, uint64_t block0,773 static errno_t gpt_check_free_range(label_t *label, uint64_t block0, 774 774 uint64_t nblocks) 775 775 { … … 796 796 } 797 797 798 static int gpt_part_to_pte(label_part_t *part, gpt_entry_t *pte)798 static errno_t gpt_part_to_pte(label_part_t *part, gpt_entry_t *pte) 799 799 { 800 800 uint64_t eblock; … … 814 814 } 815 815 816 static int gpt_pte_to_part(label_t *label, gpt_entry_t *pte, int index)816 static errno_t gpt_pte_to_part(label_t *label, gpt_entry_t *pte, int index) 817 817 { 818 818 label_part_t *part; … … 856 856 * @a pte. 857 857 */ 858 static int gpt_pte_update(label_t *label, gpt_entry_t *pte, int index)858 static errno_t gpt_pte_update(label_t *label, gpt_entry_t *pte, int index) 859 859 { 860 860 size_t pos; … … 866 866 uint32_t crc; 867 867 int i; 868 int rc;868 errno_t rc; 869 869 870 870 /* Byte offset of partition entry */ … … 921 921 } 922 922 923 static int gpt_update_pt_crc(label_t *label, uint32_t crc)923 static errno_t gpt_update_pt_crc(label_t *label, uint32_t crc) 924 924 { 925 925 gpt_header_t *gpt_hdr; 926 int rc;926 errno_t rc; 927 927 int i; 928 928 … … 968 968 } 969 969 970 static int gpt_hdr_get_crc(gpt_header_t *hdr, size_t hdr_size, uint32_t *crc)970 static errno_t gpt_hdr_get_crc(gpt_header_t *hdr, size_t hdr_size, uint32_t *crc) 971 971 { 972 972 gpt_header_t *c; … … 985 985 986 986 /** Create GPT Protective MBR */ 987 static int gpt_pmbr_create(label_bd_t *bd, size_t bsize, uint64_t nblocks)987 static errno_t gpt_pmbr_create(label_bd_t *bd, size_t bsize, uint64_t nblocks) 988 988 { 989 989 mbr_br_block_t *pmbr = NULL; 990 990 uint64_t pmbr_nb; 991 int rc;991 errno_t rc; 992 992 993 993 pmbr = calloc(1, bsize); … … 1023 1023 1024 1024 /** Destroy GPT Protective MBR */ 1025 static int gpt_pmbr_destroy(label_bd_t *bd, size_t bsize)1025 static errno_t gpt_pmbr_destroy(label_bd_t *bd, size_t bsize) 1026 1026 { 1027 1027 mbr_br_block_t *pmbr = NULL; 1028 int rc;1028 errno_t rc; 1029 1029 1030 1030 pmbr = calloc(1, bsize); -
uspace/lib/label/src/label.c
r36f0738 rb7fd2a0 51 51 }; 52 52 53 int label_open(label_bd_t *bd, label_t **rlabel)53 errno_t label_open(label_bd_t *bd, label_t **rlabel) 54 54 { 55 55 label_ops_t **ops; 56 int rc;56 errno_t rc; 57 57 58 58 ops = &probe_list[0]; … … 67 67 } 68 68 69 int label_create(label_bd_t *bd, label_type_t ltype, label_t **rlabel)69 errno_t label_create(label_bd_t *bd, label_type_t ltype, label_t **rlabel) 70 70 { 71 71 label_ops_t *ops = NULL; … … 96 96 } 97 97 98 int label_destroy(label_t *label)98 errno_t label_destroy(label_t *label) 99 99 { 100 100 return label->ops->destroy(label); 101 101 } 102 102 103 int label_get_info(label_t *label, label_info_t *linfo)103 errno_t label_get_info(label_t *label, label_info_t *linfo) 104 104 { 105 105 return label->ops->get_info(label, linfo); … … 121 121 } 122 122 123 int label_part_create(label_t *label, label_part_spec_t *pspec,123 errno_t label_part_create(label_t *label, label_part_spec_t *pspec, 124 124 label_part_t **rpart) 125 125 { … … 127 127 } 128 128 129 int label_part_destroy(label_part_t *part)129 errno_t label_part_destroy(label_part_t *part) 130 130 { 131 131 return part->label->ops->part_destroy(part); … … 137 137 } 138 138 139 int label_suggest_ptype(label_t *label, label_pcnt_t pcnt,139 errno_t label_suggest_ptype(label_t *label, label_pcnt_t pcnt, 140 140 label_ptype_t *ptype) 141 141 { -
uspace/lib/label/src/mbr.c
r36f0738 rb7fd2a0 43 43 #include "mbr.h" 44 44 45 static int mbr_open(label_bd_t *, label_t **);46 static int mbr_open_ext(label_t *);47 static int mbr_create(label_bd_t *, label_t **);45 static errno_t mbr_open(label_bd_t *, label_t **); 46 static errno_t mbr_open_ext(label_t *); 47 static errno_t mbr_create(label_bd_t *, label_t **); 48 48 static void mbr_close(label_t *); 49 static int mbr_destroy(label_t *);50 static int mbr_get_info(label_t *, label_info_t *);49 static errno_t mbr_destroy(label_t *); 50 static errno_t mbr_get_info(label_t *, label_info_t *); 51 51 static label_part_t *mbr_part_first(label_t *); 52 52 static label_part_t *mbr_part_next(label_part_t *); 53 53 static void mbr_part_get_info(label_part_t *, label_part_info_t *); 54 static int mbr_part_create(label_t *, label_part_spec_t *, label_part_t **);55 static int mbr_part_destroy(label_part_t *);56 static int mbr_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *);57 58 static int mbr_check_free_idx(label_t *, int);59 static int mbr_check_free_pri_range(label_t *, uint64_t, uint64_t);60 static int mbr_check_free_log_range(label_t *, uint64_t, uint64_t, uint64_t);54 static errno_t mbr_part_create(label_t *, label_part_spec_t *, label_part_t **); 55 static errno_t mbr_part_destroy(label_part_t *); 56 static errno_t mbr_suggest_ptype(label_t *, label_pcnt_t, label_ptype_t *); 57 58 static errno_t mbr_check_free_idx(label_t *, int); 59 static errno_t mbr_check_free_pri_range(label_t *, uint64_t, uint64_t); 60 static errno_t mbr_check_free_log_range(label_t *, uint64_t, uint64_t, uint64_t); 61 61 62 62 static void mbr_unused_pte(mbr_pte_t *); 63 static int mbr_part_to_pte(label_part_t *, mbr_pte_t *);64 static int mbr_pte_to_part(label_t *, mbr_pte_t *, int);65 static int mbr_pte_to_log_part(label_t *, uint64_t, mbr_pte_t *);63 static errno_t mbr_part_to_pte(label_part_t *, mbr_pte_t *); 64 static errno_t mbr_pte_to_part(label_t *, mbr_pte_t *, int); 65 static errno_t mbr_pte_to_log_part(label_t *, uint64_t, mbr_pte_t *); 66 66 static void mbr_log_part_to_ptes(label_part_t *, mbr_pte_t *, mbr_pte_t *); 67 static int mbr_pte_update(label_t *, mbr_pte_t *, int);68 static int mbr_log_part_insert(label_t *, label_part_t *);69 static int mbr_ebr_create(label_t *, label_part_t *);70 static int mbr_ebr_delete(label_t *, label_part_t *);71 static int mbr_ebr_update_next(label_t *, label_part_t *);67 static errno_t mbr_pte_update(label_t *, mbr_pte_t *, int); 68 static errno_t mbr_log_part_insert(label_t *, label_part_t *); 69 static errno_t mbr_ebr_create(label_t *, label_part_t *); 70 static errno_t mbr_ebr_delete(label_t *, label_part_t *); 71 static errno_t mbr_ebr_update_next(label_t *, label_part_t *); 72 72 static void mbr_update_log_indices(label_t *); 73 73 … … 86 86 }; 87 87 88 static int mbr_open(label_bd_t *bd, label_t **rlabel)88 static errno_t mbr_open(label_bd_t *bd, label_t **rlabel) 89 89 { 90 90 label_t *label = NULL; … … 96 96 aoff64_t nblocks; 97 97 uint32_t entry; 98 int rc;98 errno_t rc; 99 99 100 100 rc = bd->ops->get_bsize(bd->arg, &bsize); … … 202 202 203 203 /** Open extended partition */ 204 static int mbr_open_ext(label_t *label)204 static errno_t mbr_open_ext(label_t *label) 205 205 { 206 206 mbr_br_block_t *ebr = NULL; … … 215 215 uint64_t pnblocks; 216 216 uint64_t ep_b0; 217 int rc;217 errno_t rc; 218 218 219 219 ebr = calloc(1, label->block_size); … … 300 300 } 301 301 302 static int mbr_create(label_bd_t *bd, label_t **rlabel)302 static errno_t mbr_create(label_bd_t *bd, label_t **rlabel) 303 303 { 304 304 label_t *label = NULL; … … 307 307 size_t bsize; 308 308 int i; 309 int rc;309 errno_t rc; 310 310 311 311 rc = bd->ops->get_bsize(bd->arg, &bsize); … … 389 389 } 390 390 391 static int mbr_destroy(label_t *label)391 static errno_t mbr_destroy(label_t *label) 392 392 { 393 393 mbr_br_block_t *mbr = NULL; 394 394 label_part_t *part; 395 int rc;395 errno_t rc; 396 396 397 397 part = mbr_part_first(label); … … 428 428 } 429 429 430 static int mbr_get_info(label_t *label, label_info_t *linfo)430 static errno_t mbr_get_info(label_t *label, label_info_t *linfo) 431 431 { 432 432 memset(linfo, 0, sizeof(label_info_t)); … … 546 546 } 547 547 548 static int mbr_part_create(label_t *label, label_part_spec_t *pspec,548 static errno_t mbr_part_create(label_t *label, label_part_spec_t *pspec, 549 549 label_part_t **rpart) 550 550 { … … 553 553 label_part_t *next; 554 554 mbr_pte_t pte; 555 int rc;555 errno_t rc; 556 556 557 557 if (pspec->ptype.fmt != lptf_num) … … 694 694 } 695 695 696 static int mbr_part_destroy(label_part_t *part)696 static errno_t mbr_part_destroy(label_part_t *part) 697 697 { 698 698 mbr_pte_t pte; … … 700 700 label_part_t *next; 701 701 uint64_t ep_b0; 702 int rc;702 errno_t rc; 703 703 704 704 if (link_used(&part->lpri)) { … … 776 776 } 777 777 778 static int mbr_suggest_ptype(label_t *label, label_pcnt_t pcnt,778 static errno_t mbr_suggest_ptype(label_t *label, label_pcnt_t pcnt, 779 779 label_ptype_t *ptype) 780 780 { … … 813 813 814 814 /** Verify that the specified index is valid and free. */ 815 static int mbr_check_free_idx(label_t *label, int index)815 static errno_t mbr_check_free_idx(label_t *label, int index) 816 816 { 817 817 label_part_t *part; … … 830 830 } 831 831 832 static int mbr_check_free_pri_range(label_t *label, uint64_t block0,832 static errno_t mbr_check_free_pri_range(label_t *label, uint64_t block0, 833 833 uint64_t nblocks) 834 834 { … … 850 850 } 851 851 852 static int mbr_check_free_log_range(label_t *label, uint64_t hdr_blocks,852 static errno_t mbr_check_free_log_range(label_t *label, uint64_t hdr_blocks, 853 853 uint64_t block0, uint64_t nblocks) 854 854 { … … 877 877 } 878 878 879 static int mbr_part_to_pte(label_part_t *part, mbr_pte_t *pte)879 static errno_t mbr_part_to_pte(label_part_t *part, mbr_pte_t *pte) 880 880 { 881 881 if ((part->block0 >> 32) != 0) … … 893 893 } 894 894 895 static int mbr_pte_to_part(label_t *label, mbr_pte_t *pte, int index)895 static errno_t mbr_pte_to_part(label_t *label, mbr_pte_t *pte, int index) 896 896 { 897 897 label_part_t *part; … … 931 931 } 932 932 933 static int mbr_pte_to_log_part(label_t *label, uint64_t ebr_b0,933 static errno_t mbr_pte_to_log_part(label_t *label, uint64_t ebr_b0, 934 934 mbr_pte_t *pte) 935 935 { … … 1009 1009 * @a pte. 1010 1010 */ 1011 static int mbr_pte_update(label_t *label, mbr_pte_t *pte, int index)1011 static errno_t mbr_pte_update(label_t *label, mbr_pte_t *pte, int index) 1012 1012 { 1013 1013 mbr_br_block_t *br; 1014 int rc;1014 errno_t rc; 1015 1015 1016 1016 br = calloc(1, label->block_size); … … 1040 1040 1041 1041 /** Insert logical partition into logical partition list. */ 1042 static int mbr_log_part_insert(label_t *label, label_part_t *part)1042 static errno_t mbr_log_part_insert(label_t *label, label_part_t *part) 1043 1043 { 1044 1044 label_part_t *cur; … … 1066 1066 * @return EOK on success or non-zero error code 1067 1067 */ 1068 static int mbr_ebr_create(label_t *label, label_part_t *part)1068 static errno_t mbr_ebr_create(label_t *label, label_part_t *part) 1069 1069 { 1070 1070 mbr_br_block_t *br; 1071 1071 uint64_t ba; 1072 int rc;1072 errno_t rc; 1073 1073 1074 1074 br = calloc(1, label->block_size); … … 1099 1099 } 1100 1100 1101 static int mbr_ebr_delete(label_t *label, label_part_t *part)1101 static errno_t mbr_ebr_delete(label_t *label, label_part_t *part) 1102 1102 { 1103 1103 mbr_br_block_t *br; 1104 1104 uint64_t ba; 1105 int rc;1105 errno_t rc; 1106 1106 1107 1107 br = calloc(1, label->block_size); … … 1125 1125 1126 1126 /** Update 'next' PTE in EBR of partition. */ 1127 static int mbr_ebr_update_next(label_t *label, label_part_t *part)1127 static errno_t mbr_ebr_update_next(label_t *label, label_part_t *part) 1128 1128 { 1129 1129 mbr_br_block_t *br; 1130 1130 uint64_t ba; 1131 1131 uint16_t sgn; 1132 int rc;1132 errno_t rc; 1133 1133 1134 1134 ba = part->block0 - part->hdr_blocks; -
uspace/lib/label/test/label.c
r36f0738 rb7fd2a0 37 37 PCUT_TEST_SUITE(label); 38 38 39 static int label_test_get_bsize(void *, size_t *);40 static int label_test_get_nblocks(void *, aoff64_t *);41 static int label_test_read(void *, aoff64_t, size_t, void *);42 static int label_test_write(void *, aoff64_t, size_t, const void *);39 static errno_t label_test_get_bsize(void *, size_t *); 40 static errno_t label_test_get_nblocks(void *, aoff64_t *); 41 static errno_t label_test_read(void *, aoff64_t, size_t, void *); 42 static errno_t label_test_write(void *, aoff64_t, size_t, const void *); 43 43 44 44 label_bd_ops_t label_test_ops = { … … 67 67 * @param rbd Place to store pointer to new pretended block device 68 68 */ 69 static int test_bd_create(size_t bsize, aoff64_t nblocks, test_bd_t **rbd)69 static errno_t test_bd_create(size_t bsize, aoff64_t nblocks, test_bd_t **rbd) 70 70 { 71 71 test_bd_t *bd; … … 99 99 100 100 /** Get block size wrapper for liblabel */ 101 static int label_test_get_bsize(void *arg, size_t *bsize)101 static errno_t label_test_get_bsize(void *arg, size_t *bsize) 102 102 { 103 103 test_bd_t *bd = (test_bd_t *)arg; … … 108 108 109 109 /** Get number of blocks wrapper for liblabel */ 110 static int label_test_get_nblocks(void *arg, aoff64_t *nblocks)110 static errno_t label_test_get_nblocks(void *arg, aoff64_t *nblocks) 111 111 { 112 112 test_bd_t *bd = (test_bd_t *)arg; … … 117 117 118 118 /** Read blocks wrapper for liblabel */ 119 static int label_test_read(void *arg, aoff64_t ba, size_t cnt, void *buf)119 static errno_t label_test_read(void *arg, aoff64_t ba, size_t cnt, void *buf) 120 120 { 121 121 test_bd_t *bd = (test_bd_t *)arg; … … 129 129 130 130 /** Write blocks wrapper for liblabel */ 131 static int label_test_write(void *arg, aoff64_t ba, size_t cnt, const void *data)131 static errno_t label_test_write(void *arg, aoff64_t ba, size_t cnt, const void *data) 132 132 { 133 133 test_bd_t *bd = (test_bd_t *)arg; … … 146 146 label_part_t *part; 147 147 test_bd_t *bd = NULL; 148 int rc;148 errno_t rc; 149 149 150 150 rc = test_bd_create(test_block_size, test_nblocks, &bd); … … 181 181 label_part_t *part; 182 182 test_bd_t *bd = NULL; 183 int rc;183 errno_t rc; 184 184 185 185 rc = test_bd_create(test_block_size, test_nblocks, &bd); … … 242 242 label_part_t *part; 243 243 test_bd_t *bd = NULL; 244 int rc;244 errno_t rc; 245 245 246 246 rc = test_bd_create(test_block_size, test_nblocks, &bd); … … 304 304 label_ptype_t ptype; 305 305 test_bd_t *bd = NULL; 306 int rc;306 errno_t rc; 307 307 308 308 rc = test_bd_create(test_block_size, test_nblocks, &bd); … … 393 393 label_part_info_t pinfo, lpinfo, epinfo; 394 394 test_bd_t *bd = NULL; 395 int rc;395 errno_t rc; 396 396 397 397 rc = test_bd_create(test_block_size, test_nblocks, &bd); … … 531 531 label_ptype_t ptype; 532 532 test_bd_t *bd = NULL; 533 int rc;533 errno_t rc; 534 534 535 535 rc = test_bd_create(test_block_size, test_nblocks, &bd);
Note:
See TracChangeset
for help on using the changeset viewer.