2005-03-15 00:37:43 +03:00
|
|
|
/* $NetBSD: label.c,v 1.47 2005/03/14 21:37:43 dsl Exp $ */
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1997 Jonathan Stone
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1999-06-20 10:08:13 +04:00
|
|
|
* This product includes software developed for the NetBSD Project by
|
1997-12-04 14:27:56 +03:00
|
|
|
* Jonathan Stone.
|
|
|
|
* 4. The name of Jonathan Stone may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JONATHAN STONE ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
2005-03-15 00:37:43 +03:00
|
|
|
__RCSID("$NetBSD: label.c,v 1.47 2005/03/14 21:37:43 dsl Exp $");
|
1997-12-04 14:27:56 +03:00
|
|
|
#endif
|
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
#include <sys/types.h>
|
2003-06-09 23:06:48 +04:00
|
|
|
#include <stddef.h>
|
1997-12-05 17:00:59 +03:00
|
|
|
#include <errno.h>
|
1997-12-04 14:27:56 +03:00
|
|
|
#include <stdio.h>
|
1997-12-05 17:00:59 +03:00
|
|
|
#include <fcntl.h>
|
1997-12-04 14:27:56 +03:00
|
|
|
#include <util.h>
|
1997-12-05 17:00:59 +03:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/dkio.h>
|
2003-07-07 16:30:19 +04:00
|
|
|
#include <ufs/ffs/fs.h>
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "msg_defs.h"
|
|
|
|
#include "menu_defs.h"
|
|
|
|
|
2003-06-09 23:06:48 +04:00
|
|
|
struct ptn_menu_info {
|
|
|
|
int flags;
|
|
|
|
#define PIF_SHOW_UNUSED 1
|
|
|
|
};
|
|
|
|
|
1997-12-04 14:27:56 +03:00
|
|
|
/*
|
|
|
|
* local prototypes
|
|
|
|
*/
|
2003-06-16 23:42:13 +04:00
|
|
|
static int boringpart(partinfo *, int, int, int);
|
1997-12-04 14:27:56 +03:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
static int checklabel(partinfo *, int, int, int, int *, int *);
|
|
|
|
static void atofsb(const char *, int *, int *);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
/*
|
2002-07-29 05:30:25 +04:00
|
|
|
* Return 1 if partition i in lp should be ignored when checking
|
|
|
|
* for overlapping partitions.
|
1997-12-04 14:27:56 +03:00
|
|
|
*/
|
|
|
|
static int
|
2003-06-16 23:42:13 +04:00
|
|
|
boringpart(partinfo *lp, int i, int rawpart, int bsdpart)
|
1997-12-04 14:27:56 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
if (i == rawpart || i == bsdpart ||
|
1999-03-31 04:44:48 +04:00
|
|
|
lp[i].pi_fstype == FS_UNUSED || lp[i].pi_size == 0)
|
1997-12-04 14:27:56 +03:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check a sysinst label structure for overlapping partitions.
|
|
|
|
* Returns 0 if no overlapping partition found, nonzero otherwise.
|
|
|
|
* Sets reference arguments ovly1 and ovly2 to the indices of
|
|
|
|
* overlapping partitions if any are found.
|
|
|
|
*/
|
2003-07-07 16:30:19 +04:00
|
|
|
static int
|
2003-06-16 23:42:13 +04:00
|
|
|
checklabel(partinfo *lp, int nparts, int rawpart, int bsdpart,
|
|
|
|
int *ovly1, int *ovly2)
|
1997-12-04 14:27:56 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
|
|
|
|
*ovly1 = -1;
|
|
|
|
*ovly2 = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < nparts - 1; i ++ ) {
|
1999-03-31 04:44:48 +04:00
|
|
|
partinfo *ip = &lp[i];
|
1997-12-04 14:27:56 +03:00
|
|
|
int istart, istop;
|
|
|
|
|
|
|
|
/* skip unused or reserved partitions */
|
|
|
|
if (boringpart(lp, i, rawpart, bsdpart))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
2003-06-17 00:11:40 +04:00
|
|
|
* check succeeding partitions for overlap.
|
1997-12-04 14:27:56 +03:00
|
|
|
* O(n^2), but n is small (currently <= 16).
|
|
|
|
*/
|
1999-03-31 04:44:48 +04:00
|
|
|
istart = ip->pi_offset;
|
|
|
|
istop = istart + ip->pi_size;
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
for (j = i+1; j < nparts; j++) {
|
1999-03-31 04:44:48 +04:00
|
|
|
partinfo *jp = &lp[j];
|
1997-12-04 14:27:56 +03:00
|
|
|
int jstart, jstop;
|
|
|
|
|
|
|
|
/* skip unused or reserved partitions */
|
1997-12-05 17:46:01 +03:00
|
|
|
if (boringpart(lp, j, rawpart, bsdpart))
|
1997-12-04 14:27:56 +03:00
|
|
|
continue;
|
|
|
|
|
1999-03-31 04:44:48 +04:00
|
|
|
jstart = jp->pi_offset;
|
|
|
|
jstop = jstart + jp->pi_size;
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
/* overlap? */
|
|
|
|
if ((istart <= jstart && jstart < istop) ||
|
|
|
|
(jstart <= istart && istart < jstop)) {
|
|
|
|
*ovly1 = i;
|
|
|
|
*ovly2 = j;
|
1998-06-20 17:05:48 +04:00
|
|
|
return (1);
|
1997-12-04 14:27:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-20 17:05:48 +04:00
|
|
|
return (0);
|
1997-12-04 14:27:56 +03:00
|
|
|
}
|
|
|
|
|
2003-07-08 21:38:54 +04:00
|
|
|
static int
|
|
|
|
check_one_root(partinfo *lp, int nparts)
|
|
|
|
{
|
|
|
|
int part;
|
|
|
|
int foundroot = 0;
|
2004-03-26 22:55:13 +03:00
|
|
|
|
2003-07-08 21:38:54 +04:00
|
|
|
for (part = 0; part < nparts; lp++, part++) {
|
2003-11-30 17:36:43 +03:00
|
|
|
#if 0
|
2003-07-08 21:38:54 +04:00
|
|
|
if (!PI_ISBSDFS(lp))
|
|
|
|
continue;
|
2003-11-30 17:36:43 +03:00
|
|
|
#endif
|
2003-07-08 21:38:54 +04:00
|
|
|
if (!(lp->pi_flags & PIF_MOUNT))
|
|
|
|
continue;
|
|
|
|
if (strcmp(lp->pi_mount, "/") != 0)
|
|
|
|
continue;
|
|
|
|
if (foundroot)
|
2003-11-30 17:36:43 +03:00
|
|
|
/* Duplicate */
|
2003-07-08 21:38:54 +04:00
|
|
|
return 0;
|
|
|
|
foundroot = 1;
|
|
|
|
/* Save partition number, a few things need to know it */
|
|
|
|
rootpart = part;
|
|
|
|
}
|
|
|
|
return foundroot;
|
|
|
|
}
|
|
|
|
|
2003-06-09 23:06:48 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_fs_start(menudesc *m, void *arg)
|
2003-06-09 23:06:48 +04:00
|
|
|
{
|
2003-06-10 21:47:15 +04:00
|
|
|
partinfo *p = arg;
|
|
|
|
int start, size;
|
|
|
|
|
|
|
|
start = getpartoff(p->pi_offset);
|
|
|
|
size = p->pi_size;
|
|
|
|
if (size != 0) {
|
|
|
|
/* Try to keep end in the same place */
|
|
|
|
size += p->pi_offset - start;
|
|
|
|
if (size < 0)
|
|
|
|
size = 0;
|
|
|
|
p->pi_size = size;
|
|
|
|
}
|
|
|
|
p->pi_offset = start;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_fs_size(menudesc *m, void *arg)
|
2003-06-10 21:47:15 +04:00
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
size = getpartsize(p->pi_offset, p->pi_size);
|
|
|
|
if (size == -1)
|
|
|
|
size = dlsize - p->pi_offset;
|
|
|
|
p->pi_size = size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-11-30 17:36:43 +03:00
|
|
|
void
|
2005-01-21 00:59:35 +03:00
|
|
|
set_ptype(partinfo *p, int fstype, int flag)
|
2003-11-30 17:36:43 +03:00
|
|
|
{
|
2005-03-15 00:37:43 +03:00
|
|
|
p->pi_flags = (p->pi_flags & ~PIF_FFSv2) | flag;
|
2005-01-21 00:59:35 +03:00
|
|
|
|
|
|
|
if (p->pi_fstype == fstype)
|
|
|
|
return;
|
|
|
|
|
2003-11-30 17:36:43 +03:00
|
|
|
p->pi_fstype = fstype;
|
2005-01-21 00:59:35 +03:00
|
|
|
if (fstype == FS_BSDFFS || fstype == FS_BSDLFS) {
|
|
|
|
p->pi_frag = 8;
|
|
|
|
/* match newfs defaults for fragments size (2k if >= 1024MB) */
|
|
|
|
p->pi_fsize = p->pi_size > 1024*1024*1024 / 512 ? 2048 : 1024;
|
|
|
|
} else {
|
|
|
|
/* zero - fields not used */
|
|
|
|
p->pi_frag = 0;
|
|
|
|
p->pi_fsize = 0;
|
|
|
|
}
|
2003-11-30 17:36:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-06-10 21:47:15 +04:00
|
|
|
set_bsize(partinfo *p, int size)
|
|
|
|
{
|
2003-08-05 17:35:26 +04:00
|
|
|
int frags, sz;
|
2003-06-10 21:47:15 +04:00
|
|
|
|
2003-08-05 17:35:26 +04:00
|
|
|
sz = p->pi_fsize;
|
|
|
|
if (sz <= 0)
|
|
|
|
sz = 512;
|
|
|
|
frags = size / sz;
|
|
|
|
if (frags > 8)
|
|
|
|
frags = 8;
|
|
|
|
if (frags <= 0)
|
|
|
|
frags = 1;
|
2003-06-10 21:47:15 +04:00
|
|
|
|
2003-08-05 17:35:26 +04:00
|
|
|
p->pi_frag = frags;
|
|
|
|
p->pi_fsize = size / frags;
|
2003-06-10 21:47:15 +04:00
|
|
|
}
|
|
|
|
|
2003-11-30 17:36:43 +03:00
|
|
|
void
|
2003-08-05 17:35:26 +04:00
|
|
|
set_fsize(partinfo *p, int fsize)
|
2003-06-10 21:47:15 +04:00
|
|
|
{
|
2003-08-05 17:35:26 +04:00
|
|
|
int bsz = p->pi_fsize * p->pi_frag;
|
|
|
|
int frags = bsz / fsize;
|
2003-06-10 21:47:15 +04:00
|
|
|
|
2003-08-05 17:35:26 +04:00
|
|
|
if (frags > 8)
|
|
|
|
frags = 8;
|
|
|
|
if (frags <= 0)
|
|
|
|
frags = 1;
|
|
|
|
|
|
|
|
p->pi_fsize = fsize;
|
|
|
|
p->pi_frag = frags;
|
2003-06-10 21:47:15 +04:00
|
|
|
}
|
|
|
|
|
2003-08-10 01:36:26 +04:00
|
|
|
static int
|
|
|
|
edit_fs_isize(menudesc *m, void *arg)
|
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
char answer[12];
|
|
|
|
|
|
|
|
snprintf(answer, sizeof answer, "%u", p->pi_isize);
|
|
|
|
msg_prompt_win(MSG_fs_isize, -1, 18, 0, 0,
|
|
|
|
answer, answer, sizeof answer);
|
|
|
|
p->pi_isize = atol(answer);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-10 21:47:15 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_fs_preserve(menudesc *m, void *arg)
|
2003-06-10 21:47:15 +04:00
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
p->pi_flags ^= PIF_NEWFS;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_fs_mount(menudesc *m, void *arg)
|
2003-07-07 16:30:19 +04:00
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
|
|
|
|
p->pi_flags ^= PIF_MOUNT;
|
2003-06-10 21:47:15 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_fs_mountpt(menudesc *m, void *arg)
|
2003-06-10 21:47:15 +04:00
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
2003-07-07 16:30:19 +04:00
|
|
|
|
|
|
|
msg_prompt_win(MSG_mountpoint, -1, 18, 0, 0,
|
|
|
|
p->pi_mount, p->pi_mount, sizeof p->pi_mount);
|
|
|
|
|
|
|
|
if (p->pi_mount[0] == ' ' || strcmp(p->pi_mount, "none") == 0) {
|
|
|
|
p->pi_mount[0] = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->pi_mount[0] != '/') {
|
|
|
|
memmove(p->pi_mount + 1, p->pi_mount,
|
|
|
|
sizeof p->pi_mount - 1);
|
|
|
|
p->pi_mount[sizeof p->pi_mount - 1] = 0;
|
|
|
|
p->pi_mount[0] = '/';
|
2003-06-10 21:47:15 +04:00
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-10 21:47:15 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_restore(menudesc *m, void *arg)
|
2003-06-10 21:47:15 +04:00
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
p->pi_flags |= PIF_RESET;
|
2003-06-10 21:47:15 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-07-27 11:45:08 +04:00
|
|
|
static int
|
|
|
|
set_fstype(menudesc *m, void *arg)
|
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
|
2003-08-05 17:35:26 +04:00
|
|
|
if (m->cursel == FS_UNUSED)
|
|
|
|
memset(p, 0, sizeof *p);
|
|
|
|
else
|
|
|
|
p->pi_fstype = m->cursel;
|
2003-07-27 11:45:08 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_fstype(menudesc *m, void *arg)
|
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
|
|
|
|
m->cursel = p->pi_fstype;
|
|
|
|
}
|
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
static void set_ptn_header(menudesc *m, void *arg);
|
2003-07-07 16:30:19 +04:00
|
|
|
static void set_ptn_label(menudesc *m, int opt, void *arg);
|
2003-07-27 11:45:08 +04:00
|
|
|
int all_fstype_menu = -1;
|
2003-07-07 16:30:19 +04:00
|
|
|
|
2003-06-09 23:06:48 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
edit_ptn(menudesc *menu, void *arg)
|
2003-06-09 23:06:48 +04:00
|
|
|
{
|
2003-06-10 21:47:15 +04:00
|
|
|
static menu_ent fs_fields[] = {
|
2003-07-07 16:30:19 +04:00
|
|
|
#define PTN_MENU_FSKIND 0
|
|
|
|
{NULL, MENU_selfskind, OPT_SUB, NULL},
|
|
|
|
#define PTN_MENU_START 1
|
|
|
|
{NULL, OPT_NOMENU, 0, edit_fs_start},
|
|
|
|
#define PTN_MENU_SIZE 2
|
|
|
|
{NULL, OPT_NOMENU, 0, edit_fs_size},
|
|
|
|
#define PTN_MENU_END 3
|
|
|
|
{NULL, OPT_NOMENU, OPT_IGNORE, NULL}, /* displays 'end' */
|
2003-11-30 17:36:43 +03:00
|
|
|
#define PTN_MENU_NEWFS 4
|
|
|
|
{NULL, OPT_NOMENU, 0, edit_fs_preserve},
|
|
|
|
#define PTN_MENU_ISIZE 5
|
|
|
|
{NULL, OPT_NOMENU, 0, edit_fs_isize},
|
|
|
|
#define PTN_MENU_BSIZE 6
|
2003-07-07 16:30:19 +04:00
|
|
|
{NULL, MENU_selbsize, OPT_SUB, NULL},
|
2003-11-30 17:36:43 +03:00
|
|
|
#define PTN_MENU_FSIZE 7
|
2003-07-07 16:30:19 +04:00
|
|
|
{NULL, MENU_selfsize, OPT_SUB, NULL},
|
2003-08-10 01:36:26 +04:00
|
|
|
#define PTN_MENU_MOUNT 8
|
2003-07-07 16:30:19 +04:00
|
|
|
{NULL, OPT_NOMENU, 0, edit_fs_mount},
|
2003-08-10 01:36:26 +04:00
|
|
|
#define PTN_MENU_MOUNTOPT 9
|
2003-08-05 17:35:26 +04:00
|
|
|
{NULL, MENU_mountoptions, OPT_SUB, NULL},
|
2003-08-10 01:36:26 +04:00
|
|
|
#define PTN_MENU_MOUNTPT 10
|
2003-07-07 16:30:19 +04:00
|
|
|
{NULL, OPT_NOMENU, 0, edit_fs_mountpt},
|
2003-06-10 21:47:15 +04:00
|
|
|
{MSG_askunits, MENU_sizechoice, OPT_SUB, NULL},
|
|
|
|
{MSG_restore, OPT_NOMENU, 0, edit_restore},
|
|
|
|
};
|
|
|
|
static int fspart_menu = -1;
|
2003-07-27 11:45:08 +04:00
|
|
|
static menu_ent all_fstypes[FSMAXTYPES];
|
2003-06-10 21:47:15 +04:00
|
|
|
partinfo *p, p_save;
|
2003-07-27 11:45:08 +04:00
|
|
|
int i;
|
2003-06-10 21:47:15 +04:00
|
|
|
|
|
|
|
if (fspart_menu == -1) {
|
|
|
|
fspart_menu = new_menu(NULL, fs_fields, nelem(fs_fields),
|
2003-10-20 00:17:31 +04:00
|
|
|
0, -1, 0, 70,
|
2003-06-10 21:47:15 +04:00
|
|
|
MC_NOBOX | MC_NOCLEAR | MC_SCROLL,
|
2003-07-07 16:30:19 +04:00
|
|
|
set_ptn_header, set_ptn_label, NULL,
|
2003-06-10 21:47:15 +04:00
|
|
|
NULL, MSG_partition_sizes_ok);
|
|
|
|
}
|
|
|
|
|
2003-07-27 11:45:08 +04:00
|
|
|
if (all_fstype_menu == -1) {
|
|
|
|
for (i = 0; i < nelem(all_fstypes); i++) {
|
|
|
|
all_fstypes[i].opt_name = fstypenames[i];
|
|
|
|
all_fstypes[i].opt_menu = OPT_NOMENU;
|
|
|
|
all_fstypes[i].opt_flags = 0;
|
|
|
|
all_fstypes[i].opt_action = set_fstype;
|
|
|
|
}
|
|
|
|
all_fstype_menu = new_menu(MSG_Select_the_type,
|
|
|
|
all_fstypes, nelem(all_fstypes),
|
2004-08-14 20:06:36 +04:00
|
|
|
30, 6, 10, 0, MC_SUBMENU | MC_SCROLL,
|
2003-07-27 11:45:08 +04:00
|
|
|
get_fstype, NULL, NULL, NULL, MSG_unchanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = bsdlabel + menu->cursel;
|
2003-07-07 16:30:19 +04:00
|
|
|
p->pi_flags &= ~PIF_RESET;
|
2003-06-10 21:47:15 +04:00
|
|
|
p_save = *p;
|
|
|
|
for (;;) {
|
|
|
|
process_menu(fspart_menu, p);
|
2003-07-07 16:30:19 +04:00
|
|
|
if (!(p->pi_flags & PIF_RESET))
|
2003-06-10 21:47:15 +04:00
|
|
|
break;
|
|
|
|
*p = p_save;
|
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
|
2003-06-10 21:47:15 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
static void
|
|
|
|
set_ptn_header(menudesc *m, void *arg)
|
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
|
|
|
int i;
|
2003-11-30 17:36:43 +03:00
|
|
|
int t;
|
2003-10-20 00:17:31 +04:00
|
|
|
|
|
|
|
msg_clear();
|
|
|
|
msg_table_add(MSG_edfspart, 'a' + (p - bsdlabel));
|
|
|
|
|
2003-11-30 17:36:43 +03:00
|
|
|
/* Determine which of the properties can be changed */
|
2003-10-20 00:17:31 +04:00
|
|
|
for (i = PTN_MENU_START; i <= PTN_MENU_MOUNTPT; i++) {
|
2003-11-30 17:36:43 +03:00
|
|
|
/* Default to disabled... */
|
2003-10-20 00:17:31 +04:00
|
|
|
m->opts[i].opt_flags |= OPT_IGNORE;
|
2003-11-30 17:36:43 +03:00
|
|
|
t = p->pi_fstype;
|
|
|
|
if (i == PTN_MENU_END)
|
|
|
|
/* The 'end address' is calculated from the size */
|
2003-10-20 00:17:31 +04:00
|
|
|
continue;
|
2003-11-30 17:36:43 +03:00
|
|
|
if (t == FS_UNUSED || (t == FS_SWAP && i > PTN_MENU_END)) {
|
|
|
|
/* Nothing after 'size' can be set for swap/unused */
|
|
|
|
p->pi_flags &= ~(PIF_NEWFS | PIF_MOUNT);
|
|
|
|
p->pi_mount[0] = 0;
|
2003-10-20 00:17:31 +04:00
|
|
|
continue;
|
2003-11-30 17:36:43 +03:00
|
|
|
}
|
|
|
|
if (i == PTN_MENU_NEWFS && t != FS_BSDFFS && t != FS_BSDLFS
|
|
|
|
&& t != FS_APPLEUFS) {
|
|
|
|
/* Can only newfs UFS and LFS filesystems */
|
|
|
|
p->pi_flags &= ~PIF_NEWFS;
|
2003-10-20 00:17:31 +04:00
|
|
|
continue;
|
2003-11-30 17:36:43 +03:00
|
|
|
}
|
|
|
|
if (i >= PTN_MENU_ISIZE && i <= PTN_MENU_FSIZE) {
|
|
|
|
/* Parameters for newfs... */
|
|
|
|
if (!(p->pi_flags & PIF_NEWFS))
|
|
|
|
/* Not if we aren't going to run newfs */
|
|
|
|
continue;
|
|
|
|
if (t == FS_APPLEUFS && i != PTN_MENU_ISIZE)
|
|
|
|
/* Can only set # inodes for appleufs */
|
|
|
|
continue;
|
2005-01-21 00:59:35 +03:00
|
|
|
if (t == FS_BSDLFS && i != PTN_MENU_BSIZE)
|
2003-11-30 17:36:43 +03:00
|
|
|
/* LFS doesn't have fragments */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* Ok: we want this one */
|
2003-10-20 00:17:31 +04:00
|
|
|
m->opts[i].opt_flags &= ~OPT_IGNORE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
disp_sector_count(menudesc *m, msg fmt, uint s)
|
|
|
|
{
|
|
|
|
uint ms = MEG / sectorsize;
|
|
|
|
|
|
|
|
wprintw(m->mw, msg_string(fmt),
|
|
|
|
s / ms, s / dlcylsize, s % dlcylsize ? '*' : ' ', s );
|
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
static void
|
|
|
|
set_ptn_label(menudesc *m, int opt, void *arg)
|
|
|
|
{
|
|
|
|
partinfo *p = arg;
|
2003-11-30 17:36:43 +03:00
|
|
|
const char *c;
|
2003-10-20 00:17:31 +04:00
|
|
|
|
|
|
|
if (m->opts[opt].opt_flags & OPT_IGNORE
|
|
|
|
&& (opt != PTN_MENU_END || p->pi_fstype == FS_UNUSED)) {
|
|
|
|
wprintw(m->mw, " -");
|
|
|
|
return;
|
|
|
|
}
|
2003-07-07 16:30:19 +04:00
|
|
|
|
|
|
|
switch (opt) {
|
|
|
|
case PTN_MENU_FSKIND:
|
2003-11-30 17:36:43 +03:00
|
|
|
if (p->pi_fstype == FS_BSDFFS)
|
|
|
|
if (p->pi_flags & PIF_FFSv2)
|
|
|
|
c = "FFSv2";
|
|
|
|
else
|
|
|
|
c = "FFSv1";
|
|
|
|
else
|
|
|
|
c = fstypenames[p->pi_fstype];
|
|
|
|
wprintw(m->mw, msg_string(MSG_fstype_fmt), c);
|
2003-07-07 16:30:19 +04:00
|
|
|
break;
|
|
|
|
case PTN_MENU_START:
|
2003-10-20 00:17:31 +04:00
|
|
|
disp_sector_count(m, MSG_start_fmt, p->pi_offset);
|
2003-07-07 16:30:19 +04:00
|
|
|
break;
|
|
|
|
case PTN_MENU_SIZE:
|
2003-10-20 00:17:31 +04:00
|
|
|
disp_sector_count(m, MSG_size_fmt, p->pi_size);
|
2003-07-07 16:30:19 +04:00
|
|
|
break;
|
|
|
|
case PTN_MENU_END:
|
2003-10-20 00:17:31 +04:00
|
|
|
disp_sector_count(m, MSG_end_fmt, p->pi_offset + p->pi_size);
|
2003-07-07 16:30:19 +04:00
|
|
|
break;
|
2003-11-30 17:36:43 +03:00
|
|
|
case PTN_MENU_NEWFS:
|
|
|
|
wprintw(m->mw, msg_string(MSG_newfs_fmt),
|
|
|
|
msg_string(p->pi_flags & PIF_NEWFS ? MSG_Yes : MSG_No));
|
|
|
|
break;
|
|
|
|
case PTN_MENU_ISIZE:
|
|
|
|
wprintw(m->mw, msg_string(p->pi_isize > 0 ?
|
|
|
|
MSG_isize_fmt : MSG_isize_fmt_dflt), p->pi_isize);
|
|
|
|
break;
|
2003-08-05 17:35:26 +04:00
|
|
|
case PTN_MENU_BSIZE:
|
2003-10-20 00:17:31 +04:00
|
|
|
wprintw(m->mw, msg_string(MSG_bsize_fmt),
|
|
|
|
p->pi_fsize * p->pi_frag);
|
2003-07-07 16:30:19 +04:00
|
|
|
break;
|
2003-08-05 17:35:26 +04:00
|
|
|
case PTN_MENU_FSIZE:
|
2003-10-20 00:17:31 +04:00
|
|
|
wprintw(m->mw, msg_string(MSG_fsize_fmt), p->pi_fsize);
|
2003-08-10 01:36:26 +04:00
|
|
|
break;
|
2003-07-07 16:30:19 +04:00
|
|
|
case PTN_MENU_MOUNT:
|
|
|
|
wprintw(m->mw, msg_string(MSG_mount_fmt),
|
|
|
|
msg_string(p->pi_flags & PIF_MOUNT ? MSG_Yes : MSG_No));
|
|
|
|
break;
|
2003-08-05 17:35:26 +04:00
|
|
|
case PTN_MENU_MOUNTOPT:
|
|
|
|
wprintw(m->mw, msg_string(MSG_mount_options_fmt));
|
|
|
|
if (p->pi_flags & PIF_ASYNC)
|
|
|
|
wprintw(m->mw, "async ");
|
|
|
|
if (p->pi_flags & PIF_NOATIME)
|
|
|
|
wprintw(m->mw, "noatime ");
|
2003-08-10 18:51:48 +04:00
|
|
|
if (p->pi_flags & PIF_NODEV)
|
|
|
|
wprintw(m->mw, "nodev ");
|
2003-08-05 17:35:26 +04:00
|
|
|
if (p->pi_flags & PIF_NODEVMTIME)
|
|
|
|
wprintw(m->mw, "nodevmtime ");
|
2003-08-10 18:51:48 +04:00
|
|
|
if (p->pi_flags & PIF_NOEXEC)
|
|
|
|
wprintw(m->mw, "noexec ");
|
|
|
|
if (p->pi_flags & PIF_NOSUID)
|
|
|
|
wprintw(m->mw, "nosuid ");
|
2003-08-05 17:35:26 +04:00
|
|
|
if (p->pi_flags & PIF_SOFTDEP)
|
|
|
|
wprintw(m->mw, "softdep ");
|
|
|
|
break;
|
2003-07-07 16:30:19 +04:00
|
|
|
case PTN_MENU_MOUNTPT:
|
|
|
|
wprintw(m->mw, msg_string(MSG_mountpt_fmt), p->pi_mount);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-10 21:47:15 +04:00
|
|
|
static int
|
2003-07-27 11:45:08 +04:00
|
|
|
show_all_unused(menudesc *m, void *arg)
|
2003-06-10 21:47:15 +04:00
|
|
|
{
|
|
|
|
struct ptn_menu_info *pi = arg;
|
|
|
|
|
|
|
|
pi->flags |= PIF_SHOW_UNUSED;
|
2003-06-09 23:06:48 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_label_texts(menudesc *menu, void *arg)
|
|
|
|
{
|
|
|
|
struct ptn_menu_info *pi = arg;
|
|
|
|
menu_ent *m;
|
2003-08-05 17:35:26 +04:00
|
|
|
int ptn, show_unused_ptn;
|
2003-06-09 23:06:48 +04:00
|
|
|
int rawptn = getrawpartition();
|
|
|
|
int maxpart = getmaxpartitions();
|
|
|
|
|
2003-11-30 17:36:43 +03:00
|
|
|
msg_display(MSG_fspart);
|
|
|
|
msg_table_add(MSG_fspart_header, multname, multname, multname);
|
2003-06-09 23:06:48 +04:00
|
|
|
|
2003-08-05 17:35:26 +04:00
|
|
|
for (show_unused_ptn = 0, ptn = 0; ptn < maxpart; ptn++) {
|
2003-06-09 23:06:48 +04:00
|
|
|
m = &menu->opts[ptn];
|
|
|
|
m->opt_menu = OPT_NOMENU;
|
2003-07-07 16:30:19 +04:00
|
|
|
m->opt_name = NULL;
|
2003-08-05 17:35:26 +04:00
|
|
|
m->opt_action = edit_ptn;
|
2003-06-09 23:06:48 +04:00
|
|
|
if (ptn == rawptn
|
|
|
|
#ifdef PART_BOOT
|
|
|
|
|| ptn == PART_BOOT
|
|
|
|
#endif
|
2003-11-30 17:36:43 +03:00
|
|
|
|| ptn == PART_C) {
|
2003-07-07 16:30:19 +04:00
|
|
|
m->opt_flags = OPT_IGNORE;
|
2003-08-05 17:35:26 +04:00
|
|
|
} else {
|
2003-07-07 16:30:19 +04:00
|
|
|
m->opt_flags = 0;
|
2003-08-05 17:35:26 +04:00
|
|
|
if (bsdlabel[ptn].pi_fstype == FS_UNUSED)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
show_unused_ptn = ptn + 2;
|
2003-06-09 23:06:48 +04:00
|
|
|
}
|
|
|
|
|
2003-08-05 17:35:26 +04:00
|
|
|
if (!(pi->flags & PIF_SHOW_UNUSED) && ptn > show_unused_ptn) {
|
|
|
|
ptn = show_unused_ptn;
|
2003-06-09 23:06:48 +04:00
|
|
|
m = &menu->opts[ptn];
|
2003-06-10 21:47:15 +04:00
|
|
|
m->opt_name = MSG_show_all_unused_partitions;
|
2003-06-09 23:06:48 +04:00
|
|
|
m->opt_action = show_all_unused;
|
|
|
|
ptn++;
|
|
|
|
}
|
|
|
|
|
|
|
|
m = &menu->opts[ptn];
|
|
|
|
m->opt_menu = MENU_sizechoice;
|
|
|
|
m->opt_flags = OPT_SUB;
|
|
|
|
m->opt_action = NULL;
|
2003-06-10 21:47:15 +04:00
|
|
|
m->opt_name = MSG_askunits;
|
2003-06-09 23:06:48 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
menu->numopts = ptn + 1;
|
2003-06-09 23:06:48 +04:00
|
|
|
}
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check a disklabel.
|
2003-06-17 00:11:40 +04:00
|
|
|
* If there are overlapping active partitions,
|
|
|
|
* Ask the user if they want to edit the partition or give up.
|
1997-12-04 14:27:56 +03:00
|
|
|
*/
|
|
|
|
int
|
2003-06-16 23:42:13 +04:00
|
|
|
edit_and_check_label(partinfo *lp, int nparts, int rawpart, int bsdpart)
|
1997-12-04 14:27:56 +03:00
|
|
|
{
|
2003-06-09 23:06:48 +04:00
|
|
|
static struct menu_ent *menu;
|
2003-07-07 16:30:19 +04:00
|
|
|
static int menu_no = -1;
|
|
|
|
static struct ptn_menu_info pi;
|
2003-06-09 23:06:48 +04:00
|
|
|
int maxpart = getmaxpartitions();
|
|
|
|
|
|
|
|
if (menu == NULL) {
|
|
|
|
menu = malloc((maxpart + 1) * sizeof *menu);
|
2003-07-07 16:30:19 +04:00
|
|
|
if (!menu)
|
2003-06-09 23:06:48 +04:00
|
|
|
return 1;
|
2003-07-07 16:30:19 +04:00
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (menu_no == -1) {
|
|
|
|
menu_no = new_menu(NULL, menu, maxpart + 1,
|
2003-10-20 00:17:31 +04:00
|
|
|
0, -1, maxpart + 2, 74,
|
|
|
|
MC_ALWAYS_SCROLL | MC_NOBOX | MC_DFLTEXIT,
|
2003-07-07 16:30:19 +04:00
|
|
|
set_label_texts, fmt_fspart, NULL, NULL,
|
2003-06-10 21:47:15 +04:00
|
|
|
MSG_partition_sizes_ok);
|
2003-06-09 23:06:48 +04:00
|
|
|
}
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (menu_no < 0)
|
2003-06-09 23:06:48 +04:00
|
|
|
return 1;
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
pi.flags = 0;
|
|
|
|
current_cylsize = dlcylsize;
|
|
|
|
|
2003-01-10 23:00:27 +03:00
|
|
|
for (;;) {
|
2002-07-29 05:30:25 +04:00
|
|
|
int i, j;
|
1997-12-04 14:27:56 +03:00
|
|
|
|
2002-07-29 05:30:25 +04:00
|
|
|
/* first give the user the option to edit the label... */
|
2003-07-07 16:30:19 +04:00
|
|
|
process_menu(menu_no, &pi);
|
1997-12-04 14:27:56 +03:00
|
|
|
|
2003-07-08 21:38:54 +04:00
|
|
|
/* User thinks the label is OK. */
|
|
|
|
/* check we have a single root fs */
|
|
|
|
if (check_one_root(lp, nparts) == 0)
|
|
|
|
msg_display(MSG_must_be_one_root);
|
|
|
|
else
|
|
|
|
/* Check for overlaps */
|
|
|
|
if (checklabel(lp, nparts, rawpart, bsdpart, &i, &j))
|
|
|
|
/* partitions overlap */
|
|
|
|
msg_display(MSG_partitions_overlap,'a'+i,'a'+j);
|
|
|
|
else
|
|
|
|
return 1;
|
2004-03-26 22:55:13 +03:00
|
|
|
|
2003-07-08 21:38:54 +04:00
|
|
|
/*XXX ???*/
|
2002-07-29 05:30:25 +04:00
|
|
|
msg_display_add(MSG_edit_partitions_again);
|
2003-06-03 15:54:48 +04:00
|
|
|
process_menu(MENU_yesno, NULL);
|
2002-07-29 05:30:25 +04:00
|
|
|
if (!yesno)
|
|
|
|
return(0);
|
|
|
|
}
|
1997-12-04 14:27:56 +03:00
|
|
|
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
|
|
|
|
1997-12-05 17:00:59 +03:00
|
|
|
/*
|
2003-06-17 00:11:40 +04:00
|
|
|
* Read a label from disk into a sysinst label structure.
|
1997-12-05 17:00:59 +03:00
|
|
|
*/
|
1998-06-20 17:05:48 +04:00
|
|
|
int
|
2003-06-16 23:42:13 +04:00
|
|
|
incorelabel(const char *dkname, partinfo *lp)
|
1997-12-05 17:00:59 +03:00
|
|
|
{
|
|
|
|
struct disklabel lab;
|
|
|
|
int i, maxpart;
|
|
|
|
struct partition *pp;
|
2003-07-07 16:30:19 +04:00
|
|
|
int fd;
|
|
|
|
char buf[64];
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
if (get_real_geom(dkname, &lab) == 0)
|
|
|
|
return -1;
|
1997-12-05 17:00:59 +03:00
|
|
|
|
1999-01-21 11:02:17 +03:00
|
|
|
touchwin(stdscr);
|
1997-12-05 17:00:59 +03:00
|
|
|
maxpart = getmaxpartitions();
|
2003-07-07 16:30:19 +04:00
|
|
|
if (maxpart > MAXPARTITIONS)
|
|
|
|
maxpart = MAXPARTITIONS;
|
|
|
|
if (maxpart > lab.d_npartitions)
|
|
|
|
maxpart = lab.d_npartitions;
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2003-10-20 00:17:31 +04:00
|
|
|
/*
|
|
|
|
* Historically sysinst writes the name to d_typename rather
|
|
|
|
* than d_diskname. Who knows why, but pull the value back here.
|
|
|
|
*/
|
|
|
|
if (lab.d_typename[0] != 0 && strcmp(lab.d_typename, "unknown") != 0)
|
|
|
|
strlcpy(bsddiskname, lab.d_typename, sizeof bsddiskname);
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
fd = opendisk(dkname, O_RDONLY, buf, sizeof buf, 0);
|
1997-12-05 17:00:59 +03:00
|
|
|
pp = &lab.d_partitions[0];
|
2003-07-07 16:30:19 +04:00
|
|
|
for (i = 0; i < maxpart; lp++, pp++, i++) {
|
|
|
|
lp->pi_partition = *pp;
|
2003-07-27 11:45:08 +04:00
|
|
|
if (lp->pi_fstype >= FSMAXTYPES)
|
|
|
|
lp->pi_fstype = FS_OTHER;
|
2003-07-07 16:30:19 +04:00
|
|
|
strlcpy(lp->pi_mount, get_last_mounted(fd, pp->p_offset),
|
|
|
|
sizeof lp->pi_mount);
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
2003-07-07 16:30:19 +04:00
|
|
|
if (fd != -1)
|
|
|
|
close(fd);
|
1997-12-05 17:00:59 +03:00
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to get 'last mounted on' (or equiv) from fs superblock.
|
|
|
|
*/
|
|
|
|
const char *
|
|
|
|
get_last_mounted(int fd, int partstart)
|
|
|
|
{
|
|
|
|
static char sblk[SBLOCKSIZE]; /* is this enough? */
|
2004-03-26 22:55:13 +03:00
|
|
|
#define SB ((struct fs *)sblk)
|
2003-07-07 16:30:19 +04:00
|
|
|
const static int sblocks[] = SBLOCKSEARCH;
|
|
|
|
const int *sbp;
|
|
|
|
char *cp;
|
2003-07-25 12:26:21 +04:00
|
|
|
const char *mnt = "";
|
2003-07-07 16:30:19 +04:00
|
|
|
int l;
|
|
|
|
|
|
|
|
if (fd == -1)
|
|
|
|
return mnt;
|
|
|
|
|
|
|
|
/* Check UFS1/2 (and hence LFS) superblock */
|
|
|
|
for (sbp = sblocks; *mnt == 0 && *sbp != -1; sbp++) {
|
|
|
|
if (pread(fd, sblk, sizeof sblk,
|
|
|
|
partstart * (off_t)512 + *sbp) != sizeof sblk)
|
|
|
|
continue;
|
|
|
|
/* Maybe we should validate the checksum??? */
|
|
|
|
switch (((struct fs *)sblk)->fs_magic) {
|
|
|
|
case FS_UFS1_MAGIC:
|
|
|
|
case FS_UFS1_MAGIC_SWAPPED:
|
2004-03-26 22:55:13 +03:00
|
|
|
if (!(SB->fs_old_flags & FS_FLAGS_UPDATED)) {
|
|
|
|
if (*sbp == SBLOCK_UFS1)
|
|
|
|
mnt = SB->fs_fsmnt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case FS_UFS2_MAGIC:
|
2003-07-07 16:30:19 +04:00
|
|
|
case FS_UFS2_MAGIC_SWAPPED:
|
2004-03-26 22:55:13 +03:00
|
|
|
/* Check we have the main superblock */
|
|
|
|
if (SB->fs_sblockloc == *sbp)
|
|
|
|
mnt = SB->fs_fsmnt;
|
2003-07-07 16:30:19 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 /* Requires fs/ext2fs/ext2fs.h which collides badly... */
|
|
|
|
if ((struct ext2fs *)sblk)->e2fs_magic == E2FS_MAGIC) {
|
|
|
|
mnt = ((struct ext2fs *)sblk)->e2fs_fsmnt;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (*sbp != 0)
|
|
|
|
continue;
|
|
|
|
|
2003-07-27 11:45:08 +04:00
|
|
|
/* If start of partition check for other fs types */
|
2003-07-07 16:30:19 +04:00
|
|
|
if (sblk[0x42] == 0x29 && memcmp(sblk + 0x52, "FAT", 3) == 0) {
|
|
|
|
/* Probably a FAT filesystem, report volume name */
|
|
|
|
cp = strchr(sblk + 0x47, ' ');
|
|
|
|
if (cp == NULL || cp - (sblk + 0x47) > 11)
|
|
|
|
cp = sblk + 0x47 + 11;
|
|
|
|
*cp = 0;
|
|
|
|
return sblk + 0x47;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If sysinst mounted this last then strip prefix */
|
|
|
|
l = strlen(targetroot_mnt);
|
|
|
|
if (memcmp(mnt, targetroot_mnt, l) == 0) {
|
|
|
|
if (mnt[l] == 0)
|
|
|
|
return "/";
|
|
|
|
if (mnt[l] == '/')
|
|
|
|
return mnt + l;
|
|
|
|
}
|
|
|
|
return mnt;
|
2004-03-26 22:55:13 +03:00
|
|
|
#undef SB
|
1997-12-05 17:00:59 +03:00
|
|
|
}
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
|
2002-07-29 05:30:25 +04:00
|
|
|
/* Ask for a partition offset, check bounds and do the needed roundups */
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
int
|
2003-06-10 21:47:15 +04:00
|
|
|
getpartoff(int defpartstart)
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
{
|
2003-06-10 21:47:15 +04:00
|
|
|
char defsize[20], isize[20], maxpartc;
|
2000-10-17 23:44:28 +04:00
|
|
|
int i, localsizemult, partn;
|
2003-06-10 21:47:15 +04:00
|
|
|
const char *errmsg = "\n";
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
|
2000-10-17 23:44:28 +04:00
|
|
|
maxpartc = 'a' + getmaxpartitions() - 1;
|
2003-01-10 23:00:27 +03:00
|
|
|
for (;;) {
|
2003-06-10 21:47:15 +04:00
|
|
|
snprintf(defsize, sizeof defsize, "%d", defpartstart/sizemult);
|
|
|
|
msg_prompt_win(MSG_label_offset, -1, 13, 70, 9,
|
|
|
|
(defpartstart > 0) ? defsize : NULL, isize, sizeof isize,
|
|
|
|
errmsg, maxpartc, maxpartc, multname);
|
|
|
|
if (strcmp(defsize, isize) == 0)
|
|
|
|
/* Don't do rounding if default accepted */
|
|
|
|
return defpartstart;
|
2000-10-17 23:44:28 +04:00
|
|
|
if (isize[1] == '\0' && isize[0] >= 'a' &&
|
|
|
|
isize[0] <= maxpartc) {
|
|
|
|
partn = isize[0] - 'a';
|
|
|
|
i = bsdlabel[partn].pi_size + bsdlabel[partn].pi_offset;
|
|
|
|
localsizemult = 1;
|
|
|
|
} else if (atoi(isize) == -1) {
|
|
|
|
i = ptstart;
|
|
|
|
localsizemult = 1;
|
|
|
|
} else
|
|
|
|
atofsb(isize, &i, &localsizemult);
|
2003-06-10 21:47:15 +04:00
|
|
|
if (i < 0) {
|
|
|
|
errmsg = msg_string(MSG_invalid_sector_number);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
continue;
|
2003-06-10 21:47:15 +04:00
|
|
|
}
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
/* round to cylinder size if localsizemult != 1 */
|
|
|
|
i = NUMSEC(i/localsizemult, localsizemult, dlcylsize);
|
|
|
|
/* Adjust to start of slice if needed */
|
|
|
|
if ((i < ptstart && (ptstart - i) < localsizemult) ||
|
|
|
|
(i > ptstart && (i - ptstart) < localsizemult)) {
|
|
|
|
i = ptstart;
|
|
|
|
}
|
2003-06-10 21:47:15 +04:00
|
|
|
if (i <= dlsize)
|
|
|
|
break;
|
|
|
|
errmsg = msg_string(MSG_startoutsidedisk);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
}
|
2003-06-10 21:47:15 +04:00
|
|
|
return i;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-17 00:11:40 +04:00
|
|
|
/* Ask for a partition size, check bounds and do the needed roundups */
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
int
|
2003-06-10 21:47:15 +04:00
|
|
|
getpartsize(int partstart, int defpartsize)
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
{
|
2003-06-10 21:47:15 +04:00
|
|
|
char dsize[20], isize[20], maxpartc;
|
|
|
|
const char *errmsg = "\n";
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
int i, partend, localsizemult;
|
2003-05-21 14:05:20 +04:00
|
|
|
int fsptend = ptstart + ptsize;
|
2000-10-17 23:44:28 +04:00
|
|
|
int partn;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
|
2000-10-17 23:44:28 +04:00
|
|
|
maxpartc = 'a' + getmaxpartitions() - 1;
|
2003-01-10 23:00:27 +03:00
|
|
|
for (;;) {
|
2003-06-10 21:47:15 +04:00
|
|
|
snprintf(dsize, sizeof dsize, "%d", defpartsize/sizemult);
|
|
|
|
msg_prompt_win(MSG_label_size, -1, 12, 70, 9,
|
|
|
|
(defpartsize != 0) ? dsize : 0, isize, sizeof isize,
|
|
|
|
errmsg, maxpartc, multname);
|
|
|
|
if (strcmp(isize, dsize) == 0)
|
|
|
|
return defpartsize;
|
2000-10-17 23:44:28 +04:00
|
|
|
if (isize[1] == '\0' && isize[0] >= 'a' &&
|
|
|
|
isize[0] <= maxpartc) {
|
|
|
|
partn = isize[0] - 'a';
|
|
|
|
i = bsdlabel[partn].pi_offset - partstart;
|
|
|
|
localsizemult = 1;
|
|
|
|
} else if (atoi(isize) == -1) {
|
|
|
|
i = fsptend - partstart;
|
|
|
|
localsizemult = 1;
|
|
|
|
} else
|
|
|
|
atofsb(isize, &i, &localsizemult);
|
2003-06-10 21:47:15 +04:00
|
|
|
if (i < 0) {
|
|
|
|
errmsg = msg_string(MSG_invalid_sector_number);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
continue;
|
2003-06-10 21:47:15 +04:00
|
|
|
}
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
/*
|
|
|
|
* partend is aligned to a cylinder if localsizemult
|
|
|
|
* is not 1 sector
|
|
|
|
*/
|
|
|
|
partend = NUMSEC((partstart + i) / localsizemult,
|
|
|
|
localsizemult, dlcylsize);
|
2002-07-26 05:00:39 +04:00
|
|
|
/* Align to end-of-disk or end-of-slice if close enough */
|
2003-06-10 21:47:15 +04:00
|
|
|
i = dlsize - partend;
|
|
|
|
if (i > -localsizemult && i < localsizemult)
|
2003-05-21 14:05:20 +04:00
|
|
|
partend = dlsize;
|
2003-06-10 21:47:15 +04:00
|
|
|
i = fsptend - partend;
|
|
|
|
if (i > -localsizemult && i < localsizemult)
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
partend = fsptend;
|
|
|
|
/* sanity checks */
|
2003-05-21 14:05:20 +04:00
|
|
|
if (partend > dlsize) {
|
|
|
|
partend = dlsize;
|
2003-06-10 21:47:15 +04:00
|
|
|
msg_prompt_win(MSG_endoutsidedisk, -1, 13, 70, 6,
|
|
|
|
NULL, isize, 1,
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
(partend - partstart) / sizemult, multname);
|
|
|
|
}
|
|
|
|
/* return value */
|
|
|
|
return (partend - partstart);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* convert a string to a number of sectors, with a possible unit
|
|
|
|
* 150M = 150 Megabytes
|
|
|
|
* 2000c = 2000 cylinders
|
|
|
|
* 150256s = 150256 sectors
|
|
|
|
* Without units, use the default (sizemult)
|
2002-07-29 05:30:25 +04:00
|
|
|
* returns the number of sectors, and the unit used (for roundups).
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
*/
|
|
|
|
|
2003-07-07 16:30:19 +04:00
|
|
|
static void
|
2003-06-16 23:42:13 +04:00
|
|
|
atofsb(const char *str, int *p_val, int *localsizemult)
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
{
|
|
|
|
int i;
|
2003-06-09 23:06:48 +04:00
|
|
|
int val;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
|
|
|
|
*localsizemult = sizemult;
|
|
|
|
if (str[0] == '\0') {
|
2003-06-09 23:06:48 +04:00
|
|
|
*p_val = -1;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
return;
|
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
val = 0;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
for (i = 0; str[i] != '\0'; i++) {
|
|
|
|
if (str[i] >= '0' && str[i] <= '9') {
|
2003-06-09 23:06:48 +04:00
|
|
|
val = val * 10 + str[i] - '0';
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (str[i + 1] != '\0') {
|
|
|
|
/* A non-digit caracter, not at the end */
|
2003-06-10 21:47:15 +04:00
|
|
|
*p_val = -1;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
return;
|
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
if (str[i] == 'G' || str[i] == 'g') {
|
|
|
|
val *= 1024;
|
|
|
|
*localsizemult = MEG / sectorsize;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (str[i] == 'M' || str[i] == 'm') {
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
*localsizemult = MEG / sectorsize;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (str[i] == 'c') {
|
|
|
|
*localsizemult = dlcylsize;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (str[i] == 's') {
|
|
|
|
*localsizemult = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* not a known unit */
|
2003-06-09 23:06:48 +04:00
|
|
|
*p_val = -1;
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
return;
|
|
|
|
}
|
2003-06-09 23:06:48 +04:00
|
|
|
*p_val = val * (*localsizemult);
|
- Add 2 functions in label.c, getpartoff()/getpartsize() used to let the user
enter partitions offet and size. The user can chose unit independantly of
the unit used for display ('M'/'c'/'s'). These functions do the proper
bound checks and alignement/roudups. Used in the edfspart menu and
i386 md_make_bsd_partitions() (other ports should do the change as
well).
- now that getpartsize() does the rigth thing, kill the swapadj hack (which was
buggy anyway).
- in i386 md_make_bsd_partitions(), don't propose defaults that don't fit on
the disk. If the disk is too small, fallback to custom instead.
- fix a bug in mbr.c, where the partition flags would not have always been
reset. sysinst created me a MBR with 2 active partition. The boot code
doesn't like it :)
- added a message for eventual mount failures.
- killed donewfs and extracting messages, as we run the commands in a
subwindow these messages just flashed on the screen.
- Changes a few exit(1) to return(1), to give the user a second chance.
- added msg_clear() or wclear(stdscr) in a place or two, to make
display a bit nicer.
- in run_cmd(), if the command succeeded, don't wait for the user to
press enter.
1999-04-12 02:40:19 +04:00
|
|
|
return;
|
|
|
|
}
|