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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 237c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 27*08190127Sdh145677 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 287c478bd9Sstevel@tonic-gate * Use is subject to license terms. 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <stdio.h> 347c478bd9Sstevel@tonic-gate #include <limits.h> 357c478bd9Sstevel@tonic-gate #include <string.h> 367c478bd9Sstevel@tonic-gate #include <sys/fstyp.h> 377c478bd9Sstevel@tonic-gate #include <errno.h> 387c478bd9Sstevel@tonic-gate #include <sys/vfstab.h> 397c478bd9Sstevel@tonic-gate #include <sys/wait.h> 407c478bd9Sstevel@tonic-gate #include <sys/types.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #define FSTYPE_MAX 8 437c478bd9Sstevel@tonic-gate #define FULLPATH_MAX 64 447c478bd9Sstevel@tonic-gate #define ARGV_MAX 1024 457c478bd9Sstevel@tonic-gate #define VFS_PATH "/usr/lib/fs" 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate extern char *default_fstype(); 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate char *special = NULL; /* device special name */ 507c478bd9Sstevel@tonic-gate char *fstype = NULL; /* fstype name is filled in here */ 517c478bd9Sstevel@tonic-gate char *cbasename; /* name of command */ 527c478bd9Sstevel@tonic-gate char *newargv[ARGV_MAX]; /* args for the fstype specific command */ 537c478bd9Sstevel@tonic-gate char vfstab[] = VFSTAB; 547c478bd9Sstevel@tonic-gate char full_path[FULLPATH_MAX]; 557c478bd9Sstevel@tonic-gate char *vfs_path = VFS_PATH; 567c478bd9Sstevel@tonic-gate int newargc = 2; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate struct commands { 597c478bd9Sstevel@tonic-gate char *c_basename; 607c478bd9Sstevel@tonic-gate char *c_optstr; 617c478bd9Sstevel@tonic-gate char *c_usgstr; 627c478bd9Sstevel@tonic-gate } cmd_data[] = { 637c478bd9Sstevel@tonic-gate "ff", "F:o:p:a:m:c:n:i:?IlsuV", 647c478bd9Sstevel@tonic-gate "[-F FSType] [-V] [current_options] [-o specific_options] special ...", 657c478bd9Sstevel@tonic-gate "ncheck", "F:o:?i:asV", 667c478bd9Sstevel@tonic-gate "[-F FSType] [-V] [current_options] [-o specific_options] [special ...]", 677c478bd9Sstevel@tonic-gate NULL, "F:o:?V", 687c478bd9Sstevel@tonic-gate "[-F FSType] [-V] [current_options] [-o specific_options] special ..." 697c478bd9Sstevel@tonic-gate }; 707c478bd9Sstevel@tonic-gate struct commands *c_ptr; 717c478bd9Sstevel@tonic-gate 72*08190127Sdh145677 static void usage(char *cmd, char *usg); 73*08190127Sdh145677 static void exec_specific(void); 74*08190127Sdh145677 static void lookup(void); 75*08190127Sdh145677 76*08190127Sdh145677 int 77*08190127Sdh145677 main(int argc, char *argv[]) 787c478bd9Sstevel@tonic-gate { 797c478bd9Sstevel@tonic-gate FILE *fp; 807c478bd9Sstevel@tonic-gate struct vfstab vfsbuf; 81*08190127Sdh145677 char *ptr; 827c478bd9Sstevel@tonic-gate int i; 837c478bd9Sstevel@tonic-gate int verbose = 0; /* set if -V is specified */ 847c478bd9Sstevel@tonic-gate int F_flg = 0; 857c478bd9Sstevel@tonic-gate int usgflag = 0; 867c478bd9Sstevel@tonic-gate int fs_flag = 0; 877c478bd9Sstevel@tonic-gate int arg; /* argument from getopt() */ 887c478bd9Sstevel@tonic-gate extern char *optarg; /* getopt specific */ 897c478bd9Sstevel@tonic-gate extern int optind; 907c478bd9Sstevel@tonic-gate extern int opterr; 917c478bd9Sstevel@tonic-gate size_t strlen(); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate cbasename = ptr = argv[0]; 947c478bd9Sstevel@tonic-gate while (*ptr) { 957c478bd9Sstevel@tonic-gate if (*ptr++ == '/') 967c478bd9Sstevel@tonic-gate cbasename = ptr; 977c478bd9Sstevel@tonic-gate } 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * If there are no arguments and command is ncheck then the generic 1007c478bd9Sstevel@tonic-gate * reads the VFSTAB and executes the specific module of 1017c478bd9Sstevel@tonic-gate * each entry which has a numeric fsckpass field. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate if (argc == 1) { /* no arguments or options */ 1057c478bd9Sstevel@tonic-gate if (strcmp(cbasename, "ncheck") == 0) { 1067c478bd9Sstevel@tonic-gate /* open VFSTAB */ 1077c478bd9Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "r")) == NULL) { 1087c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: cannot open vfstab\n", 1097c478bd9Sstevel@tonic-gate cbasename); 1107c478bd9Sstevel@tonic-gate exit(2); 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate while ((i = getvfsent(fp, &vfsbuf)) == 0) { 1137c478bd9Sstevel@tonic-gate if (numbers(vfsbuf.vfs_fsckpass)) { 1147c478bd9Sstevel@tonic-gate fstype = vfsbuf.vfs_fstype; 1157c478bd9Sstevel@tonic-gate newargv[newargc] = vfsbuf.vfs_special; 1167c478bd9Sstevel@tonic-gate exec_specific(); 1177c478bd9Sstevel@tonic-gate } 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate exit(0); 1207c478bd9Sstevel@tonic-gate } 1217c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage:\n"); 1227c478bd9Sstevel@tonic-gate fprintf(stderr, 1237c478bd9Sstevel@tonic-gate "%s [-F FSType] [-V] [current_options] [-o specific_options] special ...\n", 1247c478bd9Sstevel@tonic-gate cbasename); 1257c478bd9Sstevel@tonic-gate exit(2); 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate for (c_ptr = cmd_data; ((c_ptr->c_basename != NULL) && 1297c478bd9Sstevel@tonic-gate (strcmp(c_ptr->c_basename, cbasename) != 0)); c_ptr++) 1307c478bd9Sstevel@tonic-gate ; 1317c478bd9Sstevel@tonic-gate while ((arg = getopt(argc, argv, c_ptr->c_optstr)) != -1) { 1327c478bd9Sstevel@tonic-gate switch (arg) { 1337c478bd9Sstevel@tonic-gate case 'V': /* echo complete command line */ 1347c478bd9Sstevel@tonic-gate verbose = 1; 1357c478bd9Sstevel@tonic-gate break; 1367c478bd9Sstevel@tonic-gate case 'F': /* FSType specified */ 1377c478bd9Sstevel@tonic-gate F_flg++; 1387c478bd9Sstevel@tonic-gate fstype = optarg; 1397c478bd9Sstevel@tonic-gate break; 1407c478bd9Sstevel@tonic-gate case 'o': /* FSType specific arguments */ 1417c478bd9Sstevel@tonic-gate newargv[newargc++] = "-o"; 1427c478bd9Sstevel@tonic-gate newargv[newargc++] = optarg; 1437c478bd9Sstevel@tonic-gate break; 1447c478bd9Sstevel@tonic-gate case '?': /* print usage message */ 1457c478bd9Sstevel@tonic-gate newargv[newargc++] = "-?"; 1467c478bd9Sstevel@tonic-gate usgflag = 1; 1477c478bd9Sstevel@tonic-gate break; 1487c478bd9Sstevel@tonic-gate default: 1497c478bd9Sstevel@tonic-gate newargv[newargc] = (char *)malloc(3); 1507c478bd9Sstevel@tonic-gate sprintf(newargv[newargc++], "-%c", arg); 1517c478bd9Sstevel@tonic-gate if (optarg) 1527c478bd9Sstevel@tonic-gate newargv[newargc++] = optarg; 1537c478bd9Sstevel@tonic-gate break; 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate optarg = NULL; 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate if (F_flg > 1) { 1587c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: more than one FSType specified\n", 1597c478bd9Sstevel@tonic-gate cbasename); 1607c478bd9Sstevel@tonic-gate usage(cbasename, c_ptr->c_usgstr); 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate if (F_flg && (strlen(fstype) > (size_t)FSTYPE_MAX)) { 1637c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: FSType %s exceeds %d characters\n", 1647c478bd9Sstevel@tonic-gate cbasename, fstype, FSTYPE_MAX); 1657c478bd9Sstevel@tonic-gate exit(2); 1667c478bd9Sstevel@tonic-gate } 1677c478bd9Sstevel@tonic-gate if (optind == argc) { 1687c478bd9Sstevel@tonic-gate /* all commands except ncheck must exit now */ 1697c478bd9Sstevel@tonic-gate if (strcmp(cbasename, "ncheck") != 0) { 1707c478bd9Sstevel@tonic-gate if ((F_flg) && (usgflag)) { 1717c478bd9Sstevel@tonic-gate exec_specific(); 1727c478bd9Sstevel@tonic-gate exit(0); 1737c478bd9Sstevel@tonic-gate } 1747c478bd9Sstevel@tonic-gate usage(cbasename, c_ptr->c_usgstr); 1757c478bd9Sstevel@tonic-gate } 1767c478bd9Sstevel@tonic-gate if ((F_flg) && (usgflag)) { 1777c478bd9Sstevel@tonic-gate exec_specific(); 1787c478bd9Sstevel@tonic-gate exit(0); 1797c478bd9Sstevel@tonic-gate } 1807c478bd9Sstevel@tonic-gate if (usgflag) 1817c478bd9Sstevel@tonic-gate usage(cbasename, c_ptr->c_usgstr); 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* open VFSTAB */ 1847c478bd9Sstevel@tonic-gate if ((fp = fopen(VFSTAB, "r")) == NULL) { 1857c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: cannot open vfstab\n", cbasename); 1867c478bd9Sstevel@tonic-gate exit(2); 1877c478bd9Sstevel@tonic-gate } 1887c478bd9Sstevel@tonic-gate while ((i = getvfsent(fp, &vfsbuf)) == 0) { 1897c478bd9Sstevel@tonic-gate if (!numbers(vfsbuf.vfs_fsckpass)) 1907c478bd9Sstevel@tonic-gate continue; 1917c478bd9Sstevel@tonic-gate if ((F_flg) && (strcmp(fstype, vfsbuf.vfs_fstype) != 0)) 1927c478bd9Sstevel@tonic-gate continue; 1937c478bd9Sstevel@tonic-gate fs_flag++; 1947c478bd9Sstevel@tonic-gate fstype = vfsbuf.vfs_fstype; 1957c478bd9Sstevel@tonic-gate newargv[newargc] = vfsbuf.vfs_special; 1967c478bd9Sstevel@tonic-gate if (verbose) { 1977c478bd9Sstevel@tonic-gate printf("%s -F %s ", cbasename, 1987c478bd9Sstevel@tonic-gate vfsbuf.vfs_fstype); 1997c478bd9Sstevel@tonic-gate for (i = 2; newargv[i]; i++) 2007c478bd9Sstevel@tonic-gate printf("%s\n", newargv[i]); 2017c478bd9Sstevel@tonic-gate continue; 2027c478bd9Sstevel@tonic-gate } 2037c478bd9Sstevel@tonic-gate exec_specific(); 2047c478bd9Sstevel@tonic-gate } 2057c478bd9Sstevel@tonic-gate /* 2067c478bd9Sstevel@tonic-gate * if (! fs_flag) { 2077c478bd9Sstevel@tonic-gate * if (sysfs(GETFSIND, fstype) == (-1)) { 2087c478bd9Sstevel@tonic-gate * fprintf(stderr, 2097c478bd9Sstevel@tonic-gate * "%s: FSType %s not installed in the kernel\n", 2107c478bd9Sstevel@tonic-gate * cbasename, fstype); 2117c478bd9Sstevel@tonic-gate * exit(1); 2127c478bd9Sstevel@tonic-gate * } 2137c478bd9Sstevel@tonic-gate * } 2147c478bd9Sstevel@tonic-gate */ 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate exit(0); 2177c478bd9Sstevel@tonic-gate } 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* All other arguments must be specials */ 2207c478bd9Sstevel@tonic-gate /* perform a lookup if fstype is not specified */ 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate for (; optind < argc; optind++) { 2237c478bd9Sstevel@tonic-gate newargv[newargc] = argv[optind]; 2247c478bd9Sstevel@tonic-gate special = newargv[newargc]; 2257c478bd9Sstevel@tonic-gate if ((F_flg) && (usgflag)) { 2267c478bd9Sstevel@tonic-gate exec_specific(); 2277c478bd9Sstevel@tonic-gate exit(0); 2287c478bd9Sstevel@tonic-gate } 2297c478bd9Sstevel@tonic-gate if (usgflag) 2307c478bd9Sstevel@tonic-gate usage(cbasename, c_ptr->c_usgstr); 2317c478bd9Sstevel@tonic-gate if (fstype == NULL) 2327c478bd9Sstevel@tonic-gate lookup(); 2337c478bd9Sstevel@tonic-gate if (verbose) { 2347c478bd9Sstevel@tonic-gate printf("%s -F %s ", cbasename, fstype); 2357c478bd9Sstevel@tonic-gate for (i = 2; newargv[i]; i++) 2367c478bd9Sstevel@tonic-gate printf("%s ", newargv[i]); 2377c478bd9Sstevel@tonic-gate printf("\n"); 2387c478bd9Sstevel@tonic-gate continue; 2397c478bd9Sstevel@tonic-gate } 2407c478bd9Sstevel@tonic-gate exec_specific(); 2417c478bd9Sstevel@tonic-gate if (!F_flg) 2427c478bd9Sstevel@tonic-gate fstype = NULL; 2437c478bd9Sstevel@tonic-gate } 244*08190127Sdh145677 return (0); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* see if all numbers */ 248*08190127Sdh145677 int 249*08190127Sdh145677 numbers(char *yp) 2507c478bd9Sstevel@tonic-gate { 2517c478bd9Sstevel@tonic-gate if (yp == NULL) 2527c478bd9Sstevel@tonic-gate return (0); 2537c478bd9Sstevel@tonic-gate while ('0' <= *yp && *yp <= '9') 2547c478bd9Sstevel@tonic-gate yp++; 2557c478bd9Sstevel@tonic-gate if (*yp) 2567c478bd9Sstevel@tonic-gate return (0); 2577c478bd9Sstevel@tonic-gate return (1); 2587c478bd9Sstevel@tonic-gate } 2597c478bd9Sstevel@tonic-gate 260*08190127Sdh145677 static void 261*08190127Sdh145677 usage(char *cmd, char *usg) 2627c478bd9Sstevel@tonic-gate { 2637c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage:\n"); 2647c478bd9Sstevel@tonic-gate fprintf(stderr, "%s %s\n", cmd, usg); 2657c478bd9Sstevel@tonic-gate exit(2); 2667c478bd9Sstevel@tonic-gate } 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate /* 2707c478bd9Sstevel@tonic-gate * This looks up the /etc/vfstab entry given the device 'special'. 2717c478bd9Sstevel@tonic-gate * It is called when the fstype is not specified on the command line. 2727c478bd9Sstevel@tonic-gate * 2737c478bd9Sstevel@tonic-gate * The following global variables are used: 2747c478bd9Sstevel@tonic-gate * special, fstype 2757c478bd9Sstevel@tonic-gate */ 2767c478bd9Sstevel@tonic-gate 277*08190127Sdh145677 static void 278*08190127Sdh145677 lookup(void) 2797c478bd9Sstevel@tonic-gate { 2807c478bd9Sstevel@tonic-gate FILE *fd; 2817c478bd9Sstevel@tonic-gate int ret; 2827c478bd9Sstevel@tonic-gate struct vfstab vget, vref; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate if ((fd = fopen(vfstab, "r")) == NULL) { 2857c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: cannot open vfstab\n", cbasename); 2867c478bd9Sstevel@tonic-gate exit(1); 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate vfsnull(&vref); 2897c478bd9Sstevel@tonic-gate vref.vfs_special = special; 2907c478bd9Sstevel@tonic-gate ret = getvfsany(fd, &vget, &vref); 2917c478bd9Sstevel@tonic-gate if (ret == -1) { 2927c478bd9Sstevel@tonic-gate rewind(fd); 2937c478bd9Sstevel@tonic-gate vfsnull(&vref); 2947c478bd9Sstevel@tonic-gate vref.vfs_fsckdev = special; 2957c478bd9Sstevel@tonic-gate ret = getvfsany(fd, &vget, &vref); 2967c478bd9Sstevel@tonic-gate } 2977c478bd9Sstevel@tonic-gate fclose(fd); 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate switch (ret) { 3007c478bd9Sstevel@tonic-gate case -1: 3017c478bd9Sstevel@tonic-gate fstype = default_fstype(special); 3027c478bd9Sstevel@tonic-gate break; 3037c478bd9Sstevel@tonic-gate case 0: 3047c478bd9Sstevel@tonic-gate fstype = vget.vfs_fstype; 3057c478bd9Sstevel@tonic-gate break; 3067c478bd9Sstevel@tonic-gate case VFS_TOOLONG: 3077c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: line in vfstab exceeds %d characters\n", 3087c478bd9Sstevel@tonic-gate cbasename, VFS_LINE_MAX-2); 3097c478bd9Sstevel@tonic-gate exit(1); 3107c478bd9Sstevel@tonic-gate break; 3117c478bd9Sstevel@tonic-gate case VFS_TOOFEW: 3127c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: line in vfstab has too few entries\n", 3137c478bd9Sstevel@tonic-gate cbasename); 3147c478bd9Sstevel@tonic-gate exit(1); 3157c478bd9Sstevel@tonic-gate break; 3167c478bd9Sstevel@tonic-gate case VFS_TOOMANY: 3177c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: line in vfstab has too many entries\n", 3187c478bd9Sstevel@tonic-gate cbasename); 3197c478bd9Sstevel@tonic-gate exit(1); 3207c478bd9Sstevel@tonic-gate break; 3217c478bd9Sstevel@tonic-gate } 3227c478bd9Sstevel@tonic-gate } 323*08190127Sdh145677 324*08190127Sdh145677 static void 325*08190127Sdh145677 exec_specific(void) 3267c478bd9Sstevel@tonic-gate { 3277c478bd9Sstevel@tonic-gate int status, pid, ret; 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate sprintf(full_path, "%s/%s/%s", vfs_path, fstype, cbasename); 3307c478bd9Sstevel@tonic-gate newargv[1] = &full_path[FULLPATH_MAX]; 3317c478bd9Sstevel@tonic-gate while (*newargv[1]-- != '/'); 3327c478bd9Sstevel@tonic-gate newargv[1] += 2; 3337c478bd9Sstevel@tonic-gate switch (pid = fork()) { 3347c478bd9Sstevel@tonic-gate case 0: 3357c478bd9Sstevel@tonic-gate execv(full_path, &newargv[1]); 3367c478bd9Sstevel@tonic-gate if (errno == ENOEXEC) { 3377c478bd9Sstevel@tonic-gate newargv[0] = "sh"; 3387c478bd9Sstevel@tonic-gate newargv[1] = full_path; 3397c478bd9Sstevel@tonic-gate execv("/sbin/sh", &newargv[0]); 3407c478bd9Sstevel@tonic-gate } 3417c478bd9Sstevel@tonic-gate if (errno != ENOENT) { 3427c478bd9Sstevel@tonic-gate perror(cbasename); 3437c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: cannot execute %s\n", cbasename, 3447c478bd9Sstevel@tonic-gate full_path); 3457c478bd9Sstevel@tonic-gate exit(1); 3467c478bd9Sstevel@tonic-gate } 3477c478bd9Sstevel@tonic-gate if (sysfs(GETFSIND, fstype) == (-1)) { 3487c478bd9Sstevel@tonic-gate fprintf(stderr, 3497c478bd9Sstevel@tonic-gate "%s: FSType %s not installed in the kernel\n", 3507c478bd9Sstevel@tonic-gate cbasename, fstype); 3517c478bd9Sstevel@tonic-gate exit(1); 3527c478bd9Sstevel@tonic-gate } 3537c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: operation not applicable for FSType %s\n", 3547c478bd9Sstevel@tonic-gate cbasename, fstype); 3557c478bd9Sstevel@tonic-gate exit(1); 3567c478bd9Sstevel@tonic-gate case -1: 3577c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: cannot fork process\n", cbasename); 3587c478bd9Sstevel@tonic-gate exit(2); 3597c478bd9Sstevel@tonic-gate default: 3607c478bd9Sstevel@tonic-gate /* 3617c478bd9Sstevel@tonic-gate * if cannot exec specific, or fstype is not installed, exit 3627c478bd9Sstevel@tonic-gate * after first 'exec_specific' to avoid printing duplicate 3637c478bd9Sstevel@tonic-gate * error messages 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate if (wait(&status) == pid) { 3677c478bd9Sstevel@tonic-gate ret = WHIBYTE(status); 3687c478bd9Sstevel@tonic-gate if (ret > 0) { 3697c478bd9Sstevel@tonic-gate exit(ret); 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate } 3727c478bd9Sstevel@tonic-gate } 3737c478bd9Sstevel@tonic-gate } 374