Home | History | Annotate | Line # | Download | only in fsck_lfs
setup.c revision 1.29
      1 /* $NetBSD: setup.c,v 1.29 2006/07/18 23:37:13 perseant Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2003 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Konrad E. Schroder <perseant (at) hhhh.org>.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 /*
     39  * Copyright (c) 1980, 1986, 1993
     40  *	The Regents of the University of California.  All rights reserved.
     41  *
     42  * Redistribution and use in source and binary forms, with or without
     43  * modification, are permitted provided that the following conditions
     44  * are met:
     45  * 1. Redistributions of source code must retain the above copyright
     46  *    notice, this list of conditions and the following disclaimer.
     47  * 2. Redistributions in binary form must reproduce the above copyright
     48  *    notice, this list of conditions and the following disclaimer in the
     49  *    documentation and/or other materials provided with the distribution.
     50  * 3. Neither the name of the University nor the names of its contributors
     51  *    may be used to endorse or promote products derived from this software
     52  *    without specific prior written permission.
     53  *
     54  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     55  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     56  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     57  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     58  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     59  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     60  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     61  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     62  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     63  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     64  * SUCH DAMAGE.
     65  */
     66 
     67 /* #define DKTYPENAMES */
     68 #define FSTYPENAMES
     69 #include <sys/types.h>
     70 #include <sys/param.h>
     71 #include <sys/time.h>
     72 #include <sys/buf.h>
     73 #include <sys/mount.h>
     74 #include <sys/queue.h>
     75 #include <sys/stat.h>
     76 #include <sys/ioctl.h>
     77 #include <sys/disklabel.h>
     78 #include <sys/file.h>
     79 
     80 #include <ufs/ufs/inode.h>
     81 #include <ufs/ufs/ufsmount.h>
     82 #define vnode uvnode
     83 #include <ufs/lfs/lfs.h>
     84 #undef vnode
     85 
     86 #include <ctype.h>
     87 #include <err.h>
     88 #include <errno.h>
     89 #include <stdio.h>
     90 #include <stdlib.h>
     91 #include <string.h>
     92 #include <time.h>
     93 
     94 #include "bufcache.h"
     95 #include "vnode.h"
     96 #include "lfs_user.h"
     97 
     98 #include "fsck.h"
     99 #include "extern.h"
    100 #include "fsutil.h"
    101 
    102 extern u_int32_t cksum(void *, size_t);
    103 static struct disklabel *getdisklabel(const char *, int);
    104 static uint64_t calcmaxfilesize(int);
    105 
    106 ufs_daddr_t *din_table;
    107 SEGUSE *seg_table;
    108 
    109 #ifdef DKTYPENAMES
    110 int useless(void);
    111 
    112 int
    113 useless(void)
    114 {
    115 	char **foo = (char **) dktypenames;
    116 	char **bar = (char **) fscknames;
    117 
    118 	return foo - bar;
    119 }
    120 #endif
    121 
    122 /*
    123  * calculate the maximum file size allowed with the specified block shift.
    124  */
    125 static uint64_t
    126 calcmaxfilesize(int bshift)
    127 {
    128 	uint64_t nptr; /* number of block pointers per block */
    129 	uint64_t maxblock;
    130 
    131 	nptr = (1 << bshift) / sizeof(uint32_t);
    132 	maxblock = NDADDR + nptr + nptr * nptr + nptr * nptr * nptr;
    133 
    134 	return maxblock << bshift;
    135 }
    136 
    137 void
    138 reset_maxino(ino_t len)
    139 {
    140 	if (debug)
    141 		pwarn("maxino reset from %lld to %lld\n", (long long)maxino,
    142 			(long long)len);
    143 
    144 	din_table = (ufs_daddr_t *) realloc(din_table, len * sizeof(*din_table));
    145 	statemap = realloc(statemap, len * sizeof(char));
    146 	typemap = realloc(typemap, len * sizeof(char));
    147 	lncntp = (int16_t *) realloc(lncntp, len * sizeof(int16_t));
    148 
    149 	if (din_table == NULL || statemap == NULL || typemap == NULL ||
    150 	    lncntp == NULL) {
    151 		errexit("expanding tables failed: out of memory");
    152 	}
    153 
    154 	memset(din_table + maxino, 0, (len - maxino) * sizeof(*din_table));
    155 	memset(statemap + maxino, USTATE, (len - maxino) * sizeof(char));
    156 	memset(typemap + maxino, 0, (len - maxino) * sizeof(char));
    157 	memset(lncntp + maxino, 0, (len - maxino) * sizeof(int16_t));
    158 
    159 	maxino = len;
    160 
    161 	/*
    162 	 * We can't roll forward after allocating new inodes in previous
    163 	 * phases, or thy would conflict (lost+found, for example, might
    164 	 * disappear to be replaced by a file found in roll-forward).
    165 	 */
    166 	no_roll_forward = 1;
    167 
    168 	return;
    169 }
    170 
    171 extern time_t write_time;
    172 
    173 int
    174 setup(const char *dev)
    175 {
    176 	long bmapsize;
    177 	struct disklabel *lp;
    178 	struct stat statb;
    179 	int doskipclean;
    180 	u_int64_t maxfilesize;
    181 	int open_flags;
    182 	struct uvnode *ivp;
    183 	struct ubuf *bp;
    184 	int i, isdirty;
    185 	long sn, curseg;
    186 	SEGUSE *sup;
    187 
    188 	havesb = 0;
    189 	doskipclean = skipclean;
    190 	if (stat(dev, &statb) < 0) {
    191 		pfatal("Can't stat %s: %s\n", dev, strerror(errno));
    192 		return (0);
    193 	}
    194 	if (!S_ISCHR(statb.st_mode) && skipclean) {
    195 		pfatal("%s is not a character device", dev);
    196 		if (reply("CONTINUE") == 0)
    197 			return (0);
    198 	}
    199 	if (nflag)
    200 		open_flags = O_RDONLY;
    201 	else
    202 		open_flags = O_RDWR;
    203 
    204 	if ((fsreadfd = open(dev, open_flags)) < 0) {
    205 		pfatal("Can't open %s: %s\n", dev, strerror(errno));
    206 		return (0);
    207 	}
    208 	if (nflag) {
    209 		if (preen)
    210 			pfatal("NO WRITE ACCESS");
    211 		printf("** %s (NO WRITE)\n", dev);
    212 		quiet = 0;
    213 	} else if (!preen && !quiet)
    214 		printf("** %s\n", dev);
    215 
    216 	fsmodified = 0;
    217 	lfdir = 0;
    218 
    219 	/* Initialize time in case we have to write */
    220 	time(&write_time);
    221 
    222 	bufinit(0); /* XXX we could make a better guess */
    223 	fs = lfs_init(fsreadfd, bflag, idaddr, 0, debug);
    224 	if (fs == NULL) {
    225 		if (preen)
    226 			printf("%s: ", cdevname());
    227 		errexit("BAD SUPER BLOCK OR IFILE INODE NOT FOUND\n");
    228 	}
    229 	if ((lp = getdisklabel((char *) NULL, fsreadfd)) != NULL)
    230 		dev_bsize = secsize = lp->d_secsize;
    231 	else
    232 		dev_bsize = secsize = DEV_BSIZE;
    233 
    234         /* Resize buffer cache now that we have a superblock to guess from. */
    235         bufrehash((fs->lfs_segtabsz + maxino / fs->lfs_ifpb) << 4);
    236 
    237 	if (fs->lfs_pflags & LFS_PF_CLEAN) {
    238 		if (doskipclean) {
    239 			if (!quiet)
    240 				pwarn("%sile system is clean; not checking\n",
    241 				      preen ? "f" : "** F");
    242 			return (-1);
    243 		}
    244 		if (!preen)
    245 			pwarn("** File system is already clean\n");
    246 	}
    247 
    248 	if (idaddr) {
    249 		daddr_t tdaddr;
    250 		SEGSUM *sp;
    251 		FINFO *fp;
    252 		int bc;
    253 
    254 		if (debug)
    255 			pwarn("adjusting offset, serial for -i 0x%lx\n",
    256 				(unsigned long)idaddr);
    257 		tdaddr = sntod(fs, dtosn(fs, idaddr));
    258 		if (sntod(fs, dtosn(fs, tdaddr)) == tdaddr) {
    259 			for (i = 0; i < LFS_MAXNUMSB; i++) {
    260 				if (fs->lfs_sboffs[i] == tdaddr)
    261 					tdaddr += btofsb(fs, LFS_SBPAD);
    262 				if (fs->lfs_sboffs[i] > tdaddr)
    263 					break;
    264 			}
    265 		}
    266 		fs->lfs_offset = tdaddr;
    267 		if (debug)
    268 			pwarn("begin with offset/serial 0x%x/%d\n",
    269 				(int)fs->lfs_offset, (int)fs->lfs_serial);
    270 		while (tdaddr < idaddr) {
    271 			bread(fs->lfs_devvp, fsbtodb(fs, tdaddr),
    272 			      fs->lfs_sumsize,
    273 			      NULL, &bp);
    274 			sp = (SEGSUM *)bp->b_data;
    275 			if (sp->ss_sumsum != cksum(&sp->ss_datasum,
    276 						   fs->lfs_sumsize -
    277 						   sizeof(sp->ss_sumsum))) {
    278 				brelse(bp);
    279 				break;
    280 			}
    281 			fp = (FINFO *)(sp + 1);
    282 			bc = howmany(sp->ss_ninos, INOPB(fs)) <<
    283 				(fs->lfs_version > 1 ? fs->lfs_ffshift :
    284 						       fs->lfs_bshift);
    285 			for (i = 0; i < sp->ss_nfinfo; i++) {
    286 				bc += fp->fi_lastlength + ((fp->fi_nblocks - 1)
    287 					<< fs->lfs_bshift);
    288 				fp = (FINFO *)(fp->fi_blocks + fp->fi_nblocks);
    289 			}
    290 
    291 			tdaddr += btofsb(fs, bc) + 1;
    292 			fs->lfs_offset = tdaddr;
    293 			fs->lfs_serial = sp->ss_serial + 1;
    294 			brelse(bp);
    295 		}
    296 
    297 		/*
    298 		 * Set curseg, nextseg appropriately -- inlined from
    299 		 * lfs_newseg()
    300 		 */
    301 		curseg = dtosn(fs, fs->lfs_offset);
    302 		fs->lfs_curseg = sntod(fs, curseg);
    303 		for (sn = curseg + fs->lfs_interleave;;) {
    304 			sn = (sn + 1) % fs->lfs_nseg;
    305 			if (sn == curseg)
    306 				errx(1, "init: no clean segments");
    307 			LFS_SEGENTRY(sup, fs, sn, bp);
    308 			isdirty = sup->su_flags & SEGUSE_DIRTY;
    309 			brelse(bp);
    310 
    311 			if (!isdirty)
    312 				break;
    313 		}
    314 
    315 		/* Skip superblock if necessary */
    316 		for (i = 0; i < LFS_MAXNUMSB; i++)
    317 			if (fs->lfs_offset == fs->lfs_sboffs[i])
    318 				fs->lfs_offset += btofsb(fs, LFS_SBPAD);
    319 
    320 		++fs->lfs_nactive;
    321 		fs->lfs_nextseg = sntod(fs, sn);
    322 		if (debug) {
    323 			pwarn("offset = 0x%" PRIx32 ", serial = %" PRId64 "\n",
    324 				fs->lfs_offset, fs->lfs_serial);
    325 			pwarn("curseg = %" PRIx32 ", nextseg = %" PRIx32 "\n",
    326 				fs->lfs_curseg, fs->lfs_nextseg);
    327 		}
    328 
    329 		if (!nflag && !skipclean) {
    330 			fs->lfs_idaddr = idaddr;
    331 			fsmodified = 1;
    332 			sbdirty();
    333 		}
    334 	}
    335 
    336 	if (debug) {
    337 		pwarn("idaddr    = 0x%lx\n", idaddr ? (unsigned long)idaddr :
    338 			(unsigned long)fs->lfs_idaddr);
    339 		pwarn("dev_bsize = %lu\n", dev_bsize);
    340 		pwarn("lfs_bsize = %lu\n", (unsigned long) fs->lfs_bsize);
    341 		pwarn("lfs_fsize = %lu\n", (unsigned long) fs->lfs_fsize);
    342 		pwarn("lfs_frag  = %lu\n", (unsigned long) fs->lfs_frag);
    343 		pwarn("lfs_inopb = %lu\n", (unsigned long) fs->lfs_inopb);
    344 	}
    345 	if (fs->lfs_version == 1)
    346 		maxfsblock = fs->lfs_size * (fs->lfs_bsize / dev_bsize);
    347 	else
    348 		maxfsblock = fs->lfs_size;
    349 	maxfilesize = calcmaxfilesize(fs->lfs_bshift);
    350 	if ((fs->lfs_minfree < 0 || fs->lfs_minfree > 99)) {
    351 		pfatal("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK",
    352 		    fs->lfs_minfree);
    353 		if (reply("SET TO DEFAULT") == 1) {
    354 			fs->lfs_minfree = 10;
    355 			sbdirty();
    356 		}
    357 	}
    358 	if (fs->lfs_bmask != fs->lfs_bsize - 1) {
    359 		pwarn("INCORRECT BMASK=0x%x IN SUPERBLOCK (SHOULD BE 0x%x)",
    360 		    (unsigned int) fs->lfs_bmask,
    361 		    (unsigned int) fs->lfs_bsize - 1);
    362 		fs->lfs_bmask = fs->lfs_bsize - 1;
    363 		if (preen)
    364 			printf(" (FIXED)\n");
    365 		if (preen || reply("FIX") == 1) {
    366 			sbdirty();
    367 		}
    368 	}
    369 	if (fs->lfs_ffmask != fs->lfs_fsize - 1) {
    370 		pwarn("INCORRECT FFMASK=%" PRId64 " IN SUPERBLOCK",
    371 		    fs->lfs_ffmask);
    372 		fs->lfs_ffmask = fs->lfs_fsize - 1;
    373 		if (preen)
    374 			printf(" (FIXED)\n");
    375 		if (preen || reply("FIX") == 1) {
    376 			sbdirty();
    377 		}
    378 	}
    379 	if (fs->lfs_fbmask != (1 << fs->lfs_fbshift) - 1) {
    380 		pwarn("INCORRECT FFMASK=%" PRId64 " IN SUPERBLOCK",
    381 		    fs->lfs_ffmask);
    382 		fs->lfs_fbmask = (1 << fs->lfs_fbshift) - 1;
    383 		if (preen)
    384 			printf(" (FIXED)\n");
    385 		if (preen || reply("FIX") == 1) {
    386 			sbdirty();
    387 		}
    388 	}
    389 	if (fs->lfs_maxfilesize != maxfilesize) {
    390 		pwarn(
    391 		    "INCORRECT MAXFILESIZE=%llu IN SUPERBLOCK (SHOULD BE %llu WITH BSHIFT %d)",
    392 		    (unsigned long long) fs->lfs_maxfilesize,
    393 		    (unsigned long long) maxfilesize, (int)fs->lfs_bshift);
    394 		if (preen)
    395 			printf(" (FIXED)\n");
    396 		if (preen || reply("FIX") == 1) {
    397 			fs->lfs_maxfilesize = maxfilesize;
    398 			sbdirty();
    399 		}
    400 	}
    401 	if (fs->lfs_maxsymlinklen != MAXSYMLINKLEN_UFS1) {
    402 		pwarn("INCORRECT MAXSYMLINKLEN=%d IN SUPERBLOCK",
    403 		    fs->lfs_maxsymlinklen);
    404 		fs->lfs_maxsymlinklen = MAXSYMLINKLEN_UFS1;
    405 		if (preen)
    406 			printf(" (FIXED)\n");
    407 		if (preen || reply("FIX") == 1) {
    408 			sbdirty();
    409 		}
    410 	}
    411 
    412 	/*
    413 	 * Read in the Ifile; we'll be using it a lot.
    414 	 * XXX If the Ifile is corrupted we are in bad shape.  We need to
    415 	 * XXX run through the segment headers of the entire disk to
    416 	 * XXX reconstruct the inode table, then pretend all segments are
    417 	 * XXX dirty while we do the rest.
    418 	 */
    419 	ivp = fs->lfs_ivnode;
    420 	maxino = ((VTOI(ivp)->i_ffs1_size - (fs->lfs_cleansz + fs->lfs_segtabsz)
    421 		* fs->lfs_bsize) / fs->lfs_bsize) * fs->lfs_ifpb;
    422 	if (debug)
    423 		pwarn("maxino    = %llu\n", (unsigned long long)maxino);
    424 	for (i = 0; i < VTOI(ivp)->i_ffs1_size; i += fs->lfs_bsize) {
    425 		bread(ivp, i >> fs->lfs_bshift, fs->lfs_bsize, NOCRED, &bp);
    426 		/* XXX check B_ERROR */
    427 		brelse(bp);
    428 	}
    429 
    430 	/*
    431 	 * allocate and initialize the necessary maps
    432 	 */
    433 	din_table = (ufs_daddr_t *) malloc(maxino * sizeof(*din_table));
    434 	if (din_table == NULL) {
    435 		pwarn("cannot alloc %lu bytes for din_table\n",
    436 		    (unsigned long) maxino * sizeof(*din_table));
    437 		goto badsblabel;
    438 	}
    439 	memset(din_table, 0, maxino * sizeof(*din_table));
    440 	seg_table = (SEGUSE *) malloc(fs->lfs_nseg * sizeof(SEGUSE));
    441 	if (seg_table == NULL) {
    442 		pwarn("cannot alloc %lu bytes for seg_table\n",
    443 		    (unsigned long) fs->lfs_nseg * sizeof(SEGUSE));
    444 		goto badsblabel;
    445 	}
    446 	memset(seg_table, 0, fs->lfs_nseg * sizeof(SEGUSE));
    447 	/* Get segment flags */
    448 	for (i = 0; i < fs->lfs_nseg; i++) {
    449 		LFS_SEGENTRY(sup, fs, i, bp);
    450 		seg_table[i].su_flags = sup->su_flags & ~SEGUSE_ACTIVE;
    451 		if (preen)
    452 			seg_table[i].su_nbytes = sup->su_nbytes;
    453 		brelse(bp);
    454 	}
    455 
    456 	/* Initialize Ifile entry */
    457 	din_table[fs->lfs_ifile] = fs->lfs_idaddr;
    458 	seg_table[dtosn(fs, fs->lfs_idaddr)].su_nbytes += DINODE1_SIZE;
    459 
    460 #ifndef VERBOSE_BLOCKMAP
    461 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
    462 	blockmap = calloc((unsigned) bmapsize, sizeof(char));
    463 #else
    464 	bmapsize = maxfsblock * sizeof(ino_t);
    465 	blockmap = (ino_t *) calloc(maxfsblock, sizeof(ino_t));
    466 #endif
    467 	if (blockmap == NULL) {
    468 		pwarn("cannot alloc %u bytes for blockmap\n",
    469 		    (unsigned) bmapsize);
    470 		goto badsblabel;
    471 	}
    472 	statemap = calloc((unsigned) maxino, sizeof(char));
    473 	if (statemap == NULL) {
    474 		pwarn("cannot alloc %u bytes for statemap\n",
    475 		    (unsigned) maxino);
    476 		goto badsblabel;
    477 	}
    478 	typemap = calloc((unsigned) maxino, sizeof(char));
    479 	if (typemap == NULL) {
    480 		pwarn("cannot alloc %u bytes for typemap\n",
    481 		    (unsigned) maxino);
    482 		goto badsblabel;
    483 	}
    484 	lncntp = (int16_t *) calloc((unsigned) maxino, sizeof(int16_t));
    485 	if (lncntp == NULL) {
    486 		pwarn("cannot alloc %lu bytes for lncntp\n",
    487 		    (unsigned long) maxino * sizeof(int16_t));
    488 		goto badsblabel;
    489 	}
    490 
    491 	if (preen) {
    492 		n_files = fs->lfs_nfiles;
    493 		n_blks  = fs->lfs_dsize - fs->lfs_bfree;
    494 		numdirs = maxino;
    495 		inplast = 0;
    496 		listmax = numdirs + 10;
    497 		inpsort = (struct inoinfo **) calloc((unsigned) listmax,
    498 			sizeof(struct inoinfo *));
    499 		inphead = (struct inoinfo **) calloc((unsigned) numdirs,
    500 			sizeof(struct inoinfo *));
    501 		if (inpsort == NULL || inphead == NULL) {
    502 			pwarn("cannot alloc %lu bytes for inphead\n",
    503 				(unsigned long) numdirs * sizeof(struct inoinfo *));
    504 			exit(1);
    505 		}
    506 	}
    507 
    508 	return (1);
    509 
    510 badsblabel:
    511 	ckfini(0);
    512 	return (0);
    513 }
    514 
    515 static struct disklabel *
    516 getdisklabel(const char *s, int fd)
    517 {
    518 	static struct disklabel lab;
    519 
    520 	if (ioctl(fd, DIOCGDINFO, (char *) &lab) < 0) {
    521 		if (s == NULL)
    522 			return ((struct disklabel *) NULL);
    523 		pwarn("ioctl (GCINFO): %s\n", strerror(errno));
    524 		return NULL;
    525 	}
    526 	return (&lab);
    527 }
    528