diff options
author | dillon <dillon@FreeBSD.org> | 2001-12-09 23:40:02 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2001-12-09 23:40:02 +0000 |
commit | c956ace9287cde07a8c002decbaad4801fbdb728 (patch) | |
tree | f3f84b26521094c279e0a04f4d5a2cde0af6dbb2 /usr.sbin | |
parent | 845894074a1beb0a467683592d77d4c5999cb88b (diff) | |
download | FreeBSD-src-c956ace9287cde07a8c002decbaad4801fbdb728.zip FreeBSD-src-c956ace9287cde07a8c002decbaad4801fbdb728.tar.gz |
Add auto-fill-on-delete. When deleting an 'A'uto created partition
sysinstall will automatically expand the previous partition to take up
the freed up space. So you can 'D'elete /home and /usr will get the
combined space, or you can 'D'elete /tmp and /var will get the combined space.
This gives the user, developer, or lay person a huge amount of flexibility
in constructing partitions from an 'A'uto base. It takes only 3 or 4
keystrokes to achieve virtually any combination of having or not having
a /tmp and/or /home after doing an 'A'uto create.
Change 'A'uto creation of /var/tmp to 'A'uto creation /tmp, which should
be less controversial.
MFC after: 6 days
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sade/install.c | 24 | ||||
-rw-r--r-- | usr.sbin/sade/label.c | 56 | ||||
-rw-r--r-- | usr.sbin/sysinstall/install.c | 24 | ||||
-rw-r--r-- | usr.sbin/sysinstall/label.c | 56 |
4 files changed, 94 insertions, 66 deletions
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 468b202..27dc295 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -66,12 +66,12 @@ static void fixit_common(void); static void installConfigure(void); Boolean -checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev, Chunk **vtdev, Chunk **hdev) +checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev, Chunk **tdev, Chunk **hdev) { Device **devs; Boolean status; Disk *disk; - Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev, *vartmpdev, *homedev; + Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev, *tmpdev, *homedev; int i; /* Don't allow whinging if noWarn is set */ @@ -87,11 +87,11 @@ checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vd *udev = NULL; if (vdev) *vdev = NULL; - if (vtdev) - *vtdev = NULL; + if (tdev) + *tdev = NULL; if (hdev) *hdev = NULL; - rootdev = swapdev = usrdev = vardev = vartmpdev = homedev = NULL; + rootdev = swapdev = usrdev = vardev = tmpdev = homedev = NULL; /* We don't need to worry about root/usr/swap if we're already multiuser */ if (!RunningAsInit) @@ -148,17 +148,17 @@ checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vd if (isDebug()) msgDebug("Found vardev at %s!\n", vardev->name); } - } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var/tmp")) { - if (vartmpdev) { + } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/tmp")) { + if (tmpdev) { if (whinge) - msgConfirm("WARNING: You have more than one /var/tmp filesystem.\n" + msgConfirm("WARNING: You have more than one /tmp filesystem.\n" "Using the first one found."); continue; } else { - vartmpdev = c2; + tmpdev = c2; if (isDebug()) - msgDebug("Found vartmpdev at %s!\n", vartmpdev->name); + msgDebug("Found tmpdev at %s!\n", tmpdev->name); } } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/home")) { if (homedev) { @@ -210,8 +210,8 @@ checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vd *udev = usrdev; if (vdev) *vdev = vardev; - if (vtdev) - *vtdev = vartmpdev; + if (tdev) + *tdev = tmpdev; if (hdev) *hdev = homedev; diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c index 39ed48c..383ae55 100644 --- a/usr.sbin/sade/label.c +++ b/usr.sbin/sade/label.c @@ -1027,6 +1027,11 @@ diskLabel(Device *dev) case 'T': /* Toggle newfs state */ if (label_chunk_info[here].type == PART_FILESYSTEM) { PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data); + if (!pi->newfs) + label_chunk_info[here].c->flags |= CHUNK_NEWFS; + else + label_chunk_info[here].c->flags &= ~CHUNK_NEWFS; + label_chunk_info[here].c->private_data = new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size); if (pi && pi->soft) @@ -1165,13 +1170,13 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) struct chunk *swap_chunk = NULL; struct chunk *usr_chunk = NULL; struct chunk *var_chunk = NULL; - struct chunk *vartmp_chunk = NULL; + struct chunk *tmp_chunk = NULL; struct chunk *home_chunk = NULL; int mib[2]; unsigned int physmem; size_t size; Chunk *rootdev, *swapdev, *usrdev, *vardev; - Chunk *vartmpdev, *homedev; + Chunk *tmpdev, *homedev; char *msg = NULL; sz = space_free(label_chunk_info[here].c); @@ -1179,12 +1184,13 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) return("Not enough free space to create a new partition in the slice"); (void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, - &vardev, &vartmpdev, &homedev); + &vardev, &tmpdev, &homedev); if (!rootdev) { sz = requested_part_size(VAR_ROOT_SIZE, ROOT_NOMINAL_SIZE, ROOT_DEFAULT_SIZE, perc); - root_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, CHUNK_IS_ROOT); + root_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_IS_ROOT | CHUNK_AUTO_SIZE); if (!root_chunk) { *req = 1; msg = "Unable to create the root partition. Too big?"; @@ -1192,6 +1198,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } root_chunk->private_data = new_part("/", TRUE, root_chunk->size); root_chunk->private_free = safe_free; + root_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } if (!swapdev) { @@ -1212,8 +1219,9 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) nom = (int)(physmem / 512) / 2; sz = nom + (def - nom) * perc / 100; } - swap_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_SWAP, 0); + swap_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_SWAP, CHUNK_AUTO_SIZE); if (!swap_chunk) { *req = 1; msg = "Unable to create the swap partition. Too big?"; @@ -1226,8 +1234,9 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) if (!vardev) { sz = requested_part_size(VAR_VAR_SIZE, VAR_NOMINAL_SIZE, VAR_DEFAULT_SIZE, perc); - var_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); + var_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); if (!var_chunk) { *req = 1; msg = "Not enough free space for /var - you will need to\n" @@ -1236,21 +1245,24 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } var_chunk->private_data = new_part("/var", TRUE, var_chunk->size); var_chunk->private_free = safe_free; + var_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } - if (!vartmpdev && !variable_get(VAR_NO_VARTMP)) { + if (!tmpdev && !variable_get(VAR_NO_VARTMP)) { sz = requested_part_size(VAR_VARTMP_SIZE, VARTMP_NOMINAL_SIZE, VARTMP_DEFAULT_SIZE, perc); - vartmp_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); - if (!vartmp_chunk) { + tmp_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); + if (!tmp_chunk) { *req = 1; msg = "Not enough free space for /var/tmp - you will need to\n" "partition your disk manually with a custom install!"; goto done; } - vartmp_chunk->private_data = new_part("/var/tmp", TRUE, vartmp_chunk->size); - vartmp_chunk->private_free = safe_free; + tmp_chunk->private_data = new_part("/tmp", TRUE, tmp_chunk->size); + tmp_chunk->private_free = safe_free; + tmp_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } if (!usrdev && !variable_get(VAR_NO_USR)) { @@ -1266,8 +1278,8 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } usr_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); if (!usr_chunk) { msg = "Unable to create the /usr partition. Not enough space?\n" "You will need to partition your disk manually with a custom install!"; @@ -1275,6 +1287,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } usr_chunk->private_data = new_part("/usr", TRUE, usr_chunk->size); usr_chunk->private_free = safe_free; + usr_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } } @@ -1291,8 +1304,8 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } home_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); if (!home_chunk) { msg = "Unable to create the /home partition. Not enough space?\n" "You will need to partition your disk manually with a custom install!"; @@ -1300,6 +1313,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } home_chunk->private_data = new_part("/home", TRUE, home_chunk->size); home_chunk->private_free = safe_free; + home_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } } @@ -1316,8 +1330,8 @@ done: Delete_Chunk(swap_chunk->disk, swap_chunk); if (var_chunk) Delete_Chunk(var_chunk->disk, var_chunk); - if (vartmp_chunk) - Delete_Chunk(vartmp_chunk->disk, vartmp_chunk); + if (tmp_chunk) + Delete_Chunk(tmp_chunk->disk, tmp_chunk); if (usr_chunk) Delete_Chunk(usr_chunk->disk, usr_chunk); if (home_chunk) diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index 468b202..27dc295 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -66,12 +66,12 @@ static void fixit_common(void); static void installConfigure(void); Boolean -checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev, Chunk **vtdev, Chunk **hdev) +checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev, Chunk **tdev, Chunk **hdev) { Device **devs; Boolean status; Disk *disk; - Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev, *vartmpdev, *homedev; + Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev, *tmpdev, *homedev; int i; /* Don't allow whinging if noWarn is set */ @@ -87,11 +87,11 @@ checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vd *udev = NULL; if (vdev) *vdev = NULL; - if (vtdev) - *vtdev = NULL; + if (tdev) + *tdev = NULL; if (hdev) *hdev = NULL; - rootdev = swapdev = usrdev = vardev = vartmpdev = homedev = NULL; + rootdev = swapdev = usrdev = vardev = tmpdev = homedev = NULL; /* We don't need to worry about root/usr/swap if we're already multiuser */ if (!RunningAsInit) @@ -148,17 +148,17 @@ checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vd if (isDebug()) msgDebug("Found vardev at %s!\n", vardev->name); } - } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var/tmp")) { - if (vartmpdev) { + } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/tmp")) { + if (tmpdev) { if (whinge) - msgConfirm("WARNING: You have more than one /var/tmp filesystem.\n" + msgConfirm("WARNING: You have more than one /tmp filesystem.\n" "Using the first one found."); continue; } else { - vartmpdev = c2; + tmpdev = c2; if (isDebug()) - msgDebug("Found vartmpdev at %s!\n", vartmpdev->name); + msgDebug("Found tmpdev at %s!\n", tmpdev->name); } } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/home")) { if (homedev) { @@ -210,8 +210,8 @@ checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vd *udev = usrdev; if (vdev) *vdev = vardev; - if (vtdev) - *vtdev = vartmpdev; + if (tdev) + *tdev = tmpdev; if (hdev) *hdev = homedev; diff --git a/usr.sbin/sysinstall/label.c b/usr.sbin/sysinstall/label.c index 39ed48c..383ae55 100644 --- a/usr.sbin/sysinstall/label.c +++ b/usr.sbin/sysinstall/label.c @@ -1027,6 +1027,11 @@ diskLabel(Device *dev) case 'T': /* Toggle newfs state */ if (label_chunk_info[here].type == PART_FILESYSTEM) { PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data); + if (!pi->newfs) + label_chunk_info[here].c->flags |= CHUNK_NEWFS; + else + label_chunk_info[here].c->flags &= ~CHUNK_NEWFS; + label_chunk_info[here].c->private_data = new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size); if (pi && pi->soft) @@ -1165,13 +1170,13 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) struct chunk *swap_chunk = NULL; struct chunk *usr_chunk = NULL; struct chunk *var_chunk = NULL; - struct chunk *vartmp_chunk = NULL; + struct chunk *tmp_chunk = NULL; struct chunk *home_chunk = NULL; int mib[2]; unsigned int physmem; size_t size; Chunk *rootdev, *swapdev, *usrdev, *vardev; - Chunk *vartmpdev, *homedev; + Chunk *tmpdev, *homedev; char *msg = NULL; sz = space_free(label_chunk_info[here].c); @@ -1179,12 +1184,13 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) return("Not enough free space to create a new partition in the slice"); (void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, - &vardev, &vartmpdev, &homedev); + &vardev, &tmpdev, &homedev); if (!rootdev) { sz = requested_part_size(VAR_ROOT_SIZE, ROOT_NOMINAL_SIZE, ROOT_DEFAULT_SIZE, perc); - root_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, CHUNK_IS_ROOT); + root_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_IS_ROOT | CHUNK_AUTO_SIZE); if (!root_chunk) { *req = 1; msg = "Unable to create the root partition. Too big?"; @@ -1192,6 +1198,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } root_chunk->private_data = new_part("/", TRUE, root_chunk->size); root_chunk->private_free = safe_free; + root_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } if (!swapdev) { @@ -1212,8 +1219,9 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) nom = (int)(physmem / 512) / 2; sz = nom + (def - nom) * perc / 100; } - swap_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_SWAP, 0); + swap_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_SWAP, CHUNK_AUTO_SIZE); if (!swap_chunk) { *req = 1; msg = "Unable to create the swap partition. Too big?"; @@ -1226,8 +1234,9 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) if (!vardev) { sz = requested_part_size(VAR_VAR_SIZE, VAR_NOMINAL_SIZE, VAR_DEFAULT_SIZE, perc); - var_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); + var_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); if (!var_chunk) { *req = 1; msg = "Not enough free space for /var - you will need to\n" @@ -1236,21 +1245,24 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } var_chunk->private_data = new_part("/var", TRUE, var_chunk->size); var_chunk->private_free = safe_free; + var_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } - if (!vartmpdev && !variable_get(VAR_NO_VARTMP)) { + if (!tmpdev && !variable_get(VAR_NO_VARTMP)) { sz = requested_part_size(VAR_VARTMP_SIZE, VARTMP_NOMINAL_SIZE, VARTMP_DEFAULT_SIZE, perc); - vartmp_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); - if (!vartmp_chunk) { + tmp_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); + if (!tmp_chunk) { *req = 1; msg = "Not enough free space for /var/tmp - you will need to\n" "partition your disk manually with a custom install!"; goto done; } - vartmp_chunk->private_data = new_part("/var/tmp", TRUE, vartmp_chunk->size); - vartmp_chunk->private_free = safe_free; + tmp_chunk->private_data = new_part("/tmp", TRUE, tmp_chunk->size); + tmp_chunk->private_free = safe_free; + tmp_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } if (!usrdev && !variable_get(VAR_NO_USR)) { @@ -1266,8 +1278,8 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } usr_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); if (!usr_chunk) { msg = "Unable to create the /usr partition. Not enough space?\n" "You will need to partition your disk manually with a custom install!"; @@ -1275,6 +1287,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } usr_chunk->private_data = new_part("/usr", TRUE, usr_chunk->size); usr_chunk->private_free = safe_free; + usr_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } } @@ -1291,8 +1304,8 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } home_chunk = Create_Chunk_DWIM(label_chunk_info[here].c->disk, - label_chunk_info[here].c, - sz, part, FS_BSDFFS, 0); + label_chunk_info[here].c, sz, part, + FS_BSDFFS, CHUNK_AUTO_SIZE); if (!home_chunk) { msg = "Unable to create the /home partition. Not enough space?\n" "You will need to partition your disk manually with a custom install!"; @@ -1300,6 +1313,7 @@ try_auto_label(Device **devs, Device *dev, int perc, int *req) } home_chunk->private_data = new_part("/home", TRUE, home_chunk->size); home_chunk->private_free = safe_free; + home_chunk->flags |= CHUNK_NEWFS; record_label_chunks(devs, dev); } } @@ -1316,8 +1330,8 @@ done: Delete_Chunk(swap_chunk->disk, swap_chunk); if (var_chunk) Delete_Chunk(var_chunk->disk, var_chunk); - if (vartmp_chunk) - Delete_Chunk(vartmp_chunk->disk, vartmp_chunk); + if (tmp_chunk) + Delete_Chunk(tmp_chunk->disk, tmp_chunk); if (usr_chunk) Delete_Chunk(usr_chunk->disk, usr_chunk); if (home_chunk) |