Subject: Just got pdisk partially working under NetBSD-mac68k!
To: Michael R Zucca <mrz5149@cs.rit.edu>
From: David A. Gatwood <marsmail@globegate.utm.edu>
List: port-mac68k
Date: 04/11/1998 23:36:00
On Thu, 9 Apr 1998, Michael R Zucca wrote:

> Well, we'd need three more things:
> 
> - The ability to partition a drive using MacOS style partitions from
>   NetBSD.
>   This requires some additions to the kernel.


After a few hours of hacking, I've managed to get Apple's (MkLinux's) 
pdisk to compile and partially work (haven't tried writing anything yet,
only reading, don't want to hose my drive... need to find an old drive to
hork....)  Getting it to compile was a bit of a drag, but nothing too
complicated.


1.  all references to #ifdef/#ifndef __linux__ should be changed to
something like BUILD_UNIX.  BUID_UNIX should then be defined.  This makes
it distinct from the MacOS version.

2.  all references to <linux/fs.h> should be replaced by
<ufs/ffs/ffs_extern.h>

3.  add the following

#ifndef loff_t
typedef long long  loff_t;
#endif

and download a copy of MkLinux's getopt.h, possibly.

4. change getopt_long to getopt by removing the last two arguments and
deleting the _long part.

5. using a define, replace every reference to llseek with lseek (this
appears to be a typo, as the code apparently left out the second and
fourth arguments to llseek entirely otherwise).

6. use #ifndef __linux__ to comment out the reference to the long options
for getopt in pdisk.c

7. eliminate includes of <linux/hdreg.h>

8. use a #ifndef BSD or something to comment out the code that calls the
ioctl for the kernel to reread the partition table, unless such an ioctl
exists under a different name.  Is such an ioctl needed for pdisk to write
partition tables safely under NetBSD?

9. call it with something like... "pdisk /dev/sd0c" and when you get a
prompt, hit "Q" to force it to read the partition table (I don't know why
this works or what else it does, but it worked for me), then p to list the
partitions and other info about that drive.  It manages that much, at
least for me.

Unfortunately, my pdisk sources appear to be rather old, so there are a
bunch of illegal requests in a row (either that or it's testing for some
feature of the drive that's not supported on either of my drives).
Regardless, though, it looks like it has serious potential for use under
NetBSD-mac68k.


David

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/FA/H/L/MC/M/MU/PA/TW d-@ s:>- a-- C++++>$ UBLAS*++++>$
P+?>$ L+++>$ !E--- W+++>$ N++(+++)>+++$ !o? K-? !w--- !O
M++>$ !V-- PS+>$ !PE- Y+>$ PGP+>$ t+++>$ 5+>++++$ !X- !R tv+>$
b++>$ !DI !D- G++(+++)>$ e>++++ h--! r--- !y-
------END GEEK CODE BLOCK------