8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / fs.d / deffs.c
blob402106eae9e460a851c8d20248920521c98eda27
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990, 1991, 1997 SMI */
28 /* All Rights Reserved */
30 #include <stdio.h>
31 #include <deflt.h>
32 #include <string.h>
34 #define LOCAL "/etc/default/fs"
35 #define REMOTE "/etc/dfs/fstypes"
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.
46 char *
47 default_fstype(char *special)
49 char *deffs = NULL;
50 static char buf[BUFSIZ];
51 FILE *fp;
53 if (*special == '/') {
54 if (defopen(LOCAL) == 0) {
55 deffs = defread("LOCAL=");
56 defopen(NULL); /* close default file */
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);
64 if (deffs == NULL)
65 deffs = "nfs";
68 return (deffs != NULL ? deffs : "ufs");