17c478bd9Sstevel@tonic-gate /*
2*fe0e7ec4Smaheshvs * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
77c478bd9Sstevel@tonic-gate /* All Rights Reserved */
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
117c478bd9Sstevel@tonic-gate * All rights reserved.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted
147c478bd9Sstevel@tonic-gate * provided that: (1) source distributions retain this entire copyright
157c478bd9Sstevel@tonic-gate * notice and comment, and (2) distributions including binaries display
167c478bd9Sstevel@tonic-gate * the following acknowledgement: ``This product includes software
177c478bd9Sstevel@tonic-gate * developed by the University of California, Berkeley and its contributors''
187c478bd9Sstevel@tonic-gate * in the documentation or other materials provided with the distribution
197c478bd9Sstevel@tonic-gate * and in all advertising materials mentioning features or use of this
207c478bd9Sstevel@tonic-gate * software. Neither the name of the University nor the names of its
217c478bd9Sstevel@tonic-gate * contributors may be used to endorse or promote products derived
227c478bd9Sstevel@tonic-gate * from this software without specific prior written permission.
237c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
247c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
257c478bd9Sstevel@tonic-gate * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #include <stdio.h>
317c478bd9Sstevel@tonic-gate #include <string.h>
327c478bd9Sstevel@tonic-gate #include <ctype.h> /* use isdigit macro rather than 4.1 libc routine */
337c478bd9Sstevel@tonic-gate #include <unistd.h>
347c478bd9Sstevel@tonic-gate #include <stdlib.h>
357c478bd9Sstevel@tonic-gate #include <signal.h>
367c478bd9Sstevel@tonic-gate #include <malloc.h>
377c478bd9Sstevel@tonic-gate #include <ustat.h>
387c478bd9Sstevel@tonic-gate #include <sys/param.h>
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
417c478bd9Sstevel@tonic-gate #include <sys/mntent.h>
427c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
437c478bd9Sstevel@tonic-gate #include <sys/stat.h>
447c478bd9Sstevel@tonic-gate #include <sys/wait.h>
457c478bd9Sstevel@tonic-gate #include <sys/mnttab.h>
467c478bd9Sstevel@tonic-gate #include <sys/signal.h>
477c478bd9Sstevel@tonic-gate #include <sys/vfstab.h>
487c478bd9Sstevel@tonic-gate #include <sys/fs/udf_volume.h>
497c478bd9Sstevel@tonic-gate #include "fsck.h"
507c478bd9Sstevel@tonic-gate #include <locale.h>
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate extern int32_t writable(char *);
537c478bd9Sstevel@tonic-gate extern void pfatal(char *, ...);
547c478bd9Sstevel@tonic-gate extern void printfree();
557c478bd9Sstevel@tonic-gate extern void pwarn(char *, ...);
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate extern void pass1();
587c478bd9Sstevel@tonic-gate extern void dofreemap();
597c478bd9Sstevel@tonic-gate extern void dolvint();
607c478bd9Sstevel@tonic-gate extern char *getfullblkname();
617c478bd9Sstevel@tonic-gate extern char *getfullrawname();
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate static int mflag = 0; /* sanity check only */
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate char *mntopt();
667c478bd9Sstevel@tonic-gate void catch(), catchquit(), voidquit();
677c478bd9Sstevel@tonic-gate int returntosingle;
687c478bd9Sstevel@tonic-gate static void checkfilesys();
697c478bd9Sstevel@tonic-gate static void check_sanity();
707c478bd9Sstevel@tonic-gate static void usage();
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate static char *subopts [] = {
737c478bd9Sstevel@tonic-gate #define PREEN 0
747c478bd9Sstevel@tonic-gate "p",
757c478bd9Sstevel@tonic-gate #define DEBUG 1
767c478bd9Sstevel@tonic-gate "d",
777c478bd9Sstevel@tonic-gate #define READ_ONLY 2
787c478bd9Sstevel@tonic-gate "r",
797c478bd9Sstevel@tonic-gate #define ONLY_WRITES 3
807c478bd9Sstevel@tonic-gate "w",
817c478bd9Sstevel@tonic-gate #define FORCE 4 /* force checking, even if clean */
827c478bd9Sstevel@tonic-gate "f",
837c478bd9Sstevel@tonic-gate #define STATS 5 /* print time and busy stats */
847c478bd9Sstevel@tonic-gate "s",
857c478bd9Sstevel@tonic-gate NULL
867c478bd9Sstevel@tonic-gate };
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gate uint32_t ecma_version = 2;
897c478bd9Sstevel@tonic-gate
90*fe0e7ec4Smaheshvs int
main(int argc,char * argv[])91*fe0e7ec4Smaheshvs main(int argc, char *argv[])
927c478bd9Sstevel@tonic-gate {
937c478bd9Sstevel@tonic-gate int c;
947c478bd9Sstevel@tonic-gate char *suboptions, *value;
957c478bd9Sstevel@tonic-gate int suboption;
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, "");
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate while ((c = getopt(argc, argv, "mnNo:VyYz")) != EOF) {
1007c478bd9Sstevel@tonic-gate switch (c) {
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gate case 'm':
1037c478bd9Sstevel@tonic-gate mflag++;
1047c478bd9Sstevel@tonic-gate break;
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate case 'n': /* default no answer flag */
1077c478bd9Sstevel@tonic-gate case 'N':
1087c478bd9Sstevel@tonic-gate nflag++;
1097c478bd9Sstevel@tonic-gate yflag = 0;
1107c478bd9Sstevel@tonic-gate break;
1117c478bd9Sstevel@tonic-gate
1127c478bd9Sstevel@tonic-gate case 'o':
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate * udfs specific options.
1157c478bd9Sstevel@tonic-gate */
1167c478bd9Sstevel@tonic-gate suboptions = optarg;
1177c478bd9Sstevel@tonic-gate while (*suboptions != '\0') {
1187c478bd9Sstevel@tonic-gate suboption = getsubopt(&suboptions,
1197c478bd9Sstevel@tonic-gate subopts, &value);
1207c478bd9Sstevel@tonic-gate switch (suboption) {
1217c478bd9Sstevel@tonic-gate
1227c478bd9Sstevel@tonic-gate case PREEN:
1237c478bd9Sstevel@tonic-gate preen++;
1247c478bd9Sstevel@tonic-gate break;
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate case DEBUG:
1277c478bd9Sstevel@tonic-gate debug++;
1287c478bd9Sstevel@tonic-gate break;
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate case READ_ONLY:
1317c478bd9Sstevel@tonic-gate break;
1327c478bd9Sstevel@tonic-gate
1337c478bd9Sstevel@tonic-gate case ONLY_WRITES:
1347c478bd9Sstevel@tonic-gate /* check only writable filesystems */
1357c478bd9Sstevel@tonic-gate wflag++;
1367c478bd9Sstevel@tonic-gate break;
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gate case FORCE:
1397c478bd9Sstevel@tonic-gate fflag++;
1407c478bd9Sstevel@tonic-gate break;
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gate case STATS:
1437c478bd9Sstevel@tonic-gate sflag++;
1447c478bd9Sstevel@tonic-gate break;
1457c478bd9Sstevel@tonic-gate
1467c478bd9Sstevel@tonic-gate default:
1477c478bd9Sstevel@tonic-gate usage();
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate }
1507c478bd9Sstevel@tonic-gate break;
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate case 'V':
1537c478bd9Sstevel@tonic-gate {
1547c478bd9Sstevel@tonic-gate int opt_count;
1557c478bd9Sstevel@tonic-gate char *opt_text;
1567c478bd9Sstevel@tonic-gate
1577c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "fsck -F udfs ");
1587c478bd9Sstevel@tonic-gate for (opt_count = 1; opt_count < argc;
1597c478bd9Sstevel@tonic-gate opt_count++) {
1607c478bd9Sstevel@tonic-gate opt_text = argv[opt_count];
1617c478bd9Sstevel@tonic-gate if (opt_text)
1627c478bd9Sstevel@tonic-gate (void) fprintf(stdout, " %s ",
1637c478bd9Sstevel@tonic-gate opt_text);
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate (void) fprintf(stdout, "\n");
1667c478bd9Sstevel@tonic-gate }
1677c478bd9Sstevel@tonic-gate break;
1687c478bd9Sstevel@tonic-gate
1697c478bd9Sstevel@tonic-gate case 'y': /* default yes answer flag */
1707c478bd9Sstevel@tonic-gate case 'Y':
1717c478bd9Sstevel@tonic-gate yflag++;
1727c478bd9Sstevel@tonic-gate nflag = 0;
1737c478bd9Sstevel@tonic-gate break;
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gate case '?':
1767c478bd9Sstevel@tonic-gate usage();
1777c478bd9Sstevel@tonic-gate }
1787c478bd9Sstevel@tonic-gate }
1797c478bd9Sstevel@tonic-gate argc -= optind;
1807c478bd9Sstevel@tonic-gate argv = &argv[optind];
1817c478bd9Sstevel@tonic-gate rflag++; /* check raw devices */
1827c478bd9Sstevel@tonic-gate if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
1837c478bd9Sstevel@tonic-gate (void) signal(SIGINT, catch);
1847c478bd9Sstevel@tonic-gate }
1857c478bd9Sstevel@tonic-gate
1867c478bd9Sstevel@tonic-gate if (preen) {
1877c478bd9Sstevel@tonic-gate (void) signal(SIGQUIT, catchquit);
1887c478bd9Sstevel@tonic-gate }
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate if (argc) {
1917c478bd9Sstevel@tonic-gate while (argc-- > 0) {
1927c478bd9Sstevel@tonic-gate if (wflag && !writable(*argv)) {
1937c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
1947c478bd9Sstevel@tonic-gate gettext("not writeable '%s'\n"), *argv);
1957c478bd9Sstevel@tonic-gate argv++;
1967c478bd9Sstevel@tonic-gate } else
1977c478bd9Sstevel@tonic-gate checkfilesys(*argv++);
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate exit(exitstat);
2007c478bd9Sstevel@tonic-gate }
201*fe0e7ec4Smaheshvs return (0);
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate
2057c478bd9Sstevel@tonic-gate static void
checkfilesys(char * filesys)206*fe0e7ec4Smaheshvs checkfilesys(char *filesys)
2077c478bd9Sstevel@tonic-gate {
2087c478bd9Sstevel@tonic-gate char *devstr;
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate mountfd = -1;
2117c478bd9Sstevel@tonic-gate mountedfs = 0;
2127c478bd9Sstevel@tonic-gate iscorrupt = 1;
2137c478bd9Sstevel@tonic-gate
2147c478bd9Sstevel@tonic-gate if ((devstr = setup(filesys)) == 0) {
2157c478bd9Sstevel@tonic-gate if (iscorrupt == 0)
2167c478bd9Sstevel@tonic-gate return;
2177c478bd9Sstevel@tonic-gate if (preen)
2187c478bd9Sstevel@tonic-gate pfatal(gettext("CAN'T CHECK FILE SYSTEM."));
2197c478bd9Sstevel@tonic-gate if ((exitstat == 0) && (mflag))
2207c478bd9Sstevel@tonic-gate exitstat = 32;
2217c478bd9Sstevel@tonic-gate exit(exitstat);
2227c478bd9Sstevel@tonic-gate }
2237c478bd9Sstevel@tonic-gate else
2247c478bd9Sstevel@tonic-gate devname = devstr;
2257c478bd9Sstevel@tonic-gate if (mflag)
2267c478bd9Sstevel@tonic-gate check_sanity(filesys); /* this never returns */
2277c478bd9Sstevel@tonic-gate iscorrupt = 0;
2287c478bd9Sstevel@tonic-gate /*
2297c478bd9Sstevel@tonic-gate * 1: scan inodes tallying blocks used
2307c478bd9Sstevel@tonic-gate */
2317c478bd9Sstevel@tonic-gate if (preen == 0) {
2327c478bd9Sstevel@tonic-gate if (mountedfs)
2337c478bd9Sstevel@tonic-gate (void) printf(gettext("** Currently Mounted on %s\n"),
2347c478bd9Sstevel@tonic-gate mountpoint);
2357c478bd9Sstevel@tonic-gate if (mflag) {
2367c478bd9Sstevel@tonic-gate (void) printf(
2377c478bd9Sstevel@tonic-gate gettext("** Phase 1 - Sanity Check only\n"));
2387c478bd9Sstevel@tonic-gate return;
2397c478bd9Sstevel@tonic-gate } else
2407c478bd9Sstevel@tonic-gate (void) printf(
2417c478bd9Sstevel@tonic-gate gettext("** Phase 1 - Check Directories "
2427c478bd9Sstevel@tonic-gate "and Blocks\n"));
2437c478bd9Sstevel@tonic-gate }
2447c478bd9Sstevel@tonic-gate pass1();
2457c478bd9Sstevel@tonic-gate if (sflag) {
2467c478bd9Sstevel@tonic-gate if (preen)
2477c478bd9Sstevel@tonic-gate (void) printf("%s: ", devname);
2487c478bd9Sstevel@tonic-gate else
2497c478bd9Sstevel@tonic-gate (void) printf("** ");
2507c478bd9Sstevel@tonic-gate }
2517c478bd9Sstevel@tonic-gate if (debug)
2527c478bd9Sstevel@tonic-gate (void) printf("pass1 isdirty %d\n", isdirty);
2537c478bd9Sstevel@tonic-gate if (debug)
2547c478bd9Sstevel@tonic-gate printfree();
2557c478bd9Sstevel@tonic-gate dofreemap();
2567c478bd9Sstevel@tonic-gate dolvint();
2577c478bd9Sstevel@tonic-gate
2587c478bd9Sstevel@tonic-gate /*
2597c478bd9Sstevel@tonic-gate * print out summary statistics
2607c478bd9Sstevel@tonic-gate */
2617c478bd9Sstevel@tonic-gate pwarn(gettext("%d files, %d dirs, %d used, %d free\n"), n_files, n_dirs,
2627c478bd9Sstevel@tonic-gate n_blks, part_len - n_blks);
2637c478bd9Sstevel@tonic-gate if (iscorrupt)
2647c478bd9Sstevel@tonic-gate exitstat = 36;
2657c478bd9Sstevel@tonic-gate if (!fsmodified)
2667c478bd9Sstevel@tonic-gate return;
2677c478bd9Sstevel@tonic-gate if (!preen)
2687c478bd9Sstevel@tonic-gate (void) printf(
2697c478bd9Sstevel@tonic-gate gettext("\n***** FILE SYSTEM WAS MODIFIED *****\n"));
2707c478bd9Sstevel@tonic-gate
2717c478bd9Sstevel@tonic-gate if (mountedfs) {
2727c478bd9Sstevel@tonic-gate exitstat = 40;
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate }
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate * exit 0 - file system is unmounted and okay
2797c478bd9Sstevel@tonic-gate * exit 32 - file system is unmounted and needs checking
2807c478bd9Sstevel@tonic-gate * exit 33 - file system is mounted
2817c478bd9Sstevel@tonic-gate * for root file system
2827c478bd9Sstevel@tonic-gate * exit 34 - cannot stat device
2837c478bd9Sstevel@tonic-gate */
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate static void
check_sanity(char * filename)286*fe0e7ec4Smaheshvs check_sanity(char *filename)
2877c478bd9Sstevel@tonic-gate {
2887c478bd9Sstevel@tonic-gate struct stat stbd, stbr;
2897c478bd9Sstevel@tonic-gate struct ustat usb;
2907c478bd9Sstevel@tonic-gate char *devname;
2917c478bd9Sstevel@tonic-gate struct vfstab vfsbuf;
2927c478bd9Sstevel@tonic-gate FILE *vfstab;
2937c478bd9Sstevel@tonic-gate int is_root = 0;
2947c478bd9Sstevel@tonic-gate int is_usr = 0;
2957c478bd9Sstevel@tonic-gate int is_block = 0;
2967c478bd9Sstevel@tonic-gate
2977c478bd9Sstevel@tonic-gate if (stat(filename, &stbd) < 0) {
2987c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
2997c478bd9Sstevel@tonic-gate gettext("udfs fsck: sanity check failed : cannot stat "
3007c478bd9Sstevel@tonic-gate "%s\n"), filename);
3017c478bd9Sstevel@tonic-gate exit(34);
3027c478bd9Sstevel@tonic-gate }
3037c478bd9Sstevel@tonic-gate
3047c478bd9Sstevel@tonic-gate if ((stbd.st_mode & S_IFMT) == S_IFBLK)
3057c478bd9Sstevel@tonic-gate is_block = 1;
3067c478bd9Sstevel@tonic-gate else if ((stbd.st_mode & S_IFMT) == S_IFCHR)
3077c478bd9Sstevel@tonic-gate is_block = 0;
3087c478bd9Sstevel@tonic-gate else {
3097c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
3107c478bd9Sstevel@tonic-gate gettext("udfs fsck: sanity check failed: %s not "
3117c478bd9Sstevel@tonic-gate "block or character device\n"), filename);
3127c478bd9Sstevel@tonic-gate exit(34);
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate /*
3167c478bd9Sstevel@tonic-gate * Determine if this is the root file system via vfstab. Give up
3177c478bd9Sstevel@tonic-gate * silently on failures. The whole point of this is not to care
3187c478bd9Sstevel@tonic-gate * if the root file system is already mounted.
3197c478bd9Sstevel@tonic-gate *
3207c478bd9Sstevel@tonic-gate * XXX - similar for /usr. This should be fixed to simply return
3217c478bd9Sstevel@tonic-gate * a new code indicating, mounted and needs to be checked.
3227c478bd9Sstevel@tonic-gate */
3237c478bd9Sstevel@tonic-gate if ((vfstab = fopen(VFSTAB, "r")) != 0) {
3247c478bd9Sstevel@tonic-gate if (getvfsfile(vfstab, &vfsbuf, "/") == 0) {
3257c478bd9Sstevel@tonic-gate if (is_block)
3267c478bd9Sstevel@tonic-gate devname = vfsbuf.vfs_special;
3277c478bd9Sstevel@tonic-gate else
3287c478bd9Sstevel@tonic-gate devname = vfsbuf.vfs_fsckdev;
3297c478bd9Sstevel@tonic-gate if (stat(devname, &stbr) == 0)
3307c478bd9Sstevel@tonic-gate if (stbr.st_rdev == stbd.st_rdev)
3317c478bd9Sstevel@tonic-gate is_root = 1;
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate if (getvfsfile(vfstab, &vfsbuf, "/usr") == 0) {
3347c478bd9Sstevel@tonic-gate if (is_block)
3357c478bd9Sstevel@tonic-gate devname = vfsbuf.vfs_special;
3367c478bd9Sstevel@tonic-gate else
3377c478bd9Sstevel@tonic-gate devname = vfsbuf.vfs_fsckdev;
3387c478bd9Sstevel@tonic-gate if (stat(devname, &stbr) == 0)
3397c478bd9Sstevel@tonic-gate if (stbr.st_rdev == stbd.st_rdev)
3407c478bd9Sstevel@tonic-gate is_usr = 1;
3417c478bd9Sstevel@tonic-gate }
3427c478bd9Sstevel@tonic-gate }
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate /*
3467c478bd9Sstevel@tonic-gate * XXX - only works if filename is a block device or if
3477c478bd9Sstevel@tonic-gate * character and block device has the same dev_t value
3487c478bd9Sstevel@tonic-gate */
3497c478bd9Sstevel@tonic-gate if (is_root == 0 && is_usr == 0 && ustat(stbd.st_rdev, &usb) == 0) {
3507c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
3517c478bd9Sstevel@tonic-gate gettext("udfs fsck: sanity check: %s "
3527c478bd9Sstevel@tonic-gate "already mounted\n"), filename);
3537c478bd9Sstevel@tonic-gate exit(33);
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate
3567c478bd9Sstevel@tonic-gate if (lvintp->lvid_int_type == LVI_CLOSE) {
3577c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
3587c478bd9Sstevel@tonic-gate gettext("udfs fsck: sanity check: %s okay\n"),
3597c478bd9Sstevel@tonic-gate filename);
3607c478bd9Sstevel@tonic-gate } else {
3617c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
3627c478bd9Sstevel@tonic-gate gettext("udfs fsck: sanity check: %s needs checking\n"),
3637c478bd9Sstevel@tonic-gate filename);
3647c478bd9Sstevel@tonic-gate exit(32);
3657c478bd9Sstevel@tonic-gate }
3667c478bd9Sstevel@tonic-gate exit(0);
3677c478bd9Sstevel@tonic-gate }
3687c478bd9Sstevel@tonic-gate
3697c478bd9Sstevel@tonic-gate char *
unrawname(char * name)370*fe0e7ec4Smaheshvs unrawname(char *name)
3717c478bd9Sstevel@tonic-gate {
3727c478bd9Sstevel@tonic-gate char *dp;
3737c478bd9Sstevel@tonic-gate
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate if ((dp = getfullblkname(name)) == NULL)
3767c478bd9Sstevel@tonic-gate return ("");
3777c478bd9Sstevel@tonic-gate return (dp);
3787c478bd9Sstevel@tonic-gate }
3797c478bd9Sstevel@tonic-gate
3807c478bd9Sstevel@tonic-gate char *
rawname(char * name)381*fe0e7ec4Smaheshvs rawname(char *name)
3827c478bd9Sstevel@tonic-gate {
3837c478bd9Sstevel@tonic-gate char *dp;
3847c478bd9Sstevel@tonic-gate
3857c478bd9Sstevel@tonic-gate if ((dp = getfullrawname(name)) == NULL)
3867c478bd9Sstevel@tonic-gate return ("");
3877c478bd9Sstevel@tonic-gate return (dp);
3887c478bd9Sstevel@tonic-gate }
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate char *
hasvfsopt(struct vfstab * vfs,char * opt)391*fe0e7ec4Smaheshvs hasvfsopt(struct vfstab *vfs, char *opt)
3927c478bd9Sstevel@tonic-gate {
3937c478bd9Sstevel@tonic-gate char *f, *opts;
3947c478bd9Sstevel@tonic-gate static char *tmpopts;
3957c478bd9Sstevel@tonic-gate
3967c478bd9Sstevel@tonic-gate if (vfs->vfs_mntopts == NULL)
3977c478bd9Sstevel@tonic-gate return (NULL);
3987c478bd9Sstevel@tonic-gate if (tmpopts == 0) {
3997c478bd9Sstevel@tonic-gate tmpopts = (char *)calloc(256, sizeof (char));
4007c478bd9Sstevel@tonic-gate if (tmpopts == 0)
4017c478bd9Sstevel@tonic-gate return (0);
4027c478bd9Sstevel@tonic-gate }
4037c478bd9Sstevel@tonic-gate (void) strncpy(tmpopts, vfs->vfs_mntopts, (sizeof (tmpopts) - 1));
4047c478bd9Sstevel@tonic-gate opts = tmpopts;
4057c478bd9Sstevel@tonic-gate f = mntopt(&opts);
4067c478bd9Sstevel@tonic-gate for (; *f; f = mntopt(&opts)) {
4077c478bd9Sstevel@tonic-gate if (strncmp(opt, f, strlen(opt)) == 0)
4087c478bd9Sstevel@tonic-gate return (f - tmpopts + vfs->vfs_mntopts);
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate return (NULL);
4117c478bd9Sstevel@tonic-gate }
4127c478bd9Sstevel@tonic-gate
4137c478bd9Sstevel@tonic-gate static void
usage()4147c478bd9Sstevel@tonic-gate usage()
4157c478bd9Sstevel@tonic-gate {
4167c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("udfs usage: fsck [-F udfs] "
4177c478bd9Sstevel@tonic-gate "[generic options] [-o p,w,s] [special ....]\n"));
4187c478bd9Sstevel@tonic-gate exit(31+1);
4197c478bd9Sstevel@tonic-gate }
420