17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0e42dee6Sartem * Common Development and Distribution License (the "License").
6*0e42dee6Sartem * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*0e42dee6Sartem * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23*0e42dee6Sartem * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #include <stdio.h>
297c478bd9Sstevel@tonic-gate #include <unistd.h>
307c478bd9Sstevel@tonic-gate #include <stdlib.h>
317c478bd9Sstevel@tonic-gate #include <string.h>
327c478bd9Sstevel@tonic-gate #include <strings.h>
337c478bd9Sstevel@tonic-gate #include <fcntl.h>
347c478bd9Sstevel@tonic-gate #include <signal.h>
357c478bd9Sstevel@tonic-gate #include <setjmp.h>
367c478bd9Sstevel@tonic-gate #include <errno.h>
377c478bd9Sstevel@tonic-gate #include <inttypes.h>
387c478bd9Sstevel@tonic-gate #include <libgen.h>
397c478bd9Sstevel@tonic-gate #include <locale.h>
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gate #include <sys/param.h>
427c478bd9Sstevel@tonic-gate #include <sys/signal.h>
437c478bd9Sstevel@tonic-gate #include <sys/file.h>
447c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
457c478bd9Sstevel@tonic-gate #include <sys/types.h>
467c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
477c478bd9Sstevel@tonic-gate #include <sys/mntent.h>
487c478bd9Sstevel@tonic-gate #include <sys/wait.h>
497c478bd9Sstevel@tonic-gate #include <sys/vtoc.h>
507c478bd9Sstevel@tonic-gate #include <sys/dkio.h>
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate #include <sys/fs/udf_volume.h>
537c478bd9Sstevel@tonic-gate #include "ud_lib.h"
547c478bd9Sstevel@tonic-gate #include "y.tab.h"
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gate typedef unsigned short unicode_t;
577c478bd9Sstevel@tonic-gate #define MAXNAMLEN 0x200
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate extern uint32_t i_number;
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate extern int32_t run_fsdb();
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate void usage();
647c478bd9Sstevel@tonic-gate void init_buffers();
657c478bd9Sstevel@tonic-gate char *getblk(u_offset_t);
667c478bd9Sstevel@tonic-gate int32_t parse_udfs(uint32_t);
677c478bd9Sstevel@tonic-gate int32_t parse_vds(uint32_t, uint32_t);
687c478bd9Sstevel@tonic-gate int32_t parse_part(struct part_desc *);
697c478bd9Sstevel@tonic-gate int32_t parse_lvd(struct log_vol_desc *);
707c478bd9Sstevel@tonic-gate int32_t parse_fsds();
717c478bd9Sstevel@tonic-gate int32_t get_vat_loc();
727c478bd9Sstevel@tonic-gate int32_t get_fid(uint32_t, uint8_t *, uint64_t);
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate
757c478bd9Sstevel@tonic-gate char *progname;
767c478bd9Sstevel@tonic-gate char prompt[256] = "fsdb>";
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate #define ARG_OVERRIDE 0
797c478bd9Sstevel@tonic-gate #define ARG_NEW_PROMPT 1
807c478bd9Sstevel@tonic-gate #define ARG_WR_ENABLED 2
817c478bd9Sstevel@tonic-gate #define ARG_USAGE 3
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate char *subopt_v[] = {
847c478bd9Sstevel@tonic-gate "o",
857c478bd9Sstevel@tonic-gate "p",
867c478bd9Sstevel@tonic-gate "w",
877c478bd9Sstevel@tonic-gate "?",
887c478bd9Sstevel@tonic-gate NULL
897c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate int32_t override = 0;
917c478bd9Sstevel@tonic-gate int32_t openflg = O_RDONLY;
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate #define MAX_PARTS 10
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate * udp_flags
977c478bd9Sstevel@tonic-gate */
987c478bd9Sstevel@tonic-gate #define UDP_BITMAPS 0x00
997c478bd9Sstevel@tonic-gate #define UDP_SPACETBLS 0x01
1007c478bd9Sstevel@tonic-gate
101*0e42dee6Sartem ud_handle_t udh;
1027c478bd9Sstevel@tonic-gate int32_t fd, nparts, nmaps;
1037c478bd9Sstevel@tonic-gate int32_t bmask, l2d, l2b;
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate uint16_t ricb_prn;
1077c478bd9Sstevel@tonic-gate uint32_t ricb_loc, ricb_len;
1087c478bd9Sstevel@tonic-gate extern int value;
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate int32_t
main(int argc,char * argv[])1127c478bd9Sstevel@tonic-gate main(int argc, char *argv[])
1137c478bd9Sstevel@tonic-gate {
1147c478bd9Sstevel@tonic-gate int opt, ret;
1157c478bd9Sstevel@tonic-gate uint32_t bsize;
1167c478bd9Sstevel@tonic-gate char *subopts, *optval;
1177c478bd9Sstevel@tonic-gate
1187c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)
1197c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST"
1207c478bd9Sstevel@tonic-gate #endif
1217c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN);
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate progname = argv[0];
1247c478bd9Sstevel@tonic-gate
1257c478bd9Sstevel@tonic-gate while ((opt = getopt(argc, argv, "o:")) != EOF) {
1267c478bd9Sstevel@tonic-gate switch (opt) {
1277c478bd9Sstevel@tonic-gate case 'o' :
1287c478bd9Sstevel@tonic-gate subopts = optarg;
1297c478bd9Sstevel@tonic-gate while (*subopts != '\0') {
1307c478bd9Sstevel@tonic-gate switch (getsubopt(&subopts,
1317c478bd9Sstevel@tonic-gate subopt_v, &optval)) {
1327c478bd9Sstevel@tonic-gate case ARG_OVERRIDE :
1337c478bd9Sstevel@tonic-gate override = 1;
1347c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
1357c478bd9Sstevel@tonic-gate gettext("error checking off\n"));
1367c478bd9Sstevel@tonic-gate break;
1377c478bd9Sstevel@tonic-gate case ARG_NEW_PROMPT :
1387c478bd9Sstevel@tonic-gate if (optval == NULL) {
1397c478bd9Sstevel@tonic-gate usage();
1407c478bd9Sstevel@tonic-gate }
1417c478bd9Sstevel@tonic-gate if (strlen(optval) > 255) {
1427c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
1437c478bd9Sstevel@tonic-gate gettext("prompt should be less"
1447c478bd9Sstevel@tonic-gate "than 255 bytes\n"));
1457c478bd9Sstevel@tonic-gate exit(1);
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate (void) strcpy(prompt, optval);
1487c478bd9Sstevel@tonic-gate break;
1497c478bd9Sstevel@tonic-gate case ARG_WR_ENABLED :
1507c478bd9Sstevel@tonic-gate openflg = O_RDWR;
1517c478bd9Sstevel@tonic-gate break;
1527c478bd9Sstevel@tonic-gate case ARG_USAGE :
1537c478bd9Sstevel@tonic-gate default :
1547c478bd9Sstevel@tonic-gate usage();
1557c478bd9Sstevel@tonic-gate }
1567c478bd9Sstevel@tonic-gate }
1577c478bd9Sstevel@tonic-gate break;
1587c478bd9Sstevel@tonic-gate default :
1597c478bd9Sstevel@tonic-gate usage();
1607c478bd9Sstevel@tonic-gate }
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate if ((argc - optind) != 1) { /* Should just have "special" left */
1647c478bd9Sstevel@tonic-gate usage();
1657c478bd9Sstevel@tonic-gate }
1667c478bd9Sstevel@tonic-gate
167*0e42dee6Sartem if (ud_init(-1, &udh) != 0) {
168*0e42dee6Sartem (void) fprintf(stderr,
169*0e42dee6Sartem gettext("udfs labelit: cannot initialize ud_lib\n"));
170*0e42dee6Sartem exit(1);
171*0e42dee6Sartem }
1727c478bd9Sstevel@tonic-gate
173*0e42dee6Sartem if ((fd = ud_open_dev(udh, argv[optind], openflg)) < 0) {
1747c478bd9Sstevel@tonic-gate perror("open");
1757c478bd9Sstevel@tonic-gate exit(1);
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate
178*0e42dee6Sartem if ((ret = ud_fill_udfs_info(udh)) != 0) {
1797c478bd9Sstevel@tonic-gate return (ret);
1807c478bd9Sstevel@tonic-gate }
1817c478bd9Sstevel@tonic-gate
182*0e42dee6Sartem if ((udh->udfs.flags & VALID_UDFS) == 0) {
1837c478bd9Sstevel@tonic-gate return (1);
1847c478bd9Sstevel@tonic-gate }
1857c478bd9Sstevel@tonic-gate
186*0e42dee6Sartem bsize = udh->udfs.lbsize;
1877c478bd9Sstevel@tonic-gate bmask = bsize - 1;
1887c478bd9Sstevel@tonic-gate l2d = 0;
1897c478bd9Sstevel@tonic-gate while ((bsize >> l2d) > DEV_BSIZE) {
1907c478bd9Sstevel@tonic-gate l2d++;
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate l2b = l2d + 9;
1937c478bd9Sstevel@tonic-gate
194*0e42dee6Sartem ricb_prn = udh->udfs.ricb_prn;
195*0e42dee6Sartem ricb_loc = udh->udfs.ricb_loc;
196*0e42dee6Sartem ricb_len = udh->udfs.ricb_len;
1977c478bd9Sstevel@tonic-gate
198*0e42dee6Sartem value = i_number = ud_xlate_to_daddr(udh, ricb_prn, ricb_loc);
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate init_buffers();
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gate run_fsdb();
2037c478bd9Sstevel@tonic-gate
204*0e42dee6Sartem ud_fini(udh);
2057c478bd9Sstevel@tonic-gate (void) close(fd);
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate return (0);
2087c478bd9Sstevel@tonic-gate }
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate /*
2117c478bd9Sstevel@tonic-gate * usage - print usage and exit
2127c478bd9Sstevel@tonic-gate */
2137c478bd9Sstevel@tonic-gate void
usage()2147c478bd9Sstevel@tonic-gate usage()
2157c478bd9Sstevel@tonic-gate {
2167c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2177c478bd9Sstevel@tonic-gate gettext("usage: %s [options] special\n"), progname);
2187c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2197c478bd9Sstevel@tonic-gate gettext("options:\n"));
2207c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2217c478bd9Sstevel@tonic-gate gettext("\t-o\tSpecify udfs filesystem sepcific options\n"));
2227c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2237c478bd9Sstevel@tonic-gate gettext("\t\tAvailable suboptions are:\n"));
2247c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2257c478bd9Sstevel@tonic-gate gettext("\t\t?\tdisplay usage\n"));
2267c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2277c478bd9Sstevel@tonic-gate gettext("\t\to\toverride some error conditions\n"));
2287c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2297c478bd9Sstevel@tonic-gate gettext("\t\tp\t\"string\" set prompt to string\n"));
2307c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2317c478bd9Sstevel@tonic-gate gettext("\t\tw\topen for write\n"));
2327c478bd9Sstevel@tonic-gate exit(1);
2337c478bd9Sstevel@tonic-gate }
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gate #define NBUF 10
2367c478bd9Sstevel@tonic-gate static struct lbuf {
2377c478bd9Sstevel@tonic-gate struct lbuf *fwd;
2387c478bd9Sstevel@tonic-gate struct lbuf *back;
2397c478bd9Sstevel@tonic-gate int32_t valid;
2407c478bd9Sstevel@tonic-gate char *blkaddr;
2417c478bd9Sstevel@tonic-gate u_offset_t blkno;
2427c478bd9Sstevel@tonic-gate } lbuf[NBUF], bhdr;
2437c478bd9Sstevel@tonic-gate
2447c478bd9Sstevel@tonic-gate #define INSERT(bp) \
2457c478bd9Sstevel@tonic-gate { \
2467c478bd9Sstevel@tonic-gate bp->back = &bhdr; \
2477c478bd9Sstevel@tonic-gate bp->fwd = bhdr.fwd; \
2487c478bd9Sstevel@tonic-gate bhdr.fwd->back = bp; \
2497c478bd9Sstevel@tonic-gate bhdr.fwd = bp; \
2507c478bd9Sstevel@tonic-gate }
2517c478bd9Sstevel@tonic-gate
2527c478bd9Sstevel@tonic-gate void
init_buffers()2537c478bd9Sstevel@tonic-gate init_buffers()
2547c478bd9Sstevel@tonic-gate {
2557c478bd9Sstevel@tonic-gate int32_t i;
2567c478bd9Sstevel@tonic-gate char *addr;
2577c478bd9Sstevel@tonic-gate struct lbuf *bp;
2587c478bd9Sstevel@tonic-gate
259*0e42dee6Sartem addr = malloc(NBUF * udh->udfs.lbsize);
2607c478bd9Sstevel@tonic-gate bhdr.fwd = bhdr.back = &bhdr;
2617c478bd9Sstevel@tonic-gate for (i = 0; i < NBUF; i++) {
2627c478bd9Sstevel@tonic-gate bp = &lbuf[i];
263*0e42dee6Sartem bp->blkaddr = addr + i * udh->udfs.lbsize;
2647c478bd9Sstevel@tonic-gate bp->valid = 0;
2657c478bd9Sstevel@tonic-gate INSERT(bp);
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate }
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gate char *
getblk(u_offset_t address)2707c478bd9Sstevel@tonic-gate getblk(u_offset_t address)
2717c478bd9Sstevel@tonic-gate {
2727c478bd9Sstevel@tonic-gate u_offset_t off, block;
2737c478bd9Sstevel@tonic-gate struct lbuf *bp;
2747c478bd9Sstevel@tonic-gate
2757c478bd9Sstevel@tonic-gate off = address & ~bmask;
2767c478bd9Sstevel@tonic-gate block = address >> l2b;
2777c478bd9Sstevel@tonic-gate for (bp = bhdr.fwd; bp != &bhdr; bp = bp->fwd) {
2787c478bd9Sstevel@tonic-gate if (bp->valid && bp->blkno == block) {
2797c478bd9Sstevel@tonic-gate goto found;
2807c478bd9Sstevel@tonic-gate }
2817c478bd9Sstevel@tonic-gate }
2827c478bd9Sstevel@tonic-gate bp = bhdr.back;
2837c478bd9Sstevel@tonic-gate bp->blkno = block;
2847c478bd9Sstevel@tonic-gate bp->valid = 0;
2857c478bd9Sstevel@tonic-gate errno = 0;
2867c478bd9Sstevel@tonic-gate if (llseek(fd, off, SEEK_SET) != off) {
2877c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2887c478bd9Sstevel@tonic-gate gettext("Seek failed fd %x off %llx errno %x\n"),
2897c478bd9Sstevel@tonic-gate fd, off, errno);
2907c478bd9Sstevel@tonic-gate return (NULL);
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate errno = 0;
293*0e42dee6Sartem if (read(fd, bp->blkaddr, udh->udfs.lbsize) != udh->udfs.lbsize) {
2947c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
2957c478bd9Sstevel@tonic-gate gettext("Read failed fd %x off %llx errno %x\n"),
2967c478bd9Sstevel@tonic-gate fd, off, errno);
2977c478bd9Sstevel@tonic-gate return (NULL);
2987c478bd9Sstevel@tonic-gate }
2997c478bd9Sstevel@tonic-gate bp->valid = 1;
3007c478bd9Sstevel@tonic-gate found:
3017c478bd9Sstevel@tonic-gate bp->back->fwd = bp->fwd;
3027c478bd9Sstevel@tonic-gate bp->fwd->back = bp->back;
3037c478bd9Sstevel@tonic-gate INSERT(bp);
3047c478bd9Sstevel@tonic-gate return (bp->blkaddr);
3057c478bd9Sstevel@tonic-gate }
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate int32_t
putblk(caddr_t address)3097c478bd9Sstevel@tonic-gate putblk(caddr_t address)
3107c478bd9Sstevel@tonic-gate {
3117c478bd9Sstevel@tonic-gate u_offset_t off;
3127c478bd9Sstevel@tonic-gate struct lbuf *bp;
3137c478bd9Sstevel@tonic-gate
3147c478bd9Sstevel@tonic-gate if (openflg == O_RDONLY) {
3157c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
3167c478bd9Sstevel@tonic-gate gettext("Not run with -w flag\n"));
3177c478bd9Sstevel@tonic-gate return (1);
3187c478bd9Sstevel@tonic-gate }
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate for (bp = bhdr.fwd; bp != &bhdr; bp = bp->fwd) {
3217c478bd9Sstevel@tonic-gate if (bp->valid && bp->blkaddr == address) {
3227c478bd9Sstevel@tonic-gate goto found;
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate }
3257c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
3267c478bd9Sstevel@tonic-gate gettext("Could not find the buffer\n"));
3277c478bd9Sstevel@tonic-gate return (1);
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate found:
3307c478bd9Sstevel@tonic-gate off = bp->blkno << l2b;
3317c478bd9Sstevel@tonic-gate if (llseek(fd, off, SEEK_SET) == off) {
332*0e42dee6Sartem if (write(fd, bp->blkaddr, udh->udfs.lbsize) ==
333*0e42dee6Sartem udh->udfs.lbsize) {
3347c478bd9Sstevel@tonic-gate return (0);
3357c478bd9Sstevel@tonic-gate }
3367c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
3377c478bd9Sstevel@tonic-gate gettext("Write failed fd %x off %llx errno %x\n"),
3387c478bd9Sstevel@tonic-gate fd, off, errno);
3397c478bd9Sstevel@tonic-gate } else {
3407c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
3417c478bd9Sstevel@tonic-gate gettext("Seek failed fd %x off %llx errno %x\n"),
3427c478bd9Sstevel@tonic-gate fd, off, errno);
3437c478bd9Sstevel@tonic-gate }
3447c478bd9Sstevel@tonic-gate return (1);
3457c478bd9Sstevel@tonic-gate }
3467c478bd9Sstevel@tonic-gate
3477c478bd9Sstevel@tonic-gate void
inval_bufs()3487c478bd9Sstevel@tonic-gate inval_bufs()
3497c478bd9Sstevel@tonic-gate {
3507c478bd9Sstevel@tonic-gate struct lbuf *bp;
3517c478bd9Sstevel@tonic-gate
3527c478bd9Sstevel@tonic-gate for (bp = bhdr.fwd; bp != &bhdr; bp = bp->fwd) {
3537c478bd9Sstevel@tonic-gate bp->valid = 0;
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate }
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate * If addr == NULL then use id to print the desc
3597c478bd9Sstevel@tonic-gate * other wise use addr to self identify the type of desc
3607c478bd9Sstevel@tonic-gate */
3617c478bd9Sstevel@tonic-gate void
print_desc(uint32_t addr,int32_t id)3627c478bd9Sstevel@tonic-gate print_desc(uint32_t addr, int32_t id)
3637c478bd9Sstevel@tonic-gate {
3647c478bd9Sstevel@tonic-gate struct tag *tag;
3657c478bd9Sstevel@tonic-gate caddr_t baddr;
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gate /*
3687c478bd9Sstevel@tonic-gate * Read the block at addr
3697c478bd9Sstevel@tonic-gate * find out the type of tag
3707c478bd9Sstevel@tonic-gate * and print the descriptor
3717c478bd9Sstevel@tonic-gate */
3727c478bd9Sstevel@tonic-gate if (addr != NULL) {
3737c478bd9Sstevel@tonic-gate if ((baddr = getblk(addr & (~bmask))) == NULL) {
3747c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
3757c478bd9Sstevel@tonic-gate gettext("Could not read block %x\n"),
3767c478bd9Sstevel@tonic-gate addr >> l2b);
3777c478bd9Sstevel@tonic-gate }
3787c478bd9Sstevel@tonic-gate /* LINTED */
3797c478bd9Sstevel@tonic-gate tag = (struct tag *)(baddr + (addr & bmask));
3807c478bd9Sstevel@tonic-gate } else {
3817c478bd9Sstevel@tonic-gate switch (id) {
3827c478bd9Sstevel@tonic-gate case AVD :
3837c478bd9Sstevel@tonic-gate /* LINTED */
3847c478bd9Sstevel@tonic-gate if ((tag = (struct tag *)getblk(
385*0e42dee6Sartem udh->udfs.avdp_loc << l2b)) == NULL) {
3867c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
3877c478bd9Sstevel@tonic-gate gettext("Could not read AVDP\n"));
3887c478bd9Sstevel@tonic-gate }
3897c478bd9Sstevel@tonic-gate break;
3907c478bd9Sstevel@tonic-gate case MVDS :
3917c478bd9Sstevel@tonic-gate case RVDS :
3927c478bd9Sstevel@tonic-gate case INTS :
3937c478bd9Sstevel@tonic-gate {
3947c478bd9Sstevel@tonic-gate uint32_t i, end;
3957c478bd9Sstevel@tonic-gate
3967c478bd9Sstevel@tonic-gate if (id == MVDS) {
397*0e42dee6Sartem i = udh->udfs.mvds_loc;
3987c478bd9Sstevel@tonic-gate end = i +
399*0e42dee6Sartem (udh->udfs.mvds_len >> l2b);
4007c478bd9Sstevel@tonic-gate } else if (id == RVDS) {
401*0e42dee6Sartem i = udh->udfs.rvds_loc;
4027c478bd9Sstevel@tonic-gate end = i +
403*0e42dee6Sartem (udh->udfs.rvds_len >> l2b);
4047c478bd9Sstevel@tonic-gate } else {
405*0e42dee6Sartem i = udh->udfs.lvid_loc;
4067c478bd9Sstevel@tonic-gate end = i +
407*0e42dee6Sartem (udh->udfs.lvid_len >> l2b);
4087c478bd9Sstevel@tonic-gate }
4097c478bd9Sstevel@tonic-gate
4107c478bd9Sstevel@tonic-gate for (; i < end; i++) {
4117c478bd9Sstevel@tonic-gate print_desc(i << l2b, 0);
4127c478bd9Sstevel@tonic-gate }
4137c478bd9Sstevel@tonic-gate }
4147c478bd9Sstevel@tonic-gate return;
4157c478bd9Sstevel@tonic-gate case FSDS :
4167c478bd9Sstevel@tonic-gate case ROOT :
4177c478bd9Sstevel@tonic-gate {
4187c478bd9Sstevel@tonic-gate uint16_t prn;
4197c478bd9Sstevel@tonic-gate uint32_t i, end, block;
4207c478bd9Sstevel@tonic-gate
4217c478bd9Sstevel@tonic-gate if (id == FSDS) {
422*0e42dee6Sartem prn = udh->udfs.fsds_prn;
423*0e42dee6Sartem i = udh->udfs.fsds_loc;
4247c478bd9Sstevel@tonic-gate end = i +
425*0e42dee6Sartem (udh->udfs.fsds_len >> l2b);
4267c478bd9Sstevel@tonic-gate } else {
4277c478bd9Sstevel@tonic-gate prn = ricb_prn;
4287c478bd9Sstevel@tonic-gate i = ricb_loc;
4297c478bd9Sstevel@tonic-gate end = i + (ricb_len >> l2b);
4307c478bd9Sstevel@tonic-gate }
4317c478bd9Sstevel@tonic-gate
4327c478bd9Sstevel@tonic-gate for (; i < end; i++) {
4337c478bd9Sstevel@tonic-gate if ((block = ud_xlate_to_daddr(
434*0e42dee6Sartem udh, prn, i)) == 0) {
4357c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
4367c478bd9Sstevel@tonic-gate gettext("Cannot xlate "
4377c478bd9Sstevel@tonic-gate "prn %x loc %x\n"),
4387c478bd9Sstevel@tonic-gate prn, i);
4397c478bd9Sstevel@tonic-gate continue;
4407c478bd9Sstevel@tonic-gate }
4417c478bd9Sstevel@tonic-gate print_desc(block << l2b, 0);
4427c478bd9Sstevel@tonic-gate }
4437c478bd9Sstevel@tonic-gate }
4447c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
4457c478bd9Sstevel@tonic-gate default :
4467c478bd9Sstevel@tonic-gate return;
4477c478bd9Sstevel@tonic-gate }
4487c478bd9Sstevel@tonic-gate }
4497c478bd9Sstevel@tonic-gate
4507c478bd9Sstevel@tonic-gate switch (SWAP_16(tag->tag_id)) {
4517c478bd9Sstevel@tonic-gate case UD_PRI_VOL_DESC :
452*0e42dee6Sartem print_pvd(stdout, (struct pri_vol_desc *)tag);
4537c478bd9Sstevel@tonic-gate break;
4547c478bd9Sstevel@tonic-gate case UD_ANCH_VOL_DESC :
455*0e42dee6Sartem print_avd(stdout, (struct anch_vol_desc_ptr *)tag);
4567c478bd9Sstevel@tonic-gate break;
4577c478bd9Sstevel@tonic-gate case UD_VOL_DESC_PTR :
458*0e42dee6Sartem print_vdp(stdout, (struct vol_desc_ptr *)tag);
4597c478bd9Sstevel@tonic-gate break;
4607c478bd9Sstevel@tonic-gate case UD_IMPL_USE_DESC :
461*0e42dee6Sartem print_iuvd(stdout, (struct iuvd_desc *)tag);
4627c478bd9Sstevel@tonic-gate break;
4637c478bd9Sstevel@tonic-gate case UD_PART_DESC :
464*0e42dee6Sartem print_part(stdout, (struct part_desc *)tag);
4657c478bd9Sstevel@tonic-gate break;
4667c478bd9Sstevel@tonic-gate case UD_LOG_VOL_DESC :
467*0e42dee6Sartem print_lvd(stdout, (struct log_vol_desc *)tag);
4687c478bd9Sstevel@tonic-gate break;
4697c478bd9Sstevel@tonic-gate case UD_UNALL_SPA_DESC :
470*0e42dee6Sartem print_usd(stdout, (struct unall_spc_desc *)tag);
4717c478bd9Sstevel@tonic-gate break;
4727c478bd9Sstevel@tonic-gate case UD_TERM_DESC :
4737c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "TERM DESC\n");
474*0e42dee6Sartem print_tag(stdout, tag);
4757c478bd9Sstevel@tonic-gate break;
4767c478bd9Sstevel@tonic-gate case UD_LOG_VOL_INT :
477*0e42dee6Sartem print_lvid(stdout, (struct log_vol_int_desc *)tag);
4787c478bd9Sstevel@tonic-gate break;
4797c478bd9Sstevel@tonic-gate case UD_FILE_SET_DESC :
480*0e42dee6Sartem print_fsd(stdout, udh, (struct file_set_desc *)tag);
4817c478bd9Sstevel@tonic-gate break;
4827c478bd9Sstevel@tonic-gate case UD_FILE_ID_DESC :
483*0e42dee6Sartem print_fid(stdout, (struct file_id *)tag);
4847c478bd9Sstevel@tonic-gate break;
4857c478bd9Sstevel@tonic-gate case UD_ALLOC_EXT_DESC :
486*0e42dee6Sartem print_aed(stdout, (struct alloc_ext_desc *)tag);
4877c478bd9Sstevel@tonic-gate break;
4887c478bd9Sstevel@tonic-gate case UD_INDIRECT_ENT :
489*0e42dee6Sartem print_ie(stdout, (struct indirect_entry *)tag);
4907c478bd9Sstevel@tonic-gate break;
4917c478bd9Sstevel@tonic-gate case UD_TERMINAL_ENT :
492*0e42dee6Sartem print_td(stdout, (struct term_desc *)tag);
4937c478bd9Sstevel@tonic-gate break;
4947c478bd9Sstevel@tonic-gate case UD_FILE_ENTRY :
495*0e42dee6Sartem print_fe(stdout, (struct file_entry *)tag);
4967c478bd9Sstevel@tonic-gate break;
4977c478bd9Sstevel@tonic-gate case UD_EXT_ATTR_HDR :
4987c478bd9Sstevel@tonic-gate case UD_UNALL_SPA_ENT :
4997c478bd9Sstevel@tonic-gate case UD_SPA_BMAP_DESC :
5007c478bd9Sstevel@tonic-gate case UD_PART_INT_DESC :
5017c478bd9Sstevel@tonic-gate case UD_EXT_FILE_ENT :
5027c478bd9Sstevel@tonic-gate break;
5037c478bd9Sstevel@tonic-gate default :
5047c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
5057c478bd9Sstevel@tonic-gate gettext("unknown descriptor\n"));
506*0e42dee6Sartem print_tag(stdout, tag);
5077c478bd9Sstevel@tonic-gate break;
5087c478bd9Sstevel@tonic-gate }
5097c478bd9Sstevel@tonic-gate }
5107c478bd9Sstevel@tonic-gate
5117c478bd9Sstevel@tonic-gate void
set_file(int32_t id,uint32_t iloc,uint64_t value)5127c478bd9Sstevel@tonic-gate set_file(int32_t id, uint32_t iloc, uint64_t value)
5137c478bd9Sstevel@tonic-gate {
5147c478bd9Sstevel@tonic-gate uint8_t i8;
5157c478bd9Sstevel@tonic-gate uint16_t i16;
5167c478bd9Sstevel@tonic-gate uint32_t i32, block, ea_len, ea_off;
5177c478bd9Sstevel@tonic-gate uint64_t i64;
5187c478bd9Sstevel@tonic-gate struct file_entry *fe;
5197c478bd9Sstevel@tonic-gate struct dev_spec_ear *ds;
5207c478bd9Sstevel@tonic-gate struct attr_hdr *ah;
5217c478bd9Sstevel@tonic-gate struct ext_attr_hdr *eah;
5227c478bd9Sstevel@tonic-gate
5237c478bd9Sstevel@tonic-gate /* LINTED */
5247c478bd9Sstevel@tonic-gate if ((fe = (struct file_entry *)getblk(iloc)) == NULL) {
5257c478bd9Sstevel@tonic-gate return;
5267c478bd9Sstevel@tonic-gate }
527*0e42dee6Sartem if (ud_verify_tag(udh, &fe->fe_tag, UD_FILE_ENTRY,
5287c478bd9Sstevel@tonic-gate SWAP_32(fe->fe_tag.tag_loc), 1, 1) != 0) {
5297c478bd9Sstevel@tonic-gate return;
5307c478bd9Sstevel@tonic-gate }
5317c478bd9Sstevel@tonic-gate i8 = (uint8_t)value;
5327c478bd9Sstevel@tonic-gate i16 = SWAP_16(((uint16_t)value));
5337c478bd9Sstevel@tonic-gate i32 = SWAP_32(((uint32_t)value));
5347c478bd9Sstevel@tonic-gate i64 = SWAP_64(value);
5357c478bd9Sstevel@tonic-gate switch (id) {
5367c478bd9Sstevel@tonic-gate case ATTZ :
5377c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_tzone = i16;
5387c478bd9Sstevel@tonic-gate break;
5397c478bd9Sstevel@tonic-gate case ATYE :
5407c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_year = i16;
5417c478bd9Sstevel@tonic-gate break;
5427c478bd9Sstevel@tonic-gate case ATMO :
5437c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_month = i8;
5447c478bd9Sstevel@tonic-gate break;
5457c478bd9Sstevel@tonic-gate case ATDA :
5467c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_day = i8;
5477c478bd9Sstevel@tonic-gate break;
5487c478bd9Sstevel@tonic-gate case ATHO :
5497c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_hour = i8;
5507c478bd9Sstevel@tonic-gate break;
5517c478bd9Sstevel@tonic-gate case ATMI :
5527c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_min = i8;
5537c478bd9Sstevel@tonic-gate break;
5547c478bd9Sstevel@tonic-gate case ATSE :
5557c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_sec = i8;
5567c478bd9Sstevel@tonic-gate break;
5577c478bd9Sstevel@tonic-gate case ATCE :
5587c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_csec = i8;
5597c478bd9Sstevel@tonic-gate break;
5607c478bd9Sstevel@tonic-gate case ATHU :
5617c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_husec = i8;
5627c478bd9Sstevel@tonic-gate break;
5637c478bd9Sstevel@tonic-gate case ATMIC :
5647c478bd9Sstevel@tonic-gate fe->fe_acc_time.ts_usec = i8;
5657c478bd9Sstevel@tonic-gate break;
5667c478bd9Sstevel@tonic-gate case CTTZ :
5677c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_tzone = i16;
5687c478bd9Sstevel@tonic-gate break;
5697c478bd9Sstevel@tonic-gate case CTYE :
5707c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_year = i16;
5717c478bd9Sstevel@tonic-gate break;
5727c478bd9Sstevel@tonic-gate case CTMO :
5737c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_month = i8;
5747c478bd9Sstevel@tonic-gate break;
5757c478bd9Sstevel@tonic-gate case CTDA :
5767c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_day = i8;
5777c478bd9Sstevel@tonic-gate break;
5787c478bd9Sstevel@tonic-gate case CTHO :
5797c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_hour = i8;
5807c478bd9Sstevel@tonic-gate break;
5817c478bd9Sstevel@tonic-gate case CTMI :
5827c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_min = i8;
5837c478bd9Sstevel@tonic-gate break;
5847c478bd9Sstevel@tonic-gate case CTSE :
5857c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_sec = i8;
5867c478bd9Sstevel@tonic-gate break;
5877c478bd9Sstevel@tonic-gate case CTCE :
5887c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_csec = i8;
5897c478bd9Sstevel@tonic-gate break;
5907c478bd9Sstevel@tonic-gate case CTHU :
5917c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_husec = i8;
5927c478bd9Sstevel@tonic-gate break;
5937c478bd9Sstevel@tonic-gate case CTMIC :
5947c478bd9Sstevel@tonic-gate fe->fe_attr_time.ts_usec = i8;
5957c478bd9Sstevel@tonic-gate break;
5967c478bd9Sstevel@tonic-gate case MTTZ :
5977c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_tzone = i16;
5987c478bd9Sstevel@tonic-gate break;
5997c478bd9Sstevel@tonic-gate case MTYE :
6007c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_year = i16;
6017c478bd9Sstevel@tonic-gate break;
6027c478bd9Sstevel@tonic-gate case MTMO :
6037c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_month = i8;
6047c478bd9Sstevel@tonic-gate break;
6057c478bd9Sstevel@tonic-gate case MTDA :
6067c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_day = i8;
6077c478bd9Sstevel@tonic-gate break;
6087c478bd9Sstevel@tonic-gate case MTHO :
6097c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_hour = i8;
6107c478bd9Sstevel@tonic-gate break;
6117c478bd9Sstevel@tonic-gate case MTMI :
6127c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_min = i8;
6137c478bd9Sstevel@tonic-gate break;
6147c478bd9Sstevel@tonic-gate case MTSE :
6157c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_sec = i8;
6167c478bd9Sstevel@tonic-gate break;
6177c478bd9Sstevel@tonic-gate case MTCE :
6187c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_csec = i8;
6197c478bd9Sstevel@tonic-gate break;
6207c478bd9Sstevel@tonic-gate case MTHU :
6217c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_husec = i8;
6227c478bd9Sstevel@tonic-gate break;
6237c478bd9Sstevel@tonic-gate case MTMIC :
6247c478bd9Sstevel@tonic-gate fe->fe_mod_time.ts_usec = i8;
6257c478bd9Sstevel@tonic-gate break;
6267c478bd9Sstevel@tonic-gate case GID :
6277c478bd9Sstevel@tonic-gate fe->fe_gid = i32;
6287c478bd9Sstevel@tonic-gate break;
6297c478bd9Sstevel@tonic-gate case LN :
6307c478bd9Sstevel@tonic-gate fe->fe_lcount = i16;
6317c478bd9Sstevel@tonic-gate break;
6327c478bd9Sstevel@tonic-gate case MD :
6337c478bd9Sstevel@tonic-gate fe->fe_perms = i32;
6347c478bd9Sstevel@tonic-gate break;
6357c478bd9Sstevel@tonic-gate case MAJ :
6367c478bd9Sstevel@tonic-gate case MIO :
6377c478bd9Sstevel@tonic-gate if ((fe->fe_icb_tag.itag_ftype != VBLK) &&
6387c478bd9Sstevel@tonic-gate (fe->fe_icb_tag.itag_ftype != VCHR)) {
6397c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
6407c478bd9Sstevel@tonic-gate gettext("Not a device\n"));
6417c478bd9Sstevel@tonic-gate break;
6427c478bd9Sstevel@tonic-gate }
6437c478bd9Sstevel@tonic-gate /* LINTED */
6447c478bd9Sstevel@tonic-gate eah = (struct ext_attr_hdr *)fe->fe_spec;
6457c478bd9Sstevel@tonic-gate ea_off = SWAP_32(eah->eah_ial);
6467c478bd9Sstevel@tonic-gate ea_len = SWAP_32(fe->fe_len_ear);
6477c478bd9Sstevel@tonic-gate block = SWAP_32(eah->eah_tag.tag_loc);
648*0e42dee6Sartem if (ea_len && (ud_verify_tag(udh, &eah->eah_tag,
6497c478bd9Sstevel@tonic-gate UD_EXT_ATTR_HDR, block, 1, 1) == 0)) {
6507c478bd9Sstevel@tonic-gate while (ea_off < ea_len) {
6517c478bd9Sstevel@tonic-gate /* LINTED */
6527c478bd9Sstevel@tonic-gate ah = (struct attr_hdr *)
6537c478bd9Sstevel@tonic-gate &fe->fe_spec[ea_off];
6547c478bd9Sstevel@tonic-gate if ((ah->ahdr_atype == SWAP_32(12)) &&
6557c478bd9Sstevel@tonic-gate (ah->ahdr_astype == 1)) {
6567c478bd9Sstevel@tonic-gate
6577c478bd9Sstevel@tonic-gate ds = (struct dev_spec_ear *)ah;
6587c478bd9Sstevel@tonic-gate if (id == MAJ) {
6597c478bd9Sstevel@tonic-gate ds->ds_major_id = i32;
6607c478bd9Sstevel@tonic-gate } else {
6617c478bd9Sstevel@tonic-gate ds->ds_minor_id = i32;
6627c478bd9Sstevel@tonic-gate }
663*0e42dee6Sartem ud_make_tag(udh, &eah->eah_tag,
6647c478bd9Sstevel@tonic-gate UD_EXT_ATTR_HDR, block,
6657c478bd9Sstevel@tonic-gate eah->eah_tag.tag_crc_len);
6667c478bd9Sstevel@tonic-gate break;
6677c478bd9Sstevel@tonic-gate }
6687c478bd9Sstevel@tonic-gate }
6697c478bd9Sstevel@tonic-gate }
6707c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
6717c478bd9Sstevel@tonic-gate gettext("does not have a Device Specification EA\n"));
6727c478bd9Sstevel@tonic-gate break;
6737c478bd9Sstevel@tonic-gate case NM :
6747c478bd9Sstevel@tonic-gate break;
6757c478bd9Sstevel@tonic-gate case SZ :
6767c478bd9Sstevel@tonic-gate fe->fe_info_len = i64;
6777c478bd9Sstevel@tonic-gate break;
6787c478bd9Sstevel@tonic-gate case UID :
6797c478bd9Sstevel@tonic-gate fe->fe_uid = i32;
6807c478bd9Sstevel@tonic-gate break;
6817c478bd9Sstevel@tonic-gate case UNIQ :
6827c478bd9Sstevel@tonic-gate fe->fe_uniq_id = i32;
6837c478bd9Sstevel@tonic-gate break;
6847c478bd9Sstevel@tonic-gate default :
6857c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
6867c478bd9Sstevel@tonic-gate gettext("Unknown set\n"));
6877c478bd9Sstevel@tonic-gate }
688*0e42dee6Sartem ud_make_tag(udh, &fe->fe_tag, UD_FILE_ENTRY,
6897c478bd9Sstevel@tonic-gate SWAP_32(fe->fe_tag.tag_loc), fe->fe_tag.tag_crc_len);
6907c478bd9Sstevel@tonic-gate (void) putblk((caddr_t)fe);
6917c478bd9Sstevel@tonic-gate }
6927c478bd9Sstevel@tonic-gate
6937c478bd9Sstevel@tonic-gate caddr_t
verify_inode(uint32_t addr,uint32_t type)6947c478bd9Sstevel@tonic-gate verify_inode(uint32_t addr, uint32_t type)
6957c478bd9Sstevel@tonic-gate {
6967c478bd9Sstevel@tonic-gate struct file_entry *fe;
6977c478bd9Sstevel@tonic-gate struct tag *tag;
6987c478bd9Sstevel@tonic-gate
6997c478bd9Sstevel@tonic-gate /* LINTED */
7007c478bd9Sstevel@tonic-gate if ((tag = (struct tag *)getblk(addr & (~bmask))) == NULL) {
7017c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
7027c478bd9Sstevel@tonic-gate gettext("Could not read block %x\n"),
7037c478bd9Sstevel@tonic-gate addr >> l2b);
7047c478bd9Sstevel@tonic-gate } else {
705*0e42dee6Sartem if (ud_verify_tag(udh, tag, UD_FILE_ENTRY,
706*0e42dee6Sartem addr >> l2b, 0, 1) != 0) {
7077c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
7087c478bd9Sstevel@tonic-gate gettext("Not a file entry(inode) at %x\n"),
7097c478bd9Sstevel@tonic-gate addr >> l2b);
7107c478bd9Sstevel@tonic-gate } else {
711*0e42dee6Sartem if (ud_verify_tag(udh, tag, UD_FILE_ENTRY,
7127c478bd9Sstevel@tonic-gate SWAP_32(tag->tag_loc), 1, 1) != 0) {
7137c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
7147c478bd9Sstevel@tonic-gate gettext("CRC failed\n"));
7157c478bd9Sstevel@tonic-gate } else {
7167c478bd9Sstevel@tonic-gate fe = (struct file_entry *)tag;
7177c478bd9Sstevel@tonic-gate if ((type == 0) ||
7187c478bd9Sstevel@tonic-gate (type == fe->fe_icb_tag.itag_ftype)) {
7197c478bd9Sstevel@tonic-gate return ((caddr_t)tag);
7207c478bd9Sstevel@tonic-gate }
7217c478bd9Sstevel@tonic-gate }
7227c478bd9Sstevel@tonic-gate }
7237c478bd9Sstevel@tonic-gate }
7247c478bd9Sstevel@tonic-gate return (0);
7257c478bd9Sstevel@tonic-gate }
7267c478bd9Sstevel@tonic-gate
7277c478bd9Sstevel@tonic-gate void
print_inode(uint32_t addr)7287c478bd9Sstevel@tonic-gate print_inode(uint32_t addr)
7297c478bd9Sstevel@tonic-gate {
7307c478bd9Sstevel@tonic-gate if (verify_inode(addr, 0) != NULL) {
7317c478bd9Sstevel@tonic-gate print_desc(addr, 0);
7327c478bd9Sstevel@tonic-gate }
7337c478bd9Sstevel@tonic-gate }
7347c478bd9Sstevel@tonic-gate
7357c478bd9Sstevel@tonic-gate int32_t
verify_dent(uint32_t i_addr,uint32_t nent)7367c478bd9Sstevel@tonic-gate verify_dent(uint32_t i_addr, uint32_t nent)
7377c478bd9Sstevel@tonic-gate {
7387c478bd9Sstevel@tonic-gate uint32_t ent = 0;
7397c478bd9Sstevel@tonic-gate uint64_t off = 0;
7407c478bd9Sstevel@tonic-gate uint8_t buf[1024];
7417c478bd9Sstevel@tonic-gate struct file_id *fid;
7427c478bd9Sstevel@tonic-gate
7437c478bd9Sstevel@tonic-gate /* LINTED */
7447c478bd9Sstevel@tonic-gate fid = (struct file_id *)buf;
7457c478bd9Sstevel@tonic-gate
7467c478bd9Sstevel@tonic-gate if (verify_inode(i_addr, 4) == 0) {
7477c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
7487c478bd9Sstevel@tonic-gate gettext("Inode is not a directory\n"));
7497c478bd9Sstevel@tonic-gate return (1);
7507c478bd9Sstevel@tonic-gate }
7517c478bd9Sstevel@tonic-gate
7527c478bd9Sstevel@tonic-gate while (get_fid(i_addr >> l2b, buf, off) == 0) {
7537c478bd9Sstevel@tonic-gate off += FID_LEN(fid);
7547c478bd9Sstevel@tonic-gate if (ent == nent) {
7557c478bd9Sstevel@tonic-gate return (0);
7567c478bd9Sstevel@tonic-gate }
7577c478bd9Sstevel@tonic-gate ent++;
7587c478bd9Sstevel@tonic-gate }
7597c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
7607c478bd9Sstevel@tonic-gate gettext("Reached EOF\n"));
7617c478bd9Sstevel@tonic-gate return (1);
7627c478bd9Sstevel@tonic-gate }
7637c478bd9Sstevel@tonic-gate
7647c478bd9Sstevel@tonic-gate void
print_dent(uint32_t i_addr,uint32_t nent)7657c478bd9Sstevel@tonic-gate print_dent(uint32_t i_addr, uint32_t nent)
7667c478bd9Sstevel@tonic-gate {
7677c478bd9Sstevel@tonic-gate uint32_t ent = 0;
7687c478bd9Sstevel@tonic-gate uint64_t off = 0;
7697c478bd9Sstevel@tonic-gate uint8_t buf[1024];
7707c478bd9Sstevel@tonic-gate struct file_id *fid;
7717c478bd9Sstevel@tonic-gate
7727c478bd9Sstevel@tonic-gate /* LINTED */
7737c478bd9Sstevel@tonic-gate fid = (struct file_id *)buf;
7747c478bd9Sstevel@tonic-gate
7757c478bd9Sstevel@tonic-gate if (verify_dent(i_addr, nent) == 0) {
7767c478bd9Sstevel@tonic-gate while (get_fid(i_addr >> l2b, buf, off) == 0) {
7777c478bd9Sstevel@tonic-gate off += FID_LEN(fid);
7787c478bd9Sstevel@tonic-gate if (ent == nent) {
779*0e42dee6Sartem print_fid(stdout, fid);
7807c478bd9Sstevel@tonic-gate return;
7817c478bd9Sstevel@tonic-gate }
7827c478bd9Sstevel@tonic-gate ent++;
7837c478bd9Sstevel@tonic-gate }
7847c478bd9Sstevel@tonic-gate }
7857c478bd9Sstevel@tonic-gate }
7867c478bd9Sstevel@tonic-gate
7877c478bd9Sstevel@tonic-gate uint32_t in;
7887c478bd9Sstevel@tonic-gate uint32_t de_count, ie_count;
7897c478bd9Sstevel@tonic-gate struct ext {
7907c478bd9Sstevel@tonic-gate uint16_t prn;
7917c478bd9Sstevel@tonic-gate uint16_t flags;
7927c478bd9Sstevel@tonic-gate uint32_t blkno;
7937c478bd9Sstevel@tonic-gate uint32_t len;
7947c478bd9Sstevel@tonic-gate } *de, *ie;
7957c478bd9Sstevel@tonic-gate
7967c478bd9Sstevel@tonic-gate int32_t
get_blkno(uint32_t inode,uint32_t * blkno,uint64_t off)7977c478bd9Sstevel@tonic-gate get_blkno(uint32_t inode, uint32_t *blkno, uint64_t off)
7987c478bd9Sstevel@tonic-gate {
7997c478bd9Sstevel@tonic-gate struct file_entry *fe;
8007c478bd9Sstevel@tonic-gate int32_t i, d, nent;
8017c478bd9Sstevel@tonic-gate uint16_t prn, flags, elen;
8027c478bd9Sstevel@tonic-gate uint32_t desc_type, bno, len;
8037c478bd9Sstevel@tonic-gate struct short_ad *sad;
8047c478bd9Sstevel@tonic-gate struct long_ad *lad;
8057c478bd9Sstevel@tonic-gate uint64_t b_off, e_off;
8067c478bd9Sstevel@tonic-gate
8077c478bd9Sstevel@tonic-gate if (inode != in) {
8087c478bd9Sstevel@tonic-gate /* LINTED */
8097c478bd9Sstevel@tonic-gate if ((fe = (struct file_entry *)
8107c478bd9Sstevel@tonic-gate getblk(inode << l2b)) == NULL) {
8117c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
8127c478bd9Sstevel@tonic-gate gettext("Could not read block %x\n"),
8137c478bd9Sstevel@tonic-gate off & (~bmask));
8147c478bd9Sstevel@tonic-gate return (1);
8157c478bd9Sstevel@tonic-gate }
8167c478bd9Sstevel@tonic-gate desc_type = SWAP_16(fe->fe_icb_tag.itag_flags) & 0x7;
8177c478bd9Sstevel@tonic-gate if (desc_type == ICB_FLAG_SHORT_AD) {
8187c478bd9Sstevel@tonic-gate elen = sizeof (struct short_ad);
8197c478bd9Sstevel@tonic-gate /* LINTED */
8207c478bd9Sstevel@tonic-gate sad = (struct short_ad *)
8217c478bd9Sstevel@tonic-gate (fe->fe_spec + SWAP_32(fe->fe_len_ear));
8227c478bd9Sstevel@tonic-gate } else if (desc_type == ICB_FLAG_LONG_AD) {
8237c478bd9Sstevel@tonic-gate elen = sizeof (struct long_ad);
8247c478bd9Sstevel@tonic-gate /* LINTED */
8257c478bd9Sstevel@tonic-gate lad = (struct long_ad *)
8267c478bd9Sstevel@tonic-gate (fe->fe_spec + SWAP_32(fe->fe_len_ear));
8277c478bd9Sstevel@tonic-gate } else if (desc_type == ICB_FLAG_ONE_AD) {
8287c478bd9Sstevel@tonic-gate *blkno = inode;
8297c478bd9Sstevel@tonic-gate return (0);
8307c478bd9Sstevel@tonic-gate } else {
8317c478bd9Sstevel@tonic-gate /* This cannot happen return */
8327c478bd9Sstevel@tonic-gate return (EINVAL);
8337c478bd9Sstevel@tonic-gate }
8347c478bd9Sstevel@tonic-gate
8357c478bd9Sstevel@tonic-gate nent = SWAP_32(fe->fe_len_adesc) / elen;
8367c478bd9Sstevel@tonic-gate de = malloc(nent * sizeof (struct ext));
8377c478bd9Sstevel@tonic-gate if (de == NULL) {
8387c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
8397c478bd9Sstevel@tonic-gate gettext("could not allocate memeory\n"));
8407c478bd9Sstevel@tonic-gate return (1);
8417c478bd9Sstevel@tonic-gate }
8427c478bd9Sstevel@tonic-gate in = inode;
8437c478bd9Sstevel@tonic-gate de_count = nent;
8447c478bd9Sstevel@tonic-gate for (d = 0, i = 0; i < nent; i++) {
8457c478bd9Sstevel@tonic-gate if (desc_type == ICB_FLAG_SHORT_AD) {
8467c478bd9Sstevel@tonic-gate prn = 0;
8477c478bd9Sstevel@tonic-gate bno = SWAP_32(sad->sad_ext_loc);
8487c478bd9Sstevel@tonic-gate len = SWAP_32(sad->sad_ext_len);
8497c478bd9Sstevel@tonic-gate } else if (desc_type == ICB_FLAG_LONG_AD) {
8507c478bd9Sstevel@tonic-gate prn = SWAP_16(lad->lad_ext_prn);
8517c478bd9Sstevel@tonic-gate bno = SWAP_32(lad->lad_ext_loc);
8527c478bd9Sstevel@tonic-gate len = SWAP_32(lad->lad_ext_len);
8537c478bd9Sstevel@tonic-gate }
8547c478bd9Sstevel@tonic-gate flags = len >> 30;
8557c478bd9Sstevel@tonic-gate if (flags == 0x3) {
8567c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
8577c478bd9Sstevel@tonic-gate gettext("Handle IE\n"));
8587c478bd9Sstevel@tonic-gate } else {
8597c478bd9Sstevel@tonic-gate de[d].prn = prn;
8607c478bd9Sstevel@tonic-gate de[d].flags = flags;
8617c478bd9Sstevel@tonic-gate de[d].blkno = bno;
8627c478bd9Sstevel@tonic-gate de[d].len = len & 0x3FFFFFFF;
8637c478bd9Sstevel@tonic-gate d++;
8647c478bd9Sstevel@tonic-gate }
8657c478bd9Sstevel@tonic-gate }
8667c478bd9Sstevel@tonic-gate }
8677c478bd9Sstevel@tonic-gate
8687c478bd9Sstevel@tonic-gate b_off = 0;
8697c478bd9Sstevel@tonic-gate for (i = 0; i < de_count; i++) {
8707c478bd9Sstevel@tonic-gate e_off = b_off + de[i].len;
8717c478bd9Sstevel@tonic-gate if (off < e_off) {
8727c478bd9Sstevel@tonic-gate bno = de[i].blkno + ((off - b_off) >> l2b);
8737c478bd9Sstevel@tonic-gate if ((*blkno = ud_xlate_to_daddr(
874*0e42dee6Sartem udh, de[i].prn, bno)) == 0) {
8757c478bd9Sstevel@tonic-gate return (1);
8767c478bd9Sstevel@tonic-gate }
8777c478bd9Sstevel@tonic-gate return (0);
8787c478bd9Sstevel@tonic-gate }
8797c478bd9Sstevel@tonic-gate b_off = e_off;
8807c478bd9Sstevel@tonic-gate }
8817c478bd9Sstevel@tonic-gate return (1);
8827c478bd9Sstevel@tonic-gate }
8837c478bd9Sstevel@tonic-gate
8847c478bd9Sstevel@tonic-gate /*
8857c478bd9Sstevel@tonic-gate * assume the buffer is big enough
8867c478bd9Sstevel@tonic-gate * for the entire request
8877c478bd9Sstevel@tonic-gate */
8887c478bd9Sstevel@tonic-gate int32_t
read_file(uint32_t inode,uint8_t * buf,uint32_t count,uint64_t off)8897c478bd9Sstevel@tonic-gate read_file(uint32_t inode, uint8_t *buf, uint32_t count, uint64_t off)
8907c478bd9Sstevel@tonic-gate {
8917c478bd9Sstevel@tonic-gate caddr_t addr;
8927c478bd9Sstevel@tonic-gate uint32_t bno, tcount;
8937c478bd9Sstevel@tonic-gate
8947c478bd9Sstevel@tonic-gate
8957c478bd9Sstevel@tonic-gate while (count) {
8967c478bd9Sstevel@tonic-gate if (get_blkno(inode, &bno, off) != 0) {
8977c478bd9Sstevel@tonic-gate return (1);
8987c478bd9Sstevel@tonic-gate }
8997c478bd9Sstevel@tonic-gate if ((addr = getblk(bno << l2b)) == NULL) {
9007c478bd9Sstevel@tonic-gate return (1);
9017c478bd9Sstevel@tonic-gate }
9027c478bd9Sstevel@tonic-gate if (bno == inode) {
9037c478bd9Sstevel@tonic-gate struct file_entry *fe;
9047c478bd9Sstevel@tonic-gate /*
9057c478bd9Sstevel@tonic-gate * embedded file
9067c478bd9Sstevel@tonic-gate */
9077c478bd9Sstevel@tonic-gate /* LINTED */
9087c478bd9Sstevel@tonic-gate fe = (struct file_entry *)addr;
9097c478bd9Sstevel@tonic-gate addr += 0xB0 + SWAP_32(fe->fe_len_ear);
9107c478bd9Sstevel@tonic-gate if (off >= SWAP_64(fe->fe_info_len)) {
9117c478bd9Sstevel@tonic-gate return (1);
9127c478bd9Sstevel@tonic-gate }
9137c478bd9Sstevel@tonic-gate }
914*0e42dee6Sartem tcount = udh->udfs.lbsize - (off & bmask);
9157c478bd9Sstevel@tonic-gate if (tcount > count) {
9167c478bd9Sstevel@tonic-gate tcount = count;
9177c478bd9Sstevel@tonic-gate }
9187c478bd9Sstevel@tonic-gate addr += off & bmask;
9197c478bd9Sstevel@tonic-gate (void) memcpy(buf, addr, tcount);
9207c478bd9Sstevel@tonic-gate count -= tcount;
9217c478bd9Sstevel@tonic-gate buf += tcount;
9227c478bd9Sstevel@tonic-gate off += tcount;
9237c478bd9Sstevel@tonic-gate }
9247c478bd9Sstevel@tonic-gate return (0);
9257c478bd9Sstevel@tonic-gate }
9267c478bd9Sstevel@tonic-gate
9277c478bd9Sstevel@tonic-gate int32_t
get_fid(uint32_t inode,uint8_t * buf,uint64_t off)9287c478bd9Sstevel@tonic-gate get_fid(uint32_t inode, uint8_t *buf, uint64_t off)
9297c478bd9Sstevel@tonic-gate {
9307c478bd9Sstevel@tonic-gate struct file_id *fid;
9317c478bd9Sstevel@tonic-gate
9327c478bd9Sstevel@tonic-gate /* LINTED */
9337c478bd9Sstevel@tonic-gate fid = (struct file_id *)buf;
9347c478bd9Sstevel@tonic-gate if ((read_file(inode, buf, sizeof (struct file_id), off)) != 0) {
9357c478bd9Sstevel@tonic-gate return (1);
9367c478bd9Sstevel@tonic-gate }
9377c478bd9Sstevel@tonic-gate
938*0e42dee6Sartem if (ud_verify_tag(udh, &fid->fid_tag, UD_FILE_ID_DESC, 0, 0, 1) != 0) {
9397c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
9407c478bd9Sstevel@tonic-gate gettext("file_id tag does not verify off %llx\n"),
9417c478bd9Sstevel@tonic-gate off);
9427c478bd9Sstevel@tonic-gate return (1);
9437c478bd9Sstevel@tonic-gate }
9447c478bd9Sstevel@tonic-gate
9457c478bd9Sstevel@tonic-gate if ((read_file(inode, buf, FID_LEN(fid), off)) != 0) {
9467c478bd9Sstevel@tonic-gate return (1);
9477c478bd9Sstevel@tonic-gate }
9487c478bd9Sstevel@tonic-gate
9497c478bd9Sstevel@tonic-gate return (0);
9507c478bd9Sstevel@tonic-gate }
9517c478bd9Sstevel@tonic-gate
9527c478bd9Sstevel@tonic-gate /*
9537c478bd9Sstevel@tonic-gate * Path is absolute path
9547c478bd9Sstevel@tonic-gate */
9557c478bd9Sstevel@tonic-gate int32_t
inode_from_path(char * path,uint32_t * in,uint8_t * fl)9567c478bd9Sstevel@tonic-gate inode_from_path(char *path, uint32_t *in, uint8_t *fl)
9577c478bd9Sstevel@tonic-gate {
9587c478bd9Sstevel@tonic-gate char dname[1024];
9597c478bd9Sstevel@tonic-gate char fname[256];
9607c478bd9Sstevel@tonic-gate int32_t err;
9617c478bd9Sstevel@tonic-gate uint32_t dinode;
9627c478bd9Sstevel@tonic-gate struct tag *tag;
9637c478bd9Sstevel@tonic-gate uint8_t flags;
9647c478bd9Sstevel@tonic-gate
9657c478bd9Sstevel@tonic-gate uint8_t buf[1024];
9667c478bd9Sstevel@tonic-gate uint64_t off;
9677c478bd9Sstevel@tonic-gate struct file_id *fid;
9687c478bd9Sstevel@tonic-gate uint8_t *addr;
9697c478bd9Sstevel@tonic-gate
9707c478bd9Sstevel@tonic-gate if (strcmp(path, "/") == 0) {
9717c478bd9Sstevel@tonic-gate *fl = FID_DIR;
972*0e42dee6Sartem if ((*in = ud_xlate_to_daddr(udh, ricb_prn, ricb_loc)) == 0) {
9737c478bd9Sstevel@tonic-gate return (1);
9747c478bd9Sstevel@tonic-gate }
9757c478bd9Sstevel@tonic-gate return (0);
9767c478bd9Sstevel@tonic-gate }
9777c478bd9Sstevel@tonic-gate
9787c478bd9Sstevel@tonic-gate (void) strcpy(dname, path);
9797c478bd9Sstevel@tonic-gate (void) strcpy(fname, basename(dname));
9807c478bd9Sstevel@tonic-gate (void) dirname(dname);
9817c478bd9Sstevel@tonic-gate
9827c478bd9Sstevel@tonic-gate if ((err = inode_from_path(dname, &dinode, &flags)) != 0) {
9837c478bd9Sstevel@tonic-gate return (1);
9847c478bd9Sstevel@tonic-gate }
9857c478bd9Sstevel@tonic-gate
9867c478bd9Sstevel@tonic-gate
9877c478bd9Sstevel@tonic-gate /*
9887c478bd9Sstevel@tonic-gate * Check if dname is a directory
9897c478bd9Sstevel@tonic-gate */
9907c478bd9Sstevel@tonic-gate if ((flags & FID_DIR) == 0) {
9917c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
9927c478bd9Sstevel@tonic-gate gettext("Path %s is not a directory\n"), path);
9937c478bd9Sstevel@tonic-gate }
9947c478bd9Sstevel@tonic-gate
9957c478bd9Sstevel@tonic-gate /*
9967c478bd9Sstevel@tonic-gate * Search for the fname in the directory now
9977c478bd9Sstevel@tonic-gate */
9987c478bd9Sstevel@tonic-gate
9997c478bd9Sstevel@tonic-gate
10007c478bd9Sstevel@tonic-gate off = 0;
10017c478bd9Sstevel@tonic-gate /* LINTED */
10027c478bd9Sstevel@tonic-gate fid = (struct file_id *)buf;
10037c478bd9Sstevel@tonic-gate while (get_fid(dinode, buf, off) == 0) {
10047c478bd9Sstevel@tonic-gate off += FID_LEN(fid);
10057c478bd9Sstevel@tonic-gate if (fid->fid_flags & FID_DELETED) {
10067c478bd9Sstevel@tonic-gate continue;
10077c478bd9Sstevel@tonic-gate }
10087c478bd9Sstevel@tonic-gate addr = &fid->fid_spec[SWAP_16((fid)->fid_iulen) + 1];
10097c478bd9Sstevel@tonic-gate if (fid->fid_flags & FID_PARENT) {
10107c478bd9Sstevel@tonic-gate addr[0] = '.';
10117c478bd9Sstevel@tonic-gate addr[1] = '.';
10127c478bd9Sstevel@tonic-gate addr[2] = '\0';
10137c478bd9Sstevel@tonic-gate } else {
10147c478bd9Sstevel@tonic-gate addr[fid->fid_idlen] = '\0';
10157c478bd9Sstevel@tonic-gate }
10167c478bd9Sstevel@tonic-gate if (strcmp((caddr_t)addr, fname) == 0) {
10177c478bd9Sstevel@tonic-gate *fl = fid->fid_flags;
1018*0e42dee6Sartem if ((*in = ud_xlate_to_daddr(udh,
10197c478bd9Sstevel@tonic-gate SWAP_16(fid->fid_icb.lad_ext_prn),
10207c478bd9Sstevel@tonic-gate SWAP_32(fid->fid_icb.lad_ext_loc))) == 0) {
10217c478bd9Sstevel@tonic-gate return (1);
10227c478bd9Sstevel@tonic-gate }
10237c478bd9Sstevel@tonic-gate /* LINTED */
10247c478bd9Sstevel@tonic-gate if ((tag = (struct tag *)getblk(*in << l2b)) == NULL) {
10257c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10267c478bd9Sstevel@tonic-gate gettext("Could not read block %x\n"),
10277c478bd9Sstevel@tonic-gate *in);
10287c478bd9Sstevel@tonic-gate return (1);
10297c478bd9Sstevel@tonic-gate }
1030*0e42dee6Sartem if (ud_verify_tag(udh, tag, UD_FILE_ENTRY,
1031*0e42dee6Sartem 0, 0, 1) != 0) {
10327c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10337c478bd9Sstevel@tonic-gate gettext("Not a file entry(inode)"
10347c478bd9Sstevel@tonic-gate " at %x\n"), *in);
10357c478bd9Sstevel@tonic-gate return (1);
10367c478bd9Sstevel@tonic-gate }
1037*0e42dee6Sartem if (ud_verify_tag(udh, tag, UD_FILE_ENTRY,
10387c478bd9Sstevel@tonic-gate SWAP_32(tag->tag_loc), 1, 1) != 0) {
10397c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10407c478bd9Sstevel@tonic-gate gettext("CRC failed\n"));
10417c478bd9Sstevel@tonic-gate return (1);
10427c478bd9Sstevel@tonic-gate }
10437c478bd9Sstevel@tonic-gate
10447c478bd9Sstevel@tonic-gate return (0);
10457c478bd9Sstevel@tonic-gate }
10467c478bd9Sstevel@tonic-gate }
10477c478bd9Sstevel@tonic-gate return (err);
10487c478bd9Sstevel@tonic-gate }
10497c478bd9Sstevel@tonic-gate
10507c478bd9Sstevel@tonic-gate struct recu_dir {
10517c478bd9Sstevel@tonic-gate struct recu_dir *next;
10527c478bd9Sstevel@tonic-gate uint32_t inode;
10537c478bd9Sstevel@tonic-gate char *nm;
10547c478bd9Sstevel@tonic-gate };
10557c478bd9Sstevel@tonic-gate
10567c478bd9Sstevel@tonic-gate void
list(char * nm,uint32_t in,uint32_t fl)10577c478bd9Sstevel@tonic-gate list(char *nm, uint32_t in, uint32_t fl)
10587c478bd9Sstevel@tonic-gate {
10597c478bd9Sstevel@tonic-gate uint8_t buf[1024];
10607c478bd9Sstevel@tonic-gate uint64_t off;
10617c478bd9Sstevel@tonic-gate struct file_id *fid;
10627c478bd9Sstevel@tonic-gate struct recu_dir *rd, *erd, *temp;
10637c478bd9Sstevel@tonic-gate uint32_t iloc;
10647c478bd9Sstevel@tonic-gate
10657c478bd9Sstevel@tonic-gate rd = erd = temp = NULL;
10667c478bd9Sstevel@tonic-gate if (verify_inode(in << l2b, 4) == 0) {
10677c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10687c478bd9Sstevel@tonic-gate gettext("Inode is not a directory\n"));
10697c478bd9Sstevel@tonic-gate return;
10707c478bd9Sstevel@tonic-gate }
10717c478bd9Sstevel@tonic-gate
10727c478bd9Sstevel@tonic-gate if (fl & 2) {
10737c478bd9Sstevel@tonic-gate (void) printf("\n");
10747c478bd9Sstevel@tonic-gate if (fl & 1) {
10757c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10767c478bd9Sstevel@tonic-gate gettext("i#: %x\t"), in);
10777c478bd9Sstevel@tonic-gate }
10787c478bd9Sstevel@tonic-gate (void) printf("%s\n", nm);
10797c478bd9Sstevel@tonic-gate }
10807c478bd9Sstevel@tonic-gate
10817c478bd9Sstevel@tonic-gate off = 0;
10827c478bd9Sstevel@tonic-gate /* LINTED */
10837c478bd9Sstevel@tonic-gate fid = (struct file_id *)buf;
10847c478bd9Sstevel@tonic-gate while (get_fid(in, buf, off) == 0) {
10857c478bd9Sstevel@tonic-gate off += FID_LEN(fid);
10867c478bd9Sstevel@tonic-gate if (fid->fid_flags & FID_DELETED) {
10877c478bd9Sstevel@tonic-gate continue;
10887c478bd9Sstevel@tonic-gate }
1089*0e42dee6Sartem iloc = ud_xlate_to_daddr(udh, SWAP_16(fid->fid_icb.lad_ext_prn),
10907c478bd9Sstevel@tonic-gate SWAP_32(fid->fid_icb.lad_ext_loc));
10917c478bd9Sstevel@tonic-gate if (fl & 1) {
10927c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10937c478bd9Sstevel@tonic-gate gettext("i#: %x\t"), iloc);
10947c478bd9Sstevel@tonic-gate }
10957c478bd9Sstevel@tonic-gate if (fid->fid_flags & FID_PARENT) {
10967c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
10977c478bd9Sstevel@tonic-gate gettext("..\n"));
10987c478bd9Sstevel@tonic-gate } else {
10997c478bd9Sstevel@tonic-gate int32_t i;
11007c478bd9Sstevel@tonic-gate uint8_t *addr;
11017c478bd9Sstevel@tonic-gate
11027c478bd9Sstevel@tonic-gate addr = &fid->fid_spec[SWAP_16((fid)->fid_iulen) + 1];
11037c478bd9Sstevel@tonic-gate for (i = 0; i < fid->fid_idlen - 1; i++)
11047c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "%c", addr[i]);
11057c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n");
11067c478bd9Sstevel@tonic-gate if ((fid->fid_flags & FID_DIR) &&
11077c478bd9Sstevel@tonic-gate (fl & 2)) {
11087c478bd9Sstevel@tonic-gate temp = (struct recu_dir *)
11097c478bd9Sstevel@tonic-gate malloc(sizeof (struct recu_dir));
11107c478bd9Sstevel@tonic-gate if (temp == NULL) {
11117c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
11127c478bd9Sstevel@tonic-gate gettext("Could not allocate memory\n"));
11137c478bd9Sstevel@tonic-gate } else {
11147c478bd9Sstevel@tonic-gate temp->next = NULL;
11157c478bd9Sstevel@tonic-gate temp->inode = iloc;
11167c478bd9Sstevel@tonic-gate temp->nm = malloc(strlen(nm) + 1 +
11177c478bd9Sstevel@tonic-gate fid->fid_idlen + 1);
11187c478bd9Sstevel@tonic-gate if (temp->nm != NULL) {
11197c478bd9Sstevel@tonic-gate (void) strcpy(temp->nm, nm);
11207c478bd9Sstevel@tonic-gate (void) strcat(temp->nm, "/");
11217c478bd9Sstevel@tonic-gate (void) strncat(temp->nm,
11227c478bd9Sstevel@tonic-gate (char *)addr,
11237c478bd9Sstevel@tonic-gate fid->fid_idlen);
11247c478bd9Sstevel@tonic-gate }
11257c478bd9Sstevel@tonic-gate if (rd == NULL) {
11267c478bd9Sstevel@tonic-gate erd = rd = temp;
11277c478bd9Sstevel@tonic-gate } else {
11287c478bd9Sstevel@tonic-gate erd->next = temp;
11297c478bd9Sstevel@tonic-gate erd = temp;
11307c478bd9Sstevel@tonic-gate }
11317c478bd9Sstevel@tonic-gate }
11327c478bd9Sstevel@tonic-gate }
11337c478bd9Sstevel@tonic-gate }
11347c478bd9Sstevel@tonic-gate }
11357c478bd9Sstevel@tonic-gate
11367c478bd9Sstevel@tonic-gate while (rd != NULL) {
11377c478bd9Sstevel@tonic-gate if (rd->nm != NULL) {
11387c478bd9Sstevel@tonic-gate list(rd->nm, rd->inode, fl);
11397c478bd9Sstevel@tonic-gate } else {
11407c478bd9Sstevel@tonic-gate list(".", rd->inode, fl);
11417c478bd9Sstevel@tonic-gate }
11427c478bd9Sstevel@tonic-gate temp = rd;
11437c478bd9Sstevel@tonic-gate rd = rd->next;
11447c478bd9Sstevel@tonic-gate if (temp->nm) {
11457c478bd9Sstevel@tonic-gate free(temp->nm);
11467c478bd9Sstevel@tonic-gate }
11477c478bd9Sstevel@tonic-gate free(temp);
11487c478bd9Sstevel@tonic-gate }
11497c478bd9Sstevel@tonic-gate }
11507c478bd9Sstevel@tonic-gate
11517c478bd9Sstevel@tonic-gate void
fill_pattern(uint32_t addr,uint32_t count,char * pattern)11527c478bd9Sstevel@tonic-gate fill_pattern(uint32_t addr, uint32_t count, char *pattern)
11537c478bd9Sstevel@tonic-gate {
11547c478bd9Sstevel@tonic-gate uint32_t beg, end, soff, lcount;
11557c478bd9Sstevel@tonic-gate int32_t len = strlen(pattern);
11567c478bd9Sstevel@tonic-gate caddr_t buf, p;
11577c478bd9Sstevel@tonic-gate
11587c478bd9Sstevel@tonic-gate if (openflg == O_RDONLY) {
11597c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
11607c478bd9Sstevel@tonic-gate gettext("Not run with -w flag\n"));
11617c478bd9Sstevel@tonic-gate return;
11627c478bd9Sstevel@tonic-gate }
11637c478bd9Sstevel@tonic-gate
11647c478bd9Sstevel@tonic-gate if (count == 0) {
11657c478bd9Sstevel@tonic-gate count = 1;
11667c478bd9Sstevel@tonic-gate }
11677c478bd9Sstevel@tonic-gate beg = addr;
11687c478bd9Sstevel@tonic-gate end = addr + count * len;
11697c478bd9Sstevel@tonic-gate soff = beg & (~bmask);
11707c478bd9Sstevel@tonic-gate lcount = ((end + bmask) & (~bmask)) - soff;
11717c478bd9Sstevel@tonic-gate
11727c478bd9Sstevel@tonic-gate inval_bufs();
11737c478bd9Sstevel@tonic-gate
11747c478bd9Sstevel@tonic-gate buf = malloc(lcount);
11757c478bd9Sstevel@tonic-gate
11767c478bd9Sstevel@tonic-gate if (llseek(fd, soff, SEEK_SET) != soff) {
11777c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
11787c478bd9Sstevel@tonic-gate gettext("Seek failed fd %x off %llx errno %x\n"),
11797c478bd9Sstevel@tonic-gate fd, soff, errno);
11807c478bd9Sstevel@tonic-gate goto end;
11817c478bd9Sstevel@tonic-gate }
11827c478bd9Sstevel@tonic-gate
11837c478bd9Sstevel@tonic-gate if (read(fd, buf, lcount) != lcount) {
11847c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
11857c478bd9Sstevel@tonic-gate gettext("Read failed fd %x off %llx errno %x\n"),
11867c478bd9Sstevel@tonic-gate fd, soff, errno);
11877c478bd9Sstevel@tonic-gate goto end;
11887c478bd9Sstevel@tonic-gate }
11897c478bd9Sstevel@tonic-gate
11907c478bd9Sstevel@tonic-gate p = buf + (addr & bmask);
11917c478bd9Sstevel@tonic-gate while (count--) {
11927c478bd9Sstevel@tonic-gate (void) strncpy(p, pattern, len);
11937c478bd9Sstevel@tonic-gate p += len;
11947c478bd9Sstevel@tonic-gate }
11957c478bd9Sstevel@tonic-gate
11967c478bd9Sstevel@tonic-gate if (write(fd, buf, lcount) != lcount) {
11977c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
11987c478bd9Sstevel@tonic-gate gettext("Write failed fd %x off %llx errno %x\n"),
11997c478bd9Sstevel@tonic-gate fd, soff, errno);
12007c478bd9Sstevel@tonic-gate goto end;
12017c478bd9Sstevel@tonic-gate }
12027c478bd9Sstevel@tonic-gate end:
12037c478bd9Sstevel@tonic-gate free(buf);
12047c478bd9Sstevel@tonic-gate }
12057c478bd9Sstevel@tonic-gate
12067c478bd9Sstevel@tonic-gate void
dump_disk(uint32_t addr,uint32_t count,char * format)12077c478bd9Sstevel@tonic-gate dump_disk(uint32_t addr, uint32_t count, char *format)
12087c478bd9Sstevel@tonic-gate {
12097c478bd9Sstevel@tonic-gate uint32_t beg, end, soff, lcount;
12107c478bd9Sstevel@tonic-gate int32_t len, prperline, n;
12117c478bd9Sstevel@tonic-gate uint8_t *buf, *p;
12127c478bd9Sstevel@tonic-gate uint16_t *p_16;
12137c478bd9Sstevel@tonic-gate uint32_t *p_32;
12147c478bd9Sstevel@tonic-gate
12157c478bd9Sstevel@tonic-gate if (strlen(format) != 1) {
12167c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12177c478bd9Sstevel@tonic-gate gettext("Invalid command\n"));
12187c478bd9Sstevel@tonic-gate return;
12197c478bd9Sstevel@tonic-gate }
12207c478bd9Sstevel@tonic-gate if (count == 0) {
12217c478bd9Sstevel@tonic-gate count = 1;
12227c478bd9Sstevel@tonic-gate }
12237c478bd9Sstevel@tonic-gate switch (*format) {
12247c478bd9Sstevel@tonic-gate case 'b' :
12257c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
12267c478bd9Sstevel@tonic-gate case 'c' :
12277c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
12287c478bd9Sstevel@tonic-gate case 'd' :
12297c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
12307c478bd9Sstevel@tonic-gate case 'o' :
12317c478bd9Sstevel@tonic-gate len = 1;
12327c478bd9Sstevel@tonic-gate prperline = 16;
12337c478bd9Sstevel@tonic-gate break;
12347c478bd9Sstevel@tonic-gate case 'x' :
12357c478bd9Sstevel@tonic-gate len = 2;
12367c478bd9Sstevel@tonic-gate prperline = 8;
12377c478bd9Sstevel@tonic-gate break;
12387c478bd9Sstevel@tonic-gate case 'D' :
12397c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
12407c478bd9Sstevel@tonic-gate case 'O' :
12417c478bd9Sstevel@tonic-gate /* FALLTHROUGH */
12427c478bd9Sstevel@tonic-gate case 'X' :
12437c478bd9Sstevel@tonic-gate len = 4;
12447c478bd9Sstevel@tonic-gate prperline = 4;
12457c478bd9Sstevel@tonic-gate break;
12467c478bd9Sstevel@tonic-gate default :
12477c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12487c478bd9Sstevel@tonic-gate gettext("Invalid format\n"));
12497c478bd9Sstevel@tonic-gate return;
12507c478bd9Sstevel@tonic-gate }
12517c478bd9Sstevel@tonic-gate
12527c478bd9Sstevel@tonic-gate beg = addr;
12537c478bd9Sstevel@tonic-gate end = addr + count * len;
12547c478bd9Sstevel@tonic-gate soff = beg & (~bmask);
12557c478bd9Sstevel@tonic-gate lcount = ((end + bmask) & (~bmask)) - soff;
12567c478bd9Sstevel@tonic-gate
12577c478bd9Sstevel@tonic-gate inval_bufs();
12587c478bd9Sstevel@tonic-gate
12597c478bd9Sstevel@tonic-gate buf = malloc(lcount);
12607c478bd9Sstevel@tonic-gate if (llseek(fd, soff, SEEK_SET) != soff) {
12617c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12627c478bd9Sstevel@tonic-gate gettext("Seek failed fd %x off %llx errno %x\n"),
12637c478bd9Sstevel@tonic-gate fd, soff, errno);
12647c478bd9Sstevel@tonic-gate goto end;
12657c478bd9Sstevel@tonic-gate }
12667c478bd9Sstevel@tonic-gate
12677c478bd9Sstevel@tonic-gate if (read(fd, buf, lcount) != lcount) {
12687c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12697c478bd9Sstevel@tonic-gate gettext("Read failed fd %x off %llx errno %x\n"),
12707c478bd9Sstevel@tonic-gate fd, soff, errno);
12717c478bd9Sstevel@tonic-gate goto end;
12727c478bd9Sstevel@tonic-gate }
12737c478bd9Sstevel@tonic-gate p = buf + (addr & bmask);
12747c478bd9Sstevel@tonic-gate /* LINTED */
12757c478bd9Sstevel@tonic-gate p_16 = (uint16_t *)p;
12767c478bd9Sstevel@tonic-gate /* LINTED */
12777c478bd9Sstevel@tonic-gate p_32 = (uint32_t *)p;
12787c478bd9Sstevel@tonic-gate n = 0;
12797c478bd9Sstevel@tonic-gate while (n < count) {
12807c478bd9Sstevel@tonic-gate switch (*format) {
12817c478bd9Sstevel@tonic-gate case 'b' :
12827c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12837c478bd9Sstevel@tonic-gate "%4x ", *((uint8_t *)p));
12847c478bd9Sstevel@tonic-gate break;
12857c478bd9Sstevel@tonic-gate case 'c' :
12867c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12877c478bd9Sstevel@tonic-gate "%4c ", *((uint8_t *)p));
12887c478bd9Sstevel@tonic-gate break;
12897c478bd9Sstevel@tonic-gate case 'd' :
12907c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12917c478bd9Sstevel@tonic-gate "%4d ", *((uint8_t *)p));
12927c478bd9Sstevel@tonic-gate break;
12937c478bd9Sstevel@tonic-gate case 'o' :
12947c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12957c478bd9Sstevel@tonic-gate "%4o ", *((uint8_t *)p));
12967c478bd9Sstevel@tonic-gate break;
12977c478bd9Sstevel@tonic-gate case 'x' :
12987c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
12997c478bd9Sstevel@tonic-gate "%8x ", *p_16);
13007c478bd9Sstevel@tonic-gate break;
13017c478bd9Sstevel@tonic-gate case 'D' :
13027c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13037c478bd9Sstevel@tonic-gate "%16d ", *p_32);
13047c478bd9Sstevel@tonic-gate break;
13057c478bd9Sstevel@tonic-gate case 'O' :
13067c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13077c478bd9Sstevel@tonic-gate "%16o ", *p_32);
13087c478bd9Sstevel@tonic-gate break;
13097c478bd9Sstevel@tonic-gate case 'X' :
13107c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13117c478bd9Sstevel@tonic-gate "%16x ", *p_32);
13127c478bd9Sstevel@tonic-gate break;
13137c478bd9Sstevel@tonic-gate }
13147c478bd9Sstevel@tonic-gate p += len;
13157c478bd9Sstevel@tonic-gate n++;
13167c478bd9Sstevel@tonic-gate if ((n % prperline) == 0) {
13177c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n");
13187c478bd9Sstevel@tonic-gate }
13197c478bd9Sstevel@tonic-gate }
13207c478bd9Sstevel@tonic-gate if (n % prperline) {
13217c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n");
13227c478bd9Sstevel@tonic-gate }
13237c478bd9Sstevel@tonic-gate end:
13247c478bd9Sstevel@tonic-gate free(buf);
13257c478bd9Sstevel@tonic-gate }
13267c478bd9Sstevel@tonic-gate
13277c478bd9Sstevel@tonic-gate void
find_it(char * dir,char * name,uint32_t in,uint32_t fl)13287c478bd9Sstevel@tonic-gate find_it(char *dir, char *name, uint32_t in, uint32_t fl)
13297c478bd9Sstevel@tonic-gate {
13307c478bd9Sstevel@tonic-gate uint8_t buf[1024], *addr;
13317c478bd9Sstevel@tonic-gate uint64_t off;
13327c478bd9Sstevel@tonic-gate struct file_id *fid;
13337c478bd9Sstevel@tonic-gate uint32_t iloc, d_in;
13347c478bd9Sstevel@tonic-gate uint8_t d_fl;
13357c478bd9Sstevel@tonic-gate struct recu_dir *rd, *erd, *temp;
13367c478bd9Sstevel@tonic-gate
13377c478bd9Sstevel@tonic-gate rd = erd = temp = NULL;
13387c478bd9Sstevel@tonic-gate
13397c478bd9Sstevel@tonic-gate if (inode_from_path(dir, &d_in, &d_fl) != 0) {
13407c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13417c478bd9Sstevel@tonic-gate gettext("Could not find directory %s"), dir);
13427c478bd9Sstevel@tonic-gate return;
13437c478bd9Sstevel@tonic-gate }
13447c478bd9Sstevel@tonic-gate
13457c478bd9Sstevel@tonic-gate if ((d_fl & FID_DIR) == 0) {
13467c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13477c478bd9Sstevel@tonic-gate gettext("Path %s is not a directory\n"), dir);
13487c478bd9Sstevel@tonic-gate return;
13497c478bd9Sstevel@tonic-gate }
13507c478bd9Sstevel@tonic-gate
13517c478bd9Sstevel@tonic-gate if (verify_inode(d_in << l2b, 4) == 0) {
13527c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13537c478bd9Sstevel@tonic-gate gettext("Inode is not a directory\n"));
13547c478bd9Sstevel@tonic-gate return;
13557c478bd9Sstevel@tonic-gate }
13567c478bd9Sstevel@tonic-gate
13577c478bd9Sstevel@tonic-gate off = 0;
13587c478bd9Sstevel@tonic-gate /* LINTED */
13597c478bd9Sstevel@tonic-gate fid = (struct file_id *)buf;
13607c478bd9Sstevel@tonic-gate while (get_fid(d_in, buf, off) == 0) {
13617c478bd9Sstevel@tonic-gate off += FID_LEN(fid);
13627c478bd9Sstevel@tonic-gate if ((fid->fid_flags & FID_DELETED) ||
13637c478bd9Sstevel@tonic-gate (fid->fid_flags & FID_PARENT)) {
13647c478bd9Sstevel@tonic-gate continue;
13657c478bd9Sstevel@tonic-gate }
13667c478bd9Sstevel@tonic-gate
1367*0e42dee6Sartem iloc = ud_xlate_to_daddr(udh, SWAP_16(fid->fid_icb.lad_ext_prn),
13687c478bd9Sstevel@tonic-gate SWAP_32(fid->fid_icb.lad_ext_loc));
13697c478bd9Sstevel@tonic-gate addr = &fid->fid_spec[SWAP_16((fid)->fid_iulen) + 1];
13707c478bd9Sstevel@tonic-gate if (((fl & 4) && (in == iloc)) ||
13717c478bd9Sstevel@tonic-gate ((fl & 2) && (strcmp(name, (char *)addr) == 0))) {
13727c478bd9Sstevel@tonic-gate (void) printf("%s %x %s\n", dir, iloc, addr);
13737c478bd9Sstevel@tonic-gate }
13747c478bd9Sstevel@tonic-gate
13757c478bd9Sstevel@tonic-gate if (fid->fid_flags & FID_DIR) {
13767c478bd9Sstevel@tonic-gate temp = (struct recu_dir *)
13777c478bd9Sstevel@tonic-gate malloc(sizeof (struct recu_dir));
13787c478bd9Sstevel@tonic-gate if (temp == NULL) {
13797c478bd9Sstevel@tonic-gate (void) fprintf(stdout,
13807c478bd9Sstevel@tonic-gate gettext("Could not allocate memory\n"));
13817c478bd9Sstevel@tonic-gate } else {
13827c478bd9Sstevel@tonic-gate temp->next = NULL;
13837c478bd9Sstevel@tonic-gate temp->inode = iloc;
13847c478bd9Sstevel@tonic-gate temp->nm = malloc(strlen(dir) + 1 +
13857c478bd9Sstevel@tonic-gate fid->fid_idlen + 1);
13867c478bd9Sstevel@tonic-gate if (temp->nm != NULL) {
13877c478bd9Sstevel@tonic-gate (void) strcpy(temp->nm, dir);
13887c478bd9Sstevel@tonic-gate (void) strcat(temp->nm, "/");
13897c478bd9Sstevel@tonic-gate (void) strncat(temp->nm, (char *)addr,
13907c478bd9Sstevel@tonic-gate fid->fid_idlen);
13917c478bd9Sstevel@tonic-gate } else {
13927c478bd9Sstevel@tonic-gate (void) fprintf(stdout, gettext(
13937c478bd9Sstevel@tonic-gate "Could not allocate memory\n"));
13947c478bd9Sstevel@tonic-gate }
13957c478bd9Sstevel@tonic-gate if (rd == NULL) {
13967c478bd9Sstevel@tonic-gate erd = rd = temp;
13977c478bd9Sstevel@tonic-gate } else {
13987c478bd9Sstevel@tonic-gate erd->next = temp;
13997c478bd9Sstevel@tonic-gate erd = temp;
14007c478bd9Sstevel@tonic-gate }
14017c478bd9Sstevel@tonic-gate }
14027c478bd9Sstevel@tonic-gate }
14037c478bd9Sstevel@tonic-gate }
14047c478bd9Sstevel@tonic-gate
14057c478bd9Sstevel@tonic-gate while (rd != NULL) {
14067c478bd9Sstevel@tonic-gate if (rd->nm != NULL) {
14077c478bd9Sstevel@tonic-gate find_it(rd->nm, name, in, fl);
14087c478bd9Sstevel@tonic-gate }
14097c478bd9Sstevel@tonic-gate temp = rd;
14107c478bd9Sstevel@tonic-gate rd = rd->next;
14117c478bd9Sstevel@tonic-gate if (temp->nm) {
14127c478bd9Sstevel@tonic-gate free(temp->nm);
14137c478bd9Sstevel@tonic-gate }
14147c478bd9Sstevel@tonic-gate free(temp);
14157c478bd9Sstevel@tonic-gate }
14167c478bd9Sstevel@tonic-gate }
1417