1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2000 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 32*0Sstevel@tonic-gate * under license from the Regents of the University of California. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate /* 38*0Sstevel@tonic-gate * make file system for udfs (UDF - ISO13346) 39*0Sstevel@tonic-gate * 40*0Sstevel@tonic-gate * usage: 41*0Sstevel@tonic-gate * 42*0Sstevel@tonic-gate * mkfs [-F FSType] [-V] [-m] [options] 43*0Sstevel@tonic-gate * [-o specific_options] special size 44*0Sstevel@tonic-gate * 45*0Sstevel@tonic-gate * where specific_options are: 46*0Sstevel@tonic-gate * N - no create 47*0Sstevel@tonic-gate * label - volume label 48*0Sstevel@tonic-gate * psize - physical block size 49*0Sstevel@tonic-gate */ 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #include <stdio.h> 52*0Sstevel@tonic-gate #include <strings.h> 53*0Sstevel@tonic-gate #include <string.h> 54*0Sstevel@tonic-gate #include <stdlib.h> 55*0Sstevel@tonic-gate #include <unistd.h> 56*0Sstevel@tonic-gate #include <time.h> 57*0Sstevel@tonic-gate #include <locale.h> 58*0Sstevel@tonic-gate #include <fcntl.h> 59*0Sstevel@tonic-gate #include <errno.h> 60*0Sstevel@tonic-gate #include <limits.h> 61*0Sstevel@tonic-gate #include <sys/mnttab.h> 62*0Sstevel@tonic-gate #include <sys/param.h> 63*0Sstevel@tonic-gate #include <sys/types.h> 64*0Sstevel@tonic-gate #include <sys/sysmacros.h> 65*0Sstevel@tonic-gate #include <sys/vnode.h> 66*0Sstevel@tonic-gate #include <sys/mntent.h> 67*0Sstevel@tonic-gate #include <sys/filio.h> 68*0Sstevel@tonic-gate #include <sys/stat.h> 69*0Sstevel@tonic-gate #include <ustat.h> 70*0Sstevel@tonic-gate #include <sys/isa_defs.h> /* for ENDIAN defines */ 71*0Sstevel@tonic-gate #include <sys/dkio.h> 72*0Sstevel@tonic-gate #include <sys/fdio.h> 73*0Sstevel@tonic-gate #include <sys/vtoc.h> 74*0Sstevel@tonic-gate #include <sys/fs/udf_volume.h> 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate extern char *getfullrawname(char *); 77*0Sstevel@tonic-gate extern char *getfullblkname(char *); 78*0Sstevel@tonic-gate extern struct tm *localtime_r(const time_t *, struct tm *); 79*0Sstevel@tonic-gate extern void maketag(struct tag *, struct tag *); 80*0Sstevel@tonic-gate extern int verifytag(struct tag *, uint32_t, struct tag *, int); 81*0Sstevel@tonic-gate extern void setcharspec(struct charspec *, int32_t, uint8_t *); 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate #define UMASK 0755 85*0Sstevel@tonic-gate #define POWEROF2(num) (((num) & ((num) - 1)) == 0) 86*0Sstevel@tonic-gate #define MB (1024*1024) 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate /* 89*0Sstevel@tonic-gate * Forward declarations 90*0Sstevel@tonic-gate */ 91*0Sstevel@tonic-gate static void rdfs(daddr_t bno, int size, char *bf); 92*0Sstevel@tonic-gate static void wtfs(daddr_t bno, int size, char *bf); 93*0Sstevel@tonic-gate static void dump_fscmd(char *fsys, int fsi); 94*0Sstevel@tonic-gate static int32_t number(long big, char *param); 95*0Sstevel@tonic-gate static void usage(); 96*0Sstevel@tonic-gate static int match(char *s); 97*0Sstevel@tonic-gate static int readvolseq(); 98*0Sstevel@tonic-gate static uint32_t get_last_block(); 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate /* 101*0Sstevel@tonic-gate * variables set up by front end. 102*0Sstevel@tonic-gate */ 103*0Sstevel@tonic-gate static int Nflag = 0; /* run mkfs without writing */ 104*0Sstevel@tonic-gate /* file system */ 105*0Sstevel@tonic-gate static int mflag = 0; /* return the command line used */ 106*0Sstevel@tonic-gate /* to create this FS */ 107*0Sstevel@tonic-gate static int fssize; /* file system size */ 108*0Sstevel@tonic-gate static uint32_t disk_size; /* partition size from VTOC */ 109*0Sstevel@tonic-gate static uint32_t unused; /* unused sectors in partition */ 110*0Sstevel@tonic-gate static int sectorsize = 2048; /* bytes/sector default */ 111*0Sstevel@tonic-gate /* If nothing specified */ 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate static char *fsys; 114*0Sstevel@tonic-gate static int fsi; 115*0Sstevel@tonic-gate static int fso; 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate #define BIG LONG_MAX 118*0Sstevel@tonic-gate static uint32_t number_flags = 0; 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate static char *string; 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate static void setstamp(tstamp_t *); 123*0Sstevel@tonic-gate static void setextad(extent_ad_t *, uint32_t, uint32_t); 124*0Sstevel@tonic-gate static void setdstring(dstring_t *, char *, int32_t); 125*0Sstevel@tonic-gate static void wtvolseq(tag_t *, daddr_t, daddr_t); 126*0Sstevel@tonic-gate static void volseqinit(); 127*0Sstevel@tonic-gate static void setstamp(tstamp_t *); 128*0Sstevel@tonic-gate static uint32_t get_bsize(); 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate #define VOLRECSTART (32 * 1024) 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate #define VOLSEQSTART 128 134*0Sstevel@tonic-gate #define VOLSEQLEN 16 135*0Sstevel@tonic-gate #define INTSEQSTART 192 136*0Sstevel@tonic-gate #define INTSEQLEN 8192 137*0Sstevel@tonic-gate #define FIRSTAVDP 256 138*0Sstevel@tonic-gate #define AVDPLEN 1 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate #define FILESETLEN 2 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate #define SPACEMAP_OFF 24 144*0Sstevel@tonic-gate #define MAXID 16 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate static time_t mkfstime; 147*0Sstevel@tonic-gate static struct tm res; 148*0Sstevel@tonic-gate static long tzone; 149*0Sstevel@tonic-gate static char vsibuf[128]; 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate static regid_t sunmicro = { 0, "*SUN SOLARIS UDF", 4, 2 }; 152*0Sstevel@tonic-gate static regid_t lvinfo = { 0, "*UDF LV Info", 0x50, 0x1, 4, 2 }; 153*0Sstevel@tonic-gate static regid_t partid = { 0, "+NSR02", 0 }; 154*0Sstevel@tonic-gate static regid_t udf_compliant = { 0, "*OSTA UDF Compliant", 0x50, 0x1, 0 }; 155*0Sstevel@tonic-gate static uint8_t osta_unicode[] = "OSTA Compressed Unicode"; 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate static int bdevismounted; 158*0Sstevel@tonic-gate static int ismounted; 159*0Sstevel@tonic-gate static int directory; 160*0Sstevel@tonic-gate static char buf[MAXBSIZE]; 161*0Sstevel@tonic-gate static char buf2[MAXBSIZE]; 162*0Sstevel@tonic-gate static char lvid[MAXBSIZE]; 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate uint32_t ecma_version = 2; 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate static int serialnum = 1; /* Tag serial number */ 167*0Sstevel@tonic-gate static char udfs_label[128] = "*NoLabel*"; 168*0Sstevel@tonic-gate static int acctype = PART_ACC_OW; 169*0Sstevel@tonic-gate static uint32_t part_start; 170*0Sstevel@tonic-gate static uint32_t part_len; 171*0Sstevel@tonic-gate static uint32_t part_bmp_bytes; 172*0Sstevel@tonic-gate static uint32_t part_bmp_sectors; 173*0Sstevel@tonic-gate static int32_t part_unalloc = -1; 174*0Sstevel@tonic-gate static uint32_t filesetblock; 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate /* Set by readvolseq for -m option */ 177*0Sstevel@tonic-gate static uint32_t oldfssize; 178*0Sstevel@tonic-gate static char *oldlabel; 179*0Sstevel@tonic-gate 180*0Sstevel@tonic-gate main(int32_t argc, int8_t *argv[]) 181*0Sstevel@tonic-gate { 182*0Sstevel@tonic-gate long i; 183*0Sstevel@tonic-gate FILE *mnttab; 184*0Sstevel@tonic-gate struct mnttab mntp; 185*0Sstevel@tonic-gate char *special, *raw_special; 186*0Sstevel@tonic-gate struct stat statarea; 187*0Sstevel@tonic-gate struct ustat ustatarea; 188*0Sstevel@tonic-gate int32_t c; 189*0Sstevel@tonic-gate uint32_t temp_secsz; 190*0Sstevel@tonic-gate int isfs; 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 193*0Sstevel@tonic-gate 194*0Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 195*0Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 196*0Sstevel@tonic-gate #endif 197*0Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate while ((c = getopt(argc, argv, "F:Vmo:")) != EOF) { 200*0Sstevel@tonic-gate switch (c) { 201*0Sstevel@tonic-gate 202*0Sstevel@tonic-gate case 'F': 203*0Sstevel@tonic-gate string = optarg; 204*0Sstevel@tonic-gate if (strcmp(string, "udfs") != 0) { 205*0Sstevel@tonic-gate usage(); 206*0Sstevel@tonic-gate } 207*0Sstevel@tonic-gate break; 208*0Sstevel@tonic-gate 209*0Sstevel@tonic-gate case 'V': 210*0Sstevel@tonic-gate { 211*0Sstevel@tonic-gate char *opt_text; 212*0Sstevel@tonic-gate int opt_count; 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate (void) fprintf(stdout, 215*0Sstevel@tonic-gate gettext("mkfs -F udfs ")); 216*0Sstevel@tonic-gate for (opt_count = 1; opt_count < argc; 217*0Sstevel@tonic-gate opt_count++) { 218*0Sstevel@tonic-gate opt_text = argv[opt_count]; 219*0Sstevel@tonic-gate if (opt_text) { 220*0Sstevel@tonic-gate (void) fprintf(stdout, 221*0Sstevel@tonic-gate " %s ", opt_text); 222*0Sstevel@tonic-gate } 223*0Sstevel@tonic-gate } 224*0Sstevel@tonic-gate (void) fprintf(stdout, "\n"); 225*0Sstevel@tonic-gate } 226*0Sstevel@tonic-gate break; 227*0Sstevel@tonic-gate 228*0Sstevel@tonic-gate case 'm': 229*0Sstevel@tonic-gate /* 230*0Sstevel@tonic-gate * return command line used 231*0Sstevel@tonic-gate * to create this FS 232*0Sstevel@tonic-gate */ 233*0Sstevel@tonic-gate mflag++; 234*0Sstevel@tonic-gate break; 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate case 'o': 237*0Sstevel@tonic-gate /* 238*0Sstevel@tonic-gate * udfs specific options. 239*0Sstevel@tonic-gate */ 240*0Sstevel@tonic-gate string = optarg; 241*0Sstevel@tonic-gate while (*string != '\0') { 242*0Sstevel@tonic-gate if (match("N")) { 243*0Sstevel@tonic-gate Nflag++; 244*0Sstevel@tonic-gate } else if (match("psize=")) { 245*0Sstevel@tonic-gate number_flags = 0; 246*0Sstevel@tonic-gate sectorsize = number(BIG, 247*0Sstevel@tonic-gate "psize"); 248*0Sstevel@tonic-gate } else if (match("label=")) { 249*0Sstevel@tonic-gate for (i = 0; i < 31; i++) { 250*0Sstevel@tonic-gate if (*string == '\0') { 251*0Sstevel@tonic-gate break; 252*0Sstevel@tonic-gate } 253*0Sstevel@tonic-gate udfs_label[i] = 254*0Sstevel@tonic-gate *string++; 255*0Sstevel@tonic-gate } 256*0Sstevel@tonic-gate udfs_label[i] = '\0'; 257*0Sstevel@tonic-gate } else if (*string == '\0') { 258*0Sstevel@tonic-gate break; 259*0Sstevel@tonic-gate } else { 260*0Sstevel@tonic-gate (void) fprintf(stdout, 261*0Sstevel@tonic-gate gettext("illegal " 262*0Sstevel@tonic-gate "option: %s\n"), 263*0Sstevel@tonic-gate string); 264*0Sstevel@tonic-gate usage(); 265*0Sstevel@tonic-gate } 266*0Sstevel@tonic-gate if (*string == ',') { 267*0Sstevel@tonic-gate string++; 268*0Sstevel@tonic-gate } 269*0Sstevel@tonic-gate if (*string == ' ') { 270*0Sstevel@tonic-gate string++; 271*0Sstevel@tonic-gate } 272*0Sstevel@tonic-gate } 273*0Sstevel@tonic-gate break; 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate case '?': 276*0Sstevel@tonic-gate usage(); 277*0Sstevel@tonic-gate break; 278*0Sstevel@tonic-gate } 279*0Sstevel@tonic-gate } 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate (void) time(&mkfstime); 282*0Sstevel@tonic-gate if (optind > (argc - 1)) { 283*0Sstevel@tonic-gate usage(); 284*0Sstevel@tonic-gate } 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gate argc -= optind; 287*0Sstevel@tonic-gate argv = &argv[optind]; 288*0Sstevel@tonic-gate fsys = argv[0]; 289*0Sstevel@tonic-gate raw_special = getfullrawname(fsys); 290*0Sstevel@tonic-gate fsi = open(raw_special, 0); 291*0Sstevel@tonic-gate if (fsi < 0) { 292*0Sstevel@tonic-gate (void) fprintf(stdout, 293*0Sstevel@tonic-gate gettext("%s: cannot open\n"), fsys); 294*0Sstevel@tonic-gate exit(32); 295*0Sstevel@tonic-gate } 296*0Sstevel@tonic-gate fso = fsi; 297*0Sstevel@tonic-gate 298*0Sstevel@tonic-gate if ((temp_secsz = get_bsize()) != 0) { 299*0Sstevel@tonic-gate sectorsize = temp_secsz; 300*0Sstevel@tonic-gate } 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate /* Get old file system information */ 303*0Sstevel@tonic-gate isfs = readvolseq(); 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate if (mflag) { 306*0Sstevel@tonic-gate /* 307*0Sstevel@tonic-gate * Figure out the block size and 308*0Sstevel@tonic-gate * file system size and print the information 309*0Sstevel@tonic-gate */ 310*0Sstevel@tonic-gate if (isfs) 311*0Sstevel@tonic-gate dump_fscmd(fsys, fsi); 312*0Sstevel@tonic-gate else 313*0Sstevel@tonic-gate (void) printf(gettext( 314*0Sstevel@tonic-gate "[not currently a valid file system]\n")); 315*0Sstevel@tonic-gate exit(0); 316*0Sstevel@tonic-gate } 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate /* 319*0Sstevel@tonic-gate * Get the disk size from the drive or VTOC for the N and N-256 320*0Sstevel@tonic-gate * AVDPs and to make sure we don't want to create a file system 321*0Sstevel@tonic-gate * bigger than the partition. 322*0Sstevel@tonic-gate */ 323*0Sstevel@tonic-gate disk_size = get_last_block(); 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate if (argc < 2 && disk_size == 0 || argc < 1) { 326*0Sstevel@tonic-gate usage(); 327*0Sstevel@tonic-gate } 328*0Sstevel@tonic-gate 329*0Sstevel@tonic-gate if (argc < 2) { 330*0Sstevel@tonic-gate (void) printf(gettext("No size specified, entire partition " 331*0Sstevel@tonic-gate "of %u sectors used\n"), disk_size); 332*0Sstevel@tonic-gate fssize = disk_size; 333*0Sstevel@tonic-gate } else { 334*0Sstevel@tonic-gate string = argv[1]; 335*0Sstevel@tonic-gate number_flags = 0; 336*0Sstevel@tonic-gate fssize = number(BIG, "size"); 337*0Sstevel@tonic-gate } 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate if (fssize < 0) { 340*0Sstevel@tonic-gate (void) fprintf(stderr, 341*0Sstevel@tonic-gate gettext("Negative number of sectors(%d) not allowed\n"), 342*0Sstevel@tonic-gate fssize); 343*0Sstevel@tonic-gate exit(32); 344*0Sstevel@tonic-gate } 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate if (fssize < (512 * sectorsize / DEV_BSIZE)) { 347*0Sstevel@tonic-gate (void) fprintf(stdout, 348*0Sstevel@tonic-gate gettext("size should be at least %d sectors\n"), 349*0Sstevel@tonic-gate (512 * sectorsize / DEV_BSIZE)); 350*0Sstevel@tonic-gate exit(32); 351*0Sstevel@tonic-gate } 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate if (disk_size != 0) { 354*0Sstevel@tonic-gate if (fssize > disk_size) { 355*0Sstevel@tonic-gate (void) fprintf(stderr, gettext("Invalid size: %d " 356*0Sstevel@tonic-gate "larger than the partition size\n"), fssize); 357*0Sstevel@tonic-gate exit(32); 358*0Sstevel@tonic-gate } else if (fssize < disk_size) { 359*0Sstevel@tonic-gate unused = disk_size - fssize; 360*0Sstevel@tonic-gate (void) printf( 361*0Sstevel@tonic-gate gettext("File system size %d smaller than " 362*0Sstevel@tonic-gate "partition, %u sectors unused\n"), 363*0Sstevel@tonic-gate fssize, unused); 364*0Sstevel@tonic-gate } 365*0Sstevel@tonic-gate } else { 366*0Sstevel@tonic-gate /* Use passed-in size */ 367*0Sstevel@tonic-gate disk_size = fssize; 368*0Sstevel@tonic-gate } 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gate if (!Nflag) { 371*0Sstevel@tonic-gate special = getfullblkname(fsys); 372*0Sstevel@tonic-gate 373*0Sstevel@tonic-gate /* 374*0Sstevel@tonic-gate * If we found the block device name, 375*0Sstevel@tonic-gate * then check the mount table. 376*0Sstevel@tonic-gate * if mounted, write lock the file system 377*0Sstevel@tonic-gate * 378*0Sstevel@tonic-gate */ 379*0Sstevel@tonic-gate if ((special != NULL) && (*special != '\0')) { 380*0Sstevel@tonic-gate mnttab = fopen(MNTTAB, "r"); 381*0Sstevel@tonic-gate while ((getmntent(mnttab, &mntp)) == NULL) { 382*0Sstevel@tonic-gate if (strcmp(special, mntp.mnt_special) == 0) { 383*0Sstevel@tonic-gate (void) fprintf(stdout, 384*0Sstevel@tonic-gate gettext("%s is mounted," 385*0Sstevel@tonic-gate " can't mkfs\n"), special); 386*0Sstevel@tonic-gate exit(32); 387*0Sstevel@tonic-gate } 388*0Sstevel@tonic-gate } 389*0Sstevel@tonic-gate (void) fclose(mnttab); 390*0Sstevel@tonic-gate } 391*0Sstevel@tonic-gate if ((bdevismounted) && (ismounted == 0)) { 392*0Sstevel@tonic-gate (void) fprintf(stdout, 393*0Sstevel@tonic-gate gettext("can't check mount point; ")); 394*0Sstevel@tonic-gate (void) fprintf(stdout, 395*0Sstevel@tonic-gate gettext("%s is mounted but not in mnttab(4)\n"), 396*0Sstevel@tonic-gate special); 397*0Sstevel@tonic-gate exit(32); 398*0Sstevel@tonic-gate } 399*0Sstevel@tonic-gate if (directory) { 400*0Sstevel@tonic-gate if (ismounted == 0) { 401*0Sstevel@tonic-gate (void) fprintf(stdout, 402*0Sstevel@tonic-gate gettext("%s is not mounted\n"), 403*0Sstevel@tonic-gate special); 404*0Sstevel@tonic-gate exit(32); 405*0Sstevel@tonic-gate } 406*0Sstevel@tonic-gate } 407*0Sstevel@tonic-gate fso = creat(fsys, 0666); 408*0Sstevel@tonic-gate if (fso < 0) { 409*0Sstevel@tonic-gate (void) fprintf(stdout, 410*0Sstevel@tonic-gate gettext("%s: cannot create\n"), fsys); 411*0Sstevel@tonic-gate exit(32); 412*0Sstevel@tonic-gate } 413*0Sstevel@tonic-gate if (stat(fsys, &statarea) < 0) { 414*0Sstevel@tonic-gate (void) fprintf(stderr, 415*0Sstevel@tonic-gate gettext("%s: %s: cannot stat\n"), 416*0Sstevel@tonic-gate argv[0], fsys); 417*0Sstevel@tonic-gate exit(32); 418*0Sstevel@tonic-gate } 419*0Sstevel@tonic-gate if (ustat(statarea.st_rdev, &ustatarea) >= 0) { 420*0Sstevel@tonic-gate (void) fprintf(stderr, 421*0Sstevel@tonic-gate gettext("%s is mounted, can't mkfs\n"), fsys); 422*0Sstevel@tonic-gate exit(32); 423*0Sstevel@tonic-gate } 424*0Sstevel@tonic-gate } else { 425*0Sstevel@tonic-gate /* 426*0Sstevel@tonic-gate * For the -N case, a file descriptor is needed for the llseek() 427*0Sstevel@tonic-gate * in wtfs(). See the comment in wtfs() for more information. 428*0Sstevel@tonic-gate * 429*0Sstevel@tonic-gate * Get a file descriptor that's read-only so that this code 430*0Sstevel@tonic-gate * doesn't accidentally write to the file. 431*0Sstevel@tonic-gate */ 432*0Sstevel@tonic-gate fso = open(fsys, O_RDONLY); 433*0Sstevel@tonic-gate if (fso < 0) { 434*0Sstevel@tonic-gate (void) fprintf(stderr, gettext("%s: cannot open\n"), 435*0Sstevel@tonic-gate fsys); 436*0Sstevel@tonic-gate exit(32); 437*0Sstevel@tonic-gate } 438*0Sstevel@tonic-gate } 439*0Sstevel@tonic-gate 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate /* 442*0Sstevel@tonic-gate * Validate the given file system size. 443*0Sstevel@tonic-gate * Verify that its last block can actually be accessed. 444*0Sstevel@tonic-gate */ 445*0Sstevel@tonic-gate fssize = fssize / (sectorsize / DEV_BSIZE); 446*0Sstevel@tonic-gate if (fssize <= 0) { 447*0Sstevel@tonic-gate (void) fprintf(stdout, 448*0Sstevel@tonic-gate gettext("preposterous size %d. sectors\n"), fssize); 449*0Sstevel@tonic-gate exit(32); 450*0Sstevel@tonic-gate } 451*0Sstevel@tonic-gate fssize --; 452*0Sstevel@tonic-gate 453*0Sstevel@tonic-gate /* 454*0Sstevel@tonic-gate * verify device size 455*0Sstevel@tonic-gate */ 456*0Sstevel@tonic-gate rdfs(fssize - 1, sectorsize, buf); 457*0Sstevel@tonic-gate 458*0Sstevel@tonic-gate if ((sectorsize < DEV_BSIZE) || 459*0Sstevel@tonic-gate (sectorsize > MAXBSIZE)) { 460*0Sstevel@tonic-gate (void) fprintf(stdout, 461*0Sstevel@tonic-gate gettext("sector size must be" 462*0Sstevel@tonic-gate " between 512, 8192 bytes\n")); 463*0Sstevel@tonic-gate } 464*0Sstevel@tonic-gate if (!POWEROF2(sectorsize)) { 465*0Sstevel@tonic-gate (void) fprintf(stdout, 466*0Sstevel@tonic-gate gettext("sector size must be a power of 2, not %d\n"), 467*0Sstevel@tonic-gate sectorsize); 468*0Sstevel@tonic-gate exit(32); 469*0Sstevel@tonic-gate } 470*0Sstevel@tonic-gate if (Nflag) { 471*0Sstevel@tonic-gate exit(0); 472*0Sstevel@tonic-gate } 473*0Sstevel@tonic-gate 474*0Sstevel@tonic-gate (void) printf(gettext("Creating file system with sector size of " 475*0Sstevel@tonic-gate "%d bytes\n"), sectorsize); 476*0Sstevel@tonic-gate 477*0Sstevel@tonic-gate /* 478*0Sstevel@tonic-gate * Set up time stamp values 479*0Sstevel@tonic-gate */ 480*0Sstevel@tonic-gate mkfstime = time(0); 481*0Sstevel@tonic-gate (void) localtime_r(&mkfstime, &res); 482*0Sstevel@tonic-gate if (res.tm_isdst > 0) { 483*0Sstevel@tonic-gate tzone = altzone / 60; 484*0Sstevel@tonic-gate } else if (res.tm_isdst == 0) { 485*0Sstevel@tonic-gate tzone = tzone / 60; 486*0Sstevel@tonic-gate } else { 487*0Sstevel@tonic-gate tzone = 2047; /* Unknown */ 488*0Sstevel@tonic-gate } 489*0Sstevel@tonic-gate 490*0Sstevel@tonic-gate /* 491*0Sstevel@tonic-gate * Initialize the volume recognition sequence, the volume descriptor 492*0Sstevel@tonic-gate * sequences and the anchor pointer. 493*0Sstevel@tonic-gate */ 494*0Sstevel@tonic-gate volseqinit(); 495*0Sstevel@tonic-gate 496*0Sstevel@tonic-gate (void) fsync(fso); 497*0Sstevel@tonic-gate (void) close(fsi); 498*0Sstevel@tonic-gate (void) close(fso); 499*0Sstevel@tonic-gate 500*0Sstevel@tonic-gate return (0); 501*0Sstevel@tonic-gate } 502*0Sstevel@tonic-gate 503*0Sstevel@tonic-gate static void 504*0Sstevel@tonic-gate setstamp(tstamp_t *tp) 505*0Sstevel@tonic-gate { 506*0Sstevel@tonic-gate tp->ts_usec = 0; 507*0Sstevel@tonic-gate tp->ts_husec = 0; 508*0Sstevel@tonic-gate tp->ts_csec = 0; 509*0Sstevel@tonic-gate 510*0Sstevel@tonic-gate tp->ts_sec = res.tm_sec; 511*0Sstevel@tonic-gate tp->ts_min = res.tm_min; 512*0Sstevel@tonic-gate tp->ts_hour = res.tm_hour; 513*0Sstevel@tonic-gate tp->ts_day = res.tm_mday; 514*0Sstevel@tonic-gate tp->ts_month = res.tm_mon + 1; 515*0Sstevel@tonic-gate tp->ts_year = 1900 + res.tm_year; 516*0Sstevel@tonic-gate 517*0Sstevel@tonic-gate tp->ts_tzone = 0x1000 + (-tzone & 0xFFF); 518*0Sstevel@tonic-gate } 519*0Sstevel@tonic-gate 520*0Sstevel@tonic-gate static void 521*0Sstevel@tonic-gate setextad(extent_ad_t *eap, uint32_t len, uint32_t loc) 522*0Sstevel@tonic-gate { 523*0Sstevel@tonic-gate eap->ext_len = len; 524*0Sstevel@tonic-gate eap->ext_loc = loc; 525*0Sstevel@tonic-gate } 526*0Sstevel@tonic-gate 527*0Sstevel@tonic-gate static void 528*0Sstevel@tonic-gate setdstring(dstring_t *dp, char *cp, int len) 529*0Sstevel@tonic-gate { 530*0Sstevel@tonic-gate int32_t length; 531*0Sstevel@tonic-gate 532*0Sstevel@tonic-gate bzero(dp, len); 533*0Sstevel@tonic-gate length = strlen(cp); 534*0Sstevel@tonic-gate if (length > len - 3) { 535*0Sstevel@tonic-gate length = len - 3; 536*0Sstevel@tonic-gate } 537*0Sstevel@tonic-gate dp[len - 1] = length + 1; 538*0Sstevel@tonic-gate *dp++ = 8; 539*0Sstevel@tonic-gate (void) strncpy(dp, cp, len-2); 540*0Sstevel@tonic-gate } 541*0Sstevel@tonic-gate 542*0Sstevel@tonic-gate static void 543*0Sstevel@tonic-gate wtvolseq(tag_t *tp, daddr_t blk1, daddr_t blk2) 544*0Sstevel@tonic-gate { 545*0Sstevel@tonic-gate static uint32_t vdsn = 0; 546*0Sstevel@tonic-gate 547*0Sstevel@tonic-gate tp->tag_loc = blk1; 548*0Sstevel@tonic-gate switch (tp->tag_id) { 549*0Sstevel@tonic-gate case UD_PRI_VOL_DESC : 550*0Sstevel@tonic-gate ((struct pri_vol_desc *)tp)->pvd_vdsn = vdsn++; 551*0Sstevel@tonic-gate break; 552*0Sstevel@tonic-gate case UD_VOL_DESC_PTR : 553*0Sstevel@tonic-gate ((struct vol_desc_ptr *)tp)->vdp_vdsn = vdsn++; 554*0Sstevel@tonic-gate break; 555*0Sstevel@tonic-gate case UD_IMPL_USE_DESC : 556*0Sstevel@tonic-gate ((struct iuvd_desc *)tp)->iuvd_vdsn = vdsn++; 557*0Sstevel@tonic-gate break; 558*0Sstevel@tonic-gate case UD_PART_DESC : 559*0Sstevel@tonic-gate ((struct part_desc *)tp)->pd_vdsn = vdsn++; 560*0Sstevel@tonic-gate break; 561*0Sstevel@tonic-gate case UD_LOG_VOL_DESC : 562*0Sstevel@tonic-gate ((struct log_vol_desc *)tp)->lvd_vdsn = vdsn++; 563*0Sstevel@tonic-gate break; 564*0Sstevel@tonic-gate case UD_UNALL_SPA_DESC : 565*0Sstevel@tonic-gate ((struct unall_spc_desc *)tp)->ua_vdsn = vdsn++; 566*0Sstevel@tonic-gate break; 567*0Sstevel@tonic-gate } 568*0Sstevel@tonic-gate 569*0Sstevel@tonic-gate bzero(buf2, sectorsize); 570*0Sstevel@tonic-gate /* LINTED */ 571*0Sstevel@tonic-gate maketag(tp, (struct tag *)buf2); 572*0Sstevel@tonic-gate 573*0Sstevel@tonic-gate /* 574*0Sstevel@tonic-gate * Write at Main Volume Descriptor Sequence 575*0Sstevel@tonic-gate */ 576*0Sstevel@tonic-gate wtfs(blk1, sectorsize, buf2); 577*0Sstevel@tonic-gate 578*0Sstevel@tonic-gate tp->tag_loc = blk2; 579*0Sstevel@tonic-gate switch (tp->tag_id) { 580*0Sstevel@tonic-gate case UD_PRI_VOL_DESC : 581*0Sstevel@tonic-gate ((struct pri_vol_desc *)tp)->pvd_vdsn = vdsn++; 582*0Sstevel@tonic-gate break; 583*0Sstevel@tonic-gate case UD_VOL_DESC_PTR : 584*0Sstevel@tonic-gate ((struct vol_desc_ptr *)tp)->vdp_vdsn = vdsn++; 585*0Sstevel@tonic-gate break; 586*0Sstevel@tonic-gate case UD_IMPL_USE_DESC : 587*0Sstevel@tonic-gate ((struct iuvd_desc *)tp)->iuvd_vdsn = vdsn++; 588*0Sstevel@tonic-gate break; 589*0Sstevel@tonic-gate case UD_PART_DESC : 590*0Sstevel@tonic-gate ((struct part_desc *)tp)->pd_vdsn = vdsn++; 591*0Sstevel@tonic-gate break; 592*0Sstevel@tonic-gate case UD_LOG_VOL_DESC : 593*0Sstevel@tonic-gate ((struct log_vol_desc *)tp)->lvd_vdsn = vdsn++; 594*0Sstevel@tonic-gate break; 595*0Sstevel@tonic-gate case UD_UNALL_SPA_DESC : 596*0Sstevel@tonic-gate ((struct unall_spc_desc *)tp)->ua_vdsn = vdsn++; 597*0Sstevel@tonic-gate break; 598*0Sstevel@tonic-gate } 599*0Sstevel@tonic-gate maketag(tp, tp); 600*0Sstevel@tonic-gate /* 601*0Sstevel@tonic-gate * Write at Reserve Volume Descriptor Sequence 602*0Sstevel@tonic-gate */ 603*0Sstevel@tonic-gate wtfs(blk2, sectorsize, buf); 604*0Sstevel@tonic-gate } 605*0Sstevel@tonic-gate 606*0Sstevel@tonic-gate static void 607*0Sstevel@tonic-gate volseqinit() 608*0Sstevel@tonic-gate { 609*0Sstevel@tonic-gate struct tag *tp; 610*0Sstevel@tonic-gate struct nsr_desc *nsp; 611*0Sstevel@tonic-gate struct pri_vol_desc *pvdp; 612*0Sstevel@tonic-gate struct iuvd_desc *iudp; 613*0Sstevel@tonic-gate struct part_desc *pp; 614*0Sstevel@tonic-gate struct phdr_desc *php; 615*0Sstevel@tonic-gate struct log_vol_desc *lvp; 616*0Sstevel@tonic-gate long_ad_t *lap; 617*0Sstevel@tonic-gate struct pmap_typ1 *pmp; 618*0Sstevel@tonic-gate struct unall_spc_desc *uap; 619*0Sstevel@tonic-gate struct log_vol_int_desc *lvip; 620*0Sstevel@tonic-gate struct term_desc *tdp; 621*0Sstevel@tonic-gate struct anch_vol_desc_ptr *avp; 622*0Sstevel@tonic-gate struct lvid_iu *lviup; 623*0Sstevel@tonic-gate struct file_set_desc *fsp; 624*0Sstevel@tonic-gate struct file_entry *fp; 625*0Sstevel@tonic-gate struct icb_tag *icb; 626*0Sstevel@tonic-gate struct short_ad *sap; 627*0Sstevel@tonic-gate struct file_id *fip; 628*0Sstevel@tonic-gate struct space_bmap_desc *sbp; 629*0Sstevel@tonic-gate uint8_t *cp; 630*0Sstevel@tonic-gate daddr_t nextblock, endblock; 631*0Sstevel@tonic-gate int32_t volseq_sectors, nextlogblock, rootfelen, i; 632*0Sstevel@tonic-gate uint32_t mvds_loc, rvds_loc; 633*0Sstevel@tonic-gate 634*0Sstevel@tonic-gate bzero(buf, MAXBSIZE); 635*0Sstevel@tonic-gate 636*0Sstevel@tonic-gate /* 637*0Sstevel@tonic-gate * Starting from MAXBSIZE, clear out till 256 sectors. 638*0Sstevel@tonic-gate */ 639*0Sstevel@tonic-gate for (i = MAXBSIZE / sectorsize; i < FIRSTAVDP; i++) { 640*0Sstevel@tonic-gate wtfs(i, sectorsize, buf); 641*0Sstevel@tonic-gate } 642*0Sstevel@tonic-gate 643*0Sstevel@tonic-gate /* Zero out the avdp at N - 257 */ 644*0Sstevel@tonic-gate wtfs(fssize - 256, sectorsize, buf); 645*0Sstevel@tonic-gate 646*0Sstevel@tonic-gate /* 647*0Sstevel@tonic-gate * Leave 1st 32K for O.S. 648*0Sstevel@tonic-gate */ 649*0Sstevel@tonic-gate nextblock = VOLRECSTART / sectorsize; 650*0Sstevel@tonic-gate 651*0Sstevel@tonic-gate /* 652*0Sstevel@tonic-gate * Write BEA01/NSR02/TEA01 sequence. 653*0Sstevel@tonic-gate * Each one must be 2K bytes in length. 654*0Sstevel@tonic-gate */ 655*0Sstevel@tonic-gate nsp = (struct nsr_desc *)buf; 656*0Sstevel@tonic-gate nsp->nsr_str_type = 0; 657*0Sstevel@tonic-gate nsp->nsr_ver = 1; 658*0Sstevel@tonic-gate (void) strncpy((int8_t *)nsp->nsr_id, "BEA01", 5); 659*0Sstevel@tonic-gate 660*0Sstevel@tonic-gate nsp = (struct nsr_desc *)&buf[2048]; 661*0Sstevel@tonic-gate nsp->nsr_str_type = 0; 662*0Sstevel@tonic-gate nsp->nsr_ver = 1; 663*0Sstevel@tonic-gate (void) strncpy((int8_t *)nsp->nsr_id, "NSR02", 5); 664*0Sstevel@tonic-gate 665*0Sstevel@tonic-gate nsp = (struct nsr_desc *)&buf[4096]; 666*0Sstevel@tonic-gate nsp->nsr_str_type = 0; 667*0Sstevel@tonic-gate nsp->nsr_ver = 1; 668*0Sstevel@tonic-gate (void) strncpy((int8_t *)nsp->nsr_id, "TEA01", 5); 669*0Sstevel@tonic-gate 670*0Sstevel@tonic-gate wtfs(nextblock, 8192, buf); 671*0Sstevel@tonic-gate bzero(buf, MAXBSIZE); 672*0Sstevel@tonic-gate 673*0Sstevel@tonic-gate /* 674*0Sstevel@tonic-gate * Minimum length of volume sequences 675*0Sstevel@tonic-gate */ 676*0Sstevel@tonic-gate volseq_sectors = 16; 677*0Sstevel@tonic-gate 678*0Sstevel@tonic-gate /* 679*0Sstevel@tonic-gate * Round up to next 32K boundary for 680*0Sstevel@tonic-gate * volume descriptor sequences 681*0Sstevel@tonic-gate */ 682*0Sstevel@tonic-gate nextblock = VOLSEQSTART; 683*0Sstevel@tonic-gate bzero(buf, sectorsize); 684*0Sstevel@tonic-gate mvds_loc = VOLSEQSTART; 685*0Sstevel@tonic-gate rvds_loc = mvds_loc + volseq_sectors; 686*0Sstevel@tonic-gate 687*0Sstevel@tonic-gate /* 688*0Sstevel@tonic-gate * Primary Volume Descriptor 689*0Sstevel@tonic-gate */ 690*0Sstevel@tonic-gate /* LINTED */ 691*0Sstevel@tonic-gate pvdp = (struct pri_vol_desc *)buf; 692*0Sstevel@tonic-gate tp = &pvdp->pvd_tag; 693*0Sstevel@tonic-gate tp->tag_id = UD_PRI_VOL_DESC; 694*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 695*0Sstevel@tonic-gate tp->tag_sno = serialnum; 696*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct pri_vol_desc) - 697*0Sstevel@tonic-gate sizeof (struct tag); 698*0Sstevel@tonic-gate pvdp->pvd_vdsn = 0; 699*0Sstevel@tonic-gate pvdp->pvd_pvdn = 0; 700*0Sstevel@tonic-gate setdstring(pvdp->pvd_vol_id, udfs_label, 32); 701*0Sstevel@tonic-gate pvdp->pvd_vsn = 1; 702*0Sstevel@tonic-gate pvdp->pvd_mvsn = 1; 703*0Sstevel@tonic-gate pvdp->pvd_il = 2; /* Single-volume */ 704*0Sstevel@tonic-gate pvdp->pvd_mil = 3; /* Multi-volume */ 705*0Sstevel@tonic-gate pvdp->pvd_csl = 1; /* CS0 */ 706*0Sstevel@tonic-gate pvdp->pvd_mcsl = 1; /* CS0 */ 707*0Sstevel@tonic-gate (void) sprintf(vsibuf, "%08X", SWAP_32((uint32_t)mkfstime)); 708*0Sstevel@tonic-gate setdstring(pvdp->pvd_vsi, vsibuf, 128); 709*0Sstevel@tonic-gate (void) strncpy(pvdp->pvd_vsi + 17, udfs_label, 128 - 17); 710*0Sstevel@tonic-gate setcharspec(&pvdp->pvd_desc_cs, 0, osta_unicode); 711*0Sstevel@tonic-gate setcharspec(&pvdp->pvd_exp_cs, 0, osta_unicode); 712*0Sstevel@tonic-gate setextad(&pvdp->pvd_vol_abs, 0, 0); 713*0Sstevel@tonic-gate setextad(&pvdp->pvd_vcn, 0, 0); 714*0Sstevel@tonic-gate bzero(&pvdp->pvd_appl_id, sizeof (regid_t)); 715*0Sstevel@tonic-gate setstamp(&pvdp->pvd_time); 716*0Sstevel@tonic-gate bcopy(&sunmicro, &pvdp->pvd_ii, sizeof (regid_t)); 717*0Sstevel@tonic-gate pvdp->pvd_flags = 0; 718*0Sstevel@tonic-gate wtvolseq(tp, nextblock, nextblock + volseq_sectors); 719*0Sstevel@tonic-gate nextblock++; 720*0Sstevel@tonic-gate 721*0Sstevel@tonic-gate /* 722*0Sstevel@tonic-gate * Implementation Use Descriptor 723*0Sstevel@tonic-gate */ 724*0Sstevel@tonic-gate bzero(buf, sectorsize); 725*0Sstevel@tonic-gate /* LINTED */ 726*0Sstevel@tonic-gate iudp = (struct iuvd_desc *)buf; 727*0Sstevel@tonic-gate tp = &iudp->iuvd_tag; 728*0Sstevel@tonic-gate tp->tag_id = UD_IMPL_USE_DESC; 729*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 730*0Sstevel@tonic-gate tp->tag_sno = serialnum; 731*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct iuvd_desc) - 732*0Sstevel@tonic-gate sizeof (struct tag); 733*0Sstevel@tonic-gate iudp->iuvd_vdsn = 0; 734*0Sstevel@tonic-gate bcopy(&lvinfo, &iudp->iuvd_ii, sizeof (regid_t)); 735*0Sstevel@tonic-gate setcharspec(&iudp->iuvd_cset, 0, osta_unicode); 736*0Sstevel@tonic-gate setdstring(iudp->iuvd_lvi, udfs_label, 128); 737*0Sstevel@tonic-gate 738*0Sstevel@tonic-gate setdstring(iudp->iuvd_ifo1, "", 36); 739*0Sstevel@tonic-gate setdstring(iudp->iuvd_ifo2, "", 36); 740*0Sstevel@tonic-gate setdstring(iudp->iuvd_ifo3, "", 36); 741*0Sstevel@tonic-gate 742*0Sstevel@tonic-gate 743*0Sstevel@tonic-gate /* 744*0Sstevel@tonic-gate * info1,2,3 = user specified 745*0Sstevel@tonic-gate */ 746*0Sstevel@tonic-gate bcopy(&sunmicro, &iudp->iuvd_iid, sizeof (regid_t)); 747*0Sstevel@tonic-gate wtvolseq(tp, nextblock, nextblock + volseq_sectors); 748*0Sstevel@tonic-gate nextblock++; 749*0Sstevel@tonic-gate 750*0Sstevel@tonic-gate /* 751*0Sstevel@tonic-gate * Partition Descriptor 752*0Sstevel@tonic-gate */ 753*0Sstevel@tonic-gate bzero(buf, sectorsize); 754*0Sstevel@tonic-gate /* LINTED */ 755*0Sstevel@tonic-gate pp = (struct part_desc *)buf; 756*0Sstevel@tonic-gate tp = &pp->pd_tag; 757*0Sstevel@tonic-gate tp->tag_id = UD_PART_DESC; 758*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 759*0Sstevel@tonic-gate tp->tag_sno = serialnum; 760*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct part_desc) - 761*0Sstevel@tonic-gate sizeof (struct tag); 762*0Sstevel@tonic-gate pp->pd_vdsn = 0; 763*0Sstevel@tonic-gate pp->pd_pflags = 1; /* Allocated */ 764*0Sstevel@tonic-gate pp->pd_pnum = 0; 765*0Sstevel@tonic-gate bcopy(&partid, &pp->pd_pcontents, sizeof (regid_t)); 766*0Sstevel@tonic-gate 767*0Sstevel@tonic-gate part_start = FIRSTAVDP + AVDPLEN; 768*0Sstevel@tonic-gate part_len = fssize - part_start; 769*0Sstevel@tonic-gate part_bmp_bytes = (part_len + NBBY - 1) / NBBY; 770*0Sstevel@tonic-gate part_bmp_sectors = (part_bmp_bytes + SPACEMAP_OFF + sectorsize - 1) / 771*0Sstevel@tonic-gate sectorsize; 772*0Sstevel@tonic-gate 773*0Sstevel@tonic-gate pp->pd_part_start = part_start; 774*0Sstevel@tonic-gate pp->pd_part_length = part_len; 775*0Sstevel@tonic-gate 776*0Sstevel@tonic-gate pp->pd_acc_type = acctype; 777*0Sstevel@tonic-gate nextlogblock = 0; 778*0Sstevel@tonic-gate 779*0Sstevel@tonic-gate /* 780*0Sstevel@tonic-gate * Do the partition header 781*0Sstevel@tonic-gate */ 782*0Sstevel@tonic-gate /* LINTED */ 783*0Sstevel@tonic-gate php = (struct phdr_desc *)&pp->pd_pc_use; 784*0Sstevel@tonic-gate 785*0Sstevel@tonic-gate /* 786*0Sstevel@tonic-gate * Set up unallocated space bitmap 787*0Sstevel@tonic-gate */ 788*0Sstevel@tonic-gate if (acctype == PART_ACC_RW || acctype == PART_ACC_OW) { 789*0Sstevel@tonic-gate php->phdr_usb.sad_ext_len = 790*0Sstevel@tonic-gate (part_bmp_bytes + SPACEMAP_OFF + sectorsize - 1) & 791*0Sstevel@tonic-gate (~(sectorsize - 1)); 792*0Sstevel@tonic-gate php->phdr_usb.sad_ext_loc = nextlogblock; 793*0Sstevel@tonic-gate part_unalloc = nextlogblock; 794*0Sstevel@tonic-gate nextlogblock += part_bmp_sectors; 795*0Sstevel@tonic-gate } 796*0Sstevel@tonic-gate 797*0Sstevel@tonic-gate bcopy(&sunmicro, &pp->pd_ii, sizeof (regid_t)); 798*0Sstevel@tonic-gate wtvolseq(tp, nextblock, nextblock + volseq_sectors); 799*0Sstevel@tonic-gate nextblock++; 800*0Sstevel@tonic-gate 801*0Sstevel@tonic-gate /* 802*0Sstevel@tonic-gate * Logical Volume Descriptor 803*0Sstevel@tonic-gate */ 804*0Sstevel@tonic-gate bzero(buf, sectorsize); 805*0Sstevel@tonic-gate /* LINTED */ 806*0Sstevel@tonic-gate lvp = (struct log_vol_desc *)buf; 807*0Sstevel@tonic-gate tp = &lvp->lvd_tag; 808*0Sstevel@tonic-gate tp->tag_id = UD_LOG_VOL_DESC; 809*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 810*0Sstevel@tonic-gate tp->tag_sno = serialnum; 811*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct log_vol_desc) - 812*0Sstevel@tonic-gate sizeof (struct tag); 813*0Sstevel@tonic-gate lvp->lvd_vdsn = 0; 814*0Sstevel@tonic-gate setcharspec(&lvp->lvd_desc_cs, 0, osta_unicode); 815*0Sstevel@tonic-gate setdstring(lvp->lvd_lvid, udfs_label, 128); 816*0Sstevel@tonic-gate lvp->lvd_log_bsize = sectorsize; 817*0Sstevel@tonic-gate bcopy(&udf_compliant, &lvp->lvd_dom_id, sizeof (regid_t)); 818*0Sstevel@tonic-gate lap = (long_ad_t *)&lvp->lvd_lvcu; 819*0Sstevel@tonic-gate lap->lad_ext_len = FILESETLEN * sectorsize; 820*0Sstevel@tonic-gate filesetblock = nextlogblock; 821*0Sstevel@tonic-gate lap->lad_ext_loc = nextlogblock; 822*0Sstevel@tonic-gate lap->lad_ext_prn = 0; 823*0Sstevel@tonic-gate lvp->lvd_mtbl_len = 6; 824*0Sstevel@tonic-gate lvp->lvd_num_pmaps = 1; 825*0Sstevel@tonic-gate bcopy(&sunmicro, &lvp->lvd_ii, sizeof (regid_t)); 826*0Sstevel@tonic-gate /* LINTED */ 827*0Sstevel@tonic-gate pmp = (struct pmap_typ1 *)&lvp->lvd_pmaps; 828*0Sstevel@tonic-gate pmp->map1_type = 1; 829*0Sstevel@tonic-gate pmp->map1_length = 6; 830*0Sstevel@tonic-gate pmp->map1_vsn = SWAP_16(1); 831*0Sstevel@tonic-gate pmp->map1_pn = 0; 832*0Sstevel@tonic-gate tp->tag_crc_len = (char *)(pmp + 1) - buf - sizeof (struct tag); 833*0Sstevel@tonic-gate setextad(&lvp->lvd_int_seq_ext, INTSEQLEN, INTSEQSTART); 834*0Sstevel@tonic-gate wtvolseq(tp, nextblock, nextblock + volseq_sectors); 835*0Sstevel@tonic-gate nextblock++; 836*0Sstevel@tonic-gate 837*0Sstevel@tonic-gate /* 838*0Sstevel@tonic-gate * Unallocated Space Descriptor 839*0Sstevel@tonic-gate */ 840*0Sstevel@tonic-gate bzero(buf, sectorsize); 841*0Sstevel@tonic-gate /* LINTED */ 842*0Sstevel@tonic-gate uap = (struct unall_spc_desc *)buf; 843*0Sstevel@tonic-gate tp = &uap->ua_tag; 844*0Sstevel@tonic-gate tp->tag_id = UD_UNALL_SPA_DESC; 845*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 846*0Sstevel@tonic-gate tp->tag_sno = serialnum; 847*0Sstevel@tonic-gate uap->ua_vdsn = 0; 848*0Sstevel@tonic-gate uap->ua_nad = 0; 849*0Sstevel@tonic-gate tp->tag_crc_len = (char *)uap->ua_al_dsc - buf - sizeof (struct tag); 850*0Sstevel@tonic-gate wtvolseq(tp, nextblock, nextblock + volseq_sectors); 851*0Sstevel@tonic-gate nextblock++; 852*0Sstevel@tonic-gate 853*0Sstevel@tonic-gate /* 854*0Sstevel@tonic-gate * Terminating Descriptor 855*0Sstevel@tonic-gate */ 856*0Sstevel@tonic-gate bzero(buf, sectorsize); 857*0Sstevel@tonic-gate /* LINTED */ 858*0Sstevel@tonic-gate tdp = (struct term_desc *)buf; 859*0Sstevel@tonic-gate tp = &tdp->td_tag; 860*0Sstevel@tonic-gate tp->tag_id = UD_TERM_DESC; 861*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 862*0Sstevel@tonic-gate tp->tag_sno = serialnum; 863*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct term_desc) - 864*0Sstevel@tonic-gate sizeof (struct tag); 865*0Sstevel@tonic-gate tp->tag_loc = nextblock; 866*0Sstevel@tonic-gate wtvolseq(tp, nextblock, nextblock + volseq_sectors); 867*0Sstevel@tonic-gate nextblock++; 868*0Sstevel@tonic-gate 869*0Sstevel@tonic-gate /* 870*0Sstevel@tonic-gate * Do the anchor volume descriptor 871*0Sstevel@tonic-gate */ 872*0Sstevel@tonic-gate if (nextblock > FIRSTAVDP) { 873*0Sstevel@tonic-gate (void) fprintf(stdout, 874*0Sstevel@tonic-gate gettext("Volume integrity sequence" 875*0Sstevel@tonic-gate " descriptors too long\n")); 876*0Sstevel@tonic-gate exit(32); 877*0Sstevel@tonic-gate } 878*0Sstevel@tonic-gate 879*0Sstevel@tonic-gate nextblock = FIRSTAVDP; 880*0Sstevel@tonic-gate bzero(buf, sectorsize); 881*0Sstevel@tonic-gate /* LINTED */ 882*0Sstevel@tonic-gate avp = (struct anch_vol_desc_ptr *)buf; 883*0Sstevel@tonic-gate tp = &avp->avd_tag; 884*0Sstevel@tonic-gate tp->tag_id = UD_ANCH_VOL_DESC; 885*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 886*0Sstevel@tonic-gate tp->tag_sno = serialnum; 887*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct anch_vol_desc_ptr) - 888*0Sstevel@tonic-gate sizeof (struct tag); 889*0Sstevel@tonic-gate tp->tag_loc = nextblock; 890*0Sstevel@tonic-gate setextad(&avp->avd_main_vdse, 891*0Sstevel@tonic-gate volseq_sectors * sectorsize, mvds_loc); 892*0Sstevel@tonic-gate setextad(&avp->avd_res_vdse, 893*0Sstevel@tonic-gate volseq_sectors * sectorsize, rvds_loc); 894*0Sstevel@tonic-gate bzero(buf2, sectorsize); 895*0Sstevel@tonic-gate /* LINTED */ 896*0Sstevel@tonic-gate maketag(tp, (struct tag *)buf2); 897*0Sstevel@tonic-gate wtfs(nextblock, sectorsize, buf2); 898*0Sstevel@tonic-gate nextblock++; 899*0Sstevel@tonic-gate 900*0Sstevel@tonic-gate tp->tag_loc = fssize; 901*0Sstevel@tonic-gate /* LINTED */ 902*0Sstevel@tonic-gate maketag(tp, (struct tag *)buf2); 903*0Sstevel@tonic-gate wtfs(fssize, sectorsize, buf2); 904*0Sstevel@tonic-gate 905*0Sstevel@tonic-gate /* 906*0Sstevel@tonic-gate * File Set Descriptor 907*0Sstevel@tonic-gate */ 908*0Sstevel@tonic-gate bzero(buf, sectorsize); 909*0Sstevel@tonic-gate /* LINTED */ 910*0Sstevel@tonic-gate fsp = (struct file_set_desc *)&buf; 911*0Sstevel@tonic-gate tp = &fsp->fsd_tag; 912*0Sstevel@tonic-gate tp->tag_id = UD_FILE_SET_DESC; 913*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 914*0Sstevel@tonic-gate tp->tag_sno = serialnum; 915*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct file_set_desc) - 916*0Sstevel@tonic-gate sizeof (struct tag); 917*0Sstevel@tonic-gate tp->tag_loc = nextlogblock; 918*0Sstevel@tonic-gate setstamp(&fsp->fsd_time); 919*0Sstevel@tonic-gate fsp->fsd_ilevel = 3; 920*0Sstevel@tonic-gate fsp->fsd_mi_level = 3; 921*0Sstevel@tonic-gate fsp->fsd_cs_list = 1; 922*0Sstevel@tonic-gate fsp->fsd_mcs_list = 1; 923*0Sstevel@tonic-gate fsp->fsd_fs_no = 0; 924*0Sstevel@tonic-gate fsp->fsd_fsd_no = 0; 925*0Sstevel@tonic-gate setcharspec(&fsp->fsd_lvidcs, 0, osta_unicode); 926*0Sstevel@tonic-gate setdstring(fsp->fsd_lvid, udfs_label, 128); 927*0Sstevel@tonic-gate setcharspec(&fsp->fsd_fscs, 0, osta_unicode); 928*0Sstevel@tonic-gate setdstring(fsp->fsd_fsi, udfs_label, 32); 929*0Sstevel@tonic-gate setdstring(fsp->fsd_cfi, "", 32); 930*0Sstevel@tonic-gate setdstring(fsp->fsd_afi, "", 32); 931*0Sstevel@tonic-gate lap = (long_ad_t *)&fsp->fsd_root_icb; 932*0Sstevel@tonic-gate lap->lad_ext_len = sectorsize; 933*0Sstevel@tonic-gate lap->lad_ext_loc = filesetblock + FILESETLEN; 934*0Sstevel@tonic-gate lap->lad_ext_prn = 0; 935*0Sstevel@tonic-gate bcopy(&udf_compliant, &fsp->fsd_did, sizeof (regid_t)); 936*0Sstevel@tonic-gate maketag(tp, tp); 937*0Sstevel@tonic-gate wtfs(nextlogblock + part_start, sectorsize, (char *)tp); 938*0Sstevel@tonic-gate nextlogblock++; 939*0Sstevel@tonic-gate 940*0Sstevel@tonic-gate /* 941*0Sstevel@tonic-gate * Terminating Descriptor 942*0Sstevel@tonic-gate */ 943*0Sstevel@tonic-gate bzero(buf, sectorsize); 944*0Sstevel@tonic-gate /* LINTED */ 945*0Sstevel@tonic-gate tdp = (struct term_desc *)buf; 946*0Sstevel@tonic-gate tp = &tdp->td_tag; 947*0Sstevel@tonic-gate tp->tag_id = UD_TERM_DESC; 948*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 949*0Sstevel@tonic-gate tp->tag_sno = serialnum; 950*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct term_desc) - 951*0Sstevel@tonic-gate sizeof (struct tag); 952*0Sstevel@tonic-gate tp->tag_loc = nextlogblock; 953*0Sstevel@tonic-gate maketag(tp, tp); 954*0Sstevel@tonic-gate wtfs(nextlogblock + part_start, sectorsize, (char *)tp); 955*0Sstevel@tonic-gate nextlogblock++; 956*0Sstevel@tonic-gate 957*0Sstevel@tonic-gate if (nextlogblock > filesetblock + FILESETLEN) { 958*0Sstevel@tonic-gate (void) fprintf(stdout, 959*0Sstevel@tonic-gate gettext("File set descriptor too long\n")); 960*0Sstevel@tonic-gate exit(32); 961*0Sstevel@tonic-gate } 962*0Sstevel@tonic-gate nextlogblock = filesetblock + FILESETLEN; 963*0Sstevel@tonic-gate 964*0Sstevel@tonic-gate /* 965*0Sstevel@tonic-gate * Root File Entry 966*0Sstevel@tonic-gate */ 967*0Sstevel@tonic-gate bzero(buf, sectorsize); 968*0Sstevel@tonic-gate /* LINTED */ 969*0Sstevel@tonic-gate fp = (struct file_entry *)&buf; 970*0Sstevel@tonic-gate tp = &fp->fe_tag; 971*0Sstevel@tonic-gate tp->tag_id = UD_FILE_ENTRY; 972*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 973*0Sstevel@tonic-gate tp->tag_sno = serialnum; 974*0Sstevel@tonic-gate tp->tag_loc = nextlogblock; 975*0Sstevel@tonic-gate icb = &fp->fe_icb_tag; 976*0Sstevel@tonic-gate icb->itag_prnde = 0; 977*0Sstevel@tonic-gate icb->itag_strategy = STRAT_TYPE4; 978*0Sstevel@tonic-gate icb->itag_param = 0; /* what does this mean? */ 979*0Sstevel@tonic-gate icb->itag_max_ent = 1; 980*0Sstevel@tonic-gate icb->itag_ftype = FTYPE_DIRECTORY; 981*0Sstevel@tonic-gate icb->itag_lb_loc = 0; 982*0Sstevel@tonic-gate icb->itag_lb_prn = 0; 983*0Sstevel@tonic-gate icb->itag_flags = ICB_FLAG_ARCHIVE; 984*0Sstevel@tonic-gate fp->fe_uid = getuid(); 985*0Sstevel@tonic-gate fp->fe_gid = getgid(); 986*0Sstevel@tonic-gate fp->fe_perms = (0x1f << 10) | (0x5 << 5) | 0x5; 987*0Sstevel@tonic-gate fp->fe_lcount = 1; 988*0Sstevel@tonic-gate fp->fe_rec_for = 0; 989*0Sstevel@tonic-gate fp->fe_rec_dis = 0; 990*0Sstevel@tonic-gate fp->fe_rec_len = 0; 991*0Sstevel@tonic-gate fp->fe_info_len = sizeof (struct file_id); 992*0Sstevel@tonic-gate fp->fe_lbr = 1; 993*0Sstevel@tonic-gate setstamp(&fp->fe_acc_time); 994*0Sstevel@tonic-gate setstamp(&fp->fe_mod_time); 995*0Sstevel@tonic-gate setstamp(&fp->fe_attr_time); 996*0Sstevel@tonic-gate fp->fe_ckpoint = 1; 997*0Sstevel@tonic-gate bcopy(&sunmicro, &fp->fe_impl_id, sizeof (regid_t)); 998*0Sstevel@tonic-gate fp->fe_uniq_id = 0; 999*0Sstevel@tonic-gate fp->fe_len_ear = 0; 1000*0Sstevel@tonic-gate fp->fe_len_adesc = sizeof (short_ad_t); 1001*0Sstevel@tonic-gate 1002*0Sstevel@tonic-gate /* LINTED */ 1003*0Sstevel@tonic-gate sap = (short_ad_t *)(fp->fe_spec + fp->fe_len_ear); 1004*0Sstevel@tonic-gate sap->sad_ext_len = sizeof (struct file_id); 1005*0Sstevel@tonic-gate sap->sad_ext_loc = nextlogblock + 1; 1006*0Sstevel@tonic-gate rootfelen = (char *)(sap + 1) - buf; 1007*0Sstevel@tonic-gate tp->tag_crc_len = rootfelen - sizeof (struct tag); 1008*0Sstevel@tonic-gate maketag(tp, tp); 1009*0Sstevel@tonic-gate wtfs(nextlogblock + part_start, sectorsize, (char *)tp); 1010*0Sstevel@tonic-gate nextlogblock++; 1011*0Sstevel@tonic-gate 1012*0Sstevel@tonic-gate /* 1013*0Sstevel@tonic-gate * Root Directory 1014*0Sstevel@tonic-gate */ 1015*0Sstevel@tonic-gate bzero(buf, sectorsize); 1016*0Sstevel@tonic-gate /* LINTED */ 1017*0Sstevel@tonic-gate fip = (struct file_id *)&buf; 1018*0Sstevel@tonic-gate tp = &fip->fid_tag; 1019*0Sstevel@tonic-gate tp->tag_id = UD_FILE_ID_DESC; 1020*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 1021*0Sstevel@tonic-gate tp->tag_sno = serialnum; 1022*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct file_id) - 1023*0Sstevel@tonic-gate sizeof (struct tag); 1024*0Sstevel@tonic-gate tp->tag_loc = nextlogblock; 1025*0Sstevel@tonic-gate fip->fid_ver = 1; 1026*0Sstevel@tonic-gate fip->fid_flags = FID_DIR | FID_PARENT; 1027*0Sstevel@tonic-gate fip->fid_idlen = 0; 1028*0Sstevel@tonic-gate fip->fid_iulen = 0; 1029*0Sstevel@tonic-gate fip->fid_icb.lad_ext_len = sectorsize; /* rootfelen; */ 1030*0Sstevel@tonic-gate fip->fid_icb.lad_ext_loc = nextlogblock - 1; 1031*0Sstevel@tonic-gate fip->fid_icb.lad_ext_prn = 0; 1032*0Sstevel@tonic-gate maketag(tp, tp); 1033*0Sstevel@tonic-gate wtfs(nextlogblock + part_start, sectorsize, (char *)tp); 1034*0Sstevel@tonic-gate nextlogblock++; 1035*0Sstevel@tonic-gate 1036*0Sstevel@tonic-gate /* 1037*0Sstevel@tonic-gate * Now do the space bitmaps 1038*0Sstevel@tonic-gate */ 1039*0Sstevel@tonic-gate if (part_unalloc >= 0) { 1040*0Sstevel@tonic-gate int size = sectorsize * part_bmp_sectors; 1041*0Sstevel@tonic-gate 1042*0Sstevel@tonic-gate sbp = (struct space_bmap_desc *)malloc(size); 1043*0Sstevel@tonic-gate if (!sbp) { 1044*0Sstevel@tonic-gate (void) fprintf(stdout, 1045*0Sstevel@tonic-gate gettext("Can't allocate bitmap space\n")); 1046*0Sstevel@tonic-gate exit(32); 1047*0Sstevel@tonic-gate } 1048*0Sstevel@tonic-gate bzero((char *)sbp, sectorsize * part_bmp_sectors); 1049*0Sstevel@tonic-gate tp = &sbp->sbd_tag; 1050*0Sstevel@tonic-gate tp->tag_id = UD_SPA_BMAP_DESC; 1051*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 1052*0Sstevel@tonic-gate tp->tag_sno = serialnum; 1053*0Sstevel@tonic-gate tp->tag_crc_len = 0; /* Don't do CRCs on bitmaps */ 1054*0Sstevel@tonic-gate tp->tag_loc = part_unalloc; 1055*0Sstevel@tonic-gate sbp->sbd_nbits = part_len; 1056*0Sstevel@tonic-gate sbp->sbd_nbytes = part_bmp_bytes; 1057*0Sstevel@tonic-gate maketag(tp, tp); 1058*0Sstevel@tonic-gate if (part_unalloc >= 0) { 1059*0Sstevel@tonic-gate int32_t i; 1060*0Sstevel@tonic-gate 1061*0Sstevel@tonic-gate cp = (uint8_t *)sbp + SPACEMAP_OFF; 1062*0Sstevel@tonic-gate i = nextlogblock / NBBY; 1063*0Sstevel@tonic-gate cp[i++] = (0xff << (nextlogblock % NBBY)) & 0xff; 1064*0Sstevel@tonic-gate while (i < part_bmp_bytes) 1065*0Sstevel@tonic-gate cp[i++] = 0xff; 1066*0Sstevel@tonic-gate if (part_len % NBBY) 1067*0Sstevel@tonic-gate cp[--i] = (unsigned)0xff >> 1068*0Sstevel@tonic-gate (NBBY - part_len % NBBY); 1069*0Sstevel@tonic-gate 1070*0Sstevel@tonic-gate wtfs(part_unalloc + part_start, size, (char *)tp); 1071*0Sstevel@tonic-gate } 1072*0Sstevel@tonic-gate free((char *)sbp); 1073*0Sstevel@tonic-gate } 1074*0Sstevel@tonic-gate 1075*0Sstevel@tonic-gate /* 1076*0Sstevel@tonic-gate * Volume Integrity Descriptor 1077*0Sstevel@tonic-gate */ 1078*0Sstevel@tonic-gate nextblock = INTSEQSTART; 1079*0Sstevel@tonic-gate endblock = nextblock + INTSEQLEN / sectorsize; 1080*0Sstevel@tonic-gate /* LINTED */ 1081*0Sstevel@tonic-gate lvip = (struct log_vol_int_desc *)&lvid; 1082*0Sstevel@tonic-gate tp = &lvip->lvid_tag; 1083*0Sstevel@tonic-gate tp->tag_id = UD_LOG_VOL_INT; 1084*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 1085*0Sstevel@tonic-gate tp->tag_sno = serialnum; 1086*0Sstevel@tonic-gate tp->tag_loc = nextblock; 1087*0Sstevel@tonic-gate setstamp(&lvip->lvid_tstamp); 1088*0Sstevel@tonic-gate lvip->lvid_int_type = LOG_VOL_CLOSE_INT; 1089*0Sstevel@tonic-gate setextad(&lvip->lvid_nie, 0, 0); 1090*0Sstevel@tonic-gate lvip->lvid_npart = 1; 1091*0Sstevel@tonic-gate lvip->lvid_liu = 0x2e; 1092*0Sstevel@tonic-gate lvip->lvid_uniqid = MAXID + 1; 1093*0Sstevel@tonic-gate lvip->lvid_fst[0] = part_len - nextlogblock; /* Free space */ 1094*0Sstevel@tonic-gate lvip->lvid_fst[1] = part_len; /* Size */ 1095*0Sstevel@tonic-gate lviup = (struct lvid_iu *)&lvip->lvid_fst[2]; 1096*0Sstevel@tonic-gate bcopy(&sunmicro, &lviup->lvidiu_regid, sizeof (regid_t)); 1097*0Sstevel@tonic-gate lviup->lvidiu_nfiles = 0; 1098*0Sstevel@tonic-gate lviup->lvidiu_ndirs = 1; 1099*0Sstevel@tonic-gate lviup->lvidiu_mread = 0x102; 1100*0Sstevel@tonic-gate lviup->lvidiu_mwrite = 0x102; 1101*0Sstevel@tonic-gate lviup->lvidiu_maxwr = 0x150; 1102*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct log_vol_int_desc) + lvip->lvid_liu - 1103*0Sstevel@tonic-gate sizeof (struct tag); 1104*0Sstevel@tonic-gate maketag(tp, tp); 1105*0Sstevel@tonic-gate wtfs(nextblock, sectorsize, (char *)tp); 1106*0Sstevel@tonic-gate nextblock++; 1107*0Sstevel@tonic-gate 1108*0Sstevel@tonic-gate /* 1109*0Sstevel@tonic-gate * Terminating Descriptor 1110*0Sstevel@tonic-gate */ 1111*0Sstevel@tonic-gate bzero(buf, sectorsize); 1112*0Sstevel@tonic-gate /* LINTED */ 1113*0Sstevel@tonic-gate tdp = (struct term_desc *)buf; 1114*0Sstevel@tonic-gate tp = &tdp->td_tag; 1115*0Sstevel@tonic-gate tp->tag_id = UD_TERM_DESC; 1116*0Sstevel@tonic-gate tp->tag_desc_ver = ecma_version; 1117*0Sstevel@tonic-gate tp->tag_sno = serialnum; 1118*0Sstevel@tonic-gate tp->tag_crc_len = sizeof (struct term_desc) - sizeof (struct tag); 1119*0Sstevel@tonic-gate tp->tag_loc = nextblock; 1120*0Sstevel@tonic-gate maketag(tp, tp); 1121*0Sstevel@tonic-gate wtfs(nextblock, sectorsize, (char *)tp); 1122*0Sstevel@tonic-gate nextblock++; 1123*0Sstevel@tonic-gate 1124*0Sstevel@tonic-gate /* Zero out the rest of the LVI extent */ 1125*0Sstevel@tonic-gate bzero(buf, sectorsize); 1126*0Sstevel@tonic-gate while (nextblock < endblock) 1127*0Sstevel@tonic-gate wtfs(nextblock++, sectorsize, buf); 1128*0Sstevel@tonic-gate } 1129*0Sstevel@tonic-gate 1130*0Sstevel@tonic-gate /* 1131*0Sstevel@tonic-gate * read a block from the file system 1132*0Sstevel@tonic-gate */ 1133*0Sstevel@tonic-gate static void 1134*0Sstevel@tonic-gate rdfs(daddr_t bno, int size, char *bf) 1135*0Sstevel@tonic-gate { 1136*0Sstevel@tonic-gate int n, saverr; 1137*0Sstevel@tonic-gate 1138*0Sstevel@tonic-gate if (llseek(fsi, (offset_t)bno * sectorsize, 0) < 0) { 1139*0Sstevel@tonic-gate saverr = errno; 1140*0Sstevel@tonic-gate (void) fprintf(stderr, 1141*0Sstevel@tonic-gate gettext("seek error on sector %ld: %s\n"), 1142*0Sstevel@tonic-gate bno, strerror(saverr)); 1143*0Sstevel@tonic-gate exit(32); 1144*0Sstevel@tonic-gate } 1145*0Sstevel@tonic-gate n = read(fsi, bf, size); 1146*0Sstevel@tonic-gate if (n != size) { 1147*0Sstevel@tonic-gate saverr = errno; 1148*0Sstevel@tonic-gate (void) fprintf(stderr, 1149*0Sstevel@tonic-gate gettext("read error on sector %ld: %s\n"), 1150*0Sstevel@tonic-gate bno, strerror(saverr)); 1151*0Sstevel@tonic-gate exit(32); 1152*0Sstevel@tonic-gate } 1153*0Sstevel@tonic-gate } 1154*0Sstevel@tonic-gate 1155*0Sstevel@tonic-gate /* 1156*0Sstevel@tonic-gate * write a block to the file system 1157*0Sstevel@tonic-gate */ 1158*0Sstevel@tonic-gate static void 1159*0Sstevel@tonic-gate wtfs(daddr_t bno, int size, char *bf) 1160*0Sstevel@tonic-gate { 1161*0Sstevel@tonic-gate int n, saverr; 1162*0Sstevel@tonic-gate 1163*0Sstevel@tonic-gate if (fso == -1) 1164*0Sstevel@tonic-gate return; 1165*0Sstevel@tonic-gate 1166*0Sstevel@tonic-gate if (llseek(fso, (offset_t)bno * sectorsize, 0) < 0) { 1167*0Sstevel@tonic-gate saverr = errno; 1168*0Sstevel@tonic-gate (void) fprintf(stderr, 1169*0Sstevel@tonic-gate gettext("seek error on sector %ld: %s\n"), 1170*0Sstevel@tonic-gate bno, strerror(saverr)); 1171*0Sstevel@tonic-gate exit(32); 1172*0Sstevel@tonic-gate } 1173*0Sstevel@tonic-gate if (Nflag) 1174*0Sstevel@tonic-gate return; 1175*0Sstevel@tonic-gate n = write(fso, bf, size); 1176*0Sstevel@tonic-gate if (n != size) { 1177*0Sstevel@tonic-gate saverr = errno; 1178*0Sstevel@tonic-gate (void) fprintf(stderr, 1179*0Sstevel@tonic-gate gettext("write error on sector %ld: %s\n"), 1180*0Sstevel@tonic-gate bno, strerror(saverr)); 1181*0Sstevel@tonic-gate exit(32); 1182*0Sstevel@tonic-gate } 1183*0Sstevel@tonic-gate } 1184*0Sstevel@tonic-gate 1185*0Sstevel@tonic-gate static void 1186*0Sstevel@tonic-gate usage() 1187*0Sstevel@tonic-gate { 1188*0Sstevel@tonic-gate (void) fprintf(stderr, 1189*0Sstevel@tonic-gate gettext("udfs usage: mkfs [-F FSType] [-V]" 1190*0Sstevel@tonic-gate " [-m] [-o options] special size(sectors)\n")); 1191*0Sstevel@tonic-gate (void) fprintf(stderr, 1192*0Sstevel@tonic-gate gettext(" -m : dump fs cmd line used to make" 1193*0Sstevel@tonic-gate " this partition\n")); 1194*0Sstevel@tonic-gate (void) fprintf(stderr, 1195*0Sstevel@tonic-gate gettext(" -V : print this command line and return\n")); 1196*0Sstevel@tonic-gate (void) fprintf(stderr, 1197*0Sstevel@tonic-gate gettext(" -o : udfs options: :psize=%d:label=%s\n"), 1198*0Sstevel@tonic-gate sectorsize, udfs_label); 1199*0Sstevel@tonic-gate (void) fprintf(stderr, 1200*0Sstevel@tonic-gate gettext("NOTE that all -o suboptions: must" 1201*0Sstevel@tonic-gate " be separated only by commas so as to\n")); 1202*0Sstevel@tonic-gate (void) fprintf(stderr, 1203*0Sstevel@tonic-gate gettext("be parsed as a single argument\n")); 1204*0Sstevel@tonic-gate exit(32); 1205*0Sstevel@tonic-gate } 1206*0Sstevel@tonic-gate 1207*0Sstevel@tonic-gate /*ARGSUSED*/ 1208*0Sstevel@tonic-gate static void 1209*0Sstevel@tonic-gate dump_fscmd(char *fsys, int fsi) 1210*0Sstevel@tonic-gate { 1211*0Sstevel@tonic-gate (void) printf(gettext("mkfs -F udfs -o ")); 1212*0Sstevel@tonic-gate (void) printf("psize=%d,label=\"%s\" %s %d\n", 1213*0Sstevel@tonic-gate sectorsize, oldlabel, fsys, oldfssize); 1214*0Sstevel@tonic-gate } 1215*0Sstevel@tonic-gate 1216*0Sstevel@tonic-gate /* number ************************************************************* */ 1217*0Sstevel@tonic-gate /* */ 1218*0Sstevel@tonic-gate /* Convert a numeric arg to binary */ 1219*0Sstevel@tonic-gate /* */ 1220*0Sstevel@tonic-gate /* Arg: big - maximum valid input number */ 1221*0Sstevel@tonic-gate /* Global arg: string - pointer to command arg */ 1222*0Sstevel@tonic-gate /* */ 1223*0Sstevel@tonic-gate /* Valid forms: 123 | 123k | 123*123 | 123x123 */ 1224*0Sstevel@tonic-gate /* */ 1225*0Sstevel@tonic-gate /* Return: converted number */ 1226*0Sstevel@tonic-gate /* */ 1227*0Sstevel@tonic-gate /* ******************************************************************** */ 1228*0Sstevel@tonic-gate 1229*0Sstevel@tonic-gate static int32_t 1230*0Sstevel@tonic-gate number(long big, char *param) 1231*0Sstevel@tonic-gate { 1232*0Sstevel@tonic-gate char *cs; 1233*0Sstevel@tonic-gate int64_t n = 0; 1234*0Sstevel@tonic-gate int64_t cut = BIG; 1235*0Sstevel@tonic-gate int32_t minus = 0; 1236*0Sstevel@tonic-gate 1237*0Sstevel@tonic-gate #define FOUND_MULT 0x1 1238*0Sstevel@tonic-gate #define FOUND_K 0x2 1239*0Sstevel@tonic-gate 1240*0Sstevel@tonic-gate cs = string; 1241*0Sstevel@tonic-gate if (*cs == '-') { 1242*0Sstevel@tonic-gate minus = 1; 1243*0Sstevel@tonic-gate cs++; 1244*0Sstevel@tonic-gate } 1245*0Sstevel@tonic-gate n = 0; 1246*0Sstevel@tonic-gate while ((*cs != ' ') && (*cs != '\0') && (*cs != ',')) { 1247*0Sstevel@tonic-gate if ((*cs >= '0') && (*cs <= '9')) { 1248*0Sstevel@tonic-gate n = n * 10 + *cs - '0'; 1249*0Sstevel@tonic-gate cs++; 1250*0Sstevel@tonic-gate } else if ((*cs == '*') || (*cs == 'x')) { 1251*0Sstevel@tonic-gate if (number_flags & FOUND_MULT) { 1252*0Sstevel@tonic-gate (void) fprintf(stderr, 1253*0Sstevel@tonic-gate gettext("mkfs: only one \"*\" " 1254*0Sstevel@tonic-gate "or \"x\" allowed\n")); 1255*0Sstevel@tonic-gate exit(2); 1256*0Sstevel@tonic-gate } 1257*0Sstevel@tonic-gate number_flags |= FOUND_MULT; 1258*0Sstevel@tonic-gate cs++; 1259*0Sstevel@tonic-gate string = cs; 1260*0Sstevel@tonic-gate n = n * number(big, param); 1261*0Sstevel@tonic-gate cs = string; 1262*0Sstevel@tonic-gate continue; 1263*0Sstevel@tonic-gate } else if (*cs == 'k') { 1264*0Sstevel@tonic-gate if (number_flags & FOUND_K) { 1265*0Sstevel@tonic-gate (void) fprintf(stderr, 1266*0Sstevel@tonic-gate gettext("mkfs: only one \"k\" allowed\n")); 1267*0Sstevel@tonic-gate exit(2); 1268*0Sstevel@tonic-gate } 1269*0Sstevel@tonic-gate number_flags |= FOUND_K; 1270*0Sstevel@tonic-gate n = n * 1024; 1271*0Sstevel@tonic-gate cs++; 1272*0Sstevel@tonic-gate continue; 1273*0Sstevel@tonic-gate } else { 1274*0Sstevel@tonic-gate (void) fprintf(stderr, 1275*0Sstevel@tonic-gate gettext("mkfs: bad numeric arg: \"%s\"\n"), 1276*0Sstevel@tonic-gate string); 1277*0Sstevel@tonic-gate exit(2); 1278*0Sstevel@tonic-gate } 1279*0Sstevel@tonic-gate } 1280*0Sstevel@tonic-gate 1281*0Sstevel@tonic-gate if (n > cut) { 1282*0Sstevel@tonic-gate (void) fprintf(stderr, 1283*0Sstevel@tonic-gate gettext("mkfs: value for %s overflowed\n"), param); 1284*0Sstevel@tonic-gate exit(2); 1285*0Sstevel@tonic-gate } 1286*0Sstevel@tonic-gate 1287*0Sstevel@tonic-gate if (minus) { 1288*0Sstevel@tonic-gate n = -n; 1289*0Sstevel@tonic-gate } 1290*0Sstevel@tonic-gate 1291*0Sstevel@tonic-gate if ((n > big) || (n < 0)) { 1292*0Sstevel@tonic-gate (void) fprintf(stderr, 1293*0Sstevel@tonic-gate gettext("mkfs: argument %s out of range\n"), param); 1294*0Sstevel@tonic-gate exit(2); 1295*0Sstevel@tonic-gate } 1296*0Sstevel@tonic-gate 1297*0Sstevel@tonic-gate string = cs; 1298*0Sstevel@tonic-gate return ((int32_t)n); 1299*0Sstevel@tonic-gate } 1300*0Sstevel@tonic-gate 1301*0Sstevel@tonic-gate /* match ************************************************************** */ 1302*0Sstevel@tonic-gate /* */ 1303*0Sstevel@tonic-gate /* Compare two text strings for equality */ 1304*0Sstevel@tonic-gate /* */ 1305*0Sstevel@tonic-gate /* Arg: s - pointer to string to match with a command arg */ 1306*0Sstevel@tonic-gate /* Global arg: string - pointer to command arg */ 1307*0Sstevel@tonic-gate /* */ 1308*0Sstevel@tonic-gate /* Return: 1 if match, 0 if no match */ 1309*0Sstevel@tonic-gate /* If match, also reset `string' to point to the text */ 1310*0Sstevel@tonic-gate /* that follows the matching text. */ 1311*0Sstevel@tonic-gate /* */ 1312*0Sstevel@tonic-gate /* ******************************************************************** */ 1313*0Sstevel@tonic-gate 1314*0Sstevel@tonic-gate static int 1315*0Sstevel@tonic-gate match(char *s) 1316*0Sstevel@tonic-gate { 1317*0Sstevel@tonic-gate char *cs; 1318*0Sstevel@tonic-gate 1319*0Sstevel@tonic-gate cs = string; 1320*0Sstevel@tonic-gate while (*cs++ == *s) { 1321*0Sstevel@tonic-gate if (*s++ == '\0') { 1322*0Sstevel@tonic-gate goto true; 1323*0Sstevel@tonic-gate } 1324*0Sstevel@tonic-gate } 1325*0Sstevel@tonic-gate if (*s != '\0') { 1326*0Sstevel@tonic-gate return (0); 1327*0Sstevel@tonic-gate } 1328*0Sstevel@tonic-gate 1329*0Sstevel@tonic-gate true: 1330*0Sstevel@tonic-gate cs--; 1331*0Sstevel@tonic-gate string = cs; 1332*0Sstevel@tonic-gate return (1); 1333*0Sstevel@tonic-gate } 1334*0Sstevel@tonic-gate 1335*0Sstevel@tonic-gate static uint32_t 1336*0Sstevel@tonic-gate get_bsize() 1337*0Sstevel@tonic-gate { 1338*0Sstevel@tonic-gate struct dk_cinfo info; 1339*0Sstevel@tonic-gate struct fd_char fd_char; 1340*0Sstevel@tonic-gate 1341*0Sstevel@tonic-gate if (ioctl(fso, DKIOCINFO, &info) < 0) { 1342*0Sstevel@tonic-gate perror("mkfs DKIOCINFO "); 1343*0Sstevel@tonic-gate (void) fprintf(stdout, 1344*0Sstevel@tonic-gate gettext("DKIOCINFO failed using psize = 2048" 1345*0Sstevel@tonic-gate " for creating file-system\n")); 1346*0Sstevel@tonic-gate return (0); 1347*0Sstevel@tonic-gate } 1348*0Sstevel@tonic-gate 1349*0Sstevel@tonic-gate switch (info.dki_ctype) { 1350*0Sstevel@tonic-gate case DKC_CDROM : 1351*0Sstevel@tonic-gate return (2048); 1352*0Sstevel@tonic-gate case DKC_SCSI_CCS : 1353*0Sstevel@tonic-gate /* FALLTHROUGH */ 1354*0Sstevel@tonic-gate case DKC_INTEL82072 : 1355*0Sstevel@tonic-gate /* FALLTHROUGH */ 1356*0Sstevel@tonic-gate case DKC_INTEL82077 : 1357*0Sstevel@tonic-gate /* FALLTHROUGH */ 1358*0Sstevel@tonic-gate case DKC_DIRECT : 1359*0Sstevel@tonic-gate if (ioctl(fso, FDIOGCHAR, &fd_char) >= 0) { 1360*0Sstevel@tonic-gate return (fd_char.fdc_sec_size); 1361*0Sstevel@tonic-gate } 1362*0Sstevel@tonic-gate /* FALLTHROUGH */ 1363*0Sstevel@tonic-gate case DKC_PCMCIA_ATA : 1364*0Sstevel@tonic-gate return (512); 1365*0Sstevel@tonic-gate default : 1366*0Sstevel@tonic-gate return (0); 1367*0Sstevel@tonic-gate } 1368*0Sstevel@tonic-gate } 1369*0Sstevel@tonic-gate 1370*0Sstevel@tonic-gate /* 1371*0Sstevel@tonic-gate * Read in the volume sequences descriptors. 1372*0Sstevel@tonic-gate */ 1373*0Sstevel@tonic-gate static int 1374*0Sstevel@tonic-gate readvolseq() 1375*0Sstevel@tonic-gate { 1376*0Sstevel@tonic-gate struct tag *tp; 1377*0Sstevel@tonic-gate uint8_t *cp, *end; 1378*0Sstevel@tonic-gate int err; 1379*0Sstevel@tonic-gate struct pri_vol_desc *pvolp; 1380*0Sstevel@tonic-gate struct part_desc *partp; 1381*0Sstevel@tonic-gate struct log_vol_desc *logvp; 1382*0Sstevel@tonic-gate struct anch_vol_desc_ptr *avp; 1383*0Sstevel@tonic-gate char *main_vdbuf; 1384*0Sstevel@tonic-gate uint32_t nextblock; 1385*0Sstevel@tonic-gate 1386*0Sstevel@tonic-gate avp = (struct anch_vol_desc_ptr *)malloc(sectorsize); 1387*0Sstevel@tonic-gate rdfs(FIRSTAVDP, sectorsize, (char *)avp); 1388*0Sstevel@tonic-gate tp = (struct tag *)avp; 1389*0Sstevel@tonic-gate err = verifytag(tp, FIRSTAVDP, tp, UD_ANCH_VOL_DESC); 1390*0Sstevel@tonic-gate if (err) 1391*0Sstevel@tonic-gate return (0); 1392*0Sstevel@tonic-gate main_vdbuf = malloc(avp->avd_main_vdse.ext_len); 1393*0Sstevel@tonic-gate if (main_vdbuf == NULL) { 1394*0Sstevel@tonic-gate (void) fprintf(stderr, gettext("Cannot allocate space for " 1395*0Sstevel@tonic-gate "volume sequences\n")); 1396*0Sstevel@tonic-gate exit(32); 1397*0Sstevel@tonic-gate } 1398*0Sstevel@tonic-gate rdfs(avp->avd_main_vdse.ext_loc, avp->avd_main_vdse.ext_len, 1399*0Sstevel@tonic-gate main_vdbuf); 1400*0Sstevel@tonic-gate end = (uint8_t *)main_vdbuf + avp->avd_main_vdse.ext_len; 1401*0Sstevel@tonic-gate 1402*0Sstevel@tonic-gate nextblock = avp->avd_main_vdse.ext_loc; 1403*0Sstevel@tonic-gate for (cp = (uint8_t *)main_vdbuf; cp < end; cp += sectorsize, 1404*0Sstevel@tonic-gate nextblock++) { 1405*0Sstevel@tonic-gate /* LINTED */ 1406*0Sstevel@tonic-gate tp = (struct tag *)cp; 1407*0Sstevel@tonic-gate err = verifytag(tp, nextblock, tp, 0); 1408*0Sstevel@tonic-gate if (err) 1409*0Sstevel@tonic-gate continue; 1410*0Sstevel@tonic-gate 1411*0Sstevel@tonic-gate switch (tp->tag_id) { 1412*0Sstevel@tonic-gate case UD_PRI_VOL_DESC: 1413*0Sstevel@tonic-gate /* Bump serial number, according to spec. */ 1414*0Sstevel@tonic-gate serialnum = tp->tag_sno + 1; 1415*0Sstevel@tonic-gate pvolp = (struct pri_vol_desc *)tp; 1416*0Sstevel@tonic-gate oldlabel = pvolp->pvd_vol_id + 1; 1417*0Sstevel@tonic-gate break; 1418*0Sstevel@tonic-gate case UD_ANCH_VOL_DESC: 1419*0Sstevel@tonic-gate avp = (struct anch_vol_desc_ptr *)tp; 1420*0Sstevel@tonic-gate break; 1421*0Sstevel@tonic-gate case UD_VOL_DESC_PTR: 1422*0Sstevel@tonic-gate break; 1423*0Sstevel@tonic-gate case UD_IMPL_USE_DESC: 1424*0Sstevel@tonic-gate break; 1425*0Sstevel@tonic-gate case UD_PART_DESC: 1426*0Sstevel@tonic-gate partp = (struct part_desc *)tp; 1427*0Sstevel@tonic-gate part_start = partp->pd_part_start; 1428*0Sstevel@tonic-gate part_len = partp->pd_part_length; 1429*0Sstevel@tonic-gate oldfssize = part_start + part_len; 1430*0Sstevel@tonic-gate break; 1431*0Sstevel@tonic-gate case UD_LOG_VOL_DESC: 1432*0Sstevel@tonic-gate logvp = (struct log_vol_desc *)tp; 1433*0Sstevel@tonic-gate break; 1434*0Sstevel@tonic-gate case UD_UNALL_SPA_DESC: 1435*0Sstevel@tonic-gate break; 1436*0Sstevel@tonic-gate case UD_TERM_DESC: 1437*0Sstevel@tonic-gate goto done; 1438*0Sstevel@tonic-gate break; 1439*0Sstevel@tonic-gate case UD_LOG_VOL_INT: 1440*0Sstevel@tonic-gate break; 1441*0Sstevel@tonic-gate default: 1442*0Sstevel@tonic-gate break; 1443*0Sstevel@tonic-gate } 1444*0Sstevel@tonic-gate } 1445*0Sstevel@tonic-gate done: 1446*0Sstevel@tonic-gate if (!partp || !logvp) { 1447*0Sstevel@tonic-gate return (0); 1448*0Sstevel@tonic-gate } 1449*0Sstevel@tonic-gate return (1); 1450*0Sstevel@tonic-gate } 1451*0Sstevel@tonic-gate 1452*0Sstevel@tonic-gate uint32_t 1453*0Sstevel@tonic-gate get_last_block() 1454*0Sstevel@tonic-gate { 1455*0Sstevel@tonic-gate struct vtoc vtoc; 1456*0Sstevel@tonic-gate struct dk_cinfo dki_info; 1457*0Sstevel@tonic-gate 1458*0Sstevel@tonic-gate if (ioctl(fsi, DKIOCGVTOC, (intptr_t)&vtoc) != 0) { 1459*0Sstevel@tonic-gate (void) fprintf(stderr, gettext("Unable to read VTOC\n")); 1460*0Sstevel@tonic-gate return (0); 1461*0Sstevel@tonic-gate } 1462*0Sstevel@tonic-gate 1463*0Sstevel@tonic-gate if (vtoc.v_sanity != VTOC_SANE) { 1464*0Sstevel@tonic-gate (void) fprintf(stderr, gettext("Vtoc.v_sanity != VTOC_SANE\n")); 1465*0Sstevel@tonic-gate return (0); 1466*0Sstevel@tonic-gate } 1467*0Sstevel@tonic-gate 1468*0Sstevel@tonic-gate if (ioctl(fsi, DKIOCINFO, (intptr_t)&dki_info) != 0) { 1469*0Sstevel@tonic-gate (void) fprintf(stderr, 1470*0Sstevel@tonic-gate gettext("Could not get the slice information\n")); 1471*0Sstevel@tonic-gate return (0); 1472*0Sstevel@tonic-gate } 1473*0Sstevel@tonic-gate 1474*0Sstevel@tonic-gate if (dki_info.dki_partition > V_NUMPAR) { 1475*0Sstevel@tonic-gate (void) fprintf(stderr, 1476*0Sstevel@tonic-gate gettext("dki_info.dki_partition > V_NUMPAR\n")); 1477*0Sstevel@tonic-gate return (0); 1478*0Sstevel@tonic-gate } 1479*0Sstevel@tonic-gate 1480*0Sstevel@tonic-gate return ((uint32_t)vtoc.v_part[dki_info.dki_partition].p_size); 1481*0Sstevel@tonic-gate } 1482