C Program to Read the NeXT Disklabel

NeXT Computer, Inc. -> NEXTSTEP / OPENSTEP Software

Title: C Program to Read the NeXT Disklabel
Post by: Nitro on April 27, 2025, 07:44:29 PM
As a learning exercise I've been working on a C program that reads the NeXT disklabel at the beginning of a disk image and prints out label field information as well as partition info similar to the NeXT disk program. It also calculates and verifies the disklabel checksum. It's a work in progress so it may be a while before it's finished. There are a number of operating systems that have existing code that can read the NeXT disklabel, but the idea behind this program was to learn how the disklabel is structured; which fields are used by NEXTSTEP, etc. Next up will be to add code to search the disk image for the disklabel rather than assuming it will be at the beginning of the disk. There are bits and pieces of code in this programming exercise from elsewhere so I can't release it, but the disklabel structure and field order are listed below.

This is the output for a disk image file named HD30_512_NeXT_26GiB.hda with one 2GB slice and six 4GB slices:
Disk Label Information:
  Label Version: dlv3
  Label Block Number: 0
  Disk Size: 0
  Volume Label: BlueSCSI26GiB
  Initialized Flags: 0x00000000
  Volume Tag: 0x4B30A330
  Disktab Information:
    Drive Name: BlueSCSIDesktop
    Drive Type: fixed_rw_scsi
    Sector Size: 512
    Number of Tracks: 64
    Sectors/Track: 32
    Number of Cylinders: 13523
    RPM: 10000
    Front Porch Size: 320
    Back Porch Size: 0
    MO: Number of Alternate Groups: 0
    MO: Alternate Group Size: 0
    MO: Number of Alternates/Group: 0
    MO: Alternate Group Offset: 0
    Boot Block Start Sector [0]: 64
    Boot Block Start Sector [1]: 192
    Kernel Name: sdmach
    Host Name: localhost
    Root Partition: a
    R/W Partition:
    Label Checksum (verified): 0x9f29

Part  StartSect    # Sect  BlkSize  FragSize  Cyl/Grp  IDensity  MinFree  Newfs  Optim  Automnt  FileSys
a             0   4194304     8192      1024        8      4096      10%    yes   time       no   4.3BSD
b       4194304   8388608     8192      1024        8      4096      10%    yes   time       no   4.3BSD
c      12582912   8388608     8192      1024        8      4096      10%    yes   time       no   4.3BSD
d      20971520   8388608     8192      1024        8      4096      10%    yes   time       no   4.3BSD
e      29360128   8388608     8192      1024        8      4096      10%    yes   time       no   4.3BSD
f      37748736   8388608     8192      1024        8      4096      10%    yes   time       no   4.3BSD
g      46137344   8388608     8192      1024        8      4096      10%    yes   time       no   4.3BSD

Here's the output from an ISO file of the NEXTSTEP 3.3 CD:
NeXT Disklabel Information:
  Label Version: dlv3
  Label Block Number: 0
  Disk Size: 0
  Volume Label: NEXTSTEP_3.3
  Initialized Flags: 0x00000000
  Volume Tag: 0x17526488
  Disktab Information:
    Drive Name: NEXTSTEP_3.3
    Drive Type: removable_rw_scsi
    Sector Size: 2048
    Number of Tracks: 32
    Sectors/Track: 64
    Number of Cylinders: 1024
    RPM: 300
    Front Porch Size: 80
    Back Porch Size: 0
    MO: Number of Alternate Groups: 0
    MO: Alternate Group Size: 0
    MO: Number of Alternates/Group: 0
    MO: Alternate Group Offset: 0
    Boot Block Start Sector [0]: 16
    Boot Block Start Sector [1]: 48
    Kernel Name: sdmach
    Host Name: localhost
    Root Partition: a
    R/W Partition: b
    Label Checksum (verified): 0x8c46

Part  StartSect    # Sect  BlkSize  FragSize  Cyl/Grp  IDensity  MinFree  Newfs  Optim  Automnt  FileSys
a             0    182272     8192      2048        2      4096      10%    yes   time      yes   4.3BSD
Title: Re: C Program to Read the NeXT Disklabel
Post by: pTeK on May 23, 2025, 04:15:10 PM
Good util @Nitro so this util of yours is able to display all the start and finish offsets on the partition when you use:

# fdisk -useAllSectors

Were you using a /usr/etc/disktab? As you have perfect 4GB and 2GB partition sizes and it wasn't divided a number to make it fit under the max partition size as I read in a NeXTAnswer which I can't remember.
Title: Re: C Program to Read the NeXT Disklabel
Post by: Nitro on May 23, 2025, 05:43:21 PM
I used a disktab to create the disk image. This was done on black hardware so no fdisk was involved. Currently the program can only read disklabels at the beginning of the disk image, so it just supports black hardware at the moment. The output is similar to that of the disk program. I'll have to add the ability to search the disk image for the disklabel in order to support other platforms.
Title: Re: C Program to Read the NeXT Disklabel
Post by: ramalhais on May 28, 2025, 06:27:34 PM
Maybe it's of some use for someone:

Program to read and write next disklabels and bootloader:
https://github.com/ramalhais/linux/blob/linux-6.9.y-NeXT/arch/m68k/tools/next/next-disklabel.c

Linux kernel next disklabel support:
https://github.com/ramalhais/linux/blob/linux-6.9.y-NeXT/block/partitions/next.c

Go to top  Forum index