[1081] | 1 | /* subroutines for handling mountlist
|
---|
| 2 | $Id: libmondo-mountlist.c 1176 2007-02-16 13:16:14Z bruno $
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
[1176] | 5 |
|
---|
[1] | 6 | /**
|
---|
| 7 | * @file
|
---|
| 8 | * Functions which manipulate the mountlist.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | #include "my-stuff.h"
|
---|
| 12 | #include "mondostructures.h"
|
---|
| 13 | #include "libmondo-mountlist.h"
|
---|
| 14 | #include "libmondo-raid-EXT.h"
|
---|
| 15 | #include "libmondo-devices-EXT.h"
|
---|
| 16 | #include "libmondo-tools-EXT.h"
|
---|
| 17 | #include "libmondo-string-EXT.h"
|
---|
[507] | 18 | #include "newt-specific-EXT.h"
|
---|
[900] | 19 | #include "mr_mem.h"
|
---|
[1161] | 20 | #include "mr_msg.h"
|
---|
[1] | 21 |
|
---|
| 22 | /*@unused@*/
|
---|
[48] | 23 | //static char cvsid[] = "$Id: libmondo-mountlist.c 1176 2007-02-16 13:16:14Z bruno $";
|
---|
[1] | 24 |
|
---|
| 25 | /**
|
---|
| 26 | * @addtogroup mountlistGroup
|
---|
| 27 | * @{
|
---|
| 28 | */
|
---|
| 29 | /**
|
---|
| 30 | * Evaluate a drive within the mountlist for flaws. For example, too many
|
---|
| 31 | * primary partitions, the first logical isn't 5, duplicate partitions,
|
---|
| 32 | * ovar-allocated or under-allocated, unsupported format, silly size, or
|
---|
| 33 | * silly mountpoint. Under FreeBSD, this checks the disklabel too, for the above-mentioned
|
---|
| 34 | * errors as well as too many BSD partitions (more than 'h').
|
---|
| 35 | * @param mountlist The mountlist to check.
|
---|
| 36 | * @param drive The drive to check (e.g. @c /dev/hda).
|
---|
| 37 | * @param flaws_str Where to put the found flaws (human-readable).
|
---|
| 38 | * @return The number of flaws found (0 for success).
|
---|
| 39 | * @see evaluate_mountlist
|
---|
| 40 | */
|
---|
[48] | 41 | int evaluate_drive_within_mountlist(struct mountlist_itself *mountlist,
|
---|
| 42 | char *drive, char *flaws_str)
|
---|
[1] | 43 | #ifdef __FreeBSD__
|
---|
| 44 | {
|
---|
| 45 | // FreeBSD-specific version of evaluate_drive_within_mountlist()
|
---|
[48] | 46 | /*@ int ************************************************************* */
|
---|
| 47 | int prev_part_no = 0;
|
---|
[1] | 48 | int curr_part_no = 0;
|
---|
| 49 | int pos = 0, npos = 0;
|
---|
| 50 | int res = 0;
|
---|
| 51 | int mountpoint_copies = 0;
|
---|
| 52 | int device_copies = 0;
|
---|
| 53 | int i = 0;
|
---|
| 54 | int cur_sp_no = 0;
|
---|
| 55 | int prev_sp_no = 0;
|
---|
| 56 | int foundsome = FALSE;
|
---|
| 57 |
|
---|
[48] | 58 | /*@ buffers ******************************************************** */
|
---|
[688] | 59 | char *tmp = NULL;
|
---|
| 60 | char *tmp1 = NULL;
|
---|
| 61 | char *device = NULL;
|
---|
[783] | 62 | char *ndevice = NULL;
|
---|
[48] | 63 | // BERLIOS : useless ? char *mountpoint;
|
---|
[1] | 64 |
|
---|
[48] | 65 | /*@ long *********************************************************** */
|
---|
| 66 | long physical_drive_size = 0;
|
---|
[1] | 67 | long amount_allocated = 0;
|
---|
| 68 |
|
---|
[48] | 69 | /*@ pointers ******************************************************* */
|
---|
[688] | 70 | char *part_table_fmt = NULL;
|
---|
[1] | 71 |
|
---|
[48] | 72 | /*@ initialize ***************************************************** */
|
---|
| 73 | prev_part_no = 0;
|
---|
[1] | 74 |
|
---|
| 75 |
|
---|
[48] | 76 | physical_drive_size = get_phys_size_of_drive(drive);
|
---|
[1] | 77 |
|
---|
[48] | 78 | if (physical_drive_size < 0) {
|
---|
[1176] | 79 | mr_asprintf(&tmp, "%s %s does not exist.", flaw_str, drive);
|
---|
| 80 | mr_free(flaw_str);
|
---|
[688] | 81 | flaws_str = tmp;
|
---|
[48] | 82 | } else {
|
---|
[900] | 83 | mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
|
---|
[688] | 84 | flaws_str = NULL;
|
---|
[48] | 85 | }
|
---|
| 86 | log_it(tmp);
|
---|
[900] | 87 | mr_free(tmp);
|
---|
[1] | 88 |
|
---|
| 89 |
|
---|
[48] | 90 | /* check DD */
|
---|
| 91 | for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
|
---|
[900] | 92 | mr_asprintf(&device, "%s%c", drive, cur_sp_no);
|
---|
[48] | 93 | if (find_device_in_mountlist(mountlist, device) >= 0)
|
---|
| 94 | foundsome = TRUE;
|
---|
[900] | 95 | mr_free(device);
|
---|
[48] | 96 | }
|
---|
| 97 | if (foundsome) {
|
---|
| 98 | for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
|
---|
[900] | 99 | mr_asprintf(&device, "%s%c", drive, cur_sp_no);
|
---|
[48] | 100 | pos = find_device_in_mountlist(mountlist, device);
|
---|
| 101 | if (pos < 0) {
|
---|
| 102 | continue;
|
---|
| 103 | }
|
---|
[900] | 104 | // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
|
---|
[48] | 105 | /* is it too big? */
|
---|
| 106 | if (curr_part_no > 'h') {
|
---|
[900] | 107 | mr_asprintf(&tmp, " Can only have up to 'h' in disklabel.");
|
---|
[48] | 108 | log_it(tmp);
|
---|
[688] | 109 | if (flaws_str) {
|
---|
[900] | 110 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 111 | } else {
|
---|
[900] | 112 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 113 | }
|
---|
[900] | 114 | mr_free(flaws_str);
|
---|
[688] | 115 | flaws_str = tmp1;
|
---|
[900] | 116 | mr_free(tmp);
|
---|
[48] | 117 | res++;
|
---|
| 118 | }
|
---|
| 119 | /* does partition /dev/adXsYZ exist more than once in the mountlist? */
|
---|
| 120 | for (i = 0, mountpoint_copies = 0, device_copies = 0;
|
---|
| 121 | i < mountlist->entries; i++) {
|
---|
| 122 | if (!strcmp(device, mountlist->el[i].device)) {
|
---|
| 123 | device_copies++;
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | if (device_copies > 1) {
|
---|
[900] | 127 | mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
|
---|
[59] | 128 | device);
|
---|
[48] | 129 | if (!strstr(flaws_str, tmp)) {
|
---|
| 130 | log_it(tmp);
|
---|
[688] | 131 | if (flaws_str) {
|
---|
[900] | 132 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 133 | } else {
|
---|
[900] | 134 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 135 | }
|
---|
[900] | 136 | mr_free(flaws_str);
|
---|
[688] | 137 | flaws_str = tmp1;
|
---|
[48] | 138 | res++;
|
---|
| 139 | }
|
---|
[900] | 140 | mr_free(tmp);
|
---|
[48] | 141 | }
|
---|
| 142 | /* silly partition size? */
|
---|
| 143 | if (mountlist->el[pos].size < 8192
|
---|
| 144 | && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
|
---|
[900] | 145 | mr_asprintf(&tmp, " %s is tiny!", device);
|
---|
[48] | 146 | log_it(tmp);
|
---|
[688] | 147 | if (flaws_str) {
|
---|
[900] | 148 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 149 | } else {
|
---|
[900] | 150 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 151 | }
|
---|
[900] | 152 | mr_free(flaws_str);
|
---|
[688] | 153 | flaws_str = tmp1;
|
---|
[900] | 154 | mr_free(tmp);
|
---|
[48] | 155 | res++;
|
---|
| 156 | }
|
---|
| 157 | /* mountpoint should begin with / unless it is swap, lvm or raid */
|
---|
| 158 | if (strcmp(mountlist->el[pos].mountpoint, "swap")
|
---|
| 159 | && strcmp(mountlist->el[pos].mountpoint, "lvm")
|
---|
| 160 | && strcmp(mountlist->el[pos].mountpoint, "raid")
|
---|
| 161 | && strcmp(mountlist->el[pos].mountpoint, "image")
|
---|
| 162 | && strcmp(mountlist->el[pos].mountpoint, "none")
|
---|
| 163 | && mountlist->el[pos].mountpoint[0] != '/') {
|
---|
[900] | 164 | mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
|
---|
[48] | 165 | log_it(tmp);
|
---|
[688] | 166 | if (flaws_str) {
|
---|
[900] | 167 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 168 | } else {
|
---|
[900] | 169 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 170 | }
|
---|
[900] | 171 | mr_free(flaws_str);
|
---|
[688] | 172 | flaws_str = tmp1;
|
---|
[900] | 173 | mr_free(tmp);
|
---|
[48] | 174 | res++;
|
---|
| 175 | }
|
---|
| 176 | /* is format sensible? */
|
---|
| 177 | if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
|
---|
[900] | 178 | mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
|
---|
[48] | 179 | log_it(tmp);
|
---|
[688] | 180 | if (flaws_str) {
|
---|
[900] | 181 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 182 | } else {
|
---|
[900] | 183 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 184 | }
|
---|
[900] | 185 | mr_free(flaws_str);
|
---|
[688] | 186 | flaws_str = tmp1;
|
---|
[900] | 187 | mr_free(tmp);
|
---|
[48] | 188 | res++;
|
---|
| 189 | }
|
---|
| 190 | amount_allocated += mountlist->el[pos].size / 1024;
|
---|
| 191 | prev_sp_no = cur_sp_no;
|
---|
[1] | 192 |
|
---|
[900] | 193 | mr_free(device);
|
---|
[48] | 194 | }
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | npos = pos = 0;
|
---|
| 198 | for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
|
---|
[900] | 199 | mr_asprintf(&device, "%ss%d", drive, curr_part_no);
|
---|
[48] | 200 | pos = find_device_in_mountlist(mountlist, device);
|
---|
| 201 | npos = 0;
|
---|
| 202 | for (cur_sp_no = 'a'; cur_sp_no <= 'h'; cur_sp_no++) {
|
---|
[900] | 203 | mr_asprintf(&ndevice, "%ss%d%c", device, curr_part_no, cur_sp_no);
|
---|
[783] | 204 | if (find_device_in_mountlist(mountlist, ndevice) >= 0)
|
---|
[48] | 205 | npos++;
|
---|
[900] | 206 | mr_free(ndevice);
|
---|
[48] | 207 | }
|
---|
[900] | 208 | mr_free(device);
|
---|
[48] | 209 |
|
---|
| 210 | if (((pos >= 0) || npos) && foundsome) {
|
---|
[900] | 211 | mr_asprintf(&tmp, " %s has both DD and PC-style partitions.", drive);
|
---|
[688] | 212 | if (flaws_str) {
|
---|
[900] | 213 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 214 | } else {
|
---|
[900] | 215 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 216 | }
|
---|
[900] | 217 | mr_free(flaws_str);
|
---|
[688] | 218 | flaws_str = tmp1;
|
---|
[900] | 219 | mr_free(tmp);
|
---|
[48] | 220 | return ++res; // fatal error
|
---|
| 221 | }
|
---|
[1176] | 222 |
|
---|
| 223 | mr_asprintf(&device, "%ss%d", drive, curr_part_no);
|
---|
[900] | 224 | // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
|
---|
[48] | 225 | if (pos > 0 && !npos) {
|
---|
| 226 | /* gap in the partition list? */
|
---|
| 227 | if (curr_part_no - prev_part_no > 1) {
|
---|
| 228 | if (prev_part_no == 0) {
|
---|
[900] | 229 | mr_asprintf(&tmp, " Gap prior to %s.", device);
|
---|
[48] | 230 | log_it(tmp);
|
---|
[688] | 231 | if (flaws_str) {
|
---|
[900] | 232 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 233 | } else {
|
---|
[900] | 234 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 235 | }
|
---|
[900] | 236 | mr_free(flaws_str);
|
---|
[688] | 237 | flaws_str = tmp1;
|
---|
[900] | 238 | mr_free(tmp);
|
---|
[48] | 239 | res++;
|
---|
| 240 | } else if (curr_part_no > 5
|
---|
| 241 | || (curr_part_no <= 4 && prev_part_no > 0)) {
|
---|
[900] | 242 | mr_asprintf(&tmp, " Gap between %ss%d and %d.", drive,
|
---|
[59] | 243 | prev_part_no, curr_part_no);
|
---|
[48] | 244 | log_it(tmp);
|
---|
[688] | 245 | if (flaws_str) {
|
---|
[900] | 246 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 247 | } else {
|
---|
[900] | 248 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 249 | }
|
---|
[900] | 250 | mr_free(flaws_str);
|
---|
[688] | 251 | flaws_str = tmp1;
|
---|
[900] | 252 | mr_free(tmp);
|
---|
[48] | 253 | res++;
|
---|
| 254 | }
|
---|
| 255 | }
|
---|
| 256 | /* GPT allows more than 4 primary partitions */
|
---|
| 257 | part_table_fmt = which_partition_format(drive);
|
---|
| 258 | /* no spare primary partitions to help accommodate the logical(s)? */
|
---|
| 259 | if ((curr_part_no >= 5 && prev_part_no == 4)
|
---|
| 260 | && (strcmp(part_table_fmt, "MBR") == 0)) {
|
---|
[900] | 261 | mr_asprintf(&tmp, " Partition %ss4 is occupied.", drive);
|
---|
[48] | 262 | log_it(tmp);
|
---|
[688] | 263 | if (flaws_str) {
|
---|
[900] | 264 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 265 | } else {
|
---|
[900] | 266 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 267 | }
|
---|
[900] | 268 | mr_free(flaws_str);
|
---|
[688] | 269 | flaws_str = tmp1;
|
---|
[900] | 270 | mr_free(tmp);
|
---|
[48] | 271 | res++;
|
---|
| 272 | }
|
---|
| 273 | /* does partition /dev/adXsY exist more than once in the mountlist? */
|
---|
| 274 | for (i = 0, mountpoint_copies = 0, device_copies = 0;
|
---|
| 275 | i < mountlist->entries; i++) {
|
---|
| 276 | if (!strcmp(device, mountlist->el[i].device)) {
|
---|
| 277 | device_copies++;
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 | if (device_copies > 1) {
|
---|
[900] | 281 | mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
|
---|
[59] | 282 | device);
|
---|
[48] | 283 | if (!strstr(flaws_str, tmp)) {
|
---|
| 284 | log_it(tmp);
|
---|
[688] | 285 | if (flaws_str) {
|
---|
[900] | 286 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 287 | } else {
|
---|
[900] | 288 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 289 | }
|
---|
[900] | 290 | mr_free(flaws_str);
|
---|
[688] | 291 | flaws_str = tmp1;
|
---|
[48] | 292 | res++;
|
---|
| 293 | }
|
---|
[900] | 294 | mr_free(tmp);
|
---|
[48] | 295 | }
|
---|
| 296 | /* silly partition size? */
|
---|
| 297 | if (mountlist->el[pos].size < 8192
|
---|
| 298 | && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
|
---|
[900] | 299 | mr_asprintf(&tmp, " %s is tiny!", device);
|
---|
[48] | 300 | log_it(tmp);
|
---|
[688] | 301 | if (flaws_str) {
|
---|
[900] | 302 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 303 | } else {
|
---|
[900] | 304 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 305 | }
|
---|
[900] | 306 | mr_free(flaws_str);
|
---|
[688] | 307 | flaws_str = tmp1;
|
---|
[900] | 308 | mr_free(tmp);
|
---|
[48] | 309 | res++;
|
---|
| 310 | }
|
---|
| 311 | /* mountpoint should begin with / unless it is swap, lvm or raid */
|
---|
| 312 | if (strcmp(mountlist->el[pos].mountpoint, "swap")
|
---|
| 313 | && strcmp(mountlist->el[pos].mountpoint, "lvm")
|
---|
| 314 | && strcmp(mountlist->el[pos].mountpoint, "raid")
|
---|
| 315 | && strcmp(mountlist->el[pos].mountpoint, "image")
|
---|
| 316 | && strcmp(mountlist->el[pos].mountpoint, "none")
|
---|
| 317 | && mountlist->el[pos].mountpoint[0] != '/') {
|
---|
[900] | 318 | mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
|
---|
[48] | 319 | log_it(tmp);
|
---|
[688] | 320 | if (flaws_str) {
|
---|
[900] | 321 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 322 | } else {
|
---|
[900] | 323 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 324 | }
|
---|
[900] | 325 | mr_free(flaws_str);
|
---|
[688] | 326 | flaws_str = tmp1;
|
---|
[900] | 327 | mr_free(tmp);
|
---|
[48] | 328 | res++;
|
---|
| 329 | }
|
---|
| 330 | /* is format sensible? */
|
---|
| 331 | if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
|
---|
[900] | 332 | mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
|
---|
[48] | 333 | log_it(tmp);
|
---|
[688] | 334 | if (flaws_str) {
|
---|
[900] | 335 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 336 | } else {
|
---|
[900] | 337 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 338 | }
|
---|
[900] | 339 | mr_free(flaws_str);
|
---|
[688] | 340 | flaws_str = tmp1;
|
---|
[900] | 341 | mr_free(tmp);
|
---|
[48] | 342 | res++;
|
---|
| 343 | }
|
---|
| 344 | } else {
|
---|
| 345 | /* Check subpartitions */
|
---|
| 346 | for (cur_sp_no = 'a'; cur_sp_no < 'z'; ++cur_sp_no) {
|
---|
[1176] | 347 | mr_asprintf(&device, "%ss%d%c", drive, curr_part_no, cur_sp_no);
|
---|
[48] | 348 | pos = find_device_in_mountlist(mountlist, device);
|
---|
| 349 | if (pos < 0) {
|
---|
| 350 | continue;
|
---|
| 351 | }
|
---|
[900] | 352 | // BERLIOS : useless ? mr_asprintf(&mountpoint, mountlist->el[pos].mountpoint);
|
---|
[48] | 353 | /* is it too big? */
|
---|
| 354 | if (curr_part_no > 'h') {
|
---|
[900] | 355 | mr_asprintf(&tmp,
|
---|
[59] | 356 | " Can only have up to 'h' in disklabel.");
|
---|
[48] | 357 | log_it(tmp);
|
---|
[688] | 358 | if (flaws_str) {
|
---|
[900] | 359 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 360 | } else {
|
---|
[900] | 361 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 362 | }
|
---|
[900] | 363 | mr_free(flaws_str);
|
---|
[688] | 364 | flaws_str = tmp1;
|
---|
[900] | 365 | mr_free(tmp);
|
---|
[48] | 366 | res++;
|
---|
| 367 | }
|
---|
| 368 | /* does partition /dev/adXsYZ exist more than once in the mountlist? */
|
---|
| 369 | for (i = 0, mountpoint_copies = 0, device_copies = 0;
|
---|
| 370 | i < mountlist->entries; i++) {
|
---|
| 371 | if (!strcmp(device, mountlist->el[i].device)) {
|
---|
| 372 | device_copies++;
|
---|
| 373 | }
|
---|
| 374 | }
|
---|
| 375 | if (device_copies > 1) {
|
---|
[900] | 376 | mr_asprintf(&tmp, " %s %s's.",
|
---|
[59] | 377 | number_to_text(device_copies), device);
|
---|
[48] | 378 | if (!strstr(flaws_str, tmp)) {
|
---|
| 379 | log_it(tmp);
|
---|
[688] | 380 | if (flaws_str) {
|
---|
[900] | 381 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 382 | } else {
|
---|
[900] | 383 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 384 | }
|
---|
[900] | 385 | mr_free(flaws_str);
|
---|
[688] | 386 | flaws_str = tmp1;
|
---|
[48] | 387 | res++;
|
---|
| 388 | }
|
---|
[900] | 389 | mr_free(tmp);
|
---|
[48] | 390 | }
|
---|
| 391 | /* silly partition size? */
|
---|
| 392 | if (mountlist->el[pos].size < 8192
|
---|
| 393 | && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
|
---|
[900] | 394 | mr_asprintf(&tmp, " %s is tiny!", device);
|
---|
[48] | 395 | log_it(tmp);
|
---|
[688] | 396 | if (flaws_str) {
|
---|
[900] | 397 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 398 | } else {
|
---|
[900] | 399 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 400 | }
|
---|
[900] | 401 | mr_free(flaws_str);
|
---|
[688] | 402 | flaws_str = tmp1;
|
---|
[900] | 403 | mr_free(tmp);
|
---|
[48] | 404 | res++;
|
---|
| 405 | }
|
---|
| 406 | /* mountpoint should begin with / unless it is swap, lvm or raid */
|
---|
| 407 | if (strcmp(mountlist->el[pos].mountpoint, "swap")
|
---|
| 408 | && strcmp(mountlist->el[pos].mountpoint, "lvm")
|
---|
| 409 | && strcmp(mountlist->el[pos].mountpoint, "raid")
|
---|
| 410 | && strcmp(mountlist->el[pos].mountpoint, "image")
|
---|
| 411 | && strcmp(mountlist->el[pos].mountpoint, "none")
|
---|
| 412 | && mountlist->el[pos].mountpoint[0] != '/') {
|
---|
[900] | 413 | mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
|
---|
[48] | 414 | log_it(tmp);
|
---|
[688] | 415 | if (flaws_str) {
|
---|
[900] | 416 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 417 | } else {
|
---|
[900] | 418 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 419 | }
|
---|
[900] | 420 | mr_free(flaws_str);
|
---|
[688] | 421 | flaws_str = tmp1;
|
---|
[900] | 422 | mr_free(tmp);
|
---|
[48] | 423 | res++;
|
---|
| 424 | }
|
---|
| 425 | /* is format sensible? */
|
---|
| 426 | if (!is_this_a_valid_disk_format
|
---|
| 427 | (mountlist->el[pos].format)) {
|
---|
[900] | 428 | mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
|
---|
[48] | 429 | log_it(tmp);
|
---|
[688] | 430 | if (flaws_str) {
|
---|
[900] | 431 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 432 | } else {
|
---|
[900] | 433 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 434 | }
|
---|
[900] | 435 | mr_free(flaws_str);
|
---|
[688] | 436 | flaws_str = tmp1;
|
---|
[900] | 437 | mr_free(tmp);
|
---|
[48] | 438 | res++;
|
---|
| 439 | }
|
---|
| 440 | amount_allocated += mountlist->el[pos].size / 1024;
|
---|
| 441 | prev_sp_no = cur_sp_no;
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
[1176] | 444 | mr_free(device);
|
---|
[48] | 445 |
|
---|
| 446 | /* OK, continue with main loop */
|
---|
| 447 | amount_allocated += mountlist->el[pos].size / 1024;
|
---|
| 448 | prev_part_no = curr_part_no;
|
---|
| 449 | }
|
---|
| 450 |
|
---|
| 451 | /* Over-allocated the disk? Unallocated space on disk? */
|
---|
| 452 | if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high?
|
---|
| 453 | {
|
---|
[900] | 454 | mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
|
---|
[59] | 455 | amount_allocated - physical_drive_size, drive);
|
---|
[48] | 456 | log_it(tmp);
|
---|
[688] | 457 | if (flaws_str) {
|
---|
[900] | 458 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 459 | } else {
|
---|
[900] | 460 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 461 | }
|
---|
[900] | 462 | mr_free(flaws_str);
|
---|
[688] | 463 | flaws_str = tmp1;
|
---|
[900] | 464 | mr_free(tmp);
|
---|
[48] | 465 | res++;
|
---|
| 466 | } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */
|
---|
[900] | 467 | mr_asprintf(&tmp, " %ld MB unallocated on %s.",
|
---|
[59] | 468 | physical_drive_size - amount_allocated, drive);
|
---|
[48] | 469 | log_it(tmp);
|
---|
[688] | 470 | if (flaws_str) {
|
---|
[900] | 471 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 472 | } else {
|
---|
[900] | 473 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 474 | }
|
---|
[900] | 475 | mr_free(flaws_str);
|
---|
[688] | 476 | flaws_str = tmp1;
|
---|
[900] | 477 | mr_free(tmp);
|
---|
[1176] | 478 | /* BERLIOS: Flawed since rev 1 !! */
|
---|
| 479 | res++;
|
---|
[48] | 480 | }
|
---|
| 481 | if (res) {
|
---|
| 482 | return (FALSE);
|
---|
| 483 | } else {
|
---|
| 484 | return (TRUE);
|
---|
| 485 | }
|
---|
[1] | 486 | }
|
---|
| 487 |
|
---|
| 488 | #else
|
---|
| 489 | // Linux-specific version of evaluate_drive_within_mountlist()
|
---|
| 490 | {
|
---|
| 491 |
|
---|
[48] | 492 | /*@ int ************************************************************* */
|
---|
| 493 | int prev_part_no = 0;
|
---|
[1] | 494 | int curr_part_no = 0;
|
---|
| 495 | int pos = 0;
|
---|
| 496 | int res = 0;
|
---|
| 497 | int mountpoint_copies = 0;
|
---|
| 498 | int device_copies = 0;
|
---|
| 499 | int i = 0;
|
---|
| 500 |
|
---|
[48] | 501 | /*@ buffers ******************************************************** */
|
---|
[783] | 502 | char *tmp = NULL;
|
---|
| 503 | char *tmp1 = NULL;
|
---|
| 504 | char *device = NULL;
|
---|
[1] | 505 |
|
---|
[48] | 506 | /*@ long *********************************************************** */
|
---|
[783] | 507 | long physical_drive_size = 0L;
|
---|
| 508 | long amount_allocated = 0L;
|
---|
[1] | 509 |
|
---|
[48] | 510 | /*@ pointers ******************************************************* */
|
---|
[783] | 511 | char *part_table_fmt = NULL;
|
---|
[1] | 512 |
|
---|
[48] | 513 | /*@ initialize ***************************************************** */
|
---|
| 514 | assert_string_is_neither_NULL_nor_zerolength(drive);
|
---|
| 515 | assert(mountlist != NULL);
|
---|
[688] | 516 | flaws_str = NULL;
|
---|
[1] | 517 |
|
---|
[48] | 518 | prev_part_no = 0;
|
---|
[1] | 519 |
|
---|
[48] | 520 | physical_drive_size = get_phys_size_of_drive(drive);
|
---|
[1] | 521 |
|
---|
[48] | 522 | if (physical_drive_size < 0) {
|
---|
[900] | 523 | mr_asprintf(&tmp, " %s does not exist.", drive);
|
---|
[688] | 524 | if (flaws_str) {
|
---|
[900] | 525 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 526 | } else {
|
---|
[900] | 527 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 528 | }
|
---|
[900] | 529 | mr_free(flaws_str);
|
---|
[688] | 530 | flaws_str = tmp1;
|
---|
[48] | 531 | res++;
|
---|
[1086] | 532 | mr_msg(1, tmp);
|
---|
[900] | 533 | mr_free(tmp);
|
---|
[59] | 534 | return (FALSE);
|
---|
[48] | 535 | } else {
|
---|
[900] | 536 | mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size);
|
---|
[48] | 537 | log_it(tmp);
|
---|
[900] | 538 | mr_free(tmp);
|
---|
[48] | 539 | }
|
---|
[1] | 540 |
|
---|
[48] | 541 | for (curr_part_no = 1; curr_part_no < 99; curr_part_no++) {
|
---|
[900] | 542 | mr_asprintf(&device, "%s%d", drive, curr_part_no);
|
---|
[48] | 543 | pos = find_device_in_mountlist(mountlist, device);
|
---|
| 544 | if (pos < 0) {
|
---|
| 545 | continue;
|
---|
| 546 | }
|
---|
| 547 | if (physical_drive_size < 0) {
|
---|
[900] | 548 | mr_asprintf(&tmp, " %s refers to non-existent hardware.", device);
|
---|
[688] | 549 | if (flaws_str) {
|
---|
[900] | 550 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 551 | } else {
|
---|
[900] | 552 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 553 | }
|
---|
[900] | 554 | mr_free(flaws_str);
|
---|
[688] | 555 | flaws_str = tmp1;
|
---|
[48] | 556 | res++;
|
---|
[900] | 557 | mr_free(tmp);
|
---|
[48] | 558 | continue;
|
---|
| 559 | }
|
---|
[783] | 560 | // BERLIOS : useless ? str-cpy(mountpoint, mountlist->el[pos].mountpoint);
|
---|
[48] | 561 | /* gap in the partition list? */
|
---|
| 562 | if (curr_part_no - prev_part_no > 1) {
|
---|
| 563 | if (prev_part_no == 0) {
|
---|
[900] | 564 | mr_asprintf(&tmp, " Gap prior to %s.", device);
|
---|
[48] | 565 | log_it(tmp);
|
---|
[688] | 566 | if (flaws_str) {
|
---|
[900] | 567 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 568 | } else {
|
---|
[900] | 569 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 570 | }
|
---|
[900] | 571 | mr_free(flaws_str);
|
---|
[688] | 572 | flaws_str = tmp1;
|
---|
[900] | 573 | mr_free(tmp);
|
---|
[48] | 574 | res++;
|
---|
| 575 | } else if (curr_part_no > 5
|
---|
| 576 | || (curr_part_no <= 4 && prev_part_no > 0)) {
|
---|
[900] | 577 | mr_asprintf(&tmp, " Gap between %s%d and %d.", drive,
|
---|
[1176] | 578 | prev_part_no, curr_part_no);
|
---|
[48] | 579 | log_it(tmp);
|
---|
[688] | 580 | if (flaws_str) {
|
---|
[900] | 581 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 582 | } else {
|
---|
[900] | 583 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 584 | }
|
---|
[900] | 585 | mr_free(flaws_str);
|
---|
[688] | 586 | flaws_str = tmp1;
|
---|
[900] | 587 | mr_free(tmp);
|
---|
[48] | 588 | res++;
|
---|
| 589 | }
|
---|
| 590 | }
|
---|
| 591 | /* GPT allows more than 4 primary partitions */
|
---|
| 592 | part_table_fmt = which_partition_format(drive);
|
---|
| 593 | /* no spare primary partitions to help accommodate the logical(s)? */
|
---|
| 594 | if ((curr_part_no >= 5 && prev_part_no == 4)
|
---|
| 595 | && (strcmp(part_table_fmt, "MBR") == 0)) {
|
---|
[900] | 596 | mr_asprintf(&tmp, " Partition %s4 is occupied.", drive);
|
---|
[48] | 597 | log_it(tmp);
|
---|
[688] | 598 | if (flaws_str) {
|
---|
[900] | 599 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 600 | } else {
|
---|
[900] | 601 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 602 | }
|
---|
[900] | 603 | mr_free(flaws_str);
|
---|
[688] | 604 | flaws_str = tmp1;
|
---|
[900] | 605 | mr_free(tmp);
|
---|
[48] | 606 | res++;
|
---|
| 607 | }
|
---|
[900] | 608 | mr_free(part_table_fmt);
|
---|
[146] | 609 |
|
---|
[48] | 610 | /* does partition /dev/hdNX exist more than once in the mountlist? */
|
---|
| 611 | for (i = 0, mountpoint_copies = 0, device_copies = 0;
|
---|
| 612 | i < mountlist->entries; i++) {
|
---|
| 613 | if (!strcmp(device, mountlist->el[i].device)) {
|
---|
| 614 | device_copies++;
|
---|
| 615 | }
|
---|
| 616 | }
|
---|
| 617 | if (device_copies > 1) {
|
---|
[900] | 618 | mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies),
|
---|
[59] | 619 | device);
|
---|
[48] | 620 | if (!strstr(flaws_str, tmp)) {
|
---|
| 621 | log_it(tmp);
|
---|
[688] | 622 | if (flaws_str) {
|
---|
[900] | 623 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 624 | } else {
|
---|
[900] | 625 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 626 | }
|
---|
[900] | 627 | mr_free(flaws_str);
|
---|
[688] | 628 | flaws_str = tmp1;
|
---|
[48] | 629 | res++;
|
---|
| 630 | }
|
---|
[900] | 631 | mr_free(tmp);
|
---|
[48] | 632 | }
|
---|
| 633 | /* silly partition size? */
|
---|
| 634 | if (mountlist->el[pos].size < 8192
|
---|
| 635 | && strcmp(mountlist->el[pos].mountpoint, "lvm")) {
|
---|
[900] | 636 | mr_asprintf(&tmp, " %s is tiny!", device);
|
---|
[48] | 637 | log_it(tmp);
|
---|
[688] | 638 | if (flaws_str) {
|
---|
[900] | 639 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 640 | } else {
|
---|
[900] | 641 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 642 | }
|
---|
[900] | 643 | mr_free(flaws_str);
|
---|
[688] | 644 | flaws_str = tmp1;
|
---|
[900] | 645 | mr_free(tmp);
|
---|
[48] | 646 | res++;
|
---|
| 647 | }
|
---|
| 648 | /* mountpoint should begin with / unless it is swap, lvm or raid */
|
---|
| 649 | if (strcmp(mountlist->el[pos].mountpoint, "swap")
|
---|
| 650 | && strcmp(mountlist->el[pos].mountpoint, "lvm")
|
---|
| 651 | && strcmp(mountlist->el[pos].mountpoint, "raid")
|
---|
| 652 | && strcmp(mountlist->el[pos].mountpoint, "image")
|
---|
| 653 | && mountlist->el[pos].mountpoint[0] != '/') {
|
---|
[900] | 654 | mr_asprintf(&tmp, " %s has a weird mountpoint.", device);
|
---|
[48] | 655 | log_it(tmp);
|
---|
[688] | 656 | if (flaws_str) {
|
---|
[900] | 657 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 658 | } else {
|
---|
[900] | 659 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 660 | }
|
---|
[900] | 661 | mr_free(flaws_str);
|
---|
[688] | 662 | flaws_str = tmp1;
|
---|
[900] | 663 | mr_free(tmp);
|
---|
[48] | 664 | res++;
|
---|
| 665 | }
|
---|
| 666 | /* is format sensible? */
|
---|
| 667 | if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) {
|
---|
[900] | 668 | mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);
|
---|
[48] | 669 | log_it(tmp);
|
---|
[688] | 670 | if (flaws_str) {
|
---|
[900] | 671 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 672 | } else {
|
---|
[900] | 673 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 674 | }
|
---|
[900] | 675 | mr_free(flaws_str);
|
---|
[688] | 676 | flaws_str = tmp1;
|
---|
[900] | 677 | mr_free(tmp);
|
---|
[48] | 678 | res++;
|
---|
| 679 | }
|
---|
| 680 | /* OK, continue with main loop */
|
---|
| 681 | amount_allocated += mountlist->el[pos].size / 1024;
|
---|
| 682 | prev_part_no = curr_part_no;
|
---|
[900] | 683 | mr_free(device);
|
---|
[1] | 684 | }
|
---|
[48] | 685 |
|
---|
| 686 | /* Over-allocated the disk? Unallocated space on disk? */
|
---|
| 687 | if (amount_allocated > physical_drive_size + 1) {
|
---|
[900] | 688 | mr_asprintf(&tmp, " %ld MB over-allocated on %s.",
|
---|
[59] | 689 | amount_allocated - physical_drive_size, drive);
|
---|
[48] | 690 | log_it(tmp);
|
---|
[688] | 691 | if (flaws_str) {
|
---|
[900] | 692 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 693 | } else {
|
---|
[900] | 694 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 695 | }
|
---|
[900] | 696 | mr_free(flaws_str);
|
---|
[688] | 697 | flaws_str = tmp1;
|
---|
[900] | 698 | mr_free(tmp);
|
---|
[48] | 699 | res++;
|
---|
| 700 | } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */
|
---|
[900] | 701 | mr_asprintf(&tmp, " %ld MB unallocated on %s.",
|
---|
[59] | 702 | physical_drive_size - amount_allocated, drive);
|
---|
[48] | 703 | log_it(tmp);
|
---|
[688] | 704 | if (flaws_str) {
|
---|
[900] | 705 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
[688] | 706 | } else {
|
---|
[900] | 707 | mr_asprintf(&tmp1, "%s", tmp);
|
---|
[688] | 708 | }
|
---|
[900] | 709 | mr_free(flaws_str);
|
---|
[688] | 710 | flaws_str = tmp1;
|
---|
[900] | 711 | mr_free(tmp);
|
---|
[1176] | 712 | /* BERLIOS: Flawed since rev 1 !! - Is it sure ?? */
|
---|
| 713 | res++;
|
---|
[1] | 714 | }
|
---|
[48] | 715 |
|
---|
| 716 | if (res) {
|
---|
| 717 | return (FALSE);
|
---|
| 718 | } else {
|
---|
| 719 | return (TRUE);
|
---|
[1] | 720 | }
|
---|
| 721 | }
|
---|
| 722 | #endif
|
---|
| 723 |
|
---|
| 724 |
|
---|
| 725 | /**
|
---|
| 726 | * Evaluate a whole mountlist for flaws. Calls evaluate_drive_within_mountlist()
|
---|
| 727 | * for each drive, and then spreads the flaws across three lines.
|
---|
| 728 | * @param mountlist The mountlist to evaluate.
|
---|
| 729 | * @param flaws_str_A Where to put the first line listing errors found.
|
---|
| 730 | * @param flaws_str_B Where to put the second line listing errors found.
|
---|
| 731 | * @param flaws_str_C Where to put the third line listing errors found.
|
---|
| 732 | * @return The number of flaws found (0 for success).
|
---|
| 733 | * @see evaluate_drive_within_mountlist
|
---|
| 734 | */
|
---|
| 735 | int
|
---|
[48] | 736 | evaluate_mountlist(struct mountlist_itself *mountlist, char *flaws_str_A,
|
---|
| 737 | char *flaws_str_B, char *flaws_str_C)
|
---|
[1] | 738 | {
|
---|
| 739 |
|
---|
[48] | 740 | /*@ buffer *********************************************************** */
|
---|
[1176] | 741 | struct list_of_disks *drivelist = NULL;
|
---|
| 742 | char *tmp = NULL;
|
---|
| 743 | char *tmp1 = NULL;
|
---|
| 744 | char *flaws_str = NULL;
|
---|
[1] | 745 |
|
---|
[48] | 746 | /*@ int ************************************************************** */
|
---|
[1] | 747 | int i = 0;
|
---|
| 748 | int res = 0;
|
---|
| 749 |
|
---|
[48] | 750 | /*@ initialize ******************************************************* */
|
---|
[1] | 751 |
|
---|
[1081] | 752 | drivelist = mr_malloc(sizeof(struct list_of_disks));
|
---|
[48] | 753 | assert(mountlist != NULL);
|
---|
[1] | 754 |
|
---|
[900] | 755 | mr_asprintf(&flaws_str, " ");
|
---|
[1] | 756 |
|
---|
[48] | 757 | make_list_of_drives_in_mountlist(mountlist, drivelist);
|
---|
[1] | 758 |
|
---|
[48] | 759 | log_it("Evaluating mountlist...");
|
---|
| 760 |
|
---|
| 761 | for (i = 0; i < drivelist->entries; i++) {
|
---|
| 762 | if (strstr
|
---|
| 763 | (drivelist->el[i].device,
|
---|
| 764 | DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE)) {
|
---|
[900] | 765 | mr_asprintf(&tmp, " Not evaluating %s (I don't know how yet)",
|
---|
[59] | 766 | drivelist->el[i].device);
|
---|
[48] | 767 | log_it(tmp);
|
---|
| 768 | } else {
|
---|
[688] | 769 | // This function allocates tmp
|
---|
[48] | 770 | if (!evaluate_drive_within_mountlist
|
---|
| 771 | (mountlist, drivelist->el[i].device, tmp)) {
|
---|
| 772 | res++;
|
---|
| 773 | }
|
---|
| 774 | }
|
---|
[900] | 775 | mr_asprintf(&tmp1, "%s%s", flaws_str, tmp);
|
---|
| 776 | mr_free(tmp);
|
---|
| 777 | mr_free(flaws_str);
|
---|
[48] | 778 | flaws_str = tmp1;
|
---|
[1] | 779 | }
|
---|
[48] | 780 | res += look_for_duplicate_mountpoints(mountlist, flaws_str);
|
---|
| 781 | return (spread_flaws_across_three_lines
|
---|
| 782 | (flaws_str, flaws_str_A, flaws_str_B, flaws_str_C, res));
|
---|
[1] | 783 | }
|
---|
| 784 |
|
---|
| 785 |
|
---|
| 786 | /**
|
---|
| 787 | * Find the index number of @p device in the mountlist.
|
---|
| 788 | * The device given must match @p mountlist->el[N].device exactly, case-sensitive.
|
---|
| 789 | * @param mountlist The mountlist to search in.
|
---|
| 790 | * @param device The device to search for.
|
---|
| 791 | * @return The zero-based index of the device, or -1 if it could not be found.
|
---|
| 792 | */
|
---|
| 793 | int
|
---|
[48] | 794 | find_device_in_mountlist(struct mountlist_itself *mountlist, char *device)
|
---|
[1] | 795 | {
|
---|
| 796 |
|
---|
[48] | 797 | /*@ int ************************************************************** */
|
---|
| 798 | int i = 0;
|
---|
[1] | 799 |
|
---|
[48] | 800 | assert(mountlist != NULL);
|
---|
| 801 | assert_string_is_neither_NULL_nor_zerolength(device);
|
---|
| 802 | for (i = 0;
|
---|
| 803 | i < mountlist->entries
|
---|
| 804 | && strcmp(mountlist->el[i].device, device) != 0; i++);
|
---|
| 805 |
|
---|
| 806 | if (i == mountlist->entries) {
|
---|
| 807 | return (-1);
|
---|
| 808 | } else {
|
---|
| 809 | return (i);
|
---|
| 810 | }
|
---|
[1] | 811 | }
|
---|
| 812 |
|
---|
| 813 |
|
---|
| 814 | /**
|
---|
| 815 | * Look for duplicate mountpoints in @p mountlist.
|
---|
| 816 | * @param mountlist The mountlist to check.
|
---|
| 817 | * @param flaws_str The flaws string to append the results to.
|
---|
| 818 | * @return The number of mountpoints that have duplicates, or 0 for success.
|
---|
| 819 | */
|
---|
| 820 | int
|
---|
[48] | 821 | look_for_duplicate_mountpoints(struct mountlist_itself *mountlist,
|
---|
| 822 | char *flaws_str)
|
---|
[1] | 823 | {
|
---|
| 824 |
|
---|
[48] | 825 | /*@ int ************************************************************* */
|
---|
| 826 | int res = 0;
|
---|
[1] | 827 | int currline = 0;
|
---|
| 828 | int i = 0;
|
---|
| 829 | int copies = 0;
|
---|
| 830 | int last_copy = 0;
|
---|
| 831 |
|
---|
[48] | 832 | /*@ buffetr ********************************************************* */
|
---|
[688] | 833 | char *curr_mountpoint = NULL;
|
---|
| 834 | char *tmp = NULL;
|
---|
| 835 | char *tmp1 = NULL;
|
---|
[1] | 836 |
|
---|
[48] | 837 | assert(mountlist != NULL);
|
---|
| 838 | assert(flaws_str != NULL);
|
---|
[688] | 839 |
|
---|
[48] | 840 | for (currline = 0; currline < mountlist->entries; currline++) {
|
---|
[900] | 841 | mr_asprintf(&curr_mountpoint, mountlist->el[currline].mountpoint);
|
---|
[48] | 842 | for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries;
|
---|
| 843 | i++) {
|
---|
| 844 | if (!strcmp(mountlist->el[i].mountpoint, curr_mountpoint)
|
---|
| 845 | && strcmp(mountlist->el[i].mountpoint, "lvm")
|
---|
| 846 | && strcmp(mountlist->el[i].mountpoint, "swap")) {
|
---|
| 847 | last_copy = i;
|
---|
| 848 | copies++;
|
---|
| 849 | }
|
---|
| 850 | }
|
---|
| 851 | if (copies > 1 && last_copy == currline
|
---|
| 852 | && strcmp(curr_mountpoint, "raid")) {
|
---|
[900] | 853 | mr_asprintf(&tmp, " %s %s's.", number_to_text(copies),
|
---|
[1176] | 854 | curr_mountpoint);
|
---|
[48] | 855 | log_it(tmp);
|
---|
[900] | 856 | mr_asprintf(&tmp1, "%s%s",flaws_str, tmp);
|
---|
| 857 | mr_free(flaws_str);
|
---|
[688] | 858 | flaws_str = tmp1;
|
---|
[900] | 859 | mr_free(tmp);
|
---|
[48] | 860 | res++;
|
---|
| 861 | }
|
---|
[900] | 862 | mr_free(curr_mountpoint);
|
---|
[1] | 863 | }
|
---|
[48] | 864 | return (res);
|
---|
[1] | 865 | }
|
---|
| 866 |
|
---|
[48] | 867 |
|
---|
[1] | 868 | /**
|
---|
| 869 | * Make a list of the drives mentioned in the mountlist.
|
---|
| 870 | * @param mountlist The mountlist to examine.
|
---|
| 871 | * @param drivelist Where to put the list of drives found.
|
---|
| 872 | * @return The number of physical (non-RAID non-LVM) drives found, or \<= 0 for error.
|
---|
| 873 | */
|
---|
| 874 | int
|
---|
[48] | 875 | make_list_of_drives_in_mountlist(struct mountlist_itself *mountlist,
|
---|
| 876 | struct list_of_disks *drivelist)
|
---|
[1] | 877 | {
|
---|
| 878 |
|
---|
[48] | 879 | /*@ int ************************************************************* */
|
---|
| 880 | int lino;
|
---|
| 881 | int noof_drives;
|
---|
| 882 | int j;
|
---|
[1] | 883 |
|
---|
[48] | 884 | /*@ buffers ********************************************************* */
|
---|
[1176] | 885 | char *drive = NULL;
|
---|
[1] | 886 |
|
---|
[48] | 887 | long long size;
|
---|
[1] | 888 |
|
---|
[48] | 889 | assert(mountlist != NULL);
|
---|
| 890 | assert(drivelist != NULL);
|
---|
| 891 | log_it("Making list of drives");
|
---|
| 892 | for (lino = 0, noof_drives = 0; lino < mountlist->entries; lino++) {
|
---|
[1] | 893 |
|
---|
[900] | 894 | mr_asprintf(&drive, mountlist->el[lino].device);
|
---|
[48] | 895 | if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
|
---|
[1176] | 896 | mr_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive);
|
---|
[48] | 897 | continue;
|
---|
| 898 | }
|
---|
[1] | 899 |
|
---|
[48] | 900 | size = mountlist->el[lino].size;
|
---|
| 901 | if (size == 0) {
|
---|
[1176] | 902 | mr_msg(8, "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", drive);
|
---|
[48] | 903 | continue;
|
---|
| 904 | }
|
---|
| 905 |
|
---|
[1176] | 906 | mr_msg(8, "Putting %s with size %lli in list of drives", drive, size);
|
---|
[1] | 907 |
|
---|
[48] | 908 | (void) truncate_to_drive_name(drive);
|
---|
| 909 | for (j = 0;
|
---|
| 910 | j < noof_drives
|
---|
| 911 | && strcmp(drivelist->el[j].device, drive) != 0; j++)
|
---|
| 912 | continue;
|
---|
| 913 | if (j == noof_drives) {
|
---|
| 914 | strcpy(drivelist->el[noof_drives++].device, drive);
|
---|
| 915 | }
|
---|
[900] | 916 | mr_free(drive);
|
---|
[48] | 917 |
|
---|
[1] | 918 | }
|
---|
[48] | 919 | drivelist->entries = noof_drives;
|
---|
[1086] | 920 | mr_msg(8, "Made list of drives");
|
---|
[1] | 921 |
|
---|
[48] | 922 | return (noof_drives);
|
---|
[1] | 923 | }
|
---|
| 924 |
|
---|
| 925 |
|
---|
| 926 | /**
|
---|
| 927 | * Make a list of RAID partitions not currently associated with any RAID device.
|
---|
| 928 | * The user may add any of these partitions to the RAID device.
|
---|
| 929 | * @param output_list Where to put the list of unallocated RAID partitions.
|
---|
| 930 | * @param mountlist The mountlist to examine.
|
---|
| 931 | * @param raidlist The raidlist to examine.
|
---|
| 932 | */
|
---|
[48] | 933 | void make_list_of_unallocated_raid_partitions(struct mountlist_itself
|
---|
[1176] | 934 | *output_list,
|
---|
| 935 | struct mountlist_itself
|
---|
| 936 | *mountlist,
|
---|
| 937 | struct raidlist_itself
|
---|
[48] | 938 | *raidlist)
|
---|
[1] | 939 | {
|
---|
| 940 |
|
---|
[48] | 941 | /*@ int ************************************************************* */
|
---|
| 942 | int items = 0;
|
---|
[1] | 943 | int i = 0;
|
---|
| 944 | int used_by = 0;
|
---|
| 945 |
|
---|
[48] | 946 | /*@ buffers ********************************************************* */
|
---|
[1176] | 947 | char *tmp = NULL;
|
---|
[1] | 948 |
|
---|
[48] | 949 | assert(output_list != NULL);
|
---|
| 950 | assert(mountlist != NULL);
|
---|
| 951 | assert(raidlist != NULL);
|
---|
| 952 | log_it("MLOURP -- starting");
|
---|
| 953 | items = 0;
|
---|
[1] | 954 |
|
---|
| 955 |
|
---|
[48] | 956 | for (i = 0; i < mountlist->entries; i++) {
|
---|
| 957 | if (strstr(mountlist->el[i].mountpoint, "raid")) {
|
---|
| 958 | used_by =
|
---|
| 959 | which_raid_device_is_using_this_partition(raidlist,
|
---|
| 960 | mountlist->el[i].
|
---|
| 961 | device);
|
---|
| 962 | if (used_by < 0) {
|
---|
| 963 | memcpy((void *) &output_list->el[items++],
|
---|
| 964 | (void *) &mountlist->el[i],
|
---|
| 965 | sizeof(struct mountlist_line));
|
---|
[900] | 966 | mr_asprintf(&tmp,
|
---|
[59] | 967 | "%s is available; user may choose to add it to raid device",
|
---|
| 968 | output_list->el[items - 1].device);
|
---|
[48] | 969 | log_it(tmp);
|
---|
[900] | 970 | mr_free(tmp);
|
---|
[48] | 971 | }
|
---|
| 972 | }
|
---|
[1] | 973 | }
|
---|
[48] | 974 | output_list->entries = items;
|
---|
| 975 | log_it("MLUORP -- ending");
|
---|
[1] | 976 | }
|
---|
| 977 |
|
---|
| 978 |
|
---|
| 979 | /**
|
---|
| 980 | * Get the size of a mountlist entry by the @c device field.
|
---|
| 981 | * @param mountlist The mountlist to search in.
|
---|
| 982 | * @param device The device to search for
|
---|
| 983 | * @return The size of the device (in KB), or -1 if it could not be found.
|
---|
| 984 | */
|
---|
| 985 | long long
|
---|
[48] | 986 | size_of_specific_device_in_mountlist(struct mountlist_itself *mountlist,
|
---|
| 987 | char *device)
|
---|
[1] | 988 | {
|
---|
[48] | 989 | /*@ int ************************************************************** */
|
---|
| 990 | int i = 0;
|
---|
[1] | 991 |
|
---|
| 992 |
|
---|
[48] | 993 | assert(mountlist != NULL);
|
---|
| 994 | assert_string_is_neither_NULL_nor_zerolength(device);
|
---|
[1] | 995 |
|
---|
[48] | 996 | for (i = 0;
|
---|
| 997 | i < mountlist->entries && strcmp(mountlist->el[i].device, device);
|
---|
| 998 | i++);
|
---|
| 999 | if (i == mountlist->entries) {
|
---|
| 1000 | return (-1);
|
---|
| 1001 | } else {
|
---|
| 1002 | return (mountlist->el[i].size);
|
---|
| 1003 | }
|
---|
[1] | 1004 | }
|
---|
| 1005 |
|
---|
| 1006 |
|
---|
| 1007 | /**
|
---|
| 1008 | * Load a file on disk into @p mountlist.
|
---|
| 1009 | * The file on disk should consist of multiple lines, each containing 4 or 5
|
---|
| 1010 | * columns: the device, the mountpoint, the filesystem type, the size in kilobytes, and optionally the filesystem label.
|
---|
| 1011 | * Comments begin with a '#' without any leading whitespace. Any duplicate
|
---|
| 1012 | * entries are renamed.
|
---|
| 1013 | * @param mountlist The mountlist to load into.
|
---|
| 1014 | * @param fname The name of the file to load the mountlist from.
|
---|
| 1015 | * @return 0 for success, 1 for failure.
|
---|
| 1016 | */
|
---|
[48] | 1017 | int load_mountlist(struct mountlist_itself *mountlist, char *fname)
|
---|
[1] | 1018 | {
|
---|
[1176] | 1019 | FILE *fin = NULL;
|
---|
[48] | 1020 | /* malloc ** */
|
---|
| 1021 | char *incoming = NULL;
|
---|
[1176] | 1022 | char *siz = NULL;
|
---|
| 1023 | char *tmp = NULL;
|
---|
| 1024 | char *p = NULL;
|
---|
[1] | 1025 |
|
---|
[1176] | 1026 | int items = 0;
|
---|
| 1027 | int j = 0;
|
---|
[49] | 1028 | size_t n = 0;
|
---|
[1] | 1029 |
|
---|
[48] | 1030 | assert(mountlist != NULL);
|
---|
| 1031 | assert_string_is_neither_NULL_nor_zerolength(fname);
|
---|
[1176] | 1032 |
|
---|
[48] | 1033 | if (!(fin = fopen(fname, "r"))) {
|
---|
| 1034 | log_it("Unable to open mountlist - '%s'", fname);
|
---|
[507] | 1035 | log_to_screen(_("Cannot open mountlist"));
|
---|
[48] | 1036 | return (1);
|
---|
| 1037 | }
|
---|
[1176] | 1038 | malloc_string(siz);
|
---|
[900] | 1039 | mr_getline(&incoming, &n, fin);
|
---|
[48] | 1040 | log_it("Loading mountlist...");
|
---|
| 1041 | while (!feof(fin)) {
|
---|
[1] | 1042 | #if linux
|
---|
[48] | 1043 | sscanf(incoming,
|
---|
| 1044 | "%s %s %s %s %s",
|
---|
| 1045 | mountlist->el[items].device,
|
---|
| 1046 | mountlist->el[items].mountpoint,
|
---|
| 1047 | mountlist->el[items].format,
|
---|
| 1048 | siz, mountlist->el[items].label);
|
---|
[1] | 1049 | #elif __FreeBSD__
|
---|
[48] | 1050 | sscanf(incoming,
|
---|
| 1051 | "%s %s %s %s",
|
---|
| 1052 | mountlist->el[items].device,
|
---|
| 1053 | mountlist->el[items].mountpoint,
|
---|
| 1054 | mountlist->el[items].format, siz);
|
---|
| 1055 | strcpy(mountlist->el[items].label, "");
|
---|
[1] | 1056 | #endif
|
---|
| 1057 |
|
---|
[48] | 1058 | if (!strcmp(mountlist->el[items].device, "/proc") ||
|
---|
| 1059 | !strcmp(mountlist->el[items].device, "proc") ||
|
---|
| 1060 | !strcmp(mountlist->el[items].device, "/sys") ||
|
---|
| 1061 | !strcmp(mountlist->el[items].device, "sys") ||
|
---|
| 1062 | !strcmp(mountlist->el[items].device, "/devpts") ||
|
---|
| 1063 | !strcmp(mountlist->el[items].device, "devpts")
|
---|
| 1064 | ) {
|
---|
[1086] | 1065 | mr_msg(1,
|
---|
[48] | 1066 | "Ignoring %s in mountlist - not loading that line :) ",
|
---|
| 1067 | mountlist->el[items].device);
|
---|
[900] | 1068 | mr_getline(&incoming, &n, fin);
|
---|
[48] | 1069 | continue;
|
---|
| 1070 | }
|
---|
| 1071 | mountlist->el[items].size = atoll(siz);
|
---|
| 1072 | if (mountlist->el[items].device[0] != '\0'
|
---|
| 1073 | && mountlist->el[items].device[0] != '#') {
|
---|
| 1074 | if (items >= ARBITRARY_MAXIMUM) {
|
---|
[507] | 1075 | log_to_screen(_("Too many lines in mountlist.. ABORTING"));
|
---|
[48] | 1076 | finish(1);
|
---|
| 1077 | }
|
---|
| 1078 | for (j = 0;
|
---|
| 1079 | j < items
|
---|
| 1080 | && strcmp(mountlist->el[j].device,
|
---|
| 1081 | mountlist->el[items].device); j++);
|
---|
| 1082 | if (j < items) {
|
---|
| 1083 | strcat(mountlist->el[items].device, "_dup");
|
---|
[900] | 1084 | mr_asprintf(&tmp,
|
---|
[59] | 1085 | "Duplicate entry in mountlist - renaming to %s",
|
---|
| 1086 | mountlist->el[items].device);
|
---|
[48] | 1087 | log_it(tmp);
|
---|
[900] | 1088 | mr_free(tmp);
|
---|
[48] | 1089 | }
|
---|
[900] | 1090 | mr_asprintf(&tmp, mountlist->el[items].device);
|
---|
[48] | 1091 | if (strstr(tmp, "/dev/md/")) {
|
---|
| 1092 | log_it("format_device() --- Contracting %s", tmp);
|
---|
| 1093 | p = strrchr(tmp, '/');
|
---|
| 1094 | if (p) {
|
---|
| 1095 | *p = *(p + 1);
|
---|
| 1096 | *(p + 1) = *(p + 2);
|
---|
| 1097 | *(p + 2) = *(p + 3);
|
---|
| 1098 | }
|
---|
| 1099 | log_it("It was %s; it is now %s",
|
---|
| 1100 | mountlist->el[items].device, tmp);
|
---|
| 1101 | strcpy(mountlist->el[items].device, tmp);
|
---|
| 1102 | }
|
---|
[900] | 1103 | mr_free(tmp);
|
---|
[1] | 1104 |
|
---|
[1176] | 1105 | log_it("%s %s %s %lld %s",
|
---|
[59] | 1106 | mountlist->el[items].device,
|
---|
| 1107 | mountlist->el[items].mountpoint,
|
---|
| 1108 | mountlist->el[items].format,
|
---|
| 1109 | mountlist->el[items].size,
|
---|
| 1110 | mountlist->el[items].label);
|
---|
[48] | 1111 | items++;
|
---|
| 1112 | }
|
---|
[900] | 1113 | mr_getline(&incoming, &n, fin);
|
---|
[1] | 1114 | }
|
---|
[48] | 1115 | paranoid_fclose(fin);
|
---|
[900] | 1116 | mr_free(incoming);
|
---|
[48] | 1117 | mountlist->entries = items;
|
---|
[1] | 1118 |
|
---|
[48] | 1119 | log_it("Mountlist loaded successfully.");
|
---|
[1176] | 1120 | log_it("%d entries in mountlist", items);
|
---|
[48] | 1121 |
|
---|
[900] | 1122 | mr_free(siz);
|
---|
[48] | 1123 | return (0);
|
---|
[1] | 1124 | }
|
---|
| 1125 |
|
---|
| 1126 |
|
---|
| 1127 | /**
|
---|
| 1128 | * Save @p mountlist to a file on disk.
|
---|
| 1129 | * @param mountlist The mountlist to save.
|
---|
| 1130 | * @param fname The file to save it to.
|
---|
| 1131 | * @return 0 for success, 1 for failure.
|
---|
| 1132 | * @see load_mountlist
|
---|
| 1133 | */
|
---|
[48] | 1134 | int save_mountlist_to_disk(struct mountlist_itself *mountlist, char *fname)
|
---|
[1] | 1135 | {
|
---|
[48] | 1136 | FILE *fout;
|
---|
| 1137 | int i;
|
---|
[1] | 1138 |
|
---|
[48] | 1139 | assert(mountlist != NULL);
|
---|
| 1140 | assert_string_is_neither_NULL_nor_zerolength(fname);
|
---|
[1] | 1141 |
|
---|
[48] | 1142 | log_it("save_mountlist_to_disk() --- saving to %s", fname);
|
---|
| 1143 | if (!(fout = fopen(fname, "w"))) {
|
---|
| 1144 | log_OS_error("WMTD - Cannot openout mountlist");
|
---|
| 1145 | return (1);
|
---|
| 1146 | }
|
---|
| 1147 | for (i = 0; i < mountlist->entries; i++) {
|
---|
| 1148 | fprintf(fout,
|
---|
| 1149 | "%-15s %-15s %-15s %-15lld %-15s\n",
|
---|
| 1150 | mountlist->el[i].device, mountlist->el[i].mountpoint,
|
---|
| 1151 | mountlist->el[i].format, mountlist->el[i].size,
|
---|
| 1152 | mountlist->el[i].label);
|
---|
| 1153 | }
|
---|
| 1154 | paranoid_fclose(fout);
|
---|
| 1155 | return (0);
|
---|
[1] | 1156 | }
|
---|
| 1157 |
|
---|
| 1158 |
|
---|
| 1159 | /**
|
---|
| 1160 | * Sort the mountlist alphabetically by device.
|
---|
| 1161 | * The sorting is done in-place.
|
---|
| 1162 | * @param mountlist The mountlist to sort.
|
---|
| 1163 | */
|
---|
[48] | 1164 | void sort_mountlist_by_device(struct mountlist_itself *mountlist)
|
---|
[1] | 1165 | {
|
---|
[48] | 1166 | int diff;
|
---|
| 1167 | int lino = -999;
|
---|
[1] | 1168 |
|
---|
[48] | 1169 | assert(mountlist != NULL);
|
---|
[1] | 1170 |
|
---|
[48] | 1171 | while (lino < mountlist->entries) {
|
---|
| 1172 | for (lino = 1; lino < mountlist->entries; lino++) {
|
---|
| 1173 | diff =
|
---|
| 1174 | strcmp_inc_numbers(mountlist->el[lino - 1].device,
|
---|
| 1175 | mountlist->el[lino].device);
|
---|
| 1176 | if (diff > 0) {
|
---|
| 1177 | swap_mountlist_entries(mountlist, lino - 1, lino);
|
---|
| 1178 | break;
|
---|
| 1179 | }
|
---|
| 1180 | }
|
---|
[1] | 1181 | }
|
---|
| 1182 | }
|
---|
| 1183 |
|
---|
[48] | 1184 |
|
---|
[1] | 1185 | /**
|
---|
| 1186 | * Sort the mountlist alphabetically by mountpoint.
|
---|
| 1187 | * The sorting is done in-place.
|
---|
| 1188 | * @param mountlist The mountlist to sort.
|
---|
| 1189 | * @param reverse If TRUE, then do a reverse sort.
|
---|
| 1190 | */
|
---|
[48] | 1191 | void
|
---|
| 1192 | sort_mountlist_by_mountpoint(struct mountlist_itself *mountlist,
|
---|
| 1193 | bool reverse)
|
---|
[1] | 1194 | {
|
---|
[48] | 1195 | int diff;
|
---|
| 1196 | int lino = -999;
|
---|
[1] | 1197 |
|
---|
[48] | 1198 | assert(mountlist != NULL);
|
---|
[1] | 1199 |
|
---|
[48] | 1200 | while (lino < mountlist->entries) {
|
---|
| 1201 | for (lino = 1; lino < mountlist->entries; lino++) {
|
---|
| 1202 | diff =
|
---|
| 1203 | strcmp(mountlist->el[lino - 1].mountpoint,
|
---|
| 1204 | mountlist->el[lino].mountpoint);
|
---|
| 1205 | if ((diff > 0 && !reverse) || ((diff < 0 && reverse))) {
|
---|
| 1206 | swap_mountlist_entries(mountlist, lino - 1, lino);
|
---|
| 1207 | break;
|
---|
| 1208 | }
|
---|
| 1209 | }
|
---|
[1] | 1210 | }
|
---|
| 1211 | }
|
---|
| 1212 |
|
---|
| 1213 |
|
---|
| 1214 | /**
|
---|
| 1215 | * Swap two entries in the mountlist in-place.
|
---|
| 1216 | * @param mountlist The mountlist to swap the entries in.
|
---|
| 1217 | * @param a The index number of the first entry.
|
---|
| 1218 | * @param b The index number of the second entry.
|
---|
| 1219 | */
|
---|
[48] | 1220 | void
|
---|
[1] | 1221 | swap_mountlist_entries(struct mountlist_itself *mountlist, int a, int b)
|
---|
| 1222 | {
|
---|
[48] | 1223 | /*@ mallocs *** */
|
---|
[1176] | 1224 | char *device = NULL;
|
---|
| 1225 | char *mountpoint = NULL;
|
---|
| 1226 | char *format = NULL;
|
---|
[1] | 1227 |
|
---|
[48] | 1228 | long long size;
|
---|
[1] | 1229 |
|
---|
[48] | 1230 | assert(mountlist != NULL);
|
---|
| 1231 | assert(a >= 0);
|
---|
| 1232 | assert(b >= 0);
|
---|
[1] | 1233 |
|
---|
[900] | 1234 | mr_asprintf(&device, mountlist->el[a].device);
|
---|
| 1235 | mr_asprintf(&mountpoint, mountlist->el[a].mountpoint);
|
---|
| 1236 | mr_asprintf(&format, mountlist->el[a].format);
|
---|
[1] | 1237 |
|
---|
[48] | 1238 | size = mountlist->el[a].size;
|
---|
[1] | 1239 |
|
---|
[48] | 1240 | strcpy(mountlist->el[a].device, mountlist->el[b].device);
|
---|
| 1241 | strcpy(mountlist->el[a].mountpoint, mountlist->el[b].mountpoint);
|
---|
| 1242 | strcpy(mountlist->el[a].format, mountlist->el[b].format);
|
---|
[1] | 1243 |
|
---|
[48] | 1244 | mountlist->el[a].size = mountlist->el[b].size;
|
---|
[1] | 1245 |
|
---|
[48] | 1246 | strcpy(mountlist->el[b].device, device);
|
---|
| 1247 | strcpy(mountlist->el[b].mountpoint, mountpoint);
|
---|
| 1248 | strcpy(mountlist->el[b].format, format);
|
---|
[1] | 1249 |
|
---|
[48] | 1250 | mountlist->el[b].size = size;
|
---|
[1176] | 1251 | mr_free(device);
|
---|
| 1252 | mr_free(mountpoint);
|
---|
| 1253 | mr_free(format);
|
---|
[1] | 1254 | }
|
---|
| 1255 |
|
---|
| 1256 | /* @} - end of mountlistGroup */
|
---|