[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sysinst for New generation Mac (Re: macppc/macppc/disksubr.c)



>                                            千葉市中央区長洲
>                                                    藤原  誠

  とりあえず、作り直して見ました。iBook に入れられることだけは
確めて見ました。この後で StarMax に入れられるか確めて見ます。

修行が足りないので、
src/distrib/utils/sysinst/Makefile.inc の中にある、
   -DMACH=\"${MACHINE}\" 
の文字を (*.c の中で) 利用する方法が分らないので、その右に
   -D__macppc__
という字を付加えて、それを使って切換えています。
(従って、このままだと他の機械では使えないです)
  (1) NetBSD/macppc 以外
  (2) NetBSD/macppc OF 2.02 以前
      または
      NetBSD/macppc OF 3 で HFS partition を使わない
  (3) NetBSD/macppc OF 3
の三つを切換える必要がある訳ですが、(2),(3) の面倒しか見て
いないという意味です。

  ・以上の点をどう直すのがいいか
  ・それ以外に何を直すと -current に取込める形になるか
    を教えていただけるか、それとも
    適当に直していただいて取込んでいただけるとうれしいです。

# (OF 2.02 で動いた場合の話です)
# sleep なんて使っているのですが、これは当然必要ありません。
# 次のところにも置いて見ました。

ftp://ftp.ki.nu/pub/NetBSD/port-macppc/netbsd-1.5W.GENERIC_MD.gz
---
(藤原)
http://www.ki.nu/software/NetBSD/iBook2/
diff -ur 20010604/distrib/utils/sysinst/Makefile.inc src/distrib/utils/sysinst/Makefile.inc
--- 20010604/distrib/utils/sysinst/Makefile.inc	Sat Jan 13 02:23:44 2001
+++ src/distrib/utils/sysinst/Makefile.inc	Sat Jun 30 10:19:43 2001
@@ -20,7 +20,7 @@
 .endif
 
 CPPFLAGS+= -I. -I${.CURDIR}/../.. -I${.CURDIR} \
-	 -DREL=\"${VER}\" -DMACH=\"${MACHINE}\"
+	 -DREL=\"${VER}\" -DMACH=\"${MACHINE}\" -D__macppc__
 
 .if defined(SYSINST_FTP_HOST)
 CPPFLAGS+=-DFTP_HOST="${SYSINST_FTP_HOST}"
diff -ur 20010604/distrib/utils/sysinst/arch/macppc/md.c src/distrib/utils/sysinst/arch/macppc/md.c
--- 20010604/distrib/utils/sysinst/arch/macppc/md.c	Sun Jan 14 20:22:26 2001
+++ src/distrib/utils/sysinst/arch/macppc/md.c	Sat Jun 30 10:57:38 2001
@@ -61,6 +61,7 @@
 #define	PART_RAW	C
 #define	PART_USR	G
 
+extern int hfs_exist (const char *);
 int
 md_get_info()
 {
@@ -138,11 +139,24 @@
 {
 	const char *bootfile = target_expand("/boot");	/*XXX*/
 
+	if (! hfs_exist(diskdev)) {	 
+	  printf ("Proceeding for installboot.\n");
+process_menu(MENU_noyes);
+	if (!yesno) { 	msg_display(MSG_abort);
+		process_menu(MENU_ok);
+		return 0;}
+
 	printf (msg_string(MSG_dobootblks), diskdev);
 	cp_to_target("/usr/mdec/ofwboot", "/boot");
 	sync();
 	run_prog(RUN_DISPLAY, NULL, "/usr/mdec/installboot %s %s /dev/r%sa",
 	    bootfile,  "/usr/mdec/bootxx", diskdev);
+	 }
+	else {
+	  printf (msg_string(MSG_applelabelexists), diskdev);
+	  printf ("\nDisk label looks like Apples. Will not run installboot. ?\n");
+	  printf ("The input will be ignored anyway, hit return to continue.\n");
+process_menu(MENU_noyes);}
 	return 0;
 }
 
@@ -163,6 +177,7 @@
 	char isize[20];
 	int maxpart = getmaxpartitions();
 
+	struct disklabel disklabel;
 	/*
 	 * Initialize global variables that track  space used on this disk.
 	 * Standard 4.3BSD 8-partition labels always cover whole disk.
@@ -318,7 +333,24 @@
 			remain = fsdsize - partstart;
 			part++;
 		}
+	case 4: /* Use Existing  */
+		if (get_real_geom(diskdev,&disklabel ) == 0) {
+			msg_display(MSG_abort);	/* XXX more informative */
+		}
 
+		for (i = 0; i < maxpart; i++) {
+#define p disklabel.d_partitions[i]
+			bsdlabel[i].pi_size = p.p_size;
+			bsdlabel[i].pi_offset = p.p_offset;
+			if (i != RAW_PART) {
+				bsdlabel[i].pi_fstype = p.p_fstype;
+				bsdlabel[i].pi_bsize = p.p_fsize * p.p_frag;
+				bsdlabel[i].pi_fsize = p.p_fsize;
+				/* menu to get fsmount[] entry */
+#undef p
+			} else
+				bsdlabel[i].pi_fstype = FS_UNUSED;
+		}
 		break;
 	}
 
@@ -391,4 +423,28 @@
 	toggle_getit (11);
 	toggle_getit (12);
 	toggle_getit (13);
+}
+/* added  for macppc only*/
+int
+hfs_exist(dev)
+	const char *dev;
+{
+        /* partinfo parts[16];  */
+	int i, maxpart;
+	int hfs = 0;
+	/*
+	if (pp == NULL) {
+		emptylabel(parts);
+		if (incorelabel(dev, parts) < 0)
+			return -1;
+	}
+	*/
+	maxpart = getmaxpartitions();
+	/*	printf(" ** maxpart(%d)\n",maxpart); */
+	for (i = 0; i < maxpart; i++) {
+		if (bsdlabel[i].pi_fstype == FS_HFS) {
+		  hfs++;
+		}
+	}
+	return hfs;
 }
