Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bsdinstall/partedit/gpart_ops.c
Show All 25 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | |||||
imp: I'd be tempted to commit all the changes to this file separately. | |||||
#include <libutil.h> | #include <libutil.h> | ||||
#include <inttypes.h> | #include <inttypes.h> | ||||
#include <libgeom.h> | #include <libgeom.h> | ||||
#include <dialog.h> | #include <dialog.h> | ||||
#include <dlg_keys.h> | #include <dlg_keys.h> | ||||
#include "partedit.h" | #include "partedit.h" | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | if (!use_default) { | ||||
if (choice == 1) /* Cancel */ | if (choice == 1) /* Cancel */ | ||||
return; | return; | ||||
} | } | ||||
strcpy(command, "newfs_msdos "); | strcpy(command, "newfs_msdos "); | ||||
for (i = 0; i < (int)nitems(items); i++) { | for (i = 0; i < (int)nitems(items); i++) { | ||||
if (items[i].state == 0) | if (items[i].state == 0) | ||||
continue; | continue; | ||||
if (strcmp(items[i].name, "FAT16") == 0) | if (strcmp(items[i].name, "FAT32") == 0) | ||||
strcat(command, "-F 32 -c 1"); | |||||
else if (strcmp(items[i].name, "FAT16") == 0) | |||||
strcat(command, "-F 16 "); | strcat(command, "-F 16 "); | ||||
else if (strcmp(items[i].name, "FAT12") == 0) | else if (strcmp(items[i].name, "FAT12") == 0) | ||||
strcat(command, "-F 12 "); | strcat(command, "-F 12 "); | ||||
} | } | ||||
} else { | } else { | ||||
if (!use_default) | if (!use_default) | ||||
dialog_msgbox("Error", "No configurable options exist " | dialog_msgbox("Error", "No configurable options exist " | ||||
"for this filesystem.", 0, 0, TRUE); | "for this filesystem.", 0, 0, TRUE); | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | if (bootcode == NULL) | ||||
return; | return; | ||||
bootfd = open(bootcode, O_RDONLY); | bootfd = open(bootcode, O_RDONLY); | ||||
if (bootfd < 0) { | if (bootfd < 0) { | ||||
dialog_msgbox("Bootcode Error", strerror(errno), 0, 0, | dialog_msgbox("Bootcode Error", strerror(errno), 0, 0, | ||||
TRUE); | TRUE); | ||||
return; | return; | ||||
} | } | ||||
bootsize = lseek(bootfd, 0, SEEK_END); | bootsize = lseek(bootfd, 0, SEEK_END); | ||||
boot = malloc(bootsize); | boot = malloc(bootsize); | ||||
lseek(bootfd, 0, SEEK_SET); | lseek(bootfd, 0, SEEK_SET); | ||||
bytes = 0; | bytes = 0; | ||||
while (bytes < bootsize) | while (bytes < bootsize) | ||||
bytes += read(bootfd, boot + bytes, bootsize - bytes); | bytes += read(bootfd, boot + bytes, bootsize - bytes); | ||||
close(bootfd); | close(bootfd); | ||||
▲ Show 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | if (newfs != NULL && newfs[0] != '\0') { | ||||
sprintf(md->newfs, "%s /dev/%s", newfs, name); | sprintf(md->newfs, "%s /dev/%s", newfs, name); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (strcmp(type, "freebsd-swap") == 0) | if (strcmp(type, "freebsd-swap") == 0) | ||||
mountpoint = "none"; | mountpoint = "none"; | ||||
if (strcmp(type, bootpart_type(scheme, &default_bootmount)) == 0) { | if (strcmp(type, bootpart_type(scheme, &default_bootmount)) == 0) { | ||||
if (default_bootmount == NULL) | if (default_bootmount == NULL) { | ||||
int fd = open("/tmp/bsdinstall-esps", O_CREAT | O_WRONLY | O_APPEND, | |||||
Done Inline ActionsDoes this need protection against multiple invocations? imp: Does this need protection against multiple invocations?
| |||||
Done Inline ActionsI don't think so: from what I've seen bsdinstall isn't designed to have multiple copies running at the same time. bcran: I don't think so: from what I've seen bsdinstall isn't designed to have multiple copies running… | |||||
0600); | |||||
if (fd > 0) { | |||||
write(fd, md->name, strlen(md->name)); | |||||
write(fd, " ", 1); | |||||
Done Inline ActionsYou don't need this space. The shell will just eat it when you use this later. imp: You don't need this space. The shell will just eat it when you use this later. | |||||
close(fd); | |||||
} | |||||
md->bootcode = 1; | md->bootcode = 1; | ||||
} | |||||
else if (mountpoint == NULL || strlen(mountpoint) == 0) | else if (mountpoint == NULL || strlen(mountpoint) == 0) | ||||
mountpoint = default_bootmount; | mountpoint = default_bootmount; | ||||
} | } | ||||
/* VTOC8 needs partcode at the start of partitions */ | /* VTOC8 needs partcode at the start of partitions */ | ||||
if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0 | if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0 | ||||
|| strcmp(type, "freebsd-zfs") == 0)) | || strcmp(type, "freebsd-zfs") == 0)) | ||||
md->bootcode = 1; | md->bootcode = 1; | ||||
▲ Show 20 Lines • Show All 746 Lines • Show Last 20 Lines |
I'd be tempted to commit all the changes to this file separately.