[comp.os.minix] writing to /dev/hd0, Re: /dev/hd5

roeder@sbsvax.UUCP (Edgar Roeder) (03/02/89)

In article <424@lzaz.ATT.COM>, hcj@lzaz.ATT.COM (HC Johnson) writes:
> There are many ways to change stwini.c but please, not this way.
> /dev/hd5 is the WHOLE disk, and is, in the UNIX(r) spirit, there to allow
> backup of the whole thing.  If you want to add a new partitioning scheme
> ...
> 
> Howard C. Johnson

In article <219@nlgvax.UUCP>, johan@nlgvax.UUCP (Johan Stevenson) writes:
> I do not agree. Minor 5 is supposed to access the whole disk.
> You can already do what you want to do by allocating the whole disk
> minus sector 0 as the first and only partition.
> --
> Johan W. Stevenson	johan@pcg.philips.nl		Philips Research

Ok guys, forget my posting.
Here is another patch regarding this topic (:-):

--------------------------------------------------------------------------------
*** MINIX Manual for the Atari ST	Wed Mar  1 17:13:23 1989
--- MINIX Manual for the Atari ST	Wed Mar  1 17:13:41 1989
***************
*** page 11 ****
  that is copied to the RAM disk at boot time. See the section on boot options
  below. One of the other partitions, for instance 4 (/dev/hd4), can be as big as
  you like and can be mounted on /usr. There is no 16M disk partition limit for
! MINIX. You could even use the whole disk (/dev/hd5) as one single MINIX file
  system, but that would make the disk useless for TOS.
  Initialize the hard disk (formatting and partitioning) using the tools supplied
  by Atari, notyably the HDX.PRG utility. MINIX is not equipped to perform this
--- page 11 ----
  that is copied to the RAM disk at boot time. See the section on boot options
  below. One of the other partitions, for instance 4 (/dev/hd4), can be as big as
  you like and can be mounted on /usr. There is no 16M disk partition limit for
! MINIX. You could even use the whole disk (as /dev/hd1) as one single MINIX file
  system, but that would make the disk useless for TOS.
  Initialize the hard disk (formatting and partitioning) using the tools supplied
  by Atari, notyably the HDX.PRG utility. MINIX is not equipped to perform this
--------------------------------------------------------------------------------

I have tried to use /dev/hd1 for my whole disk as you proposed. Since HDX did
not allow to create such a big partition, i wrote some code to access /dev/hd0
from MINIX. Now i have an empty harddisk and a simple question. What is wrong
with the following code:

	#include "/usr/src/kernel/sthdc.h"

	main()
	{
		int	fd;
		struct hi	hd_info;

		fd = open("/dev/hd0",2);
		read(fd, &hd_info, sizeof(struct hi));
		hd_info.hd_pi[0].pi_flag = 1; /* validate partition 1 */
		strncpy(hd_info.hd_pi[0].pi_id,"MIX",3); /* no GEM-partition */
				/* pi_start unchanged (remains 1) */
		hd_info.hd_pi[0].pi_size = hd_info.hd_size - 1;
			...	/* invalidate the other 3 partitions */
		write(fd, &hd_info, sizeof(struct hi));
		close(fd);
	}

The observed effect is `corrupted root file system' (i used /dev/hd1 as root)
and fsck yields `bad magic number in super block'. Before i tried this code on
/dev/hd0 i applied it to a copy of /dev/hd0 (obtained by "cat /dev/hd0 > sec0")
and everything worked fine.

- Edgar