gpart_ops.c (8c7de243f4f6425bf121e2eacaa9af3630eb2f5c) gpart_ops.c (db8b56134506840832bec2d1ce07b9e00d4d6d71)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 Nathan Whitehorn
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 17 unchanged lines hidden (view full) ---

26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30
31#include <sys/param.h>
32#include <sys/stat.h>
33#include <errno.h>
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 Nathan Whitehorn
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 17 unchanged lines hidden (view full) ---

26 * SUCH DAMAGE.
27 *
28 * $FreeBSD$
29 */
30
31#include <sys/param.h>
32#include <sys/stat.h>
33#include <errno.h>
34#include <fcntl.h>
34#include <libutil.h>
35#include <inttypes.h>
36
37#include <libgeom.h>
38#include <dialog.h>
39#include <dlg_keys.h>
40
41#include "partedit.h"

--- 145 unchanged lines hidden (view full) ---

187 if (choice == 1) /* Cancel */
188 return;
189 }
190
191 strcpy(command, "newfs_msdos ");
192 for (i = 0; i < (int)nitems(items); i++) {
193 if (items[i].state == 0)
194 continue;
35#include <libutil.h>
36#include <inttypes.h>
37
38#include <libgeom.h>
39#include <dialog.h>
40#include <dlg_keys.h>
41
42#include "partedit.h"

--- 145 unchanged lines hidden (view full) ---

188 if (choice == 1) /* Cancel */
189 return;
190 }
191
192 strcpy(command, "newfs_msdos ");
193 for (i = 0; i < (int)nitems(items); i++) {
194 if (items[i].state == 0)
195 continue;
195 if (strcmp(items[i].name, "FAT16") == 0)
196 if (strcmp(items[i].name, "FAT32") == 0)
197 strcat(command, "-F 32 -c 1");
198 else if (strcmp(items[i].name, "FAT16") == 0)
196 strcat(command, "-F 16 ");
197 else if (strcmp(items[i].name, "FAT12") == 0)
198 strcat(command, "-F 12 ");
199 }
200 } else {
201 if (!use_default)
202 dialog_msgbox("Error", "No configurable options exist "
203 "for this filesystem.", 0, 0, TRUE);

--- 191 unchanged lines hidden (view full) ---

395 return;
396
397 bootfd = open(bootcode, O_RDONLY);
398 if (bootfd < 0) {
399 dialog_msgbox("Bootcode Error", strerror(errno), 0, 0,
400 TRUE);
401 return;
402 }
199 strcat(command, "-F 16 ");
200 else if (strcmp(items[i].name, "FAT12") == 0)
201 strcat(command, "-F 12 ");
202 }
203 } else {
204 if (!use_default)
205 dialog_msgbox("Error", "No configurable options exist "
206 "for this filesystem.", 0, 0, TRUE);

--- 191 unchanged lines hidden (view full) ---

398 return;
399
400 bootfd = open(bootcode, O_RDONLY);
401 if (bootfd < 0) {
402 dialog_msgbox("Bootcode Error", strerror(errno), 0, 0,
403 TRUE);
404 return;
405 }
403
406
404 bootsize = lseek(bootfd, 0, SEEK_END);
405 boot = malloc(bootsize);
406 lseek(bootfd, 0, SEEK_SET);
407 bytes = 0;
408 while (bytes < bootsize)
409 bytes += read(bootfd, boot + bytes, bootsize - bytes);
410 close(bootfd);
411

--- 289 unchanged lines hidden (view full) ---

701 sprintf(md->newfs, "%s /dev/%s", newfs, name);
702 }
703 }
704 }
705
706 if (strcmp(type, "freebsd-swap") == 0)
707 mountpoint = "none";
708 if (strcmp(type, bootpart_type(scheme, &default_bootmount)) == 0) {
407 bootsize = lseek(bootfd, 0, SEEK_END);
408 boot = malloc(bootsize);
409 lseek(bootfd, 0, SEEK_SET);
410 bytes = 0;
411 while (bytes < bootsize)
412 bytes += read(bootfd, boot + bytes, bootsize - bytes);
413 close(bootfd);
414

--- 289 unchanged lines hidden (view full) ---

704 sprintf(md->newfs, "%s /dev/%s", newfs, name);
705 }
706 }
707 }
708
709 if (strcmp(type, "freebsd-swap") == 0)
710 mountpoint = "none";
711 if (strcmp(type, bootpart_type(scheme, &default_bootmount)) == 0) {
709 if (default_bootmount == NULL)
712 if (default_bootmount == NULL) {
713
714 int fd = open("/tmp/bsdinstall-esps", O_CREAT | O_WRONLY | O_APPEND,
715 0600);
716 if (fd > 0) {
717 write(fd, md->name, strlen(md->name));
718 close(fd);
719 }
720
710 md->bootcode = 1;
721 md->bootcode = 1;
722 }
711 else if (mountpoint == NULL || strlen(mountpoint) == 0)
712 mountpoint = default_bootmount;
713 }
714
715 /* VTOC8 needs partcode at the start of partitions */
716 if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0
717 || strcmp(type, "freebsd-zfs") == 0))
718 md->bootcode = 1;

--- 746 unchanged lines hidden ---
723 else if (mountpoint == NULL || strlen(mountpoint) == 0)
724 mountpoint = default_bootmount;
725 }
726
727 /* VTOC8 needs partcode at the start of partitions */
728 if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0
729 || strcmp(type, "freebsd-zfs") == 0))
730 md->bootcode = 1;

--- 746 unchanged lines hidden ---