1 /*        $NetBSD: disklabel.h,v 1.128 2024/04/10 20:00:12 andvar Exp $         */
2 
3 /*
4  * Copyright (c) 1987, 1988, 1993
5  *        The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *        @(#)disklabel.h     8.2 (Berkeley) 7/10/94
32  */
33 
34 #ifndef _SYS_DISKLABEL_H_
35 #define   _SYS_DISKLABEL_H_
36 
37 /*
38  * We need <machine/types.h> for __HAVE_OLD_DISKLABEL
39  */
40 #ifndef _LOCORE
41 #include <sys/types.h>
42 #endif
43 
44 /*
45  * Each disk has a label which includes information about the hardware
46  * disk geometry, filesystem partitions, and drive specific information.
47  * The location of the label, as well as the number of partitions the
48  * label can describe and the number of the "whole disk" (raw)
49  * partition are machine dependent.
50  */
51 #if HAVE_NBTOOL_CONFIG_H
52 #undef MAXPARTITIONS
53 #define MAXPARTITIONS                   MAXMAXPARTITIONS
54 #else
55 #include <machine/disklabel.h>
56 #endif /* HAVE_NBTOOL_CONFIG_H */
57 
58 /*
59  * The absolute maximum number of disk partitions allowed.
60  * This is the maximum value of MAXPARTITIONS for which 'struct disklabel'
61  * is <= DEV_BSIZE bytes long.  If MAXPARTITIONS is greater than this, beware.
62  */
63 #define   MAXMAXPARTITIONS    22
64 #if MAXPARTITIONS > MAXMAXPARTITIONS
65 #warning beware: MAXPARTITIONS bigger than MAXMAXPARTITIONS
66 #endif
67 
68 /*
69  * Ports can switch their MAXPARTITIONS once, as follows:
70  *
71  * - define OLDMAXPARTITIONS in <machine/disklabel.h> as the old number
72  * - define MAXPARTITIONS as the new number
73  * - define DISKUNIT, DISKPART and DISKMINOR macros in <machine/disklabel.h>
74  *   as appropriate for the port (see the i386 one for an example).
75  * - define __HAVE_OLD_DISKLABEL in <machine/types.h>
76  */
77 
78 #if defined(_KERNEL) && defined(__HAVE_OLD_DISKLABEL) && \
79              (MAXPARTITIONS < OLDMAXPARTITIONS)
80 #error "can only grow disklabel size"
81 #endif
82 
83 
84 /*
85  * Translate between device numbers and major/disk unit/disk partition.
86  */
87 #ifndef __HAVE_OLD_DISKLABEL
88 #if !HAVE_NBTOOL_CONFIG_H
89 #define   DISKUNIT(dev)       (minor(dev) / MAXPARTITIONS)
90 #define   DISKPART(dev)       (minor(dev) % MAXPARTITIONS)
91 #define   DISKMINOR(unit, part) \
92     (((unit) * MAXPARTITIONS) + (part))
93 #endif /* !HAVE_NBTOOL_CONFIG_H */
94 #endif
95 #define   MAKEDISKDEV(maj, unit, part) \
96     (makedev((maj), DISKMINOR((unit), (part))))
97 
98 #define   DISKMAGIC ((uint32_t)0x82564557)        /* The disk magic number */
99 
100 #ifndef _LOCORE
101 struct    partition {                   /* the partition table */
102           uint32_t p_size;    /* number of sectors in partition */
103           uint32_t p_offset;  /* starting sector */
104           union {
105                     uint32_t fsize; /* FFS, ADOS: filesystem basic fragment size */
106                     uint32_t cdsession; /* ISO9660: session offset */
107           } __partition_u2;
108 #define   p_fsize             __partition_u2.fsize
109 #define   p_cdsession         __partition_u2.cdsession
110           uint8_t p_fstype;   /* filesystem type, see below */
111           uint8_t p_frag;     /* filesystem fragments per block */
112           union {
113                     uint16_t cpg;       /* UFS: FS cylinders per group */
114                     uint16_t sgs;       /* LFS: FS segment shift */
115           } __partition_u1;
116 #define   p_cpg     __partition_u1.cpg
117 #define   p_sgs     __partition_u1.sgs
118 };
119 
120 /*
121  * We'd rather have disklabel be the same size on 32 and 64 bit systems
122  * but it really isn't. In revision 108 matt@ tried to do that by adding
123  * un_d_pad as a uint64_t. This was really smart because the net effect
124  * was to grow the struct by 4 bytes on most LP32 machines and make it
125  * the same as LP64 without changing the layout (which is a nono because
126  * it is stored on existing disks). The easy way would have been to add
127  * padding at the end, but that would have been confusing (although that
128  * is what actually happens), because the partitions structure is supposed
129  * to be variable size and putting a padding uint32_t would be weird.
130  * Unfortunately mips32 and i386 align uint64_t standalone at an 8 byte
131  * boundary, but in structures at a 4 byte boundary so matt's
132  * change did not affect them.
133  *
134  * We also prefer to have the structure 4 byte aligned so that the
135  * subr_disk_mbr.c code that scans for label does not trigger ubsan
136  * when comparing magic (without making the code ugly). To do this
137  * we can unexpose the d_boot{0,1} pointers in the kernel (so that
138  * LP64 systems can become 4 byte aligned) and at the same time
139  * remove the un_d_pad member and add padding at the end. The d_boot{0,1}
140  * fields are only used in userland in getdiskbyname(3), filled with
141  * the names of the primary and secondary bootstrap from /etc/disktab.
142  *
143  * While this is a way forward, it is not clear that it is the best
144  * way forward. The ubsan warning is incorrect and the code
145  * will always work since d_magic is always 4 byte aligned even
146  * when structure disklabel is not 8 byte aligned, so what we do
147  * now is ignore it. Another way would be to do offset arithmetic
148  * on the pointer and use it as a char *. That would not prevent
149  * other misaligned accesses in the future. Finally one could
150  * copy the unaligned structure to an aligned one, but that eats
151  * up space on the stack.
152  */
153 struct disklabel {
154           uint32_t d_magic;             /* the magic number */
155           uint16_t d_type;              /* drive type */
156           uint16_t d_subtype;           /* controller/d_type specific */
157           char        d_typename[16];   /* type name, e.g. "eagle" */
158 
159           /*
160            * d_packname contains the pack identifier and is returned when
161            * the disklabel is read off the disk or in-core copy.
162            * d_boot0 and d_boot1 are the (optional) names of the
163            * primary (block 0) and secondary (block 1-15) bootstraps
164            * as found in /usr/mdec.  These are returned when using
165            * getdiskbyname(3) to retrieve the values from /etc/disktab.
166            */
167           union {
168                     char      un_d_packname[16];  /* pack identifier */
169                     struct {
170                               char *un_d_boot0;   /* primary bootstrap name */
171                               char *un_d_boot1;   /* secondary bootstrap name */
172                     } un_b;
173                     uint64_t un_d_pad;            /* force 8 byte alignment */
174           } d_un;
175 #define   d_packname          d_un.un_d_packname
176 #define   d_boot0             d_un.un_b.un_d_boot0
177 #define   d_boot1             d_un.un_b.un_d_boot1
178 
179                               /* disk geometry: */
180           uint32_t d_secsize;           /* # of bytes per sector */
181           uint32_t d_nsectors;                    /* # of data sectors per track */
182           uint32_t d_ntracks;           /* # of tracks per cylinder */
183           uint32_t d_ncylinders;                  /* # of data cylinders per unit */
184           uint32_t d_secpercyl;                   /* # of data sectors per cylinder */
185           uint32_t d_secperunit;                  /* # of data sectors per unit */
186 
187           /*
188            * Spares (bad sector replacements) below are not counted in
189            * d_nsectors or d_secpercyl.  Spare sectors are assumed to
190            * be physical sectors which occupy space at the end of each
191            * track and/or cylinder.
192            */
193           uint16_t d_sparespertrack;    /* # of spare sectors per track */
194           uint16_t d_sparespercyl;      /* # of spare sectors per cylinder */
195           /*
196            * Alternative cylinders include maintenance, replacement,
197            * configuration description areas, etc.
198            */
199           uint32_t d_acylinders;                  /* # of alt. cylinders per unit */
200 
201                               /* hardware characteristics: */
202           /*
203            * d_interleave, d_trackskew and d_cylskew describe perturbations
204            * in the media format used to compensate for a slow controller.
205            * Interleave is physical sector interleave, set up by the
206            * formatter or controller when formatting.  When interleaving is
207            * in use, logically adjacent sectors are not physically
208            * contiguous, but instead are separated by some number of
209            * sectors.  It is specified as the ratio of physical sectors
210            * traversed per logical sector.  Thus an interleave of 1:1
211            * implies contiguous layout, while 2:1 implies that logical
212            * sector 0 is separated by one sector from logical sector 1.
213            * d_trackskew is the offset of sector 0 on track N relative to
214            * sector 0 on track N-1 on the same cylinder.  Finally, d_cylskew
215            * is the offset of sector 0 on cylinder N relative to sector 0
216            * on cylinder N-1.
217            */
218           uint16_t d_rpm;               /* rotational speed */
219           uint16_t d_interleave;                  /* hardware sector interleave */
220           uint16_t d_trackskew;                   /* sector 0 skew, per track */
221           uint16_t d_cylskew;           /* sector 0 skew, per cylinder */
222           uint32_t d_headswitch;                  /* head switch time, usec */
223           uint32_t d_trkseek;           /* track-to-track seek, usec */
224           uint32_t d_flags;             /* generic flags */
225 #define   NDDATA 5
226           uint32_t d_drivedata[NDDATA]; /* drive-type specific information */
227 #define   NSPARE 5
228           uint32_t d_spare[NSPARE];     /* reserved for future use */
229           uint32_t d_magic2;            /* the magic number (again) */
230           uint16_t d_checksum;                    /* xor of data incl. partitions */
231 
232                               /* filesystem and partition information: */
233           uint16_t d_npartitions;       /* number of partitions in following */
234           uint32_t d_bbsize;            /* size of boot area at sn0, bytes */
235           uint32_t d_sbsize;            /* max size of fs superblock, bytes */
236           struct    partition  d_partitions[MAXPARTITIONS];
237                               /* the partition table, actually may be more */
238 };
239 
240 #if defined(__HAVE_OLD_DISKLABEL) && !HAVE_NBTOOL_CONFIG_H
241 /*
242  * Same as above, but with OLDMAXPARTITIONS partitions. For use in
243  * the old DIOC* ioctl calls.
244  */
245 struct olddisklabel {
246           uint32_t d_magic;
247           uint16_t d_type;
248           uint16_t d_subtype;
249           char        d_typename[16];
250           union {
251                     char      un_d_packname[16];
252                     struct {
253                               char *un_d_boot0;
254                               char *un_d_boot1;
255                     } un_b;
256           } d_un;
257           uint32_t d_secsize;
258           uint32_t d_nsectors;
259           uint32_t d_ntracks;
260           uint32_t d_ncylinders;
261           uint32_t d_secpercyl;
262           uint32_t d_secperunit;
263           uint16_t d_sparespertrack;
264           uint16_t d_sparespercyl;
265           uint32_t d_acylinders;
266           uint16_t d_rpm;
267           uint16_t d_interleave;
268           uint16_t d_trackskew;
269           uint16_t d_cylskew;
270           uint32_t d_headswitch;
271           uint32_t d_trkseek;
272           uint32_t d_flags;
273           uint32_t d_drivedata[NDDATA];
274           uint32_t d_spare[NSPARE];
275           uint32_t d_magic2;
276           uint16_t d_checksum;
277           uint16_t d_npartitions;
278           uint32_t d_bbsize;
279           uint32_t d_sbsize;
280           struct    opartition {
281                     uint32_t p_size;
282                     uint32_t p_offset;
283                     union {
284                               uint32_t fsize;
285                               uint32_t cdsession;
286                     } __partition_u2;
287                     uint8_t p_fstype;
288                     uint8_t p_frag;
289                     union {
290                               uint16_t cpg;
291                               uint16_t sgs;
292                     } __partition_u1;
293           } d_partitions[OLDMAXPARTITIONS];
294 };
295 #endif /* __HAVE_OLD_DISKLABEL */
296 #else /* _LOCORE */
297           /*
298            * offsets for asm boot files.
299            */
300           .set      d_secsize,40
301           .set      d_nsectors,44
302           .set      d_ntracks,48
303           .set      d_ncylinders,52
304           .set      d_secpercyl,56
305           .set      d_secperunit,60
306           .set      d_end_,148+(MAXPARTITIONS*16)
307 #endif /* _LOCORE */
308 
309 /*
310  * We normally use C99 initialisers (just in case the lists below are out
311  * of sequence, or have gaps), but lint doesn't grok them.
312  * Maybe some host compilers don't either, but many have for quite some time.
313  */
314 
315 #ifndef lint
316 #define ARRAY_INIT(element,value) [element]=value
317 #else
318 #define ARRAY_INIT(element,value) value
319 #endif
320 
321 /* Use pre-processor magic to get all the parameters one one line... */
322 
323 /* d_type values: */
324 #define DKTYPE_DEFN(x) \
325 x(UNKNOWN,          0,        "unknown") \
326 x(SMD,              1,        "SMD")              /* SMD, XSMD; VAX hp/up */ \
327 x(MSCP,             2,        "MSCP")             /* MSCP */ \
328 x(DEC,              3,        "old DEC")          /* other DEC (rk, rl) */ \
329 x(SCSI,             4,        "SCSI")             /* SCSI */ \
330 x(ESDI,             5,        "ESDI")             /* ESDI interface */ \
331 x(ST506,  6,        "ST506")  /* ST506 etc. */ \
332 x(HPIB,             7,        "HP-IB")  /* CS/80 on HP-IB */ \
333 x(HPFL,             8,        "HP-FL")  /* HP Fiber-link */ \
334 x(TYPE_9, 9,        "type 9") \
335 x(FLOPPY, 10,       "floppy") /* floppy */ \
336 x(CCD,              11,       "ccd")              /* concatenated disk device */ \
337 x(VND,              12,       "vnd")              /* uvnode pseudo-disk */ \
338 x(ATAPI,  13,       "ATAPI")  /* ATAPI */ \
339 x(RAID,             14,       "RAID")             /* RAIDframe */ \
340 x(LD,               15,       "ld")               /* logical disk */ \
341 x(JFS2,             16,       "jfs")              /* IBM JFS2 */ \
342 x(CGD,              17,       "cgd")              /* cryptographic pseudo-disk */ \
343 x(VINUM,  18,       "vinum")  /* vinum volume */ \
344 x(FLASH,  19,       "flash")  /* flash memory devices */ \
345 x(DM,               20,       "dm")               /* device-mapper pseudo-disk devices */\
346 x(RUMPD,  21,       "rumpd")  /* rump virtual disk */ \
347 x(MD,               22,       "md")               /* memory disk */ \
348 
349 #ifndef _LOCORE
350 #define DKTYPE_NUMS(tag, number, name) __CONCAT(DKTYPE_,tag=number),
351 #ifndef DKTYPE_ENUMNAME
352 #define DKTYPE_ENUMNAME
353 #endif
354 enum DKTYPE_ENUMNAME { DKTYPE_DEFN(DKTYPE_NUMS) DKMAXTYPES };
355 #undef    DKTYPE_NUMS
356 #endif
357 
358 #ifdef DKTYPENAMES
359 #define   DKTYPE_NAMES(tag, number, name) ARRAY_INIT(number,name),
360 static const char *const dktypenames[] = { DKTYPE_DEFN(DKTYPE_NAMES) NULL };
361 #undef    DKTYPE_NAMES
362 #endif
363 
364 /*
365  * Partition type names, numbers, label-names, fsck prog, and mount prog
366  */
367 #define   FSTYPE_DEFN(x) \
368 x(UNUSED,   0, "unused",     NULL,    NULL)   /* unused */ \
369 x(SWAP,     1, "swap",       NULL,    NULL)   /* swap */ \
370 x(V6,       2, "Version 6",  NULL,    NULL)   /* Sixth Edition */ \
371 x(V7,       3, "Version 7", "v7fs",  "v7fs")  /* Seventh Edition */ \
372 x(SYSV,     4, "System V",   NULL,    NULL)   /* System V */ \
373 x(V71K,     5, "4.1BSD",     NULL,    NULL)   /* V7, 1K blocks (4.1, 2.9) */ \
374 x(V8,    6, "Eighth Edition",NULL,    NULL)   /* Eighth Edition, 4K blocks */ \
375 x(BSDFFS,   7, "4.2BSD",    "ffs",   "ffs")   /* 4.2BSD fast file system */ \
376 x(MSDOS,    8, "MSDOS",     "msdos", "msdos") /* MSDOS file system */ \
377 x(BSDLFS,   9, "4.4LFS",    "lfs",   "lfs")   /* 4.4BSD log-structured FS */ \
378 x(OTHER,   10, "unknown",    NULL,    NULL)   /* in use, unknown/unsupported */\
379 x(HPFS,    11, "HPFS",       NULL,    NULL)   /* OS/2 high-performance FS */ \
380 x(ISO9660, 12, "ISO9660",    NULL,   "cd9660")/* ISO 9660, normally CD-ROM */ \
381 x(BOOT,    13, "boot",       NULL,    NULL)   /* bootstrap code in partition */\
382 x(ADOS,    14, "ADOS",       NULL,   "ados")  /* AmigaDOS fast file system */ \
383 x(HFS,     15, "HFS",        NULL,    NULL)   /* Macintosh HFS */ \
384 x(FILECORE,16, "FILECORE",   NULL, "filecore")/* Acorn Filecore FS */ \
385 x(EX2FS,   17, "Linux Ext2","ext2fs","ext2fs")/* Linux Extended 2 FS */ \
386 x(NTFS,    18, "NTFS",       NULL,   "ntfs")  /* Windows/NT file system */ \
387 x(RAID,    19, "RAID",       NULL,    NULL)   /* RAIDframe component */ \
388 x(CCD,     20, "ccd",        NULL,    NULL)   /* concatenated disk component */\
389 x(JFS2,    21, "jfs",        NULL,    NULL)   /* IBM JFS2 */ \
390 x(APPLEUFS,22, "Apple UFS", "ffs",   "ffs")   /* Apple UFS */ \
391 /* XXX this is not the same as FreeBSD.  How to solve? */ \
392 x(VINUM,   23, "vinum",      NULL,    NULL)   /* Vinum */ \
393 x(UDF,     24, "UDF",        NULL,   "udf")   /* UDF */ \
394 x(SYSVBFS, 25, "SysVBFS",    NULL,  "sysvbfs")/* System V boot file system */ \
395 x(EFS,     26, "EFS",        NULL,   "efs")   /* SGI's Extent Filesystem */ \
396 x(NILFS,   27, "NiLFS",      NULL,   "nilfs") /* NTT's NiLFS(2) */ \
397 x(CGD,     28, "cgd",              NULL,   NULL)    /* Cryptographic disk */ \
398 x(MINIXFS3,29, "MINIX FSv3", NULL,   NULL)    /* MINIX file system v3 */ \
399 x(VMKCORE, 30, "VMware vmkcore", NULL, NULL)  /* VMware vmkcore */ \
400 x(VMFS,    31, "VMware VMFS", NULL,  NULL)    /* VMware VMFS */ \
401 x(VMWRESV, 32, "VMware Reserved", NULL, NULL) /* VMware reserved */ \
402 x(ZFS,     33, "ZFS",        NULL,   "zfs")   /* ZFS */
403 
404 
405 #ifndef _LOCORE
406 #define   FS_TYPENUMS(tag, number, name, fsck, mount) __CONCAT(FS_,tag=number),
407 #ifndef FSTYPE_ENUMNAME
408 #define FSTYPE_ENUMNAME
409 #endif
410 enum FSTYPE_ENUMNAME { FSTYPE_DEFN(FS_TYPENUMS) FSMAXTYPES };
411 #undef    FS_TYPENUMS
412 #endif
413 
414 #ifdef    FSTYPENAMES
415 #define   FS_TYPENAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,name),
416 static const char *const fstypenames[] = { FSTYPE_DEFN(FS_TYPENAMES) NULL };
417 #undef    FS_TYPENAMES
418 #endif
419 
420 #ifdef FSCKNAMES
421 /* These are the names MOUNT_XXX from <sys/mount.h> */
422 #define   FS_FSCKNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,fsck),
423 static const char *const fscknames[] = { FSTYPE_DEFN(FS_FSCKNAMES) NULL };
424 #undef    FS_FSCKNAMES
425 #define   FSMAXNAMES          FSMAXTYPES
426 #endif
427 
428 #ifdef MOUNTNAMES
429 /* These are the names MOUNT_XXX from <sys/mount.h> */
430 #define   FS_MOUNTNAMES(tag, number, name, fsck, mount) ARRAY_INIT(number,mount),
431 static const char *const mountnames[] = { FSTYPE_DEFN(FS_MOUNTNAMES) NULL };
432 #undef    FS_MOUNTNAMES
433 #define   FSMAXMOUNTNAMES     FSMAXTYPES
434 #endif
435 
436 /*
437  * flags shared by various drives:
438  */
439 #define             D_REMOVABLE         0x01                /* removable media */
440 #define             D_ECC               0x02                /* supports ECC */
441 #define             D_BADSECT 0x04                /* supports bad sector forw. */
442 #define             D_RAMDISK 0x08                /* disk emulator */
443 #define             D_CHAIN             0x10                /* can do back-back transfers */
444 #define             D_SCSI_MMC          0x20                /* SCSI MMC sessioned media */
445 
446 /*
447  * Drive data for SMD.
448  */
449 #define   d_smdflags          d_drivedata[0]
450 #define             D_SSE               0x1                 /* supports skip sectoring */
451 #define   d_mindist d_drivedata[1]
452 #define   d_maxdist d_drivedata[2]
453 #define   d_sdist             d_drivedata[3]
454 
455 /*
456  * Drive data for ST506.
457  */
458 #define   d_precompcyl        d_drivedata[0]
459 #define   d_gap3              d_drivedata[1]                /* used only when formatting */
460 
461 /*
462  * Drive data for SCSI.
463  */
464 #define   d_blind             d_drivedata[0]
465 
466 #ifndef _LOCORE
467 /*
468  * Structure used to perform a format or other raw operation,
469  * returning data and/or register values.  Register identification
470  * and format are device- and driver-dependent. Currently unused.
471  */
472 struct format_op {
473           char      *df_buf;
474           int        df_count;                    /* value-result */
475           daddr_t    df_startblk;
476           int        df_reg[8];                   /* result */
477 };
478 
479 #ifdef _KERNEL
480 /*
481  * Structure used internally to retrieve information about a partition
482  * on a disk.
483  */
484 struct partinfo {
485           uint64_t pi_offset;
486           uint64_t pi_size;
487           uint32_t pi_secsize;
488           uint32_t pi_bsize;
489           uint8_t    pi_fstype;
490           uint8_t  pi_frag;
491           uint16_t pi_cpg;
492           uint32_t pi_fsize;
493 };
494 
495 struct disk;
496 
497 int disk_read_sectors(void (*)(struct buf *), const struct disklabel *,
498     struct buf *, unsigned int, int);
499 void       diskerr(const struct buf *, const char *, const char *, int,
500               int, const struct disklabel *);
501 int        setdisklabel(struct disklabel *, struct disklabel *, u_long,
502               struct cpu_disklabel *);
503 const char *readdisklabel(dev_t, void (*)(struct buf *),
504               struct disklabel *, struct cpu_disklabel *);
505 int        writedisklabel(dev_t, void (*)(struct buf *), struct disklabel *,
506               struct cpu_disklabel *);
507 const char *convertdisklabel(struct disklabel *, void (*)(struct buf *),
508     struct buf *, uint32_t);
509 int        bounds_check_with_label(struct disk *, struct buf *, int);
510 int        bounds_check_with_mediasize(struct buf *, int, uint64_t);
511 const char *getfstypename(int);
512 int       disklabel_dev_unit(dev_t);
513 #endif
514 #endif /* _LOCORE */
515 
516 #if !defined(_KERNEL) && !defined(_LOCORE)
517 
518 #include <sys/cdefs.h>
519 
520 #endif
521 
522 #endif /* !_SYS_DISKLABEL_H_ */
523