Changeset 8c95dff in mainline for uspace/app/hdisk/func_mbr.c
- Timestamp:
- 2013-11-30T17:49:09Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4a47e52
- Parents:
- 802898f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/hdisk/func_mbr.c
r802898f r8c95dff 41 41 #include "input.h" 42 42 43 static int set_mbr_partition(tinput_t * in, mbr_part_t *p, unsigned int alignment);43 static int set_mbr_partition(tinput_t *, mbr_part_t *, label_t *); 44 44 45 45 int construct_mbr_label(label_t *this) … … 66 66 mbr_part_t *part = mbr_alloc_partition(); 67 67 68 set_mbr_partition(in, part, this->alignment); 68 rc = set_mbr_partition(in, part, this); 69 if (rc != EOK) 70 return rc; 69 71 70 72 rc = mbr_add_partition(this->data.mbr, part); … … 89 91 rc = mbr_remove_partition(this->data.mbr, idx); 90 92 if (rc != EOK) { 91 printf("Error: something.\n");93 printf("Error: partition does not exist?\n"); 92 94 } 93 95 … … 106 108 if (this->data.mbr == NULL) 107 109 return ENOMEM; 108 else 109 return EOK; 110 111 mbr_set_device(this->data.mbr, this->device); 112 return EOK; 110 113 } 111 114 … … 115 118 int num = 0; 116 119 117 printf("Current partition scheme (MBR) :\n");120 printf("Current partition scheme (MBR)(number of blocks: %" PRIu64 "):\n", this->nblocks); 118 121 printf("\t\t%10s %10s %10s %10s %7s\n", "Bootable:", "Start:", "End:", "Length:", "Type:"); 119 122 … … 121 124 122 125 for (it = mbr_get_first_partition(this->data.mbr); it != NULL; 123 it = mbr_get_next_partition(this->data.mbr, it) , ++num) {126 it = mbr_get_next_partition(this->data.mbr, it)) { 124 127 if (it->type == PT_UNUSED) 125 128 continue; … … 133 136 printf("\t%10u %10u %10u %7u\n", it->start_addr, it->start_addr + it->length, it->length, it->type); 134 137 138 num++; 135 139 } 136 140 … … 140 144 } 141 145 142 int read_mbr_parts(label_t *this , service_id_t dev_handle)146 int read_mbr_parts(label_t *this) 143 147 { 144 148 int rc; 145 rc = mbr_read_mbr(this->data.mbr, dev_handle);149 rc = mbr_read_mbr(this->data.mbr, this->device); 146 150 if (rc != EOK) 147 151 return rc; … … 157 161 } 158 162 159 int write_mbr_parts(label_t *this , service_id_t dev_handle)160 { 161 int rc = mbr_write_partitions(this->data.mbr, dev_handle);163 int write_mbr_parts(label_t *this) 164 { 165 int rc = mbr_write_partitions(this->data.mbr, this->device); 162 166 if (rc != EOK) { 163 167 printf("Error occured during writing: ERR: %d: %s\n", rc, str_error(rc)); … … 167 171 } 168 172 169 int extra_mbr_funcs(label_t *this, tinput_t *in , service_id_t dev_handle)173 int extra_mbr_funcs(label_t *this, tinput_t *in) 170 174 { 171 175 printf("Not implemented.\n"); … … 173 177 } 174 178 175 static int set_mbr_partition(tinput_t *in, mbr_part_t *p, unsigned int alignment)179 static int set_mbr_partition(tinput_t *in, mbr_part_t *p, label_t * this) 176 180 { 177 181 int c; … … 214 218 uint32_t sa, ea; 215 219 216 printf("Set starting address (number): ");220 printf("Set starting address: "); 217 221 sa = get_input_uint32(in); 218 222 if (sa == 0 && errno != EOK) 219 223 return errno; 220 224 221 if ( alignment != 0 && alignment != 1) {222 sa = mbr_get_next_aligned(sa, alignment);225 if (this->alignment != 0 && this->alignment != 1 && sa % this->alignment != 0) { 226 sa = mbr_get_next_aligned(sa, this->alignment); 223 227 printf("Starting address was aligned to %u.\n", sa); 224 228 } 225 226 printf("Set end addres ( number): ");229 230 printf("Set end addres (max: %" PRIu64 "): ", this->nblocks); 227 231 ea = get_input_uint32(in); 228 232 if (ea == 0 && errno != EOK) … … 233 237 return EINVAL; 234 238 } 235 239 236 240 p->type = type; 237 241 p->start_addr = sa;
Note:
See TracChangeset
for help on using the changeset viewer.