diff -ur 20010604/distrib/utils/sysinst/arch/macppc/menus.md.en src/distrib/utils/sysinst/arch/macppc/menus.md.en
--- 20010604/distrib/utils/sysinst/arch/macppc/menus.md.en	Sat Jan 13 02:24:04 2001
+++ src/distrib/utils/sysinst/arch/macppc/menus.md.en	Sun Jun 24 06:06:01 2001
@@ -53,6 +53,14 @@
 	option "Change f", action { editpart = F;}, sub menu edfspart;
 	option "Change g", action { editpart = G;}, sub menu edfspart;
 	option "Change h", action { editpart = H;}, sub menu edfspart;
+	option "Change i", action { editpart = I;}, sub menu edfspart;
+	option "Change j", action { editpart = J;}, sub menu edfspart;
+	option "Change k", action { editpart = K;}, sub menu edfspart;
+	option "Change l", action { editpart = L;}, sub menu edfspart;
+	option "Change m", action { editpart = M;}, sub menu edfspart;
+	option "Change n", action { editpart = N;}, sub menu edfspart;
+	option "Change o", action { editpart = O;}, sub menu edfspart;
+	option "Change p", action { editpart = P;}, sub menu edfspart;
 	option "Set new allocation size", action { reask_sizemult(dlcylsize); };
  
 menu md_distcustom, x=26, y=5, exit, title "Selection toggles inclusion";
diff -ur 20010604/distrib/utils/sysinst/arch/macppc/msg.md.en src/distrib/utils/sysinst/arch/macppc/msg.md.en
--- 20010604/distrib/utils/sysinst/arch/macppc/msg.md.en	Sat Jan 13 02:24:04 2001
+++ src/distrib/utils/sysinst/arch/macppc/msg.md.en	Thu Jun 28 14:19:47 2001
@@ -80,3 +80,7 @@
 message askfspart
 {The next partition is /dev/%s%c.  You have %d %s left on your disk.
 Partition size? }
+
+message applelabelexists
+{The Apple type partition label found on %s. Install boot will not be
+done. ok? }
diff -ur 20010604/distrib/utils/sysinst/defs.h src/distrib/utils/sysinst/defs.h
--- 20010604/distrib/utils/sysinst/defs.h	Thu Jun 28 13:59:55 2001
+++ src/distrib/utils/sysinst/defs.h	Fri Jun 29 22:46:17 2001
@@ -278,7 +278,9 @@
 void	md_init (void);
 void	md_set_sizemultname (void);
 void	md_set_no_x (void);
-
+#ifdef __macppc__
+int	hfs_exist(const char *);
+#endif
 /* from main.c */
 void	toplevel (void);
 
diff -ur 20010604/distrib/utils/sysinst/disks.c src/distrib/utils/sysinst/disks.c
--- 20010604/distrib/utils/sysinst/disks.c	Mon Jan 15 20:37:20 2001
+++ src/distrib/utils/sysinst/disks.c	Fri Jun 29 22:46:03 2001
@@ -235,12 +235,34 @@
 write_disklabel (void)
 {
 
+#ifndef __macppc__
 #ifdef DISKLABEL_CMD
 	/* disklabel the disk */
 	return run_prog(RUN_DISPLAY, MSG_cmdfail,
 	    "%s %s %s", DISKLABEL_CMD, diskdev, bsddiskname);
 #endif
 	return 0;
+#else  
+/* 
+For macppc only, check if HFS partition exists and if found, 
+not to write disk label
+*/
+if ( hfs_exist(diskdev)) {
+    printf("HFS partition exists,\nskip writing disklabel\n");
+    sleep (2);
+    return 0;
+  }
+  else {
+    printf ("HFS partition DOES NOT exist, writing disklabel\n");
+    sleep (2);
+#ifdef DISKLABEL_CMD
+	/* disklabel the disk */
+	return run_prog(RUN_DISPLAY, MSG_cmdfail,
+	    "%s %s %s", DISKLABEL_CMD, diskdev, bsddiskname);
+#endif
+	return 0;
+  }
+#endif
 }
 
 int
@@ -280,6 +302,9 @@
 		    "/sbin/newfs" : "/sbin/newfs_lfs", partname);
 	else
 		error = 0;
+#ifdef __macppc__
+	if ( hfs_exist(diskdev)) error = 0; /* XXX MacOS special */
+#endif	
 	if (*mountpoint && error == 0) { 
 		snprintf(devname, STRSIZE, "/dev/%s", partname);
 		if (partno > 0)	/* XXX strcmp(mountpoint, "/") ? XXX */
diff -ur 20010604/distrib/utils/sysinst/install.c src/distrib/utils/sysinst/install.c
--- 20010604/distrib/utils/sysinst/install.c	Sat Jan 13 02:23:49 2001
+++ src/distrib/utils/sysinst/install.c	Sat Jun 30 10:50:48 2001
@@ -50,7 +50,10 @@
 do_install()
 {
 	doingwhat = msg_string(MSG_install);
-
+#ifdef __macppc__
+	msg_display(MSG_installusure);
+	printf("__macppc__ is enabled, MacOS label will not be corrupted.\n");
+#endif
 	msg_display(MSG_installusure);
 	process_menu(MENU_noyes);
 	if (!yesno)