Changeset 469739f in mainline for uspace/app/hdisk/func_mbr.c
- Timestamp:
- 2013-05-30T13:58:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c9f61150, cb328ab
- Parents:
- 9bda5d90 (diff), a2aa81cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/func_mbr.c
r9bda5d90 r469739f 41 41 #include "input.h" 42 42 43 static int set_mbr_partition(tinput_t * in, mbr_part_t * p); 44 45 46 int add_mbr_part(tinput_t * in, union table_data * data) 43 static int set_mbr_partition(tinput_t *in, mbr_part_t *p); 44 45 int add_mbr_part(tinput_t *in, union label_data *data) 47 46 { 48 47 int rc; 49 48 50 mbr_part_t * 49 mbr_part_t *part = mbr_alloc_partition(); 51 50 52 51 set_mbr_partition(in, part); 53 52 54 rc = mbr_add_partition(data->mbr .parts, part);53 rc = mbr_add_partition(data->mbr, part); 55 54 if (rc != EOK) { 56 55 printf("Error adding partition.\n"); 57 56 } 58 57 59 60 return rc; 61 } 62 63 int delete_mbr_part(tinput_t * in, union table_data * data) 58 return EOK; 59 } 60 61 int delete_mbr_part(tinput_t *in, union label_data *data) 64 62 { 65 63 int rc; … … 72 70 return errno; 73 71 74 rc = mbr_remove_partition(data->mbr .parts, idx);72 rc = mbr_remove_partition(data->mbr, idx); 75 73 if(rc != EOK) { 76 74 printf("Error: something.\n"); … … 80 78 } 81 79 82 int new_mbr_table(tinput_t * in, union table_data * data) 83 { 84 data->mbr.mbr = mbr_alloc_mbr(); 85 data->mbr.parts = mbr_alloc_partitions(); 86 return EOK; 80 int destroy_mbr_label(union label_data *data) 81 { 82 mbr_free_label(data->mbr); 83 return EOK; 84 } 85 86 int new_mbr_label(union label_data *data) 87 { 88 data->mbr = mbr_alloc_label(); 89 if (data->mbr == NULL) 90 return ENOMEM; 91 else 92 return EOK; 87 93 } 88 94 89 95 /** Print current partition scheme */ 90 int print_mbr_parts(union table_data *data)96 int print_mbr_parts(union label_data *data) 91 97 { 92 98 int num = 0; … … 96 102 printf("\t\t%10s %10s %10s %10s %7s\n", "Bootable:", "Start:", "End:", "Length:", "Type:"); 97 103 98 mbr_part_t * 99 mbr_part_foreach(data->mbr .parts, it) {104 mbr_part_t *it; 105 mbr_part_foreach(data->mbr->parts, it) { 100 106 if (it->type == PT_UNUSED) 101 107 continue; … … 117 123 } 118 124 119 int write_mbr_parts(service_id_t dev_handle, union table_data * data) 120 { 121 int rc = mbr_write_partitions(data->mbr.parts, data->mbr.mbr, dev_handle); 125 int read_mbr_parts(service_id_t dev_handle, union label_data *data) 126 { 127 int rc; 128 printf("mbr\n"); 129 rc = mbr_read_mbr(data->mbr, dev_handle); 130 if (rc != EOK) 131 return rc; 132 printf("ismbr\n"); 133 if (!mbr_is_mbr(data->mbr)) 134 return EINVAL; 135 printf("parts\n"); 136 rc = mbr_read_partitions(data->mbr); 137 if (rc != EOK) 138 return rc; 139 printf("end\n"); 140 return EOK; 141 } 142 143 int write_mbr_parts(service_id_t dev_handle, union label_data *data) 144 { 145 int rc = mbr_write_partitions(data->mbr, dev_handle); 122 146 if (rc != EOK) { 123 147 printf("Error occured during writing: ERR: %d: %s\n", rc, str_error(rc)); … … 127 151 } 128 152 129 int extra_mbr_funcs(tinput_t * in, service_id_t dev_handle, union table_data *data)153 int extra_mbr_funcs(tinput_t *in, service_id_t dev_handle, union label_data *data) 130 154 { 131 155 printf("Not implemented.\n"); … … 133 157 } 134 158 135 static int set_mbr_partition(tinput_t * in, mbr_part_t *p)159 static int set_mbr_partition(tinput_t *in, mbr_part_t *p) 136 160 { 137 161 int c; … … 159 183 return errno; 160 184 161 ///TODO: there can only be one boo tablepartition; let's do it just like fdisk185 ///TODO: there can only be one boolabel partition; let's do it just like fdisk 162 186 printf("Bootable? (y/n): "); 163 187 c = getchar();
Note:
See TracChangeset
for help on using the changeset viewer.