Adds slice_type_name() which extends chunk_n[] for subtype's too.
Curorary review by: phk
This commit is contained in:
parent
1bc88280ef
commit
50a88ec0cc
@ -37,7 +37,8 @@ MLINKS+= libdisk.3 Open_Disk.3 \
|
||||
libdisk.3 MakeDev.3 \
|
||||
libdisk.3 MakeDevDisk.3 \
|
||||
libdisk.3 ShowChunkFlags.3 \
|
||||
libdisk.3 ChunkCanBeRoot.3
|
||||
libdisk.3 ChunkCanBeRoot.3 \
|
||||
libdisk.3 slice_type_name.3
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
|
||||
|
@ -347,3 +347,40 @@ Set_Boot_Blocks(struct disk *d, const u_char *b1, const u_char *b2)
|
||||
if(!d->boot2) err(1,"malloc failed");
|
||||
memcpy(d->boot2,b2,15*512);
|
||||
}
|
||||
|
||||
const char *
|
||||
slice_type_name( int type, int subtype )
|
||||
{
|
||||
switch (type) {
|
||||
case 0: return "whole";
|
||||
case 1: switch (subtype) {
|
||||
case 1: return "fat (12-bit)";
|
||||
case 2: return "XENIX /";
|
||||
case 3: return "XENIX /usr";
|
||||
case 4: return "fat (16-bit)";
|
||||
case 5: return "extended DOS";
|
||||
case 6: return "fat (>32Mb)";
|
||||
case 7: return "NTFS/HPFS";
|
||||
case 10: return "OS/2 bootmgr";
|
||||
case 84: return "OnTrack diskmgr";
|
||||
case 100: return "Netware 2.x";
|
||||
case 101: return "Netware 3.x";
|
||||
case 128: return "Minix 1.1";
|
||||
case 129: return "Minix 1.5";
|
||||
case 130: return "linux_swap";
|
||||
case 131: return "ext2fs";
|
||||
case 183: return "bsd/os";
|
||||
case 184: return "bsd/os swap";
|
||||
default: return "unknown";
|
||||
}
|
||||
case 2: return "fat";
|
||||
case 3: switch (subtype) {
|
||||
case 165: return "freebsd";
|
||||
default: return "unknown";
|
||||
}
|
||||
case 4: return "extended";
|
||||
case 5: return "part";
|
||||
case 6: return "unused";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
@ -57,11 +57,19 @@
|
||||
.Nm MakeDevDisk ,
|
||||
.Nm ShowChunkFlags ,
|
||||
.Nm ChunkCanBeRoot ,
|
||||
.Nm chunk_n ,
|
||||
.Nm slice_type_name
|
||||
.Nd library interface to slice and partition labels
|
||||
.Sh SYNOPSIS
|
||||
.Fd #include <sys/types.h>
|
||||
.Fd #include <libdisk.h>
|
||||
.Dv extern const u_char *boot1, boot2;
|
||||
.\" What is the correct way to cause a single line break ???
|
||||
.Bd -literal
|
||||
.Dv extern const char *chunk_n[];
|
||||
.Ed
|
||||
.Ft const char *
|
||||
.Fn slice_type_name "int type" "int subtype"
|
||||
.Ft struct disk *
|
||||
.Fn Open_Disk "const char *devname"
|
||||
.Ft struct disk *
|
||||
@ -310,6 +318,17 @@ returns a string to show flags.
|
||||
.Pp
|
||||
.Fn ChunkCanBeRoot
|
||||
returns NULL if chunk can be
|
||||
.Pp
|
||||
Chunk name strings can be accessed directly using the external array
|
||||
.Va chunk_n .
|
||||
.Pp
|
||||
.Fn slice_type_name
|
||||
returns the name strings associated with the specified
|
||||
.Ql type .
|
||||
.Ql subtype .
|
||||
If
|
||||
.Fn slice_type_name
|
||||
returns "unknown" for slices it isn't familar with.
|
||||
.Ql / .
|
||||
.Sh AUTHOR
|
||||
.Nm Libdisk
|
||||
|
@ -86,6 +86,11 @@ struct chunk {
|
||||
extern const char *chunk_n[];
|
||||
extern const u_char boot1[], boot2[];
|
||||
|
||||
const char *
|
||||
slice_type_name( int type, int subtype );
|
||||
/* "chunk_n" for subtypes too
|
||||
*/
|
||||
|
||||
struct disk *
|
||||
Open_Disk(const char *devname);
|
||||
/* Will open the named disk, and return populated tree.
|
||||
|
Loading…
Reference in New Issue
Block a user