1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990, 1991, 1997 SMI */ 28 /* All Rights Reserved */ 29 30 #include <stdio.h> 31 #include <deflt.h> 32 #include <string.h> 33 34 #define LOCAL "/etc/default/fs" 35 #define REMOTE "/etc/dfs/fstypes" 36 37 /* 38 * This is used to figure out the default file system type if "-F FStype" 39 * is not specified with the file system command and no entry in the 40 * /etc/vfstab matches the specified special. 41 * If the first character of the "special" is a "/" (eg, "/dev/dsk/c0d1s2"), 42 * returns the default local filesystem type. 43 * Otherwise (eg, "server:/path/name" or "resource"), returns the default 44 * remote filesystem type. 45 */ 46 char * 47 default_fstype(char *special) 48 { 49 char *deffs = NULL; 50 static char buf[BUFSIZ]; 51 FILE *fp; 52 53 if (*special == '/') { 54 if (defopen(LOCAL) == 0) { 55 deffs = defread("LOCAL="); 56 defopen(NULL); /* close default file */ 57 } 58 } else { 59 if ((fp = fopen(REMOTE, "r")) != NULL) { 60 if (fgets(buf, sizeof (buf), fp) != NULL) 61 deffs = strtok(buf, " \t\n"); 62 fclose(fp); 63 } 64 if (deffs == NULL) 65 deffs = "nfs"; 66 } 67 68 return (deffs != NULL ? deffs : "ufs"); 69 } 70