From 87bb0c6b9b67431a6110db4940041d6ccac00c22 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 15 Jan 2009 19:29:09 +0100 Subject: [PATCH] Fix mounting order of partitions. If the user specified (e.g.) a /usr/bin partition before /usr, the installer would end up mounting them in the incorrect order. To fix this, we sort the partitions by mount point as they are created. --- .../src/lib/libinstaller/diskutil.c | 59 +++++++++++++--------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/contrib/bsdinstaller-1.1.6/src/lib/libinstaller/diskutil.c b/contrib/bsdinstaller-1.1.6/src/lib/libinstaller/diskutil.c index cfd11ef7b7..5578afa634 100644 --- a/contrib/bsdinstaller-1.1.6/src/lib/libinstaller/diskutil.c +++ b/contrib/bsdinstaller-1.1.6/src/lib/libinstaller/diskutil.c @@ -606,28 +606,13 @@ struct subpartition * subpartition_new(struct slice *s, const char *mountpoint, long capacity, int softupdates, long fsize, long bsize, int mfsbacked) { - struct subpartition *sp; + struct subpartition *sp, *sptmp; + int letter='d'; AURA_MALLOC(sp, subpartition); sp->parent = s; - if (mfsbacked) { - sp->letter = '@'; - } else { - struct subpartition *last = s->subpartition_tail; - while (last != NULL && last->mfsbacked) { - last = last->prev; - } - if (last == NULL) { - sp->letter = 'a'; - } else if (last->letter == 'b') { - sp->letter = 'd'; - } else { - sp->letter = (char)(last->letter + 1); - } - } - sp->mountpoint = aura_strdup(mountpoint); sp->capacity = capacity; sp->type = FS_UFS; @@ -665,14 +650,42 @@ subpartition_new(struct slice *s, const char *mountpoint, long capacity, if (strcasecmp(mountpoint, "swap") == 0) sp->is_swap = 1; - sp->next = NULL; - if (s->subpartition_head == NULL) + if (s->subpartition_head == NULL) { s->subpartition_head = sp; - else - s->subpartition_tail->next = sp; + s->subpartition_tail = sp; + } else { + for (sptmp = s->subpartition_head; sptmp != NULL; + sptmp = sptmp->next) { + if (strcmp(sptmp->mountpoint, sp->mountpoint) > 0) + break; + } + if (sptmp != NULL) { + if (s->subpartition_head == sptmp) + s->subpartition_head = sp; + else + sptmp->prev->next = sp; + sp->next = sptmp; + sp->prev = sptmp->prev; + sptmp->prev = sp; + } else { + sp->prev = s->subpartition_tail; + s->subpartition_tail->next = sp; + s->subpartition_tail = sp; + } + } - sp->prev = s->subpartition_tail; - s->subpartition_tail = sp; + for (sptmp = s->subpartition_head; sptmp != NULL; + sptmp = sptmp->next) { + if (sptmp->mfsbacked) + sptmp->letter = '@'; + else if (strcmp(sptmp->mountpoint, "/") == 0 || + strcmp(sptmp->mountpoint, "/dummy") == 0) + sptmp->letter = 'a'; + else if (strcasecmp(sptmp->mountpoint, "swap") == 0) + sptmp->letter = 'b'; + else + sptmp->letter = letter++; + } return(sp); } -- 2.11.4.GIT