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