Changeset 78d50bd in mainline for uspace/lib/label
- Timestamp:
- 2015-06-29T18:47:07Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3faa03d
- Parents:
- 28ed0d9
- Location:
- uspace/lib/label
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/label/include/label.h
r28ed0d9 r78d50bd 49 49 extern label_part_t *label_part_first(label_t *); 50 50 extern label_part_t *label_part_next(label_part_t *); 51 extern void label_part_get_info(label_part_t *, label_part_info_t *); 51 52 52 53 extern int label_part_create(label_t *, label_part_spec_t *, -
uspace/lib/label/include/types/liblabel.h
r28ed0d9 r78d50bd 39 39 #include <adt/list.h> 40 40 #include <types/label.h> 41 #include <sys/types.h> 41 42 #include <vol.h> 42 43 … … 48 49 } label_info_t; 49 50 51 typedef struct { 52 /** Address of first block */ 53 aoff64_t block0; 54 /** Number of blocks */ 55 aoff64_t nblocks; 56 } label_part_info_t; 57 50 58 /** Partition */ 51 59 typedef struct { 52 60 /** Containing label */ 53 61 struct label *label; 54 /** Link to fdisk_dev_t.parts */ 55 link_t ldev; 56 /** Capacity */ 57 // fdisk_cap_t capacity; 58 /** File system type */ 59 // fdisk_fstype_t fstype; 62 /** Link to label_t.parts */ 63 link_t llabel; 60 64 } label_part_t; 61 65 62 66 /** Specification of new partition */ 63 67 typedef struct { 64 /** Desired capacity */65 // fdisk_cap_t capacity;66 /** File system type */67 // fdisk_fstype_t fstype;68 68 } label_part_spec_t; 69 69 70 70 /** Label instance */ 71 71 typedef struct label { 72 /** Partitions */ 73 list_t parts; /* of label_part_t */ 72 74 } label_t; 73 75 -
uspace/lib/label/src/label.c
r28ed0d9 r78d50bd 34 34 */ 35 35 36 #include <adt/list.h> 36 37 #include <errno.h> 37 38 #include <label.h> … … 47 48 return ENOMEM; 48 49 50 list_initialize(&label->parts); 49 51 *rlabel = label; 50 52 return EOK; … … 59 61 return ENOMEM; 60 62 63 list_initialize(&label->parts); 61 64 *rlabel = label; 62 65 return EOK; … … 65 68 void label_close(label_t *label) 66 69 { 70 if (label == NULL) 71 return; 72 67 73 free(label); 68 74 } … … 83 89 label_part_t *label_part_first(label_t *label) 84 90 { 85 return NULL; 91 link_t *link; 92 93 link = list_first(&label->parts); 94 if (link == NULL) 95 return NULL; 96 97 return list_get_instance(link, label_part_t, llabel); 86 98 } 87 99 88 label_part_t *label_part_next(label_part_t * oart)100 label_part_t *label_part_next(label_part_t *part) 89 101 { 90 return NULL; 102 link_t *link; 103 104 link = list_next(&part->llabel, &part->label->parts); 105 if (link == NULL) 106 return NULL; 107 108 return list_get_instance(link, label_part_t, llabel); 91 109 } 92 110 111 void label_part_get_info(label_part_t *part, label_part_info_t *pinfo) 112 { 113 pinfo->block0 = 0; 114 pinfo->nblocks = 0; 115 } 93 116 94 117 int label_part_create(label_t *label, label_part_spec_t *pspec, 95 118 label_part_t **rpart) 96 119 { 97 return ENOTSUP; 120 label_part_t *part; 121 122 part = calloc(1, sizeof(label_part_t)); 123 if (part == NULL) 124 return ENOMEM; 125 126 part->label = label; 127 list_append(&part->llabel, &label->parts); 128 *rpart = part; 129 return EOK; 98 130 } 99 131 100 132 int label_part_destroy(label_part_t *part) 101 133 { 134 list_remove(&part->llabel); 135 free(part); 102 136 return EOK; 103 137 }
Note:
See TracChangeset
for help on using the changeset viewer.